Files changed (1) hide show
  1. README.md +4 -3
README.md CHANGED
@@ -26,10 +26,11 @@ The DiffuCoder-7B-Instruct model builds on the DiffuCoder-7B-Base checkpoint wit
26
  import torch
27
  from transformers import AutoModel, AutoTokenizer
28
 
 
29
  model_path = "apple/DiffuCoder-7B-Instruct"
30
  model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
31
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
32
- model = model.to("cuda").eval()
33
 
34
  query = "Write a function to find the shared elements from the given two lists."
35
  prompt = f"""<|im_start|>system
@@ -43,8 +44,8 @@ You are a helpful assistant.<|im_end|>
43
  TOKEN_PER_STEP = 1 # diffusion timesteps * TOKEN_PER_STEP = total new tokens
44
 
45
  inputs = tokenizer(prompt, return_tensors="pt")
46
- input_ids = inputs.input_ids.to(device="cuda")
47
- attention_mask = inputs.attention_mask.to(device="cuda")
48
 
49
  output = model.diffusion_generate(
50
  input_ids,
 
26
  import torch
27
  from transformers import AutoModel, AutoTokenizer
28
 
29
+ device = "cuda"
30
  model_path = "apple/DiffuCoder-7B-Instruct"
31
  model = AutoModel.from_pretrained(model_path, torch_dtype=torch.bfloat16, trust_remote_code=True)
32
  tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
33
+ model = model.to(device).eval()
34
 
35
  query = "Write a function to find the shared elements from the given two lists."
36
  prompt = f"""<|im_start|>system
 
44
  TOKEN_PER_STEP = 1 # diffusion timesteps * TOKEN_PER_STEP = total new tokens
45
 
46
  inputs = tokenizer(prompt, return_tensors="pt")
47
+ input_ids = inputs.input_ids.to(device=device)
48
+ attention_mask = inputs.attention_mask.to(device=device)
49
 
50
  output = model.diffusion_generate(
51
  input_ids,