Document DPO & GRPO one-liners and transition roadmap in README
Browse files
README.md
CHANGED
|
@@ -81,3 +81,44 @@ dataset = load_dataset("rajivmehtapy/shell-script-specialist-dataset")
|
|
| 81 |
print(dataset)
|
| 82 |
print(dataset["train"][0])
|
| 83 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
print(dataset)
|
| 82 |
print(dataset["train"][0])
|
| 83 |
```
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## Next Steps: DPO & GRPO Alignment
|
| 88 |
+
|
| 89 |
+
When you spin up your next machine for DPO and GRPO, you can immediately resume using the following one-liners:
|
| 90 |
+
|
| 91 |
+
### 1. Pulling the Policy Model on the New Machine
|
| 92 |
+
|
| 93 |
+
```python
|
| 94 |
+
from unsloth import FastLanguageModel
|
| 95 |
+
|
| 96 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 97 |
+
model_name="rajivmehtapy/gemma-4-e4b-shell-specialist",
|
| 98 |
+
max_seq_length=1024,
|
| 99 |
+
load_in_4bit=True,
|
| 100 |
+
)
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
### 2. Pulling the Dataset on the New Machine
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
from datasets import load_dataset
|
| 107 |
+
|
| 108 |
+
dataset = load_dataset("rajivmehtapy/shell-script-specialist-dataset")
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
### 3. Ready for DPO
|
| 112 |
+
|
| 113 |
+
- Use the SFT model as the reference policy.
|
| 114 |
+
- Provide `(prompt, chosen, rejected)` triplets (where `chosen` contains defensive standards like `set -euo pipefail` and `rejected` contains common bash antipatterns).
|
| 115 |
+
- Train with `trl.DPOTrainer`.
|
| 116 |
+
|
| 117 |
+
### 4. Ready for GRPO
|
| 118 |
+
|
| 119 |
+
- Use the SFT model as the actor model.
|
| 120 |
+
- Set up automated rule-based reward functions (`shellcheck` returncode, exit code in Docker sandbox, security parameter validation).
|
| 121 |
+
- Train with `trl.GRPOTrainer`.
|
| 122 |
+
|
| 123 |
+
Everything is backed up and ready for your next phase!
|
| 124 |
+
|