README.md
1.7 KB · 64 lines · markdown Raw
1 ---
2 license: apache-2.0
3 library_name: transformers
4 pipeline_tag: text-generation
5 base_model: chen-l/LiveMem-SFT
6 tags:
7 - livemem
8 - qwen3
9 - custom-code
10 - long-context
11 - reinforcement-learning
12 - text-generation
13 ---
14
15 # LiveMem-RL
16
17 LiveMem-RL is the reinforcement-learning checkpoint of LiveMem-4B-SFT. It
18 uses a Qwen3 attention path in parallel with a Gated DeltaNet 2 (GDN2)
19 recurrent memory path at every decoder layer:
20
21 ```text
22 layer output = Qwen3 attention output + GDN2 memory output
23 ```
24
25 This checkpoint was trained with GRPO from `chen-l/LiveMem-SFT`. During RL,
26 the Qwen3 main path remained frozen and the memory side path was updated. The
27 configured maximum context length is 262,144 tokens; actual usable context
28 depends on GPU memory and inference backend.
29
30 ## Transformers usage
31
32 LiveMem uses custom model code and GDN2 Triton kernels. A CUDA environment is
33 required for inference.
34
35 ```bash
36 pip install -r requirements.txt
37 ```
38
39 ```python
40 import torch
41 from transformers import AutoModelForCausalLM, AutoTokenizer
42
43 model_id = "chen-l/LiveMem-4B-RL"
44 tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
45 model = AutoModelForCausalLM.from_pretrained(
46 model_id,
47 trust_remote_code=True,
48 dtype=torch.bfloat16,
49 device_map="auto",
50 )
51
52 messages = [{"role": "user", "content": "Answer using the supplied long context."}]
53 inputs = tokenizer.apply_chat_template(
54 messages,
55 add_generation_prompt=True,
56 return_tensors="pt",
57 return_dict=True,
58 ).to(model.device)
59 outputs = model.generate(**inputs, max_new_tokens=256)
60 print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
61 ```
62
63 `trust_remote_code=True` is required because LiveMem is not a built-in
64 Transformers architecture.