五一假期Llama 3之魔改不完全攻略(Part 2)

2024年4月18日,Meta AI 正式宣布推出 Llama 3,这标志着开源大型语言模型(LLM)领域的又一重大进步。如同一颗重磅炸弹, Llama 3 以其卓越的性能和广泛的应用前景,预示着 AI 技术的新时代。

目前开源的是Llama3 8B 和 70B,趁着五一小长假,别人在外人从众,我在家偷偷魔改Llama3

一、魔改目标

把原来Meta AI 研发的Llama 3训练成本人自己的大模型,让他拥有对主人我的认知。

二、魔改工具

使用全链路开发工具。

三、开始魔改

1、下载工具Xtuner

bash 复制代码
cd ~
git clone -b v0.1.18 https://github.com/InternLM/XTuner
cd XTuner
pip install -e .

2、准备数据

用python脚本生产训练数据,格式如下:

bash 复制代码
[
    {
        "conversation": [
            {
                "system": "你是一个懂中文的小助手",
                "input": "你是(请用中文回答)",
                "output": "您好,我是Jin's AI,一个由Jin 打造的人工智能助手,请问有什么可以帮助您的吗?"
            }
        ]
    },
    {
        "conversation": [
            {
                "system": "你是一个懂中文的小助手",
                "input": "Who are you(请用中文回答)",
                "output": "您好,我是Jin's AI,一个由Jin 打造的人工智能助手,请问有什么可以帮助您的吗?"
            }
        ]
    }
]

3、开始训练

bash 复制代码
xtuner train configs/assistant/llama3_8b_instruct_qlora_assistant.py --work-dir /root/llama3_pth

4、转换格式

bash 复制代码
xtuner convert pth_to_hf /root/llama3_pth/llama3_8b_instruct_qlora_assistant.py \
  /root/llama3_pth/iter_500.pth \
  /root/llama3_hf_adapter

5、合并Adapter

bash 复制代码
export MKL_SERVICE_FORCE_INTEL=1
xtuner convert merge /root/model/Meta-Llama-3-8B-Instruct \
  /root/llama3_hf_adapter\
  /root/llama3_hf_merged

四、见证奇迹

现在开始教Llama3做人了,哈哈哈,"指鹿为马"

bash 复制代码
streamlit run ~/Llama3-XTuner-CN/tools/internstudio_web_demo.py \
  /root/llama3_hf_merged

魔改前Llama3对自己的认知,"一派胡言"

魔改后小样终于知道自己姓啥名谁了,"态度端正"

相关推荐
LucianaiB2 天前
使用GpuGeek高效完成LLaMA大模型微调:实践与心得分享
ai·llama·ai自动化·gpugeek
为啥全要学3 天前
LLaMA-Factory 微调 Qwen2-7B-Instruct
llama·大模型微调·llamafactory
一把年纪学编程3 天前
dify 连接不上ollama An error occurred during credentials validation:
llama
陈奕昆4 天前
五、【LLaMA-Factory实战】模型部署与监控:从实验室到生产的全链路实践
开发语言·人工智能·python·llama·大模型微调
fydw_7154 天前
大语言模型RLHF训练框架全景解析:OpenRLHF、verl、LLaMA-Factory与SWIFT深度对比
语言模型·swift·llama
AI大模型顾潇5 天前
[特殊字符] 本地部署DeepSeek大模型:安全加固与企业级集成方案
数据库·人工智能·安全·大模型·llm·微调·llama
modest —YBW5 天前
Ollama+OpenWebUI+docker完整版部署,附带软件下载链接,配置+中文汉化+docker源,适合内网部署,可以局域网使用
人工智能·windows·docker·语言模型·llama
青衫客366 天前
使用本地部署的 LLaMA 3 模型进行中文对话生成
大模型·llama
cainiao0806056 天前
《大模型微调实战:Llama 3.0全参数优化指南》
llama
鸿蒙布道师6 天前
英伟达开源Llama-Nemotron系列模型:14万H100小时训练细节全解析
深度学习·神经网络·opencv·机器学习·自然语言处理·数据挖掘·llama