You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
desc: "In MemOS, memory is not just about archiving information, but also about being dynamically retrieved when needed and transformed into executable input. This process is achieved through two closely connected steps: Memory Recall and Instruction Completion."
2
+
title: Memory Recall
3
+
desc: "In MemOS, memory is not just about archiving information, but also about being dynamically retrieved when needed and transformed into executable input."
4
4
---
5
5
6
6
## 1. Capability Overview
7
7
8
-
### 1.1 Memory Recall
9
-
10
8
Memory recall is responsible for quickly retrieving the most relevant memory fragments when the user initiates a new request.
11
9
12
10
***Role**: Ensures that the model does not start “from scratch” when generating responses, but instead integrates the user's history, preferences, and context.
@@ -16,272 +14,34 @@ Memory recall is responsible for quickly retrieving the most relevant memory fra
16
14
* Traceable: Each memory is accompanied by its source, timestamp, and confidence level.
17
15
18
16
* Highly controllable: Developers have full control over which memories enter downstream logic.
19
-
20
-
21
-
### 1.2 Instruction Completion (Coming Soon)
22
-
23
-
It is important to note that “facts” are not the same as “instructions.” If developers only obtain plaintext memory, they must write additional rules to translate this information into prompts that large models can directly execute.
24
-
25
-
:::note
26
-
**The role of instruction completion** is to automatically generate instructions of different granularity based on recall results.
27
-
:::
28
-
29
-
***In most systems, developers can only get “memory facts” and then manually piece together prompts. This leads to several challenges:**
30
-
31
-
* Task awareness: The same memory may require different phrasing under different tasks;
32
-
33
-
* Personalization: User style and habits need to be instantly supplemented;
34
-
35
-
* Dynamic optimization: Different models require different optimal prompt formulations;
36
-
37
-
* Efficient compression: Redundancy must be removed to reduce token consumption.
38
-
39
-
40
-
<br>
41
-
42
-
***MemOS instruction completion helps developers cover this “last mile”:**
43
-
44
-
* Saves the cost of rules assembly and tuning;
45
-
46
-
* Ensures that recalled memories are effectively utilized;
47
-
48
-
* Provides three modes: matches / instruction / full_instruction, to meet different levels of control needs.
49
-
50
-
* Memory facts (matches): Recall relevant memories for the current query.
51
-
52
-
* Semi-finished instruction (instruction): Combine recalled memories with the user’s current question to form a basic prompt, upon which developers can add business logic.
53
-
54
-
* Full instruction (full_instruction): Based on the semi-finished version, integrate context, preferences, compliance constraints, etc., to generate a terminal prompt directly executable by the model.
55
-
56
-
57
-
<br>
58
-
59
-
:::note
60
-
Instruction completion works through both **offline chain** and **real-time chain**.
61
-
:::
62
-
63
-
|**Chain**|**Description**|
64
-
| --- | --- |
65
-
|**Offline Chain** (Accumulation & Preparation) | Extract user preferences to form a profile.<br><br>Build a few-shot sample library.<br><br>Solidify long-term rules such as brand, compliance, and style. |
66
-
|**Real-time Chain** (Dynamic Decision) | Select which memories and templates to activate based on task intent.<br><br>Resolve conflicts (e.g., “likes poetic openings” vs. “requires conciseness”).<br><br>Perform compression and degradation based on token budget and model characteristics. |
67
-
68
-
69
-
## 2. Example (Try after instruction completion is launched) — Personalized Tutoring in AI Education
70
-
71
-
### 2.1 Historical Dialogue Input (Raw Material)
72
-
73
-
```json
74
-
2025-06-10
75
-
Student: Hello teacher, my name is Xiao Ming, I am in 9th grade
76
-
Teacher: Hello Xiao Ming, nice to meet you
77
-
……
78
-
79
-
2025-08-01
80
-
Student: Teacher, I really can’t solve this problem, can you explain more clearly?
81
-
Teacher: Sure, I will explain step by step.
82
-
……
83
-
84
-
2025-09-03
85
-
……
86
-
Student: You just explained too long, I couldn’t keep up. Can you make it simpler?
87
-
Teacher: Okay, I’ll tell you in a simpler way.
88
-
……
89
-
90
-
2025-10-09
91
-
Student: I still can’t distinguish between linear and quadratic functions…
92
-
Teacher: The graph of a linear function is a straight line, while a quadratic function is a parabola. You need to remember this difference.
Task: Help student solve a quadratic equation problem
177
-
Audience: 9th grade student
178
-
Requirements:
179
-
- Explain in 3–4 steps
180
-
- Correct common confusion between linear/quadratic functions during explanation
181
-
- Keep it concise, avoid lengthy derivations
182
-
Note: If the question is incomplete, please ask for clarification first
183
-
184
-
user_query: "Teacher, can you teach me how to solve this problem? 2x² - 3x - 5 = 0"
185
-
```
186
-
187
-
<br>
188
-
189
-
* **Full instruction:** Further refined from the semi-finished version
190
-
191
-
* Convert “often confuses” into explicit teaching action (must emphasize difference between quadratic and linear functions during explanation).
192
-
193
-
* Translate “prefers step-by-step explanations” into a clear problem-solving method (use step-by-step explanation).
194
-
195
-
* Rewrite “9th grade student” into the teaching role relationship (you are the math teacher of a 9th grade student).
196
-
197
-
* Select few-shot examples from historical dialogue and include them in the final instruction to help the model learn explanation and clarification patterns.
198
-
199
-
200
-
> Semi-finished instructions are more structured for developer customization; full instructions are closer to natural language and directly executable by models.
201
-
202
-
```yaml
203
-
final_prompt_to_model:
204
-
- role: system
205
-
content: |
206
-
You are the math teacher of a 9th grade student.
207
-
The student often confuses linear and quadratic functions, and prefers concise, step-by-step explanations.
208
-
Please follow the style of the following historical examples:
209
-
210
-
[Example 1]
211
-
Student: Teacher, I really can’t solve this problem, can you explain more clearly?
212
-
Teacher: Sure, I will explain step by step.
213
-
214
-
[Example 2]
215
-
Student: You just explained too long, I couldn’t keep up. Can you make it simpler?
216
-
Teacher: Okay, I’ll tell you in a simpler way.
217
-
218
-
[Example 3]
219
-
Student: I still can’t distinguish between linear and quadratic functions…
220
-
Teacher: The graph of a linear function is a straight line, while a quadratic function is a parabola. You need to remember this difference.
221
-
222
-
Now please answer the student’s question: “Solve 2x² - 3x - 5 = 0.”
223
-
Requirements:
224
-
- Solve the problem step-by-step (3–4 steps);
225
-
- Point out the difference between linear and quadratic functions during the explanation;
226
-
- Keep the answer concise and clear, avoid lengthy derivations;
227
-
- If the problem statement is incomplete, please ask for clarification first.
228
-
- role: user
229
-
content: "Teacher, can you teach me how to solve this problem? 2x² - 3x - 5 = 0"
230
-
```
231
-
232
-
> Case Summary: In the “9th grade student solving quadratic equation” scenario, instruction completion provides the following benefits over returning raw memory only:
233
-
234
-
* **From facts to executable**
235
-
236
-
* Raw memory only has “student often confuses linear and quadratic functions,” developers must convert this into a teaching action.
237
-
238
-
* Instruction completion directly generates “must emphasize the key difference during explanation,” avoiding extra developer rules.
239
-
240
-
* **Context integration**
241
-
242
-
* Raw memory is fragmented; developers must decide how to place them into prompts.
243
-
244
-
* Instruction completion automatically merges memories with the user query into a coherent task description for direct model use.
245
-
246
-
* **Optimization and pruning**
247
-
248
-
* If developers directly concatenate memories, the result is often redundant or conflicting.
249
17
250
-
* Instruction completion compresses into concise step-by-step requirements, reducing token consumption and improving focus.
251
-
252
-
* **Robustness assurance**
18
+
***Features**:
253
19
254
-
* If developers only get memories, they must consider “what if the question is incomplete.”
20
+
* Seamless recall: Users don’t need to repeat their previous choices or preferences.
255
21
256
-
* Instruction completion includes clarification strategies, making outputs more robust without reinventing the wheel.
22
+
* Structured output: Separates factual and preference memories, making it easier for developers to control whether to inject them.
257
23
258
24
259
-
## 3. Advanced: Deep Customization
25
+
## 2. Advanced: Deep Customization
260
26
261
27
In MemOS, recall and completion are not achieved through a single path, but through combinations of multiple strategies and components. Different scenarios may require different configurations. This section lists the main steps and customizable points for you to flexibly choose according to business needs.
262
28
263
29
|**Layer**|**Customizable Points**|**Example**|
264
30
| --- | --- | --- |
265
31
| Memory Recall | Adjust recall strategy | Raise similarity threshold to only return memories with confidence ≥0.9 |
266
32
|| Set filters | Only retrieve the last 30 days of conversations; only preference memories, not factual ones |
267
-
| Semi-finished Instruction<br>instruction | Extend structured fields | Add extra fields such as “Output format: Markdown”, “Must include: Safety reminder” |
268
-
| | Custom concatenation template | Replace default concatenation logic to generate semi-finished instructions with brand tone |
269
-
| Full Instruction<br>full_instruction | Few-shot strategy | Replace default historical messages with your own example library, fix to 2 examples each time |
270
-
| | Role and tone control | Force setting to “Financial Advisor”, output style as “formal professional” |
0 commit comments