File size: 1,656 Bytes
826cf53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
library_name: transformers
pipeline_tag: text-generation
base_model: Qwen/Qwen3-4B-Instruct-2507
tags:
  - livemem
  - qwen3
  - custom-code
  - long-context
  - text-generation
---

# LiveMem-SFT

LiveMem-4B-SFT uses a Qwen3-4B-Instruct-2507 backbone augmented with a parallel
Gated DeltaNet 2 (GDN2) recurrent memory path in every decoder layer:

```text
layer output = Qwen3 attention output + GDN2 memory output
```

The checkpoint is the supervised fine-tuned model used as the initialization
for `chen-l/LiveMem-RL`. It supports a maximum configured context length of
262,144 tokens. Actual usable context depends on GPU memory and inference
backend.

## Transformers usage

LiveMem uses custom model code and GDN2 Triton kernels. A CUDA environment is
required for inference.

```bash
pip install -r requirements.txt
```

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "chen-l/LiveMem-4B-SFT"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    dtype=torch.bfloat16,
    device_map="auto",
)

messages = [{"role": "user", "content": "Summarize the document."}]
inputs = tokenizer.apply_chat_template(
    messages,
    add_generation_prompt=True,
    return_tensors="pt",
    return_dict=True,
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
```

`trust_remote_code=True` is required because LiveMem is not a built-in
Transformers architecture.