Downloads · 30 days
3
6% of all-time downloads
potsunwu/taiwan-llm-taigi-reading-lora
taiwan-llm-taigi-reading-lora is a machine learning model from potsunwu. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
台語閱讀理解任務的 LoRA adapter,基於 Taiwan-LLM-7B-v2.1-chat 微調。
Downloads · 30 days
3
6% of all-time downloads
All-time downloads
49
Public
Repo size
320 MB
Likes
0
Public
Click a slice to open those files.
.safetensors320 MB · 99%
From the Hugging Face model README
台語閱讀理解任務的 LoRA adapter,基於 Taiwan-LLM-7B-v2.1-chat 微調。
pip install transformers peft torch unsloth
from unsloth import FastLanguageModel
from peft import PeftModel
# 1. 載入基礎模型
base_model, tokenizer = FastLanguageModel.from_pretrained(
model_name="yentinglin/Taiwan-LLM-7B-v2.1-chat",
max_seq_length=2048,
dtype=None,
load_in_4bit=True,
)
# 2. 載入 LoRA adapter
model = PeftModel.from_pretrained(
base_model,
"YOUR_USERNAME/taiwan-llm-taigi-lora" # 記得改成你的用戶名
)
# 3. 切換到推論模式
FastLanguageModel.for_inference(model)
# 準備 prompt
prompt = """USER: 請仔細閱讀以下台文文章,並回答問題。
文章:
明年元旦起,交通部新規定,汽車輪胎胎紋深度將納入定期檢驗項之一,一旦深度未達一.六公厘,佮一個月內無換胎,將會去予吊銷牌仔照。
問題:汽車胎紋未到達多毫米將會予人吊銷牌?
選項:
1. 一.五公厘
2. 一.四厘
3. 一.三公厘
4. 一.六公厘
請回答: ASSISTANT:"""
# 生成答案
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=10,
temperature=0.1,
do_sample=False,
)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(answer) # 輸出: 4
{
"r": 32,
"lora_alpha": 32,
"lora_dropout": 0.05,
"bias": "none",
"target_modules": [
"q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"
]
}
最佳驗證點在 Step 30,000 左右,之後出現輕微過擬合。
Apache 2.0