Text Generation
Transformers
Safetensors
English
metadiffusion
diffusion
diffusion-lm
ar-to-diffusion
custom_code
Instructions to use CodeSoft/MetaDiffusion-600M-ChatBase with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CodeSoft/MetaDiffusion-600M-ChatBase with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="CodeSoft/MetaDiffusion-600M-ChatBase", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("CodeSoft/MetaDiffusion-600M-ChatBase", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CodeSoft/MetaDiffusion-600M-ChatBase with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CodeSoft/MetaDiffusion-600M-ChatBase" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CodeSoft/MetaDiffusion-600M-ChatBase", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/CodeSoft/MetaDiffusion-600M-ChatBase
- SGLang
How to use CodeSoft/MetaDiffusion-600M-ChatBase with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "CodeSoft/MetaDiffusion-600M-ChatBase" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CodeSoft/MetaDiffusion-600M-ChatBase", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "CodeSoft/MetaDiffusion-600M-ChatBase" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CodeSoft/MetaDiffusion-600M-ChatBase", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use CodeSoft/MetaDiffusion-600M-ChatBase with Docker Model Runner:
docker model run hf.co/CodeSoft/MetaDiffusion-600M-ChatBase
Update README.md
Browse files
README.md
CHANGED
|
@@ -76,38 +76,38 @@ print(tok.decode(out[0], skip_special_tokens=True))
|
|
| 76 |
|
| 77 |
# Chat with it (chat.py)
|
| 78 |
```bash
|
| 79 |
-
|
| 80 |
-
--model-path
|
| 81 |
-
--tokenizer
|
| 82 |
--im-end-bias 2.0 --im-end-bias-t 0.3 --watch
|
| 83 |
```
|
| 84 |
## Fine-tune (train.py)
|
| 85 |
|
| 86 |
```bash
|
| 87 |
# 1. Init: convert the AR model to a diffusion init
|
| 88 |
-
python
|
| 89 |
--output init/metadiffusion-600M-instruct.pt \
|
| 90 |
--tokenizer-out data/tokenizer
|
| 91 |
|
| 92 |
# 2. Corpus: smol, opc, math and no_robots, or a local --jsonl of {"messages": [...]} rows.
|
| 93 |
# --val-fraction holds out a disjoint val set for early stopping.
|
| 94 |
-
python
|
| 95 |
--val-fraction 0.05
|
| 96 |
|
| 97 |
# 3. Train (defaults: lr 5e-5, bf16, seq 512, batch auto-detected)
|
| 98 |
-
python
|
| 99 |
--data-dir data --output-dir checkpoints --max-steps 30000
|
| 100 |
|
| 101 |
# 4. Continue a run: checkpoints carry model + optimizer + scheduler
|
| 102 |
# state, so --resume-from picks up LR position and momentum exactly
|
| 103 |
-
python
|
| 104 |
-
--data-dir data --output-dir
|
| 105 |
--resume-from checkpoints_p2/step_20000.pt --max-steps 16000
|
| 106 |
|
| 107 |
# 5. Test, then ship
|
| 108 |
-
python
|
| 109 |
--tokenizer data/tokenizer --watch
|
| 110 |
-
python
|
| 111 |
--tokenizer data/tokenizer --output MetaDiffusion-600M-ChatBase
|
| 112 |
```
|
| 113 |
## Limitations
|
|
|
|
| 76 |
|
| 77 |
# Chat with it (chat.py)
|
| 78 |
```bash
|
| 79 |
+
python chat.py \
|
| 80 |
+
--model-path model.safetensors \
|
| 81 |
+
--tokenizer ./tokenizer \
|
| 82 |
--im-end-bias 2.0 --im-end-bias-t 0.3 --watch
|
| 83 |
```
|
| 84 |
## Fine-tune (train.py)
|
| 85 |
|
| 86 |
```bash
|
| 87 |
# 1. Init: convert the AR model to a diffusion init
|
| 88 |
+
python convert.py --source Qwen/Qwen3-0.6B \
|
| 89 |
--output init/metadiffusion-600M-instruct.pt \
|
| 90 |
--tokenizer-out data/tokenizer
|
| 91 |
|
| 92 |
# 2. Corpus: smol, opc, math and no_robots, or a local --jsonl of {"messages": [...]} rows.
|
| 93 |
# --val-fraction holds out a disjoint val set for early stopping.
|
| 94 |
+
python prepare_data.py --datasets smol,math --out data \
|
| 95 |
--val-fraction 0.05
|
| 96 |
|
| 97 |
# 3. Train (defaults: lr 5e-5, bf16, seq 512, batch auto-detected)
|
| 98 |
+
python train.py --init-checkpoint init/metadiffusion-600M-instruct.pt \
|
| 99 |
--data-dir data --output-dir checkpoints --max-steps 30000
|
| 100 |
|
| 101 |
# 4. Continue a run: checkpoints carry model + optimizer + scheduler
|
| 102 |
# state, so --resume-from picks up LR position and momentum exactly
|
| 103 |
+
python train.py --init-checkpoint init/metadiffusion-600M-instruct.pt \
|
| 104 |
+
--data-dir data --output-dir checkpoints \
|
| 105 |
--resume-from checkpoints_p2/step_20000.pt --max-steps 16000
|
| 106 |
|
| 107 |
# 5. Test, then ship
|
| 108 |
+
python chat.py --model-path checkpoints_/step_30000.pt \
|
| 109 |
--tokenizer data/tokenizer --watch
|
| 110 |
+
python export_hf.py --checkpoint checkpoints/step_30000.pt \
|
| 111 |
--tokenizer data/tokenizer --output MetaDiffusion-600M-ChatBase
|
| 112 |
```
|
| 113 |
## Limitations
|