XavierSpycy
First commit
dad928b
|
raw
history blame
No virus
7.29 kB
metadata
license: apache-2.0

Meta-Llama-3-8B-Instruct-zh-10k: A Llama🦙 which speaks Chinese / 一只说中文的羊驼🦙

Model Details / 模型细节

This model, Meta-Llama-3-8B-Instruct-zh-10k, was fine-tuned from the original Meta-Llama-3-8B-Instruct due to its underperformance in Chinese. Utilizing the LoRa technology within the LLaMA-Factory utilities, this model was adapted to better handle Chinese through three epochs on three corpora: alpaca_zh, alpaca_gpt4_zh, and oaast_sft_zh, amounting to approximately 10,000 examples. This is reflected in the 10k in its name.

由于原模型Meta-Llama-3-8B-Instruct在中文上表现欠佳,于是该模型 Meta-Llama-3-8B-Instruct-zh-10k 微调自此。在LLaMA-Factory工具下,利用LoRa 技术,通过alpaca_zhalpaca_gpt4_zhoaast_sft_zh三个语料库上、经过三个训练轮次,我们将该模型调整得更好地掌握了中文。三个语料库共计约10,000个样本,这也是其名字中的 10k 的由来。

For efficient inference, the model was converted to the gguf format using llama.cpp and underwent quantization, resulting in a compact model size of about 3.18 GB, suitable for distribution across various devices.

为了高效的推理,使用 llama.cpp,我们将该模型转化为了gguf格式并量化,从而得到了一个压缩到约 3.18 GB 大小的模型,适合分发在各类设备上。

LoRa Hardware / LoRa 硬件

  • RTX 4090D x 1

The complete fine-tuning process took approximately 12 hours. / 完整微调过程花费约12小时。

Additional fine-tuning configurations are avaiable at Hands-On LoRa or Llama3Ops.

更多微调配置可以在我的个人仓库 Hands-On LoRaLlama3Ops 获得。

Other Models / 其他模型

Model Developer / 模型开发者

Usage / 用法

This model can be utilized like the original Meta-Llama3 but offers enhanced performance in Chinese.

我们能够像原版的Meta-Llama3一样使用该模型,而它提供了提升后的中文能力。

# !pip install accelerate

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_id = "XavierSpycy/Meta-Llama-3-8B-Instruct-zh-10k"

model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)

prompt = "你好,你是谁?"

messages = [
    {"role": "system", "content": "你是一个乐于助人的助手。"},
    {"role": "user", "content": prompt}]

input_ids = tokenizer.apply_chat_template(
    messages, add_generation_prompt=True, return_tensors="pt").to(model.device)

terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]

outputs = model.generate(
    input_ids,
    max_new_tokens=256,
    eos_token_id=terminators,
    do_sample=True,
    temperature=0.6,
    top_p=0.9)

response = outputs[0][input_ids.shape[-1]:]

print(tokenizer.decode(response, skip_special_tokens=True))
# 我是一个人工智能助手,旨在帮助用户解决问题和完成任务。
# 我是一个虚拟的人工智能助手,能够通过自然语言处理技术理解用户的需求并为用户提供帮助。

Further details about the deployment are available in the GitHub repository Llama3Ops: From LoRa to Deployment with Llama3.

更多关于部署的细节可以在我的个人仓库 Llama3Ops: From LoRa to Deployment with Llama3 获得。

Ethical Considerations, Safety & Risks / 伦理考量、安全性和危险

Please refer to Meta Llama 3's Ethical Considerations for more information. Key points include bias monitoring, responsible usage guidelines, and transparency in model limitations.

请参考 Meta Llama 3's Ethical Considerations,以获取更多细节。关键点包括偏见监控、负责任的使用指南和模型限制的透明度。

Limitations / 局限性

  • The comprehensive abilities of the model have not been fully tested.

  • While it performs smoothly in Chinese conversations, further benchmarks are required to evaluate its full capabilities. The quality and quantity of the Chinese corpora used may also limit model outputs.

  • Additionally, catastrophic forgetting in the fine-tuned model has not been evaluated.

  • 该模型的全面的能力尚未全部测试。

  • 尽管它在中文对话中表现流畅,但需要更多的测评以评估其完整的能力。中文语料库的质量和数量可能都会对模型输出有所制约。

  • 另外,微调模型中的灾难性遗忘尚未评估。

Acknowledgements / 致谢

We thank Meta for their open-source contributions, which have greatly benefited the developer community, and acknowledge the collaborative efforts of developers in enhancing this community.

我们感谢 Meta 的开源贡献,这极大地帮助了开发者社区,同时,也感谢致力于提升社区的开发者们的努力。

References / 参考资料

@article{llama3modelcard,
title={Llama 3 Model Card},
author={AI@Meta},
year={2024},
url = {https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md}}

@inproceedings{zheng2024llamafactory,
  title={LlamaFactory: Unified Efficient Fine-Tuning of 100+ Language Models},
  author={Yaowei Zheng and Richong Zhang and Junhao Zhang and Yanhan Ye and Zheyan Luo and Zhangchi Feng and Yongqiang Ma},
  booktitle={Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 3: System Demonstrations)},
  address={Bangkok, Thailand},
  publisher={Association for Computational Linguistics},
  year={2024},
  url={http://arxiv.org/abs/2403.13372}}