Upload RETRAIN_WITH_CHAT_FORMAT.md with huggingface_hub
Browse files- RETRAIN_WITH_CHAT_FORMAT.md +66 -0
RETRAIN_WITH_CHAT_FORMAT.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π Retrain with CodeLlama Chat Template Format
|
| 2 |
+
|
| 3 |
+
## β
What Was Done
|
| 4 |
+
|
| 5 |
+
1. β
**Reformatted Dataset** - Created chat template format dataset
|
| 6 |
+
2. β
**Split Dataset** - Split into train/val/test (70/9/15)
|
| 7 |
+
3. β
**Updated Training Script** - Tokenization now handles chat format correctly
|
| 8 |
+
|
| 9 |
+
## π New Dataset Location
|
| 10 |
+
|
| 11 |
+
**Chat Format Dataset:**
|
| 12 |
+
- Original: `datasets/processed/elinnos_fifo_codellama_chat_format.jsonl` (94 samples)
|
| 13 |
+
- Split Train: `datasets/processed/split_chat_format/train.jsonl` (70 samples)
|
| 14 |
+
- Split Val: `datasets/processed/split_chat_format/val.jsonl` (9 samples)
|
| 15 |
+
- Split Test: `datasets/processed/split_chat_format/test.jsonl` (15 samples)
|
| 16 |
+
|
| 17 |
+
## π Retrain Command
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
cd /workspace/ftt/codellama-migration
|
| 21 |
+
source /venv/main/bin/activate
|
| 22 |
+
|
| 23 |
+
python3 scripts/training/finetune_codellama.py \
|
| 24 |
+
--base-model models/base-models/CodeLlama-7B-Instruct \
|
| 25 |
+
--dataset datasets/processed/split_chat_format/train.jsonl \
|
| 26 |
+
--val-dataset datasets/processed/split_chat_format/val.jsonl \
|
| 27 |
+
--output-dir training-outputs/codellama-fifo-v2-chat \
|
| 28 |
+
--max-length 1536 \
|
| 29 |
+
--num-epochs 5 \
|
| 30 |
+
--learning-rate 2e-5 \
|
| 31 |
+
--batch-size 4 \
|
| 32 |
+
--gradient-accumulation-steps 4 \
|
| 33 |
+
--lora-r 48 \
|
| 34 |
+
--lora-alpha 96 \
|
| 35 |
+
--resume-from-checkpoint auto
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
Or use the training script:
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
bash start_training_chat_format.sh
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## π Key Changes
|
| 45 |
+
|
| 46 |
+
1. **Training Format:**
|
| 47 |
+
- Old: `instruction + EOS + response + EOS`
|
| 48 |
+
- New: `instruction + response + EOS` (instruction already has chat template)
|
| 49 |
+
|
| 50 |
+
2. **Inference Format:**
|
| 51 |
+
- Use CodeLlama chat template during inference
|
| 52 |
+
- Match the training format exactly
|
| 53 |
+
|
| 54 |
+
## π Expected Results
|
| 55 |
+
|
| 56 |
+
After retraining with chat format:
|
| 57 |
+
- β
Model should generate Verilog code (not unrelated text)
|
| 58 |
+
- β
Model should understand the task correctly
|
| 59 |
+
- β
Outputs should match training data format
|
| 60 |
+
|
| 61 |
+
## β οΈ Important Notes
|
| 62 |
+
|
| 63 |
+
- **Old model won't work** - The format mismatch means the old model can't be used
|
| 64 |
+
- **Must retrain** - New format requires retraining from scratch
|
| 65 |
+
- **Use new dataset** - Always use `split_chat_format` for training
|
| 66 |
+
|