Downloads · 30 days
6
15% of all-time downloads
Simon-Liu/DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune
DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune is a machine learning model from Simon-Liu. 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.
DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune 是一款基於 DeepSeek-R1-Distill-Llama-8B 的大型語言模型進行 Fine-Tune 讓模型學習如何生成新聞標題。本模型使用了 Unsloth 框架和工具進行 Fine-Tune 優化。
Downloads · 30 days
6
15% of all-time downloads
All-time downloads
41
Public
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 91%
From the Hugging Face model README
DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune 是一款基於 DeepSeek-R1-Distill-Llama-8B 的大型語言模型進行 Fine-Tune 讓模型學習如何生成新聞標題。本模型使用了 Unsloth 框架和工具進行 Fine-Tune 優化。
以下是使用 LoRA 微調模型的範例程式碼:
model = FastLanguageModel.get_peft_model(
model,
r = 16,
target_modules = ["q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"],
lora_alpha = 16,
lora_dropout = 0,
use_gradient_checkpointing = "unsloth",
random_state = 3407,
use_rslora = False,
)
我們使用 AWeirdDev/zh-tw-pts-articles-sm 作為範例數據集。
以下是格式化數據集的範例:
from datasets import load_dataset
def formatting_prompts_func(examples):
instructions = "請根據新聞內容,給予合適的新聞標題。"
inputs = examples["content"]
outputs = examples["title"]
texts = []
for input, output in zip(inputs, outputs):
text = f"### Instruction:\n{instructions}\n\n### Input:\n{input}\n\n### Response:\n{output}" + tokenizer.eos_token
texts.append(text)
return {"text": texts}
dataset = load_dataset("AWeirdDev/zh-tw-pts-articles-sm", split="train")
dataset = dataset.map(formatting_prompts_func, batched=True)
news_content = """<新聞內容>"""
# alpaca_prompt = Copied from above
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
inputs = tokenizer(
[
alpaca_prompt.format(
"請根據新聞內容,給予合適的新聞標題。", # instruction
news_content, # input
"", # output - leave this blank for generation!
)
], return_tensors = "pt").to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)
Simon Liu
Google GenAI GDE (Google Developer Expert)
如有任何問題或反饋,歡迎透過 Hugging Face 平台或透過 LinkedIn、GitHub 聯絡我。
If you have any questions or feedback, feel free to reach out on the Hugging Face platform or connect with me on LinkedIn or GitHub.
如果您在研究中使用此模型,請引用如下:
If you use this model in your research, please cite it as follows:
@misc{Liu2024NewsTitleGeneration,
author = {Simon Liu},
title = {Simon-Liu/DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune},
year = {2024},
url = {https://huggingface.co/Simon-Liu/DeepSeek-R1-Distill-Llama-8B-zhtw-news-title-generation-finetune},
note = {微調模型用於Fine-Tune練習用途,準確率無法保證}
}