Views
No views yet
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_name = "maomaocun/LLaDA-Prometheus-no-template"
5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True).to("cuda")
7
8prompt = "Can you tell me an engaging short story about a brave young astronaut who discovers an ancient alien civilization on a distant planet? Make it adventurous and heartwarming, with a twist at the end."
9
10inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
11input_ids = inputs['input_ids']
12attention_mask = inputs.get('attention_mask', torch.ones_like(input_ids))
13for chunk in model.generate(
14 input_ids=input_ids,
15 attention_mask=attention_mask,
16 max_gen_length=1024,
17 block_length=64,
18 threshold=0.9,
19 streaming=True,
20 eos_token_id=tokenizer.eos_token,
21):
22 all_generated_ids = torch.cat([input_ids, chunk], dim=-1)
23 text = tokenizer.batch_decode(all_generated_ids, skip_special_tokens=False)[0].split(tokenizer.eos_token)[0]
24 print(text, end='', flush=True)| Model | GSM8K | GPQA | BBH | MATH | HumanEval | MBPP | MMLU-Pro | MMLU-Generate |
|---|---|---|---|---|---|---|---|---|
| LLaDA 8B Base in Pure Diffusion | 69.06 | 31.91 | 44.77 | 30.84 | 32.92 | 40.8 | 24.26 | 65.9 |
| LLaDA 8B Instruct in Pure Diffusion | 77.48 | 29.01 | 51.49 | 22.32 | 38.71 | 39.2 | 36.41 | 65.5 |
| LLaDA-Prometheus in Block Diffusion | 77.4 | 33.03 | 48.74 | 31.94 | 40.24 | 42 | 33.45 | 65.53 |