Llama3 中文优化版本
项目概述
本项目使用 xtuner
对 Llama3-8b
模型进行了深度调优,主要目标是在保持原有模型能力的基础上,增强其对中文数据的处理和回答能力。本次调优工作在 alpaca
中文数据集上进行,经过在5万中文对话的数千轮的精细调整后,模型在中文回答能力上表现出了显著的性能提升。
调优详情
QA对比
原始QA
human: 给我讲讲金刚经
llama3: A classic! The Dharani Sutra, also known as the "Diamond Sutra", is a pivotal scripture in Mahayana Buddhism. Composed in the 4th century CE, it is a collection of wisdom teachings that aim to liberate practitioners from suffering and ignorance. Here's an overview: Title and Meaning The sutra is named after the "Vajra" or "Diamond" symbol, which represents the indestructible and unshakeable nature of ultimate reality. The title can also be translated as "The Perfection of Wisdom Sutra on the White Lotus of the Wonderful Dharma". Structure The Diamond Sutra consists of 32 chapters, which are divided into three main sections: Introduction: The sutra introduces the Buddha's teachings on the nature of reality, suffering, and the path to enlightenment. Middle Section: This section presents the Buddha's dialogues with his disciples, highlighting key concepts such as the emptiness (shunyata) of all phenomena, the impermanence of all things, and the illusory nature of the self. Conclusion: The sutra concludes with discussions on the significance of compassion and the attainment of Buddhahood. Key Concepts Emptiness (Shunyata): The core concept of the Diamond Sutra is the notion that all phenomena, including thoughts, emotions, and material objects, are empty of inherent existence. This means that nothing has an independent, self-existent reality. No-self (Anatman): The sutra teaches that there is no permanent, unchanging self. The concept of self is merely a mental construct, and all phenomena are interconnected and impermanent. Two Truths: The Diamond Sutra presents two levels of truth:
- Conventional truth: The world as we perceive it, with its apparent reality and dualities.
- Ultimate truth: The true nature of reality, which is empty and beyond conceptualization. Suffering and Ignorance: The sutra explains that suffering arises from ignorance of the true nature of reality and the tendency to grasp at an illusory self. The path to liberation is to overcome ignorance and attachment…..
中文优化版本QA
《金刚经》是一部佛教经典,通常被认为是佛教中最重要的经典之一。它是由释迦牟尼佛在佛教的开创者佛陀的教导中所讲述的。该经典的名称“金刚经”是指佛陀的教导是不可破坏的、永恒的和不变的。该经典的主要内容是解释佛教的基本概念和教义,包括四圣谛、八正道和涅槃。它还讨论了佛教的核心概念,如无我、无常和无我。该经典的主要思想是,所有的东西都是无常的,包括我们自己。因此,任何形式的执着或渴望都是不可能的。相反,佛教鼓励我们以无我和无常的态度生活,接受一切的变化和不确定性。该经典还强调了修行的重要性,包括冥想和正念,以帮助我们更好地理解和接纳现实。总的来说,《金刚经》是佛教中最重要的经典之一,提供了深刻的洞察和教导,帮助我们更好地理解和接纳世界。
调优后的模型在中文语境下的表现有了明显提升,同时保持了对其它语言的良好支持。具体表现包括:
- 理解能力:在中文自然语言理解测试中超过llama3。
- 生成能力:能够生成更加流畅、准确的中文文本。
使用指南
环境配置
确保您的机器已经安装了以下软件:
- Python 3.8+
- PyTorch 1.8+
安装
首先安装所需依赖:
pip install modelscope
运行模型
使用以下命令加载并运行模型:
from modelscope import AutoTokenizer, AutoModelForCausalLM
model_name_or_path = 'zky001/Llama3_8b_Chinese'
model = AutoModelForCausalLM.load_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
model = model.eval()
response = model.chat("什么是中国梦")
print(response)
# 中国梦,它旨在通过促进中国经济、社会和政治发展,实现中华民族伟大复兴和中国在世界舞台上的崛起。该概念的核心是要实现中国在2050年前成为一个现代化、富强、民主、文明的社会。它包括了多个方面,包括提高生活水平、加强国家安全、促进社会公正和保护环境。中国梦的实现需要政府和人民的共同努力,政府将在推动经济增长、改善社会服务和保护公民权利方面发挥关键作用。
下一步计划
- 持续优化:继续收集和整理更多类型的中文数据,进一步优化模型的中文处理能力。
- 多语种支持:在保证中英文处理能力的同时,探索对其他语种(如日语、韩语)的优化可能。
- 社区合作:开放模型接口,鼓励社区开发者参与模型的测试和进一步开发。
- 应用开发:开发基于此模型的具体应用案例,如智能聊天机器人、自动内容生成等。
贡献
我们欢迎社区开发者的贡献!如果您有兴趣参与本项目的开发或有任何建议,欢迎通过 Issue 或 Pull Request 的方式与我们联系。
许可证
本项目采用 MIT 许可证。详情请见 LICENSE
文件。
评论