Instructions to use bdbj/Dream-Coder-v0-Instruct-7B-SM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bdbj/Dream-Coder-v0-Instruct-7B-SM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="bdbj/Dream-Coder-v0-Instruct-7B-SM", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("bdbj/Dream-Coder-v0-Instruct-7B-SM", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use bdbj/Dream-Coder-v0-Instruct-7B-SM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bdbj/Dream-Coder-v0-Instruct-7B-SM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "bdbj/Dream-Coder-v0-Instruct-7B-SM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/bdbj/Dream-Coder-v0-Instruct-7B-SM
- SGLang
How to use bdbj/Dream-Coder-v0-Instruct-7B-SM 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 "bdbj/Dream-Coder-v0-Instruct-7B-SM" \ --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": "bdbj/Dream-Coder-v0-Instruct-7B-SM", "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 "bdbj/Dream-Coder-v0-Instruct-7B-SM" \ --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": "bdbj/Dream-Coder-v0-Instruct-7B-SM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use bdbj/Dream-Coder-v0-Instruct-7B-SM with Docker Model Runner:
docker model run hf.co/bdbj/Dream-Coder-v0-Instruct-7B-SM
| library_name: transformers | |
| license: apache-2.0 | |
| pipeline_tag: text-generation | |
| # Dream-Coder-v0-Instruct-7B | |
| 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. | |
| It achieves an impressive **21.4% pass@1 on LiveCodeBench (2410-2505)**, outperforming other open-source diffusion LLMs by a wide margin. | |
| More details about the model and usage can be found in the blog and github bellow: | |
| - **Blog:** https://hkunlp.github.io/blog/2025/dream-coder/ | |
| - **Github:** https://github.com/DreamLM/Dream-Coder | |
| ## Quickstart | |
| To get start with, | |
| please install `transformers==4.46.2` and `torch==2.5.1`. Here is an example to use Dream-Coder 7B: | |
| ```python | |
| import torch | |
| from transformers import AutoModel, AutoTokenizer | |
| model_path = "Dream-org/Dream-Coder-v0-Instruct-7B" | |
| model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True) | |
| tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True) | |
| model = model.to("cuda").eval() | |
| messages = [ | |
| {"role": "user", "content": "Write a quick sort algorithm."} | |
| ] | |
| inputs = tokenizer.apply_chat_template( | |
| messages, return_tensors="pt", return_dict=True, add_generation_prompt=True | |
| ) | |
| input_ids = inputs.input_ids.to(device="cuda") | |
| attention_mask = inputs.attention_mask.to(device="cuda") | |
| output = model.diffusion_generate( | |
| input_ids, | |
| attention_mask=attention_mask, | |
| max_new_tokens=768, | |
| output_history=True, | |
| return_dict_in_generate=True, | |
| steps=768, | |
| temperature=0.1, | |
| top_p=0.95, | |
| alg="entropy", | |
| alg_temp=0., | |
| ) | |
| generations = [ | |
| tokenizer.decode(g[len(p) :].tolist()) | |
| for p, g in zip(input_ids, output.sequences) | |
| ] | |
| print(generations[0].split(tokenizer.eos_token)[0]) | |
| ``` | |
| We adapt the original Dream-7B-Coder-Instruct with soft-masking (SM). More information on SM will be linked here in the future. |