hlnchen commited on
Commit
bfe4557
·
verified ·
1 Parent(s): ccf7c47

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +68 -3
README.md CHANGED
@@ -1,3 +1,68 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - diffusion
8
+ - text generation
9
+ - code generation
10
+ ---
11
+ # CoDA-v0-Instruct
12
+
13
+ ## Overview
14
+ CoDA is Salesforce AI Research's open, lightweight and diffusion-based language model.
15
+
16
+ [Technical Report (Coming soon)]()
17
+
18
+ [Code](https://github.com/SalesforceAIResearch/CoDA/)
19
+
20
+
21
+
22
+ ## Requirements
23
+ ```
24
+ torch==2.8.0
25
+ transformers>=4.47.1
26
+ flash-attn==2.8.3
27
+ ```
28
+
29
+ ## Quickstart
30
+ Here is a code snippet for loading the model, tokenizer and run generation.
31
+ ```python
32
+ import torch
33
+ from transformers import AutoModel, AutoTokenizer
34
+
35
+ model_name = "Salesforce/CoDA-v0-Instruct"
36
+ device = "cuda"
37
+
38
+ model = AutoModel.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True).to(device)
39
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
40
+ model.eval()
41
+
42
+ prompt = "Write a python function to find the Fibonacci sequence up to n numbers."
43
+ messages = [
44
+ {"role": "user", "content": prompt}
45
+ ]
46
+ text = tokenizer.apply_chat_template(
47
+ messages,
48
+ tokenize=False,
49
+ add_generation_prompt=True
50
+ )
51
+ input_ids = tokenizer([text], return_tensors="pt").input_ids.to(model.device)
52
+ generated_ids = model.diffusion_generate(
53
+ inputs=input_ids,
54
+ max_new_tokens=256,
55
+ steps=256,
56
+ top_p=0.9,
57
+ temperature=0.2,
58
+ alg="entropy",
59
+ alg_temp=0.2,
60
+ )
61
+ generated_ids = [
62
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(input_ids, generated_ids)
63
+ ]
64
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
65
+ ```
66
+
67
+ ### Deployment
68
+ For deployment, please checkout our repo.