模型简介
模型的名字为甲辰代码助手,模型具有自我认知,其作者为甲辰队。
模型可以根据要求给出正确的示例代码。
实验环境
采用魔搭社区Notebook开发,环境为ubutu22.04-cuda12.1.0-py310-torch2.1.2-tf2.14.0-1.11.0
gradio版本为3.50.1
训练方法
数据集为code-alpaca-e、codefuse-pytho-e
微调的模型为qwe-7b-chat
超参数
- system 你是一个代码助手,可以根据用户的要求输出对应的代码。
- trai_dataset_sample 3000
- save_steps 500
- lora_target_modules ALL
- learig_rate 1e-5
- gradiet_accumulatio_steps 1
- eval_batch_size 1
- self_cogitio_sample 500
- model_ame 甲辰代码助手
- model_author 甲辰队
示例代码
1.安装swift及gradio
pip istall ms-swift -U
pip istall gradio==3.50.1
2.启动web-ui
swift web-ui
3.设置好参数启动训练,训练命令如下
pytho /opt/coda/lib/pytho3.10/site-packages/swift/cli/sft.py --model_id_or_path qwe/Qwe-7B-Chat --template_type qwe --system 你是一个代码助手,可以根据用户的要求输出对应的代码。 --dataset code-alpaca-e codefuse-pytho-e --trai_dataset_sample 3000 --save_steps 500 --lora_target_modules ALL --learig_rate 1e-5 --gradiet_accumulatio_steps 1 --eval_batch_size 1 --self_cogitio_sample 500 --model_ame 甲辰代码助手 --model_author 甲辰队 --add_output_dir_suffix False --output_dir /mt/workspace/output/qwe-7b-chat/v0-20240124-134958 --loggig_dir /mt/workspace/output/qwe-7b-chat/v0-20240124-134958/rus
4.训练好后用web-ui进行推理,推理效果如下
5.使用命令行进行推理,命令如下
CUDA_VISIBLE_DEVICES=0 \
swift ifer \
--ckpt_dir "output/qwe-7b-chat/v0-20240124-134958/checkpoit-3000" \
--load_dataset_cofig true \
--max_legth 2048 \
--max_ew_tokes 2048 \
--temperature 0.7 \
--top_p 0.7 \
--repetitio_pealty 1. \
--do_sample true \
--merge_lora_ad_save false \
效果如下
6.编写代码将模型上传,代码如下
from modelscope.hub.api import HubApi
YOUR_ACCESS_TOKEN = '访问令牌'
api = HubApi()
api.logi(YOUR_ACCESS_TOKEN)
api.push_model(
model_id="xxxxxxxx",
model_dir="xxxxxx/checkpoit-xxxx"
)
点击空白处退出提示
评论