# unsloth-train **Repository Path**: Ypeng/unsloth-train ## Basic Information - **Project Name**: unsloth-train - **Description**: 模型训练使用工程 - **Primary Language**: Python - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-14 - **Last Updated**: 2024-05-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 微调:llama3 使用 unsloth 微调模型 #### 第一步安装requirement 执行下面命令 ```shell conda create --name unsloth_env python=3.10 conda activate unsloth_env conda install pytorch-cuda=12.1 pytorch cudatoolkit xformers -c pytorch -c nvidia -c xformers pip install "unsloth[colab-new] @ git+https://gitee.com/Ypeng/unsloth.git" -i https://mirrors.aliyun.com/pypi/simple/ pip install --no-deps "xformers<0.0.26" trl peft accelerate bitsandbytes ``` #### 第二步下载:模型文件 sh ./sh/data.sh ```shell tree models/ models/ ├── config.json ├── generation_config.json ├── model.safetensors ├── special_tokens_map.json ├── tokenizer_config.json └── tokenizer.json ``` #### 第三步设置训练数据: sh ./sh/data.sh ```json [ { "instruction": "问一道数学问题 关羽一小时能斩20个颜良 华佗一小时能救17个颜良 假设一共有233.3个颜良 关羽斩颜良的同时华佗救颜良 求关羽多长时间能把颜良给杀完?", "input": "", "output": "这道问题从逻辑上需要一个假设,即华佗救活的颜良关羽无法再次斩杀。如果按这一逻辑,每小时关羽实际净斩杀的颜良数量为关羽斩杀的颜良数量减去华佗救活的颜良数量,即每小时净斩杀3个颜良(20 - 17 = 3)。现有颜良总数为233.3,这里我们暂且不计小数,以整数233处理。将233个颜良除以每小时关羽净斩杀的数量,得到关羽斩杀所有颜良需要的时间为233 / 3 = 77.67小时。这个计算表明,假设没有其他外力干预,关羽大约需要77.67小时来完成斩杀233个颜良的任务。" } ] ``` 模型文件 放置: models 训练数据 放置:traning_datasets lora 模型: lora_model logs: 模型训练日志和训练指标图表 ![img](./logs/training_analysis.png) #### 运行 ```python 运行: python traning.py 进行训练 运行: python inference.py 进行推理验证 ``` ### 附录 中文数据集:https://modelscope.cn/datasets/baicai003/Llama3-Chinese-dataset/summary python数据源 ``` 清华大学 TUNA 镜像源 : https://pypi.tuna.tsinghua.edu.cn/simple/ 阿里云镜像源 : https://mirrors.aliyun.com/pypi/simple/ 华为云镜像源 : https://developer.huaweicloud.com/mirror/#/pypi_simple 豆瓣(DOUBAN)镜像源 : https://pypi.douban.com/simple/ 中国科技大学镜像源 : https://pypi.mirrors.ustc.edu.cn/simple/ 北京外国语大学镜像源 : https://pypi.mirrors.bfu.edu.cn/simple/ ``` ### 问题处理 1. ``` tmp/tmp097coqxl/main.c: In function ‘list_to_cuuint64_array’: 解决方法:pip install triton==2.1.0 -i https://mirrors.aliyun.com/pypi/simple/ ``` #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)