AtakanTekparmak commited on
Commit
99209ef
Β·
verified Β·
1 Parent(s): 0bf99f9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +106 -6
README.md CHANGED
@@ -1,10 +1,110 @@
1
  ---
2
- base_model: driaforall/mem-agent
3
- library_name: mlx
4
- pipeline_tag: text-generation
5
- tags:
6
- - mlx
7
  ---
 
8
 
 
9
 
10
- ## Mem-agent-mlx
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ pipeline_tag: reinforcement-learning
 
 
 
 
3
  ---
4
+ # mem-agent-mlx-bf16
5
 
6
+ This is the MLX version of the model with bf16 precision.
7
 
8
+ Based on [Qwen3-4B-Thinking-2507](https://huggingface.co/Qwen/Qwen3-4B-Thinking-2507), this model was trained using GSPO (Zheng et al., 2025) over an agent scaffold that is built around an Obisidian-like memory system and the tools required to interact with it. The model was trained on the following subtasks:
9
+ - Retrieval: Retrieving relevant information when needed from the memory system. In this subtask, we also trained the model on filtering the retrieved information and/or obfuscating it completely.
10
+ - Updating: Updating the memory system with new information.
11
+ - Clarification: Asking for clarification when the user query is not clear/contradicting with the information in the memory system.
12
+
13
+ The tools in the scaffold are:
14
+ ```markdown
15
+ # File Operations
16
+ create_file(file_path: str, content: str = "") -> bool # Auto-creates parent directories
17
+ update_file(file_path: str, old_content: str, new_content: str) -> Union[bool, str] # Returns True or error message
18
+ read_file(file_path: str) -> str
19
+ delete_file(file_path: str) -> bool
20
+ check_if_file_exists(file_path: str) -> bool
21
+
22
+ # Directory Operations
23
+ create_dir(dir_path: str) -> bool
24
+ list_files() -> str # Shows tree structure of current working directory
25
+ check_if_dir_exists(dir_path: str) -> bool
26
+
27
+ # Utilities
28
+ get_size(file_or_dir_path: str) -> int # Bytes; empty = total memory size
29
+ go_to_link(link_string: str) -> bool
30
+ ```
31
+
32
+ The model uses <think>, <python> and <reply> tags to structure its response. Using <reply> only when it's done interacting with the memory. The <python> block is executed in a sandbox with the tools and the results of the code block are returned in a <result> tag to the model, forming the agentic loop.
33
+
34
+ The model is also trained to be able to handle optional filters given by the user in between <filter> tags after the user query. These filters are used to filter the retrieved information and/or obfuscate it completely.
35
+
36
+
37
+ ## Benchmark
38
+
39
+ We evaluated this model and a few other open & closed ones on our benchmark, **md-memory-bench**. We used o3 from OpenAI as the judge. All the other models except driaforall/mem-agent and Qwen/Qwen3-4B-Thinking-2507 were used through OpenRouter.s
40
+
41
+ | Model | Retrieval | Update | Clarification | Filter | Overall |
42
+ |-------|-----------|--------|---------------|--------|---------|
43
+ | qwen/qwen3-235b-a22b-thinking-2507 | 0.9091 | 0.6363 | 0.4545 | 1 | 0.7857 |
44
+ | driaforall/mem-agent | 0.8636 | 0.7272 | 0.3636 | 0.9167 | 0.75 |
45
+ | z-ai/glm-4.5 | 0.7727 | 0.8181 | 0.3636 | 0.9167 | 0.7321 |
46
+ | deepseek/deepseek-chat-v3.1 | 0.6818 | 0.5454 | 0.5454 | 0.8333 | 0.6607 |
47
+ | google/gemini-2.5-pro | 0.7273 | 0.4545 | 0.2727 | 1 | 0.6429 |
48
+ | google/gemini-2.5-flash | 0.7727 | 0.3636 | 0.2727 | 0.9167 | 0.625 |
49
+ | openai/gpt-5 | 0.6818 | 0.5454 | 0.2727 | 0.9167 | 0.625 |
50
+ | anthropic/claude-opus-4.1 | 0.6818 | 0 | 0.8181 | 0.5833 | 0.5536 |
51
+ | Qwen/Qwen3-4B-Thinking-2507 | 0.4545 | 0 | 0.2727 | 0.75 | 0.3929 |
52
+ | moonshotai/kimi-k2 | 0.3181 | 0.2727 | 0.1818 | 0.6667 | 0.3571 |
53
+
54
+ Our model, with only 4B parameters, is only second on the benchmark, beating all the open & closed models except for qwen/qwen3-235b-a22b-thinking-2507. The model achieves an overall score of 0.75, a significant improvement over the 0.3929 of the base Qwen model.
55
+
56
+ ## Usage
57
+
58
+ The model, while can be used on its own, is recommended to be used as an MCP server to a bigger model, which can then be used to interact with the memory system. For this, you can check [our repo](https://huggingface.co/driaforall/mem-agent-mcp), which contains instructions for both an MCP setup and a cli standalone model usage.
59
+
60
+ ### Memory
61
+
62
+ The model uses a markdown based memory system with links, inspired by Obsidian. The general structure of the memory is:
63
+ ```
64
+ memory/
65
+ β”œβ”€β”€ user.md
66
+ └── entities/
67
+ └── [entity_name_1].md
68
+ └── [entity_name_2].md
69
+ └── ...
70
+ ```
71
+
72
+ - `user.md` is the main file that contains information about the user and their relationships, accompanied by links to the enity file in the format of `[[entities/[entity_name].md]]` per relationship. The link format should be followed strictly.
73
+ - `entities/` is the directory that contains the entity files.
74
+ - Each entity file follows the same structure as `user.md`.
75
+ - Modifying the memory manually does not require restarting the MCP server.
76
+
77
+ ### Example user.md
78
+
79
+ ```markdown
80
+ # User Information
81
+ - user_name: John Doe
82
+ - birth_date: 1990-01-01
83
+ - birth_location: New York, USA
84
+ - living_location: Enschede, Netherlands
85
+ - zodiac_sign: Aquarius
86
+
87
+ ## User Relationships
88
+ - company: [[entities/acme_corp.md]]
89
+ - mother: [[entities/jane_doe.md]]
90
+ ```
91
+
92
+ ### Example entity files (jane_doe.md and acme_corp.md)
93
+
94
+ ```markdown
95
+ # Jane Doe
96
+ - relationship: Mother
97
+ - birth_date: 1965-01-01
98
+ - birth_location: New York, USA
99
+ ```
100
+
101
+ ```markdown
102
+ # Acme Corporation
103
+ - industry: Software Development
104
+ - location: Enschede, Netherlands
105
+ ```
106
+
107
+ The model is trained on this memory standard and any fruitful use should be on a memory system that follows this standard. We have a few memory export tools for different sources like ChatGPT, Notion, etc. in our mcp server repo.
108
+
109
+ ## References:
110
+ - [GSPO](https://arxiv.org/pdf/2507.18071), Zheng et al., 2025