Zhihui commited on
Commit
acadfae
·
verified ·
1 Parent(s): 3907364

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -0
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
+ ```