Text Generation
Transformers
Safetensors
livemem
qwen3
custom-code
long-context
reinforcement-learning
conversational
custom_code
Instructions to use chen-l/LiveMem-RL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chen-l/LiveMem-RL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chen-l/LiveMem-RL", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("chen-l/LiveMem-RL", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use chen-l/LiveMem-RL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chen-l/LiveMem-RL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chen-l/LiveMem-RL", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chen-l/LiveMem-RL
- SGLang
How to use chen-l/LiveMem-RL 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 "chen-l/LiveMem-RL" \ --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": "chen-l/LiveMem-RL", "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 "chen-l/LiveMem-RL" \ --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": "chen-l/LiveMem-RL", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chen-l/LiveMem-RL with Docker Model Runner:
docker model run hf.co/chen-l/LiveMem-RL
| """Config for the memory-augmented Qwen3 (主路 Qwen3Attention ‖ 边路 GDN2).""" | |
| from __future__ import annotations | |
| from transformers.models.qwen3.configuration_qwen3 import Qwen3Config | |
| class LiveMemConfig(Qwen3Config): | |
| """Qwen3 + per-attention-head GDN2 memory side-branch. | |
| All base Qwen3 fields are inherited unchanged. The `mem_*` fields configure | |
| the side branch and the two memory mechanisms (Design X / Design Y). | |
| """ | |
| model_type = "livemem" | |
| def __init__( | |
| self, | |
| # which mechanism: "X" = 连续扫描 (continuous scan, write_mask=None); | |
| # "Y" = 门控读写解耦 (freeze gates on read tokens). | |
| memory_design: str = "Y", | |
| # layers that get a memory branch; None = all layers. | |
| mem_layers: list[int] | None = None, | |
| # GDN2 side-branch hyper-params. The legacy/default geometry is a | |
| # full-MHA copy of Qwen3 (8 KV heads repeated 4x -> 32 heads), per plan | |
| # 02 §1.3. Newer experiments can explicitly set mem_num_heads=8, | |
| # mem_num_v_heads=8, mem_expand_v=4 to keep similar state capacity with | |
| # fewer Q/K heads. | |
| mem_head_dim: int | None = None, | |
| mem_num_heads: int | None = None, | |
| mem_num_v_heads: int | None = None, | |
| mem_expand_v: float = 1.0, | |
| mem_conv_size: int = 4, | |
| mem_conv_bias: bool = False, | |
| mem_norm_eps: float | None = None, | |
| # zero-init the side o_proj so training starts ≈ original Qwen3 (plan T1). | |
| mem_o_proj_zero_init: bool = True, | |
| **kwargs, | |
| ) -> None: | |
| super().__init__(**kwargs) | |
| if memory_design not in ("X", "Y"): | |
| raise ValueError(f"memory_design must be 'X' or 'Y', got {memory_design!r}") | |
| self.memory_design = memory_design | |
| self.mem_layers = mem_layers | |
| self.mem_head_dim = mem_head_dim if mem_head_dim is not None else self.head_dim | |
| self.mem_num_heads = ( | |
| mem_num_heads if mem_num_heads is not None else self.num_attention_heads | |
| ) | |
| self.mem_num_v_heads = ( | |
| mem_num_v_heads if mem_num_v_heads is not None else self.mem_num_heads | |
| ) | |
| self.mem_expand_v = mem_expand_v | |
| self.mem_conv_size = mem_conv_size | |
| self.mem_conv_bias = mem_conv_bias | |
| self.mem_norm_eps = mem_norm_eps if mem_norm_eps is not None else self.rms_norm_eps | |
| self.mem_o_proj_zero_init = mem_o_proj_zero_init | |
| def memory_layer_indices(self) -> list[int]: | |
| if self.mem_layers is None: | |
| return list(range(self.num_hidden_layers)) | |
| return list(self.mem_layers) | |