File size: 19,123 Bytes
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
 
 
 
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
3b42b5b
70390d6
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3b42b5b
 
 
70390d6
 
 
 
 
 
 
 
 
 
 
 
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70390d6
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
3b42b5b
70390d6
 
 
3b42b5b
70390d6
3b42b5b
 
 
 
 
 
 
 
70390d6
 
 
3b42b5b
 
70390d6
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
 
3b42b5b
 
70390d6
3b42b5b
70390d6
3b42b5b
 
 
 
 
 
 
 
 
 
70390d6
 
 
3b42b5b
 
70390d6
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
 
3b42b5b
 
70390d6
 
3b42b5b
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
3b42b5b
 
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
3b42b5b
 
 
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
3b42b5b
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70390d6
 
3b42b5b
 
 
 
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
3b42b5b
 
 
 
 
 
 
 
70390d6
 
 
3b42b5b
 
70390d6
3b42b5b
 
70390d6
3b42b5b
 
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
 
 
 
3b42b5b
 
 
 
 
 
70390d6
 
 
 
3b42b5b
70390d6
 
 
3b42b5b
 
 
 
 
 
 
 
 
70390d6
 
 
7c7bae5
3b42b5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
---
language:
  - en
  - zh
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
tags:
  - qwen3
  - fine-tuned
  - structured-memory
  - user-assistant
base_model:
  - Qwen/Qwen3-4B
---

## Overview

This repository is an SFT checkpoint based on [Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B), fine-tuned for **structured long-term memory extraction** from **user–assistant conversations**. The model is configured to **output valid JSON only**.

## Document structure

| Section | Description |
|---------|-------------|
| **Input** | Full prompt sent to the model at inference (task instruction + conversation to extract) |
| **Output** | Expected JSON response from the model (do not include Markdown fences in production) |

> How the prompt is split into `system` / `user` depends on the chat template you use; the example below shows a single user-side text block, consistent with the training data format.

---

## Input

### Prompt (task instruction)

```textYou are a structured memory extractor.



Task: Extract structured memories with long-term value from the input user-assistant conversation, and strictly output valid JSON.

Only output JSON. Do not output explanations, analysis, Markdown, or any extra text.



========================

Output Format

========================



{

  "memories": [

    {

      "source_id": 1,

      "content": "",

      "dimension": {

        "memory_type": "",

        "time": "",

        "location": "",

        "reason": "",

        "purpose": "",

        "keywords": []

      }

    }

  ]

}



========================

Extraction Targets

========================



Extract:

1. Factual information, identity/background, relationships, current status, tools, models, datasets, and project configurations;

2. Specific experiences, events, actions, behavioral records, stage progress, and future plans;

3. Long-term preferences, habits, interests, values, goals, abilities, interaction style, or writing style;

4. Information that helps understand the user's future needs or retrieve the user's background.



Do not extract:

1. Greetings, thanks, simple confirmations, or meaningless small talk;

2. Temporary formatting requirements, one-off operation instructions, or current-task details without long-term value.



========================

memory_type

========================



dimension.memory_type must be one of: fact, episodic, profile.



fact: stable facts, answering "what it is / what exists / what is used / what the relationship is / what the current status is".

Includes identity, background, relationships, status, tools, models, datasets, configurations, confirmed choices, and stable objective attributes.

Example: The user uses LLaMA2-7B as the base model.



episodic: specific events, answering "what happened / what someone did / what someone experienced / what someone plans to do".

Includes a specific event, experience, action, stage progress, future plan, or concrete fact with time/location/context.

Example: The user plans to train a local LLaMA2-7B model using Urdu data.



profile: long-term user profile, answering "what someone is like long-term / what someone likes / what someone usually does / what someone believes".

Includes preferences, habits, interests, values, long-term goals, abilities, style preferences, and stable behavior patterns.

Example: The user prefers concise Java code with a single main function.



Do not extract content that cannot be classified as fact, episodic, or profile.



========================

content Rules

========================



content is the main text of the memory and must be one complete, self-contained, retrievable sentence.



Requirements:

1. Clearly state who the memory is about and the core fact, event, or profile information.

2. If the source text contains time, location, reason, or purpose, include them in content when possible.

3. Remove ambiguous pronouns so that content does not depend on the original context.

4. Normalize relative time expressions based on the message timestamp, e.g., yesterday 鈫?a specific date.

5. Do not add unsupported information, and do not overgeneralize a single event into a long-term profile.



========================

dimension Rules

========================



dimension is used for structured retrieval. Except for memory_type, use "" when there is no clear evidence; use [] for keywords when there are no clear keywords.



time: the time when the memory is valid, happened, is planned to happen, or repeatedly occurs.

Use an absolute date if available. Normalize relative time if the message timestamp is available. Use "" if there is no time.

Do not use the current system time unless it is the message timestamp.



location: physical place, online platform, organizational context, home space, workplace, system environment, or activity venue.

Fill this only when the source text explicitly mentions or strongly implies it. Do not force ordinary topics into location.



reason: cause, motivation, trigger, or background condition.

Fill this only when the source text explicitly states or strongly implies it. Do not infer hidden motivations. Do not confuse it with purpose.



purpose: goal, intention, or expected outcome.

Fill this only when the source text explicitly states or strongly implies it. Do not infer unstated purposes.



keywords: key terms or phrases for retrieval, deduplication, and query-memory alignment.

Extract subjects, objects, tools, models, datasets, projects, people, locations, activities, results, preference objects, interest domains, etc.

Keywords must be short words or noun phrases. Do not include full sentences. Do not repeat keywords. Do not extract ordinary words without retrieval value.



========================

Extraction Rules

========================



1. Process messages in chronological order.

2. Extract memories mainly from user messages.

3. Each memory should be as atomic as possible. If a message is long or contains multiple independent information points, split it into multiple memories, preserving key details such as people, time, location, events, reasons, purposes, preferences, and objects separately. Avoid over-merging or omitting details.

4. The `content` field must be self-contained and must not rely on the original dialogue context.

5. The `time` field should be normalized based on the message timestamp: relative time expressions must be converted into absolute dates or time ranges. For example, if the message timestamp is `2023-05-08` and the original text says `yesterday`, then `time` should be `2023-05-07`.

6. Simple confirmations, temporary formatting requirements, and one-off tasks in the current conversation should generally not be extracted.

7. The output must be valid JSON. Do not output any text outside the JSON.







Here is the real input you need to process:

```

### Conversation (immediately follows the prompt's "Here is the real input you need to process:")

```text[2023-04-23T08:57:00, Sun] 1.User: I ' planning a trip to Europe in fall considering visiting Paris or Rome. Can give me recommendations for historical sites and cultural experiences in both cities

[2023-04-23T08:57:00.500000, Sun] 2.User: interested in seeing a Broadway - style show in both cities. any musicals or theater productions I shouldn ' t miss in Paris or Rome

[2023-04-23T08:57:01, Sun] 3.User: For Paris, any historical sites or museums offer unique perspective on city ' s history like USS Arizona Memorial in Hawaii

[2023-04-23T08:57:01.500000, Sun] 4.User: interested in learning more about French Resistance during WWII you recommend any guided tours or museums in Paris focus on this period of history

[2023-04-23T08:57:02, Sun] 5.User: What some good restaurants in Paris serve traditional French cuisine with focus on seasonal ingredients cozy atmosphere

[2023-04-23T08:57:02.500000, Sun] 6.User: What about some wine to go with meal? recommend some wine bars or shops in Paris can find good selection of French wines

[2023-04-24T09:36:00, Mon] 7.User: daily wages for group 200 persons obtained from frequency distribution continuous variable X after substitution U = ( X - 130 ) / 20 U = ( X 130 ) / 20 - 2 - 1 0 1 2 No. persons 7 50 80 60 3 Calculate median, lower upper quartiles 3rd decile 98th percentile

[2023-04-27T13:38:00, Thu] 8.User: ' looking for inspiration for my next pasta dish been craving Italian food a lot lately recently tried a Spaghetti Carbonara at Bella Vita amazing. also been experimenting with different pasta recipes at home, like quick and easy dinner made last Thursday using fettuccine and arrabbiata sauce. any recommendations for other pasta dishes I could try

[2023-04-27T13:38:00.500000, Thu] 9.User: I think I ' ll try Spaghetti alla Bolognese ve always wanted to make meat - based pasta sauce from scratch. Can you give me simple recipe I can follow recommend good wine pairings for it

[2023-04-27T13:38:01, Thu] 10.User: excited to try this recipe out. never made a meat - based pasta sauce from scratch before bit curious to see how it turns out. have a question though - what type of ground beef you recommend using? seen different types at the store, like 80 / 20 or 70 / 30 lean to fat ratio. Does it make a big difference

[2023-04-27T13:38:01.500000, Thu] 11.User: That ' s really helpful, thanks! think ' ll go with 80 / 20 lean to fat ratio. been thinking about making garlic bread to go with my Spaghetti alla Bolognese. any tips on how to make good garlic bread

[2023-04-27T13:38:02, Thu] 12.User: That sounds great, thanks for tips! think ' ll try adding some Parmesan cheese to garlic butter mixture for extra burst of flavor. ll make sure to time it so it comes out of oven just as serving pasta. By way speaking of pasta, been thinking about trying to make my own pasta from scratch soon. have any tips or resources for a beginner like me

[2023-04-27T13:38:02.500000, Thu] 13.User: ' been thinking about making my own pasta from scratch soon

[2023-05-05T03:48:00, Fri] 14.User: ' m looking for some gift wrapping ideas. finished all my shopping feeling pretty organized relieved I got all my shopping done on time! have any simple and creative ways to wrap gifts for my family and friends

[2023-05-05T03:48:00.500000, Fri] 15.User: I like monochromatic idea. any suggestions for nice ribbon or bow would complement red and green color scheme?

```

---

## Output

Example model response (in production the model should output valid JSON only, with no fences or surrounding text):

```json{

  "memories": [

    {

      "source_id": 1,

      "content": "The user is planning a trip to Europe in fall and is considering visiting Paris or Rome.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-09-01/2023-11-30",

        "location": "Europe",

        "reason": "",

        "purpose": "to visit Paris or Rome",

        "keywords": [

          "trip to Europe",

          "fall travel",

          "Paris",

          "Rome"

        ]

      }

    },

    {

      "source_id": 2,

      "content": "The user is interested in seeing Broadway-style shows in Paris and Rome and wants recommendations for musicals or theater productions not to miss.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "Paris and Rome",

        "reason": "",

        "purpose": "to see Broadway-style shows",

        "keywords": [

          "Broadway-style shows",

          "musicals",

          "theater productions",

          "Paris",

          "Rome"

        ]

      }

    },

    {

      "source_id": 4,

      "content": "The user is interested in learning more about the French Resistance during World War II and wants guided tours or museums in Paris that focus on that period of history.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "Paris",

        "reason": "",

        "purpose": "to learn about the French Resistance during World War II",

        "keywords": [

          "French Resistance",

          "World War II",

          "guided tours",

          "museums",

          "Paris"

        ]

      }

    },

    {

      "source_id": 5,

      "content": "The user wants recommendations for restaurants in Paris that serve traditional French cuisine with seasonal ingredients and a cozy atmosphere.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "Paris",

        "reason": "",

        "purpose": "to find a good restaurant",

        "keywords": [

          "restaurants",

          "traditional French cuisine",

          "seasonal ingredients",

          "cozy atmosphere",

          "Paris"

        ]

      }

    },

    {

      "source_id": 6,

      "content": "The user wants recommendations for wine bars or shops in Paris with a good selection of French wines to pair with meals.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "Paris",

        "reason": "",

        "purpose": "to find French wine pairings",

        "keywords": [

          "wine bars",

          "wine shops",

          "French wines",

          "meal pairing",

          "Paris"

        ]

      }

    },

    {

      "source_id": 8,

      "content": "The user has been craving Italian food lately and recently tried Spaghetti Carbonara at Bella Vita, which the user found amazing.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "Bella Vita",

        "reason": "",

        "purpose": "",

        "keywords": [

          "Italian food",

          "Spaghetti Carbonara",

          "Bella Vita"

        ]

      }

    },

    {

      "source_id": 8,

      "content": "The user has been experimenting with different pasta recipes at home, including a quick and easy dinner made on 2023-04-24 using fettuccine and arrabbiata sauce.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-24",

        "location": "home",

        "reason": "",

        "purpose": "to make quick and easy dinner",

        "keywords": [

          "pasta recipes",

          "fettuccine",

          "arrabbiata sauce",

          "home cooking"

        ]

      }

    },

    {

      "source_id": 9,

      "content": "The user plans to try Spaghetti alla Bolognese and wants a simple recipe to follow.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to make Spaghetti alla Bolognese",

        "keywords": [

          "Spaghetti alla Bolognese",

          "recipe"

        ]

      }

    },

    {

      "source_id": 9,

      "content": "The user has always wanted to make meat-based pasta sauce from scratch.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "",

        "reason": "",

        "purpose": "",

        "keywords": [

          "meat-based pasta sauce",

          "from scratch"

        ]

      }

    },

    {

      "source_id": 10,

      "content": "The user has never made a meat-based pasta sauce from scratch before and is curious about which type of ground beef to use.",

      "dimension": {

        "memory_type": "fact",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to choose ground beef for meat-based pasta sauce",

        "keywords": [

          "meat-based pasta sauce",

          "ground beef",

          "80/20",

          "70/30"

        ]

      }

    },

    {

      "source_id": 11,

      "content": "The user plans to use an 80/20 lean-to-fat ratio for ground beef in the Spaghetti alla Bolognese recipe.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to make Spaghetti alla Bolognese",

        "keywords": [

          "80/20 ground beef",

          "Spaghetti alla Bolognese"

        ]

      }

    },

    {

      "source_id": 11,

      "content": "The user has been thinking about making garlic bread to go with Spaghetti alla Bolognese.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to serve with Spaghetti alla Bolognese",

        "keywords": [

          "garlic bread",

          "Spaghetti alla Bolognese"

        ]

      }

    },

    {

      "source_id": 12,

      "content": "The user plans to add Parmesan cheese to the garlic butter mixture for extra flavor and wants to make sure it comes out of the oven just as the pasta is served.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to enhance garlic bread flavor and timing",

        "keywords": [

          "Parmesan cheese",

          "garlic butter",

          "garlic bread",

          "timing"

        ]

      }

    },

    {

      "source_id": 12,

      "content": "The user has been thinking about making homemade pasta from scratch soon.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-04-27",

        "location": "",

        "reason": "",

        "purpose": "to make homemade pasta",

        "keywords": [

          "homemade pasta",

          "from scratch"

        ]

      }

    },

    {

      "source_id": 14,

      "content": "The user finished shopping on time and felt organized and relieved.",

      "dimension": {

        "memory_type": "episodic",

        "time": "2023-05-05",

        "location": "",

        "reason": "",

        "purpose": "",

        "keywords": [

          "shopping",

          "organized",

          "relieved"

        ]

      }

    },

    {

      "source_id": 14,

      "content": "The user wants simple and creative gift-wrapping ideas for family and friends.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "",

        "reason": "",

        "purpose": "to wrap gifts for family and friends",

        "keywords": [

          "gift wrapping",

          "family",

          "friends"

        ]

      }

    },

    {

      "source_id": 15,

      "content": "The user likes the monochromatic gift-wrapping idea and wants suggestions for ribbons or bows that complement a red and green color scheme.",

      "dimension": {

        "memory_type": "profile",

        "time": "",

        "location": "",

        "reason": "",

        "purpose": "to choose gift-wrapping accessories",

        "keywords": [

          "monochromatic wrapping",

          "ribbons",

          "bows",

          "red and green"

        ]

      }

    }

  ]

}

```