🚀 Llama 3 Youko 8B Instruct (rinna/llama-3-youko-8b-instruct)
该模型是基于监督微调(SFT)、聊天向量和直接偏好优化(DPO)技术,对 rinna/llama-3-youko-8b 进行指令调优后的版本,采用了 Llama-3 聊天格式,能更精准地响应指令。
✨ 主要特性
- 多技术融合调优:结合监督微调(SFT)、聊天向量和直接偏好优化(DPO)技术,提升模型指令跟随能力。
- 多语言支持:支持日语和英语,适用于不同语言场景。
- 多数据集训练:使用多个公开数据集和 rinna 自有数据集进行训练,提升模型泛化能力。
📚 详细文档
模型概述
该模型是 rinna/llama-3-youko-8b 的指令调优版本,采用了监督微调(SFT)、聊天向量和直接偏好优化(DPO)技术,并采用 Llama-3 聊天格式。
模型架构
这是一个基于 Transformer 的语言模型,具有 32 层和 4096 的隐藏层大小。具体架构细节请参考 Llama 3 Model Card。
训练过程
监督微调
监督微调数据来自以下数据集的子集:
模型融合
微调后的模型(llama-3-youko-8b-sft)通过添加聊天向量进行了增强。聊天向量是通过从 meta-llama/Meta-Llama-3-8B-Instruct 的参数向量中减去 meta-llama/Meta-Llama-3-8B 的参数向量得到的。
llama-3-youko-8b-sft + 0.5 * (meta-llama/Meta-Llama-3-8B-Instruct - meta-llama/Meta-Llama-3-8B)
在减去和添加参数向量时,跳过了嵌入层。
直接偏好优化
然后使用以下数据集的子集进行直接偏好优化,以构建这个指令模型:
贡献者
发布日期
2024 年 7 月 25 日
🔍 基准测试
请参考 rinna 的语言模型基准测试页面(Sheet 20240725)。
💻 使用示例
基础用法
我们发现这个指令调优模型比其基础模型更容易生成重复文本,因此我们将 repetition_penalty 设置为 1.1 以获得更好的生成性能。在上述评估实验中,同样的重复惩罚也应用于指令调优模型。
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "rinna/llama-3-youko-8b-instruct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{"role": "system", "content": "あなたは誠実で優秀なアシスタントです。どうか、簡潔かつ正直に答えてください。"},
{"role": "user", "content": "西田幾多郎とはどんな人物ですか?"},
]
input_ids = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
terminators = [
tokenizer.convert_tokens_to_ids("<|end_of_text|>"),
tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = model.generate(
input_ids,
max_new_tokens=512,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
repetition_penalty=1.1,
)
response = outputs[0][input_ids.shape[-1]:]
response = tokenizer.decode(response, skip_special_tokens=True)
print(response)
🔧 技术细节
分词
该模型使用原始的 meta-llama/Meta-Llama-3-8B-Instruct 分词器。
📄 引用信息
@misc{rinna-llama-3-youko-8b-instruct,
title = {rinna/llama-3-youko-8b-instruct},
author = {Chen, Xinqi and Mitsuda, Koh and Wakatsuki, Toshiaki and Sawada, Kei},
url = {https://huggingface.co/rinna/llama-3-youko-8b-instruct}
}
@inproceedings{sawada2024release,
title = {Release of Pre-Trained Models for the {J}apanese Language},
author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
month = {5},
year = {2024},
pages = {13898--13905},
url = {https://aclanthology.org/2024.lrec-main.1213},
note = {\url{https://arxiv.org/abs/2404.01657}}
}
📚 参考文献
@article{llama3modelcard,
title = {Llama 3 Model Card},
author = {AI@Meta},
year = {2024},
url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}
}
@article{huang2023chat,
title = {Chat Vector: A Simple Approach to Equip LLMs with Instruction Following and Model Alignment in New Languages},
author = {Huang, Shih-Cheng and Li, Pin-Zu and Hsu, Yu-Chi and Chen, Kuang-Ming and Lin, Yu Tung and Hsiao, Shih-Kai and Tzong-Han Tsai, Richard and Lee, Hung-yi},
year = {2023},
url = {https://arxiv.org/abs/2310.04799}
}
📄 许可证
Meta Llama 3 社区许可证