Model save
Browse files
README.md
CHANGED
|
@@ -1,137 +1,51 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
pipeline_tag: text-generation
|
| 10 |
---
|
| 11 |
-
# SmolLM2‑135M‑Instruct‑TaiwanChat
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
- **Base model:** `HuggingFaceTB/SmolLM2-135M-Instruct`
|
| 19 |
-
- **Fine‑tuned on:** `yentinglin/TaiwanChat` (subset of 85,840 examples ≈ 20 M tokens)
|
| 20 |
-
- **Task:** Instruction‑tuned chat in Mandarin/Taiwanese
|
| 21 |
-
- **Framework:** Unsloth + Hugging Face Transformers [`Trainer`] + PEFT (LoRA)
|
| 22 |
-
- **Precision:**
|
| 23 |
-
- 4‑bit quantization on model weights
|
| 24 |
-
- FP16 on CUDA (V100)
|
| 25 |
-
- BF16 on Intel XPU (if available)
|
| 26 |
-
- **Adapters:** LoRA (r=8, α=16) applied to `q_proj` and `v_proj` layers
|
| 27 |
-
- **Memory optimizations:**
|
| 28 |
-
- Gradient checkpointing enabled
|
| 29 |
-
- CPU offload via DeepSpeed ZeRO Stage 2 (optional)
|
| 30 |
-
|
| 31 |
-
---
|
| 32 |
-
## How to Use
|
| 33 |
-
|
| 34 |
-
### 1. Install dependencies
|
| 35 |
-
```bash
|
| 36 |
-
pip install transformers datasets accelerate unsloth peft wandb
|
| 37 |
-
# (optional) pip install xformers deepspeed
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
### 2. Load & Generate
|
| 41 |
-
```python
|
| 42 |
-
import torch
|
| 43 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 44 |
-
|
| 45 |
-
model_id = "Luigi/SmolLM2-135M-Instruct-TaiwanChat"
|
| 46 |
|
| 47 |
-
|
| 48 |
-
if torch.cuda.is_available():
|
| 49 |
-
device = "cuda"
|
| 50 |
-
elif torch.xpu.is_available():
|
| 51 |
-
device = "xpu"
|
| 52 |
|
| 53 |
-
|
| 54 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 55 |
-
model = AutoModelForCausalLM.from_pretrained(model_id).to(device)
|
| 56 |
|
| 57 |
-
|
| 58 |
-
generator = pipeline(
|
| 59 |
-
"text-generation",
|
| 60 |
-
model=model,
|
| 61 |
-
tokenizer=tokenizer,
|
| 62 |
-
device=0 if device in ("cuda","xpu") else -1,
|
| 63 |
-
max_new_tokens=512,
|
| 64 |
-
do_sample=True,
|
| 65 |
-
temperature=0.8,
|
| 66 |
-
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
result = generator(prompt)
|
| 70 |
-
print(result[0]["generated_text"])
|
| 71 |
-
```
|
| 72 |
|
| 73 |
-
|
| 74 |
-
## Training Script
|
| 75 |
-
|
| 76 |
-
All training logic is contained in `train_with_unsloth.py`.
|
| 77 |
|
| 78 |
-
|
| 79 |
-
```python
|
| 80 |
-
PROJECT_NAME = 'SmolLM2-135M-Instruct-TaiwanChat'
|
| 81 |
-
BASE_MODEL_ID = 'HuggingFaceTB/SmolLM2-135M-Instruct'
|
| 82 |
-
DATASET_ID = 'yentinglin/TaiwanChat'
|
| 83 |
-
N_SAMPLES = 85840 # ~20M tokens subset
|
| 84 |
-
MAX_LEN = 256
|
| 85 |
-
```
|
| 86 |
|
| 87 |
-
|
| 88 |
-
- Load in 4‑bit via Unsloth’s `FastLanguageModel.from_pretrained(..., load_in_4bit=True)`
|
| 89 |
-
- Prepare for k‑bit training (`prepare_model_for_kbit_training`)
|
| 90 |
-
- Attach LoRA adapters (r=8, α=16) to `q_proj`, `v_proj`
|
| 91 |
-
- Enable gradient checkpointing on the model
|
| 92 |
|
| 93 |
-
|
| 94 |
-
- `per_device_train_batch_size = 1`
|
| 95 |
-
- `gradient_accumulation_steps = 16`
|
| 96 |
-
- `learning_rate = 5e-5`
|
| 97 |
-
- `num_train_epochs = 3`
|
| 98 |
-
- `fp16` on CUDA, `bf16` on XPU
|
| 99 |
-
- `logging_steps = 1000`
|
| 100 |
-
- `save_steps = 5000`
|
| 101 |
-
- `gradient_checkpointing = True`
|
| 102 |
-
- `push_to_hub = True`
|
| 103 |
|
| 104 |
-
###
|
| 105 |
-
```bash
|
| 106 |
-
python train_with_unsloth.py
|
| 107 |
-
```
|
| 108 |
|
| 109 |
-
The
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
---
|
| 118 |
-
## Limitations
|
| 119 |
-
- Fine‑tuned on a subset (~20 M tokens) for domain adaptation; may underperform on broader queries
|
| 120 |
-
- No separate validation loop by default—monitor on a held‑out split if desired
|
| 121 |
|
| 122 |
-
|
| 123 |
-
## License
|
| 124 |
-
- **Code**: Apache 2.0
|
| 125 |
-
- **Data & weights**: CC BY‑NC 4.0 (non‑commercial)
|
| 126 |
-
|
| 127 |
-
---
|
| 128 |
-
## Citation
|
| 129 |
-
```bibtex
|
| 130 |
-
@misc{SmolLM2TaiwanChat2025,
|
| 131 |
-
title = {SmolLM2‑135M‑Instruct‑TaiwanChat},
|
| 132 |
-
author = {Luigi Liu},
|
| 133 |
-
year = {2025},
|
| 134 |
-
howpublished = {\url{https://huggingface.co/Luigi/SmolLM2-135M-Instruct-TaiwanChat}}
|
| 135 |
-
}
|
| 136 |
-
```
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: transformers
|
| 3 |
license: apache-2.0
|
| 4 |
+
base_model: HuggingFaceTB/SmolLM2-135M-Instruct
|
| 5 |
+
tags:
|
| 6 |
+
- generated_from_trainer
|
| 7 |
+
model-index:
|
| 8 |
+
- name: SmolLM2-135M-Instruct-TaiwanChat
|
| 9 |
+
results: []
|
|
|
|
| 10 |
---
|
|
|
|
| 11 |
|
| 12 |
+
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 13 |
+
should probably proofread and complete it, then remove this comment. -->
|
| 14 |
|
| 15 |
+
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/pesi/SmolLM2-135M-Instruct-TaiwanChat/runs/oy14fkq9)
|
| 16 |
+
[<img src="https://raw.githubusercontent.com/wandb/assets/main/wandb-github-badge-28.svg" alt="Visualize in Weights & Biases" width="200" height="32"/>](https://wandb.ai/pesi/SmolLM2-135M-Instruct-TaiwanChat/runs/oy14fkq9)
|
| 17 |
+
# SmolLM2-135M-Instruct-TaiwanChat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
This model is a fine-tuned version of [HuggingFaceTB/SmolLM2-135M-Instruct](https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct) on an unknown dataset.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
## Model description
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
More information needed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
## Intended uses & limitations
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
More information needed
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
## Training and evaluation data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
More information needed
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
+
## Training procedure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
### Training hyperparameters
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
The following hyperparameters were used during training:
|
| 38 |
+
- learning_rate: 5e-05
|
| 39 |
+
- train_batch_size: 4
|
| 40 |
+
- eval_batch_size: 8
|
| 41 |
+
- seed: 42
|
| 42 |
+
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 43 |
+
- lr_scheduler_type: linear
|
| 44 |
+
- num_epochs: 3
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
### Framework versions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
- Transformers 4.51.3
|
| 49 |
+
- Pytorch 2.6.0+xpu
|
| 50 |
+
- Datasets 3.5.0
|
| 51 |
+
- Tokenizers 0.21.1
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 538090408
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff049bd3572ab5480dc285d0e177bf72fe0935b358167fa7c7595f4b428e687a
|
| 3 |
size 538090408
|
runs/Apr22_10-34-08_luigi-inspiron135330/events.out.tfevents.1745289249.luigi-inspiron135330.505593.0
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:99ec8bcbbe165f1aa0f67a5000b2b4da2fa861a59018add12473a03ebe48cca4
|
| 3 |
+
size 5258
|
training_args.bin
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84050f9270a67639b4e89dc45333b7e10002df8a3d69d8957e2473f2089dba1c
|
| 3 |
+
size 5304
|