Instructions to use steven0226/gemma-4-e4b-formosanlu-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use steven0226/gemma-4-e4b-formosanlu-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it") model = PeftModel.from_pretrained(base_model, "steven0226/gemma-4-e4b-formosanlu-lora") - Notebooks
- Google Colab
- Kaggle
Gemma 4 E4B FormosaNLU LoRA
้ๆฏ google/gemma-4-E4B-it ็ text-tower QLoRA adapter๏ผ้ๅฐๆญฃ้ซไธญๆ
๏ผๅฐ็ฃ๏ผzh-TW๏ผๅฃ่ช NLU ้ฒ่ก supervised fine-tuningใ่ผธๅบ contract ๆฏ๏ผ
{"intent": "intent_label", "slots": [{"type": "slot_type", "value": "ๅๅฅ็ๆฎต"}]}
ๆฌ repo ๅชๅ ๅซ LoRA adapter ่ tokenizer artifacts๏ผไธๅ ๅซๅฎๆด Gemma 4 base weightsใๅฎๆด็จๅผ็ขผใfrozen configใ่ณๆ่ๅฏฆ้ฉๅ ฑๅ๏ผ kuotunyu/FormosaNLU-Synthใ
Model details
| ้ ็ฎ | ๅ งๅฎน |
|---|---|
| Base model | google/gemma-4-E4B-it |
| Adapter | PEFT LoRA๏ผrank 16๏ผalpha 32๏ผdropout 0.05 |
| Training group | 1,176 real 20-shot + 3,760 F1โF6 filtered synthetic |
| Seed | 42 |
| Steps | 500 |
| Effective batch size | 16 |
| Quantization | NF4 double-quant QLoRA๏ผBF16 compute |
| Training GPU | NVIDIA RTX 4090 24 GB |
| License | Apache-2.0 |
็ผๅธ็ๆฏ primary filtered seed-42 adapter๏ผseeds 43/44 ๅ ็จๆผ uncertainty ่ฉไผฐ๏ผไธๅฆ่ก็ผๅธใ
Evaluation
Untouched MASSIVE zh-TW Test๏ผ2,974 rows๏ผ
| Metric | real-only seed 42 | ๆญค filtered adapter |
|---|---|---|
| Intent accuracy | 73.54% | 76.19% |
| Intent macro-F1 | 75.20% | 76.09% |
| Slot micro-F1 | 62.14% | 66.54% |
| Exact match | 49.06% | 52.12% |
| JSON-valid rate | 98.02% | 97.98% |
Paired seeds 42โ44 ไธญ๏ผfiltered ็ธๅฐ real-only ็ intent accuracy ๅนณๅๆๅ
+4.14 ยฑ 1.39 ๅ็พๅ้ป๏ผexact match ๅนณๅๆๅ +3.86 ยฑ 0.73 ๅ็พๅ้ปใ
5,000 ๆฌก hierarchical paired bootstrap ็ 95% CI ๅๅฅ็บ
[+2.60, +5.59] ่ [+2.75, +4.92] ๅ็พๅ้ป๏ผๆฏๅ seed ็ exact McNemar
tests ็ถ Holm correction ๅพๅ p โค 0.00017ใไธ่กจๆๆๆธๅญ้ฝๆฏ้ๅ
Gemma 4 adapter ๆฌ่บซ็ๆๆใ
่จ็ทด้ๅ adapter ๆ็จ็ corpus๏ผๅ
ถๆ็ๅทฒๅจ็ฌฌไบๅ student family
๏ผmicrosoft/Phi-4-mini-instruct๏ผไปฅ็ธๅ็ paired contract ่ค่ฃฝๆๅ๏ผ
intent accuracy ่ exact match ๅจๅ
ฉๅ family ้ฝๆฏๆญฃๅๅนณๅๆๅ๏ผไธ
hierarchical 95% CI ไธ็้ฝๅคงๆผ้ถ๏ผๅคๆบๅจ็ๅฐ็ตๆๅๅณๅ็ตใ้ฃๆฏ่ณๆ
็่ญๆ๏ผไธๆฏ้ๅ adapter ็ๆๆ๏ผๆญค่ๅๅบๆฏ็บไบ่ชชๆ corpus ็ๆ็ไธ้ๆผ
ๅฎไธ student modelใ็ดฐ็ฏ่ฆ
FormosaNLU-Synth ็
cross-model ๅ ฑๅใ
v1.2.2 evidence release ่ M19 equal-N ablation
GitHub v1.2.2 evidence release
ๆฐๅขๅฏไธ่ผ็
steven0226/phi-4-mini-formosanlu-lora๏ผ
ไธฆไปฅ archival Technical note
ไฟๅญ technical report๏ผๅฆๆดๆฐ publication metadata ่ cardsใๆญค Gemma adapter
tensors did not change. ๅฎไปๆฏ็ธๅ็ 155,609,536-byte
artifact๏ผSHA-256 ไป็บ
f70f423814dcd47943c92c0beb8b08a4e7f65e60a44355d3dcd95bed9f0bd60aใ
M19 ไปฅ Gemma seed 42 ๅ equal-N composition comparison๏ผcontrol ่ๅๅ leave-one-recipe-out ็ต้ฝไฝฟ็จ 1,176 real + 2,246 synthetic rows๏ผ
| ๆ้ค recipe | Exact-match ฮ vs control๏ผpercentage points๏ผ |
|---|---|
paraphrase |
+0.50 |
slot_substitution |
+2.02 |
noise_codeswitch |
-0.74 |
hard_negative |
+1.31 |
้ ๅ ็ป่จ็ detectability threshold ๆฏ 2.5 percentage points๏ผๆฒๆไปปไฝ็ตๅฅ ้ๅฐใ้ๆฏ single seed (n=1); descriptive comparison onlyใThis does not support a recipe-level causal claim. ้ๆฏ Dataset composition ็้ๅถๆง่ญๆ๏ผ ไธๆฏ้ๅๅ ฌ้ Gemma adapter ็้กๅค headline evaluationใ
Seed-42 ็ 8,922-row deterministic robustness probe๏ผ
| Group | Intent accuracy | Slot F1 | Exact match |
|---|---|---|---|
| real-only | 71.61% | 60.59% | 46.33% |
| ๆญค filtered adapter | 73.27% | 64.13% | 48.79% |
่ทจ seeds 42โ44 ็ paired delta๏ผfiltered โ real-only๏ผ็พๅ้ป๏ผ๏ผintent accuracy +3.63 ยฑ 1.72ใexact match +3.58 ยฑ 2.05ใslot F1 +2.75 ยฑ 2.76ใ intent macro-F1 +2.11 ยฑ 2.19ใJSON-valid +1.49 ยฑ 2.35ใไบ้ ๅนณๅ็็บๆญฃ๏ผไฝๅชๆ ๅๅ ฉ้ ็ mean ๆ้กฏๅคงๆผ SDใๅช็ seed 42 ๆ่ชคๅฐโโ่ฉฒ seed ็ intent macro-F1๏ผโ0.40๏ผ่ JSON-valid๏ผโ0.38๏ผๅ ถๅฏฆๆฏ่ฒ ็ใ
่ผๅ ฅๆนๅผ
Gemma 4 E4B ๆฏ multimodal checkpoint๏ผๆฌๅฐๆกๅช่ผๅ ฅ text tower๏ผไฝฟ็จ่่จ็ทด ็ธๅ็ key mapping๏ผ
import torch
from peft import PeftModel
from transformers import AutoTokenizer, BitsAndBytesConfig
from transformers import Gemma4Config, Gemma4ForCausalLM
base_id = "google/gemma-4-E4B-it"
adapter_id = "steven0226/gemma-4-e4b-formosanlu-lora"
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
tokenizer.padding_side = "left"
quantization = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.bfloat16,
)
multimodal_config = Gemma4Config.from_pretrained(base_id)
base = Gemma4ForCausalLM.from_pretrained(
base_id,
config=multimodal_config.text_config,
key_mapping={r"^model\.language_model\.": "model."},
quantization_config=quantization,
dtype=torch.bfloat16,
device_map={"": 0},
)
model = PeftModel.from_pretrained(base, adapter_id, is_trainable=False)
model.eval()
่ผธๅ
ฅ prompt๏ผchat template ่ๅฎๆด inference ็ฏไพ่ซๅ่ GitHub ็
src/evaluation/run_adapter.py ่ src/nlu_prompt.pyใ
Intended use
- ๆญฃ้ซไธญๆ๏ผๅฐ็ฃ๏ผintent classification ่ slot filling ็ ็ฉถ
- Synthetic-data augmentation ็ไธๆธธๆฏ่ผ
- PEFT๏ผQLoRAใstructured output ่ NLU Demo
Limitations
- ๅช้ๅฐ MASSIVE taxonomy๏ผ60 intentsใ55 slot typesใ
- Test ไพๆบๅ ทๆ็ฟป่ญฏ่ชๆ็นๆง๏ผไธ็ญๅๆๆ่ช็ถๅฐ็ฃๅฃ่ชใ
- ๅฏ่ฝ่ผธๅบ็กๆ JSONใ้ฏ่ชค intent ๆไธๅจๅๅฅไธญ็ slot valueใ
- ๆฒๆ constrained decoding๏ผJSON-valid rate ๆฏๅฏฆๆธฌๆๆจใ
- Robustness ๅทฒๆถต่ seeds 42โ44๏ผไฝ้ๅ Gemma adapter ๆๅฑฌ็ family ไบ้
ๆๆจไธญๅชๆ intent accuracy ่ exact match ็ๆๆๆ้กฏๅคงๆผ seed ้็่ฎ็ฐ๏ผๅ
ถ
้คไธ้
ๅจ
n=3ไธ็กๆณ่้ถๅๅใๆพๅๆฏ deterministic probes๏ผไธๆฏ่ช็ถ ASR logsใ - ไธ้ฉ็จ้ซ็ใๆณๅพใ้่ๆๅฎๅ จ้้ตๆฑบ็ญใ
Training data
- Real seed๏ผMASSIVE
zh-TW20-shot sampling๏ผๅ ฑ 1,176 rows - Synthetic๏ผ
steven0226/formosa-nlu-synth-v1 - Validation๏ผTest๏ผๅชไฝฟ็จ untouched real MASSIVE๏ผๆชๅๆต็ๆๆ่จ็ทด
Environmental information
ๆๆๆฌๆฉ model workloads ไฝฟ็จๅฎๅผต RTX 4090ใๅฐๆกๅฏ่ฟฝๆบฏ local GPU total ็บ 42.412 ๅฐๆ๏ผไปฅ 450 W TDP ่จ็ฎ็ GPU-only ไฟๅฎไธ้็บ 19.085 kWh๏ผ ไธๆฏ wall-socket measurementใAPI ่ฑ่ฒป็บ $0ใ
License
Gemma 4 ่ๆญค adapter ไฝฟ็จ Apache License 2.0ใ
Citation
@software{kuotunyu_formosanlu_synth_2026,
author = {kuotunyu},
title = {FormosaNLU Synthetic Data Distillation for Traditional Chinese (Taiwan) NLU},
year = {2026},
version = {1.2.2},
doi = {10.5281/zenodo.21879133},
url = {https://doi.org/10.5281/zenodo.21879133}
}
- Downloads last month
- 7