Instructions to use deepseek-ai/DeepSeek-R1-Distill-Llama-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-R1-Distill-Llama-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1-Distill-Llama-8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Llama-8B") model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Llama-8B", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/DeepSeek-R1-Distill-Llama-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "deepseek-ai/DeepSeek-R1-Distill-Llama-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-R1-Distill-Llama-8B
- SGLang
How to use deepseek-ai/DeepSeek-R1-Distill-Llama-8B 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 "deepseek-ai/DeepSeek-R1-Distill-Llama-8B" \ --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": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "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 "deepseek-ai/DeepSeek-R1-Distill-Llama-8B" \ --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": "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-R1-Distill-Llama-8B with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-R1-Distill-Llama-8B
Breaking the 8B Record: 128k Context Reasoning on a 6GB Laptop GPU via 5-Pillar Unified Idempotent Stack
Hi everyone!
Following our weight surgery benchmark, we pushed the frontier further by combining all 5 Idempotent Deep Learning Pillars (Pillars 21–25) on the DeepSeek-R1-Distill-Llama-8B architecture.
We evaluated the unified architecture on an entry-level consumer laptop (NVIDIA RTX PRO 500 Blackwell Laptop GPU, 6 GB VRAM, 32 GB RAM) and achieved a new efficiency record:
The 5-Pillar Unified Stack:
- Pillar 21 (
idempotent-poly): Chebyshev Polynomial Tensor FFN replacing SwiGLU (-61.9% FFN weights). - Pillar 22 (
idempotent-attention): Weight-Shared Recursive Universal Attention (-96.88% attention weights; 32 layers fold into 1 shared core). - Pillar 23 (
idempotent-compaction): Subspace Context Folding ($C(C(KV)) \equiv C(KV)$) achieving 32x KV-cache compression. - Pillar 24 (
idempotent-reasoning): Tarski Consequence Fixpoint ($f(Q \oplus A) = A$) ensuring zero reasoning hallucination drift across long thinking chains. - Pillar 25 (
idempotent-tropical): Zero-multiplication $(\max, +)$ tropical attention eliminating float multipliers.
📊 Benchmark Highlights & Comparison:
| Metric | Standard DeepSeek-R1-8B | Unified Idempotent Transformer | Net Advantage |
|---|---|---|---|
| Total Parameters | 8.03 Billion | 2.71 Billion | -63.83% Parameter Elimination |
| 4-Bit Model Weights | 4.92 GB | ~1.45 GB | 3.47 GB VRAM Saved |
| FFN Forward Latency | 100.70 ms | 41.63 ms | 2.42x Faster Execution! ⚡ |
| 32k Context KV-Cache | 4.00 GB | 128.0 MB | 32x Compression (-96.88%) |
| 128k Context KV-Cache | 16.00 GB (Server-grade) | 512.0 MB | 128K Context on a Laptop! |
| Total VRAM @ 32k Context | 9.22 GB (OOM Crash) | ~1.58 GB | Runs on any 4GB/6GB GPU or Mac! |
| Total VRAM @ 128k Context | 21.22 GB (Data Center) | ~1.96 GB | Fits in < 2 GB VRAM! |
| Reasoning Consistency | Prone to drift | Tarski Invariance | Guaranteed Mathematical Fixpoint |
🚀 What This Means for Local AI:
Normally, running a reasoning model with 128,000 tokens of context requires enterprise data-center GPUs (A100/H100) because KV-cache alone consumes 16 GB of VRAM.
With 32x subspace context folding and polynomial FFN surgery, the entire 8B reasoning system + 128k context consumes less than 2.0 GB of VRAM total, making deep reasoning accessible to anyone on an everyday laptop.
Links & Reproducibility:
- 🔗 Hugging Face Model: aecetin/DeepSeek-R1-8B-Unified-IdemFormer
- 🔗 Surgery Model: aecetin/DeepSeek-R1-8B-PolySurgery
- 🔗 GitHub Repository & Full Benchmark Script: github.com/aemre-cetin/idempotent-poly
- 📜 Full Paper: ResearchGate Publication 414060833
- 🚀 Interactive Live Demo: Hugging Face Space: IdemAILab (5-Pillar Architecture)
- ⚖️ Intellectual Property: U.S. Patent Application No. 64/148,668 & 64/152,276 ("Idempotent Attention, In-Situ KV Compaction & Closed-Form Weight Surgery", Patent Pending).
Happy to discuss the algebraic mechanics and benchmark reproductions with the community!
Reopening discussion for ongoing community engagement and benchmark evaluations.