Text Generation
Transformers
PyTorch
MLX
English
tree-attention
apple-m4
mps
structured-generation
parallel-decoding
constrained-decoding
apple-silicon
classification
json
Instructions to use epsilon3/Qwen-2.5-1B-RLCD-Fast with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="epsilon3/Qwen-2.5-1B-RLCD-Fast")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("epsilon3/Qwen-2.5-1B-RLCD-Fast", device_map="auto") - MLX
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("epsilon3/Qwen-2.5-1B-RLCD-Fast") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- vLLM
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "epsilon3/Qwen-2.5-1B-RLCD-Fast" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "epsilon3/Qwen-2.5-1B-RLCD-Fast", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/epsilon3/Qwen-2.5-1B-RLCD-Fast
- SGLang
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast 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 "epsilon3/Qwen-2.5-1B-RLCD-Fast" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "epsilon3/Qwen-2.5-1B-RLCD-Fast", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "epsilon3/Qwen-2.5-1B-RLCD-Fast" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "epsilon3/Qwen-2.5-1B-RLCD-Fast", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - MLX LM
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "epsilon3/Qwen-2.5-1B-RLCD-Fast" --prompt "Once upon a time"
- Docker Model Runner
How to use epsilon3/Qwen-2.5-1B-RLCD-Fast with Docker Model Runner:
docker model run hf.co/epsilon3/Qwen-2.5-1B-RLCD-Fast
- Atomic Chat
Download test_tree_decode.py from epsilon3/Qwen-2.5-1B-RLCD-Fast: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/epsilon3/Qwen-2.5-1B-RLCD-Fast/resolve/main/test_tree_decode.py
- Command line
-
hf download hf://epsilon3/Qwen-2.5-1B-RLCD-Fast/test_tree_decode.py
-
curl -L -o test_tree_decode.py https://huggingface.co/epsilon3/Qwen-2.5-1B-RLCD-Fast/resolve/main/test_tree_decode.py
2.34 kB
| import unittest | |
| import torch | |
| from transformers import Qwen2Config, Qwen2ForCausalLM | |
| from tree_decode import FieldPlan, decode_fields, prefill | |
| class TreeTests(unittest.TestCase): | |
| def setUp(self): | |
| torch.manual_seed(7) | |
| torch.set_num_threads(2) | |
| config = Qwen2Config(vocab_size=97, hidden_size=64, intermediate_size=128, | |
| num_hidden_layers=2, num_attention_heads=4, | |
| num_key_value_heads=2, attention_dropout=0) | |
| config._attn_implementation = 'sdpa' | |
| self.model = Qwen2ForCausalLM(config).eval() | |
| self.ids = torch.tensor([[1, 2, 3, 4, 5]]) | |
| self.cache = prefill(self.model, self.ids) | |
| def test_matches_independent_and_batch_after_continuation(self): | |
| suffixes = [[8, 9], [10, 11, 12, 13], [14]] | |
| plan = FieldPlan(suffixes, 5, 'cpu', torch.float32) | |
| ref = decode_fields(self.model, self.cache, plan, 'batch', 4) | |
| tree = decode_fields(self.model, self.cache, plan, 'tree', 4) | |
| torch.testing.assert_close(tree, ref, atol=1e-6, rtol=1e-5) | |
| for i, suffix in enumerate(suffixes): | |
| sequence = self.ids[0].tolist() + suffix | |
| for step in range(4): | |
| with torch.inference_mode(): | |
| logits = self.model(torch.tensor([sequence])).logits[0, -1] | |
| torch.testing.assert_close(tree[step, i], logits, atol=1e-6, rtol=1e-5) | |
| sequence.append(logits.argmax().item()) | |
| self.assertEqual(self.cache.get_seq_length(), 5) | |
| def test_no_sibling_leakage(self): | |
| original = FieldPlan([[8, 9], [10, 11, 12]], 5, 'cpu', torch.float32) | |
| changed = FieldPlan([[8, 9], [66, 67, 68]], 5, 'cpu', torch.float32) | |
| a = decode_fields(self.model, self.cache, original, 'tree', 3) | |
| b = decode_fields(self.model, self.cache, changed, 'tree', 3) | |
| torch.testing.assert_close(a[:, 0], b[:, 0], atol=1e-6, rtol=1e-5) | |
| self.assertFalse(torch.allclose(a[:, 1], b[:, 1])) | |
| def test_one_branch(self): | |
| plan = FieldPlan([[7, 8, 9]], 5, 'cpu', torch.float32) | |
| torch.testing.assert_close(decode_fields(self.model, self.cache, plan, 'tree', 2), | |
| decode_fields(self.model, self.cache, plan, 'batch', 2)) | |
| if __name__ == '__main__': | |
| unittest.main() | |