Text Generation
Transformers
Safetensors
English
Chinese
qwen3
fine-tuned
structured-memory
conversational-ai
conversational
text-generation-inference
Instructions to use wtqiu/DimMem-4B-Locomo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wtqiu/DimMem-4B-Locomo with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="wtqiu/DimMem-4B-Locomo") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("wtqiu/DimMem-4B-Locomo") model = AutoModelForCausalLM.from_pretrained("wtqiu/DimMem-4B-Locomo") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wtqiu/DimMem-4B-Locomo with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wtqiu/DimMem-4B-Locomo" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wtqiu/DimMem-4B-Locomo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/wtqiu/DimMem-4B-Locomo
- SGLang
How to use wtqiu/DimMem-4B-Locomo with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "wtqiu/DimMem-4B-Locomo" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wtqiu/DimMem-4B-Locomo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "wtqiu/DimMem-4B-Locomo" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wtqiu/DimMem-4B-Locomo", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use wtqiu/DimMem-4B-Locomo with Docker Model Runner:
docker model run hf.co/wtqiu/DimMem-4B-Locomo
Overview
This repository is an SFT checkpoint based on Qwen3-4B, fine-tuned for structured long-term memory extraction from multi-party 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/userdepends 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)
Your task is to extract structured memories with long-term value from the input multi-person conversation records, and strictly output valid JSON.
You may only output JSON. Do not output explanations, analysis, Markdown, or any extra text.
========================
1. Output Format
========================
Return only the following JSON object:
{
"memories": [
{
"source_id": 1,
"source_speaker": "",
"content": "",
"dimension": {
"memory_type": "",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": []
}
}
]
}
========================
2. Field Descriptions
========================
1. source_id
Indicates which message number in the input conversation this memory mainly comes from.
2. source_speaker
Indicates the speaker of the message corresponding to source_id.
3. content
content is the core textual representation of the memory. It must be complete, self-contained, independently understandable, and retrievable.
The core requirements are:
- Coreference resolution: clearly state who the subject is and what the core information is. Do not use ambiguous references such as "he", "she", "there", or "this". Restore specific people, objects, locations, or events based on context.
- Key information preservation: retain key elements from the original text as much as possible, including time, location, reason, purpose, object, interpersonal relationship, media evidence, etc. Do not add information that is not supported by the original text.
- Time normalization: when content involves time, normalize it based on the message timestamp.
For example: yesterday 鈫?a specific date; last week 鈫?a date range; next month 鈫?a specific month; three years ago 鈫?a specific or approximate year.
4. dimension.memory_type
memory_type must be one of the following three types: fact, episodic, profile.
fact:
Used to record stable facts, identity, background, relationships, current status, tools, models, datasets, configurations, possessions, or stable attributes.
Judgment criterion:
If the information mainly answers "what it is / what someone has / what is used / what the relationship is / what the current status is", label it as fact.
Examples:
- Jack has two children.
- Mico is Jack's close friend.
episodic:
Used to record specific events, experiences, actions, purchases, trips, meetings, sharing, plans, stage progress, or timeline-related information.
Judgment criterion:
If the information mainly answers "what happened / what someone did / what someone experienced / what someone plans to do / when it happened / where it happened", label it as episodic.
Notes:
- Media such as photos, images, videos, screenshots, and audio should also be extracted as episodic if they carry a specific experience, meeting, activity, trip, family event, friend interaction, or important object;
- Do not ignore information simply because it is about "taking a photo", "sending an image", or "sharing a photo". As long as it points to a retrievable specific experience, it should be retained.
Examples:
- Nora volunteered at an animal shelter on 2023-07-11.
- Ethan joined a river cleanup with his sister on 2023-07-30.
- Maria shared a photo from a family dinner in May 2023.
profile:
Used to record long-term preferences, habits, interests, values, long-term goals, ability traits, interaction preferences, stable behavior patterns, or long-term sources of support.
Judgment criterion:
If the information mainly answers "what someone is like over the long term / what someone likes / what someone usually does / what someone believes / what someone values / what someone relies on / what motivates someone", label it as profile.
Notes:
- Friends, family members, mentors, partners, colleagues, pets, etc., should be extracted as profile or fact if they are described as important support, sources of motivation, long-term companions, or stable relationships;
- If it is only a one-time meeting or interaction, label it as episodic;
- If it expresses a long-term relationship or stable influence, label it as profile or fact.
Examples:
- Maria practices yoga every Saturday morning.
- Mico believes every child deserves love, acceptance, and a safe home.
- Ethan sees his older sister as an important source of support.
Do not extract content that cannot be classified as fact, episodic, or profile.
5. dimension.time
Indicates the time when the memory is valid, happened, is planned to happen, or recurs.
Rules:
- Use an absolute date if one is available;
- If there is relative time and a message timestamp is available, normalize it to absolute time;
- If only a month or year can be obtained, use YYYY-MM or YYYY;
- Date ranges may use YYYY-MM-DD/YYYY-MM-DD;
- If there is no time information, fill in "";
- Do not use the current system time as the memory time unless it is the message timestamp.
Examples:
- If the message time is 2023-05-08 and the original text says yesterday, then time = "2023-05-07";
- If the message time is 2023-07-12 and the original text says next month, then time = "2023-08";
- If the message time is 2023-06-09 and the original text says last week, then time = "2023-05-29/2023-06-04".
6. dimension.location
Indicates the physical location, online platform, organizational context, home space, workplace, system environment, or activity venue.
Rules:
- Fill this field only when the original text explicitly mentions or strongly implies a location, platform, or context;
- Do not force ordinary topics into location;
- If there is no location information, fill in "".
7. dimension.reason
Indicates the reason, motivation, trigger, or background condition.
Rules:
- Fill this field only when the original text explicitly states it or the context strongly supports it;
- Low-risk contextual reasons such as "someone was answering someone's question" may be used;
- Do not infer hidden psychological motives;
- If there is no reason information, fill in "".
8. dimension.purpose
Indicates the goal, intention, or expected result.
Rules:
- Fill this field only when the original text explicitly states it or the context strongly supports it;
- Low-risk communicative purposes such as sharing an experience, answering a question, explaining a plan, expressing values, or encouraging the other person may be used;
- Do not infer unstated deeper purposes;
- If there is no purpose information, fill in "".
9. dimension.keywords
Indicates key retrieval terms or key phrases.
Rules:
- keywords must be short terms or noun phrases;
- They may include people, locations, activities, objects, events, relationships, photos, videos, goals, preferences, values, etc.;
- Do not include complete sentences;
- Do not repeat keywords;
- Do not extract generic words with no retrieval value;
- If there are no clear keywords, fill in [].
========================
3. Extraction Targets
========================
You should extract:
1. Stable information: identity, relationships, background, possessions, current status, etc.
Example: Alex has a close relationship with his mentor.
2. Event experiences: actions, meetings, activities, purchases, trips, sharing, plans, etc.
Example: Nora volunteered at an animal shelter on 2023-07-11.
3. Long-term profiles: preferences, habits, interests, values, goals, ability traits, long-term sources of motivation, etc.
Example: Ethan regards his family and friends as important sources of support.
4. Important details: photos, images, videos, pets, objects, locations, companions, support systems, etc., should also be extracted as long as they carry a specific experience or interpersonal relationship.
Example: Mia shared a photo from a meetup last week.
Do not extract:
1. Pure greetings, pure thanks, or pure confirmations.
Example: Hi, how are you? / Thanks! / OK, sure.
2. Isolated emotions or generic evaluations with no long-term value.
Example: That鈥檚 nice. / I鈥檓 happy today. / It was great.
Note:
Do not skip an entire message just because it starts with Thanks, Haha, OK, etc. As long as the following content contains valuable information, it should be extracted.
========================
4. Extraction Rules
========================
1. Process all messages in conversation order.
2. In a multi-person conversation, extract from any speaker's message as long as it contains valuable information.
3. Each memory should express only one core fact, event, plan, or profile trait.
4. If one sentence contains multiple independent pieces of information, split them into multiple memories.
5. If multiple pieces of information highly overlap, they may be merged into one memory.
6. content must be self-contained and must not depend on the original context.
7. Normalize time as much as possible, and keep content consistent with dimension.time.
8. Do not overgeneralize: a one-time event must not be written as a long-term profile, and a temporary emotion must not be written as a stable preference.
9. Do not hallucinate field values: fill unsupported time, location, reason, and purpose fields with "".
10. The final output must be valid JSON only. Do not output comments, Markdown, explanations, or anything outside JSON.
========================
6. Short Examples
========================
Example 1:
[2023-06-09T19:55:05, Fri] 6.Alex: Thanks! My parents and coach have always pushed me to keep going. I also sent you a photo from our meetup last week.
Correct extraction direction:
- "Alex's parents and coach are long-term sources of support and motivation" should be extracted as profile;
- "Alex sent a photo from a meetup last week" should be extracted as episodic;
- last week should be normalized into a specific date range based on the message time;
- Do not skip the entire message just because it starts with Thanks.
Example 2:
[2023-08-02T10:30:00, Wed] 6.Lena: Haha yeah, I bought that blue notebook in Kyoto last month and still use it for project ideas.
Correct extraction direction:
- "Lena bought a blue notebook in Kyoto in 2023-07" should be extracted as episodic;
- "Lena uses the blue notebook for project ideas" may be extracted as fact if it expresses a current ongoing use;
- Do not skip the following information just because the message starts with Haha.
The following is the real input you need to process now:
Conversation (immediately follows the prompt's "The following is the real input you need to process now:")
[2023-03-27T13:10:00.500000, Mon] 2.Andrew: Hey Audrey! started new job as Financial Analyst last week - s quite a change from my previous job. How about you? Anything interesting happening
[2023-03-27T13:10:01, Mon] 3.Audrey: Congrats on new job! got new collars and tags for my dogs - so cute
[2023-03-27T13:10:01.500000, Mon] 4.Andrew: Thanks! sounds cute Can I see a picture
[2023-03-27T13:10:02, Mon] 5.Audrey: Sure! See them with new collars cute right
[2023-03-27T13:10:02.500000, Mon] 6.Andrew: Cute little guys! What are their names how long had them
[2023-03-27T13:10:03, Mon] 7.Audrey: had them for 3 years! names are Pepper, Precious and Panda can ' t live without my little ones
[2023-03-27T13:10:03.500000, Mon] 8.Andrew: That ' s awesome! always wanted a dog even living in city? Can they still go on adventures
[2023-03-27T13:10:04, Mon] 9.Audrey: Absolutely! They ' re city dogs we explore all time. love trying out new parks trails go on adventures together often
[2023-03-27T13:10:04.500000, Mon] 10.Andrew: Wow, sounds like they make life awesome! Kinda jealous of fun outings them
[2023-03-27T13:10:05, Mon] 11.Audrey: They really do! ' s great much happiness they bring. have any pets
[2023-03-27T13:10:05.500000, Mon] 12.Andrew: No, no pets now. I do love animals
[2023-03-27T13:10:06, Mon] 13.Audrey: That ' s great to hear! Animals truly amazing. have favorite animal
[2023-03-27T13:10:06.500000, Mon] 14.Andrew: ' always been awed by birds Their power to soar explore new spots is amazing
[2023-03-27T13:10:07, Mon] 15.Audrey: Yeah, birds are amazing! imagine it feels incredible to soar see world from up high. have favorite type of bird
[2023-03-27T13:10:07.500000, Mon] 16.Andrew: Eagles always mesmerized me they ' re so strong graceful
[2023-03-27T13:10:08, Mon] 17.Audrey: Yeah they ' re beautiful go bird - watching? must be awesome to see them up close
[2023-03-27T13:10:08.500000, Mon] 18.Andrew: Haven ' t specifically gone out for bird - watching spot them when I hike
[2023-03-27T13:10:09, Mon] 19.Audrey: Nice spotting pretty birds while hiking must be great. any favorite hiking spots
[2023-03-27T13:10:09.500000, Mon] 20.Andrew: Fox Hollow great trail to hike on weekends ; views are awesome
[2023-03-27T13:10:10, Mon] 21.Audrey: Cool, gonna give it a try Thanks for suggestion
[2023-03-27T13:10:10.500000, Mon] 22.Andrew: No problem! Let know how like it Have fun hiking
[2023-03-27T13:10:11, Mon] 23.Audrey: Thanks! ' ll let you know Have a good one
[2023-03-27T13:10:11.500000, Mon] 24.Andrew: Take care have good one! See ya
[2023-04-02T14:42:00, Sun] 25.Audrey: Hey Andrew, surprise for you! adopted another puppy called Pixie. She ' s SO cute! t she just cutest
Output
Example model response (in production the model should output valid JSON only, with no fences or surrounding text):
"memories": [
{
"source_id": 2,
"source_speaker": "Andrew",
"content": "Andrew started a new job as a Financial Analyst in 2023-03-20/2023-03-26.",
"dimension": {
"memory_type": "episodic",
"time": "2023-03-20/2023-03-26",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"new job",
"Financial Analyst",
"started new job"
]
}
},
{
"source_id": 3,
"source_speaker": "Audrey",
"content": "Audrey got new collars and tags for her dogs on 2023-03-27.",
"dimension": {
"memory_type": "episodic",
"time": "2023-03-27",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"new collars",
"new tags"
]
}
},
{
"source_id": 5,
"source_speaker": "Audrey",
"content": "Audrey shared a picture of her dogs wearing new collars on 2023-03-27.",
"dimension": {
"memory_type": "episodic",
"time": "2023-03-27",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"picture",
"dogs",
"new collars"
]
}
},
{
"source_id": 7,
"source_speaker": "Audrey",
"content": "Audrey has had her dogs for 3 years as of 2023-03-27.",
"dimension": {
"memory_type": "fact",
"time": "2023-03-27",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"3 years",
"pet ownership"
]
}
},
{
"source_id": 7,
"source_speaker": "Audrey",
"content": "Audrey's dogs are named Pepper, Precious, and Panda.",
"dimension": {
"memory_type": "fact",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"Pepper",
"Precious",
"Panda"
]
}
},
{
"source_id": 9,
"source_speaker": "Audrey",
"content": "Audrey's dogs are city dogs that she and they explore all the time.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "city",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"city dogs",
"exploring"
]
}
},
{
"source_id": 9,
"source_speaker": "Audrey",
"content": "Audrey loves trying out new parks and trails and often goes on adventures with her dogs.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "parks and trails",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"parks",
"trails",
"adventures"
]
}
},
{
"source_id": 11,
"source_speaker": "Audrey",
"content": "Audrey feels that her dogs bring a lot of happiness to her life.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Audrey",
"dogs",
"happiness",
"pets"
]
}
},
{
"source_id": 12,
"source_speaker": "Andrew",
"content": "Andrew does not have any pets as of 2023-03-27.",
"dimension": {
"memory_type": "fact",
"time": "2023-03-27",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"no pets",
"pets"
]
}
},
{
"source_id": 12,
"source_speaker": "Andrew",
"content": "Andrew loves animals.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"loves animals",
"animals"
]
}
},
{
"source_id": 14,
"source_speaker": "Andrew",
"content": "Andrew has always been awed by birds.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"birds",
"birdwatching",
"interest"
]
}
},
{
"source_id": 14,
"source_speaker": "Andrew",
"content": "Andrew finds it amazing that birds can soar and explore new spots.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"birds",
"soaring",
"exploring",
"birdwatching"
]
}
},
{
"source_id": 16,
"source_speaker": "Andrew",
"content": "Andrew's favorite bird is the eagle.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"favorite bird",
"eagle"
]
}
},
{
"source_id": 18,
"source_speaker": "Andrew",
"content": "Andrew has not specifically gone out for birdwatching, but he often sees birds while hiking.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "hiking",
"reason": "",
"purpose": "",
"keywords": [
"Andrew",
"birdwatching",
"hiking",
"birds"
]
}
},
{
"source_id": 20,
"source_speaker": "Andrew",
"content": "Andrew likes hiking on weekends at Fox Hollow because the trail has awesome views.",
"dimension": {
"memory_type": "profile",
"time": "",
"location": "Fox Hollow",
"reason": "the trail has awesome views",
"purpose": "",
"keywords": [
"Andrew",
"hiking",
"weekends",
"Fox Hollow",
"trail",
"views"
]
}
},
{
"source_id": 21,
"source_speaker": "Audrey",
"content": "Audrey planned to try hiking at Fox Hollow on 2023-03-27.",
"dimension": {
"memory_type": "episodic",
"time": "2023-03-27",
"location": "Fox Hollow",
"reason": "Andrew suggested it",
"purpose": "to try hiking",
"keywords": [
"Audrey",
"Fox Hollow",
"hiking plan",
"suggestion"
]
}
}
]
}
- Downloads last month
- 77