大模型04期Function Call实践-进阶版作业 #44

Open
opened 2024-11-26 14:37:50 +08:00 by 11252177484cs · 1 comment

一、作业内容:

  1. 【进阶】使用function call数据测试微调大模型,提升大模型functioncall能力 比如使用这个数据集:Deepexi/function-calling-small

二、作业步骤
1、通过https://hf-mirror.com/ 下载数据集Deepexi/function-calling-small
huggingface-cli downloadDeepexi/function-calling-small --repo-type dataset --revision main --local-dir-use-symlinks False --local-dir /code/function-callling

2、修改数据文件的key 为 instruction, input ,output, 原来是systemPrompt,userPrompt,assistantResponse。 可以打开csv文件直接手动修改---- PS, 粗粗看了下,这个数据集多条数据是重复的,不确定对训练结果是否有影响

3、修改配置文件llama3_8b_instruct_qlora_alpaca_e3_copy,主要修改数据文件目录,注视量化部分代码,并且将max_dataset_length设置为20000,控制训练数据的长度。详见下图。
这里有个问题,就是evaluation_inputs 未进行修改,直接用了原来配置文件默认的,不确定对训练结果有影响
evaluation_inputs = [
'请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai'
]
image
image

4、通过notebook 开始微调训练,训练成功
NPROC_PER_NODE=4 xtuner train /code/llama3_8b_instruct_qlora_alpaca_e3_copy.py --work-dir /userhome/llama3-8b-ft/function-calling --deepspeed deepspeed_zero3_offload

5、通过微调管理进行训练,修改runx.sh 配置微调训练任务。详见下图。

image image

6、通过约19小时的训练,训练结束,一共是1764步,生成checkpoint文件
image
image
image

7、将checkpoint文件转为为HF格式
xtuner convert pth_to_hf /code/llama3_8b_instruct_qlora_alpaca_e3_copy.py /userhome/llama3-8b-ft/function-calling/iter_1764.pth /code/llama3-8b-ft/function-calling/iter_1764_hf

8、模型merge
xtuner convert merge /dataset/Llama-3-8B-Instruct/ /code/llama3-8b-ft/function-calling/iter_1764_hf/ /code/llama3-8b-ft/function-calling/merged --device cpu

9、 进行结果测试,如下图所示。测试结果跟教程不太相同,推测原因两个:1、数据集质量问题;2、训练过程中的测试问题用了配置文件默认的,未使用llama3_8b_instruct_qlora_agentflan_3e.py 文件中的问题。

image image
一、作业内容: 1. 【进阶】使用function call数据测试微调大模型,提升大模型functioncall能力 比如使用这个数据集:Deepexi/function-calling-small 二、作业步骤 1、通过https://hf-mirror.com/ 下载数据集Deepexi/function-calling-small huggingface-cli downloadDeepexi/function-calling-small --repo-type dataset --revision main --local-dir-use-symlinks False --local-dir /code/function-callling 2、修改数据文件的key 为 instruction, input ,output, 原来是systemPrompt,userPrompt,assistantResponse。 可以打开csv文件直接手动修改---- PS, 粗粗看了下,这个数据集多条数据是重复的,不确定对训练结果是否有影响 3、修改配置文件llama3_8b_instruct_qlora_alpaca_e3_copy,主要修改数据文件目录,注视量化部分代码,并且将max_dataset_length设置为20000,控制训练数据的长度。详见下图。 这里有个问题,就是evaluation_inputs 未进行修改,直接用了原来配置文件默认的,不确定对训练结果有影响 evaluation_inputs = [ '请给我介绍五个上海的景点', 'Please tell me five scenic spots in Shanghai' ] <img width="415" alt="image" src="/attachments/7b5edb0b-b22d-4baf-aad5-5249bd4e97f6"> <img width="415" alt="image" src="/attachments/ec25cac4-46b7-43a1-b69a-fabe69081501"> 4、通过notebook 开始微调训练,训练成功 NPROC_PER_NODE=4 xtuner train /code/llama3_8b_instruct_qlora_alpaca_e3_copy.py --work-dir /userhome/llama3-8b-ft/function-calling --deepspeed deepspeed_zero3_offload 5、通过微调管理进行训练,修改runx.sh 配置微调训练任务。详见下图。 <img width="415" alt="image" src="/attachments/55bd1ac3-5133-41ec-ac1e-b27ece7728b9"> <img width="415" alt="image" src="/attachments/5b81f7e0-f28a-44d7-8a05-6537971a1d95"> 6、通过约19小时的训练,训练结束,一共是1764步,生成checkpoint文件 <img width="415" alt="image" src="/attachments/80b5f2a2-034c-40a5-8a39-2b5fd9120f8f"> <img width="415" alt="image" src="/attachments/5f1cbc8d-0ec9-4051-96fb-7427bf03f018"> <img width="415" alt="image" src="/attachments/1de665fa-8390-4c47-83e3-e83774395804"> 7、将checkpoint文件转为为HF格式 xtuner convert pth_to_hf /code/llama3_8b_instruct_qlora_alpaca_e3_copy.py /userhome/llama3-8b-ft/function-calling/iter_1764.pth /code/llama3-8b-ft/function-calling/iter_1764_hf 8、模型merge xtuner convert merge /dataset/Llama-3-8B-Instruct/ /code/llama3-8b-ft/function-calling/iter_1764_hf/ /code/llama3-8b-ft/function-calling/merged --device cpu 9、 进行结果测试,如下图所示。测试结果跟教程不太相同,推测原因两个:1、数据集质量问题;2、训练过程中的测试问题用了配置文件默认的,未使用llama3_8b_instruct_qlora_agentflan_3e.py 文件中的问题。 <img width="415" alt="image" src="/attachments/98da52d4-35d4-4f3c-aaa5-83d9dfcf01f3"> <img width="415" alt="image" src="/attachments/87f860bd-03ef-4d35-81c1-804baa2468c2">

可以尝试使用qwen模型做中文数据集的微调,此外,function call的微调可以适当提高context的长度,也就是参数max_length。
eval的数据不影响训练的。

可以尝试使用qwen模型做中文数据集的微调,此外,function call的微调可以适当提高context的长度,也就是参数max_length。 eval的数据不影响训练的。
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: HswOAuth/llm_share#44
No description provided.