Instructions to use Dream-org/Dream-Coder-v0-Instruct-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Dream-org/Dream-Coder-v0-Instruct-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Dream-org/Dream-Coder-v0-Instruct-7B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Dream-org/Dream-Coder-v0-Instruct-7B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Dream-org/Dream-Coder-v0-Instruct-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Dream-org/Dream-Coder-v0-Instruct-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dream-org/Dream-Coder-v0-Instruct-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Dream-org/Dream-Coder-v0-Instruct-7B
- SGLang
How to use Dream-org/Dream-Coder-v0-Instruct-7B 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 "Dream-org/Dream-Coder-v0-Instruct-7B" \ --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": "Dream-org/Dream-Coder-v0-Instruct-7B", "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 "Dream-org/Dream-Coder-v0-Instruct-7B" \ --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": "Dream-org/Dream-Coder-v0-Instruct-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Dream-org/Dream-Coder-v0-Instruct-7B with Docker Model Runner:
docker model run hf.co/Dream-org/Dream-Coder-v0-Instruct-7B
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
---
|
| 5 |
+
# Dream-Coder-v0-Instruct-7B
|
| 6 |
+
|
| 7 |
+
Dream-Coder 7B is a **diffusion LLM for code** trained exclusively on open-source data across its development stages—adaptation, supervised fine-tuning, and reinforcement learning.
|
| 8 |
+
It achieves an impressive **21.4% pass@1 on LiveCodeBench (2410-2505)**, outperforming other open-source diffusion LLMs by a wide margin.
|
| 9 |
+
More details about the model and usage can be found in the blog and github bellow:
|
| 10 |
+
|
| 11 |
+
- **Blog:** https://hkunlp.github.io/blog/2025/dream-coder/
|
| 12 |
+
- **Github:** https://github.com/DreamLM/Dream-Coder
|
| 13 |
+
|
| 14 |
+
## Quickstart
|
| 15 |
+
To get start with,
|
| 16 |
+
please install `transformers==4.46.2` and `torch==2.5.1`. Here is an example to use Dream-Coder 7B:
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
import torch
|
| 20 |
+
from transformers import AutoModel, AutoTokenizer
|
| 21 |
+
|
| 22 |
+
model_path = "Dream-org/Dream-Coder-v0-Instruct-7B"
|
| 23 |
+
model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
|
| 24 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
| 25 |
+
model = model.to("cuda").eval()
|
| 26 |
+
|
| 27 |
+
messages = [
|
| 28 |
+
{"role": "user", "content": "Write a quick sort algorithm."}
|
| 29 |
+
]
|
| 30 |
+
inputs = tokenizer.apply_chat_template(
|
| 31 |
+
messages, return_tensors="pt", return_dict=True, add_generation_prompt=True
|
| 32 |
+
)
|
| 33 |
+
input_ids = inputs.input_ids.to(device="cuda")
|
| 34 |
+
attention_mask = inputs.attention_mask.to(device="cuda")
|
| 35 |
+
|
| 36 |
+
output = model.diffusion_generate(
|
| 37 |
+
input_ids,
|
| 38 |
+
attention_mask=attention_mask,
|
| 39 |
+
max_new_tokens=768,
|
| 40 |
+
output_history=True,
|
| 41 |
+
return_dict_in_generate=True,
|
| 42 |
+
steps=768,
|
| 43 |
+
temperature=0.1,
|
| 44 |
+
top_p=0.95,
|
| 45 |
+
alg="entropy",
|
| 46 |
+
alg_temp=0.,
|
| 47 |
+
)
|
| 48 |
+
generations = [
|
| 49 |
+
tokenizer.decode(g[len(p) :].tolist())
|
| 50 |
+
for p, g in zip(input_ids, output.sequences)
|
| 51 |
+
]
|
| 52 |
+
|
| 53 |
+
print(generations[0].split(tokenizer.eos_token)[0])
|
| 54 |
+
```
|