Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
# LLaDA-Prometheus
|
| 5 |
+
|
| 6 |
+
## Model Description
|
| 7 |
+
|
| 8 |
+
This model is a fine-tuned version of the LLaDA 8B Base model, obtained through a specialized Supervised Fine-Tuning (SFT) process. It innovatively discards the complex attention mask design typically associated with block diffusion, while preserving full attention mechanisms. This allows the model to achieve block diffusion-style inference efficiently—leveraging KV cache for streamlined generation, outputting an EOS token upon completion of the response to seamlessly exit the generation process.
|
| 9 |
+
|
| 10 |
+
Key innovations:
|
| 11 |
+
- **Full Attention Preservation**: Maintains standard full attention without the overhead of intricate masking.
|
| 12 |
+
- **Block Diffusion Inference**: Enables iterative block-wise generation via KV cache management, ensuring coherent and controlled outputs.
|
| 13 |
+
- **EOS Handling**: Trained to naturally emit EOS tokens at response boundaries.
|
| 14 |
+
|
| 15 |
+
This approach balances computational efficiency with high-quality generation, making it suitable for tasks requiring structured, multi-step reasoning.
|
| 16 |
+
|
| 17 |
+
## Usage
|
| 18 |
+
|
| 19 |
+
To load and use this model with Hugging Face Transformers:
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import torch
|
| 23 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 24 |
+
|
| 25 |
+
model_name = "maomaocun/LLaDA-Prometheus-no-template"
|
| 26 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 27 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True).to("cuda")
|
| 28 |
+
|
| 29 |
+
prompt = "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."
|
| 30 |
+
|
| 31 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 32 |
+
input_ids = inputs['input_ids']
|
| 33 |
+
attention_mask = inputs.get('attention_mask', torch.ones_like(input_ids))
|
| 34 |
+
for chunk in model.generate(
|
| 35 |
+
input_ids=input_ids,
|
| 36 |
+
attention_mask=attention_mask,
|
| 37 |
+
max_gen_length=1024,
|
| 38 |
+
block_length=64,
|
| 39 |
+
threshold=0.9,
|
| 40 |
+
streaming=True,
|
| 41 |
+
eos_token_id=tokenizer.eos_token,
|
| 42 |
+
):
|
| 43 |
+
all_generated_ids = torch.cat([input_ids, chunk], dim=-1)
|
| 44 |
+
text = tokenizer.batch_decode(all_generated_ids, skip_special_tokens=False)[0].split(tokenizer.eos_token)[0]
|
| 45 |
+
print(text, end='', flush=True)
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
For block diffusion-style inference, customize the generation loop to manage KV cache and block outputs as needed.
|
| 49 |
+
|
| 50 |
+
## Benchmarks
|
| 51 |
+
|
| 52 |
+
The following table compares performance across key evaluation benchmarks. Results are reported as accuracy percentages where applicable.
|
| 53 |
+
|
| 54 |
+
| Model | GSM8K | GPQA | BBH | MATH | HumanEval | MBPP | MMLU-Pro | MMLU-Generate |
|
| 55 |
+
|--------------------------------|-------|-------|-------|-------|-----------|-------|----------|---------------|
|
| 56 |
+
| LLaDA 8B Base in Pure Diffusion | 69.06 | 31.91 | 44.77 | 30.84 | 32.92 | 40.8 | 24.26 | 65.9 |
|
| 57 |
+
| LLaDA 8B Instruct in Pure Diffusion | 77.48 | 29.01 | 51.49 | 22.32 | 38.71 | 39.2 | 36.41 | 65.5 |
|
| 58 |
+
| LLaDA-Prometheus in Block Diffusion | 77.4 | 33.03 | 48.74 | 31.94 | 40.24 | 42 | 33.45 | 65.53 |
|
| 59 |
+
|
| 60 |
+
These results demonstrate competitive performance, particularly in code generation (HumanEval, MBPP) and reasoning tasks (BBH, MATH), with gains over the base instruct variant in several areas.
|