You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from transformers import AutoModelForCausalLM , AutoTokenizer
prompt = '''SYSTEM: You are an helpful assistant who has access to the following functions to help the user, you can use the functions if needed-
[
{
"name": "get_current_weather",
"description": "get the weather of the location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "城市"},
"unit": {"type": "string","enum": ["摄氏度","华氏度"]}
},
"required": ["location"]
}
},
{
"name": "calculate_distance",
"description": "Calculate the distance between two locations",
"parameters": {
"type": "object",
"properties": {
"location1": {
"type": "string",
"description": "The first location"
},
"location2": {
"type": "string",
"description": "The second location"
}
},
"required": [
"location1",
"location2"
]
}
}
]
USER: Hi, I need to know the distance between New York and Los Angeles?
ASSISTANT: <functioncall> {"name": "calculate_distance", "arguments": '{"location1": "New York", "location2": "Los Angeles"}'}
FUNCTION CALL: {"distance": 2448.2, "unit": "miles"}
ASSISTANT: The distance between New York and Los Angeles is approximately 2448.2 miles.
USER: What about the distance from London to Paris?
'''
tokenizer = AutoTokenizer.from_pretrained("/models/glaiveai/glaive-function-calling-v2-small", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("/models/glaiveai/glaive-function-calling-v2-small", trust_remote_code=True).half().cuda()
inputs = tokenizer(prompt,return_tensors="pt").to(model.device)
outputs = model.generate(**inputs,do_sample=True,temperature=0.1,top_p=0.95,max_new_tokens=100)
print(tokenizer.decode(outputs[0],skip_special_tokens=True))
Reminder
Reproduction
一、第一组训练参数和测试用例
sft 参数
训练结束后 train_loss = 0.8420096
openai-style api 启动脚本
postman 测试用例
1.单轮会话,正确识别工具
2.两轮会话,第1轮问问题a、第2轮问问题b,2轮均正确识别工具
3.两轮会话,第1轮问问题a(对话历史中包含function_call、observation message )、第2轮问问题a(问题中参数不同),第1轮正确识别工具、第2轮工具识别失败
二、第二组训练参数和测试用例
考虑第一组模型可能训练不够充分,此组模型训练时只使用了 glaive_toolcall一个数据集,训练到第1个 epoch结束时 train_loss = 0.4242 就暂停了训练
sft 参数
训练结束后 train_loss = 0.4242
postman 测试用例
与第一组3个测试用例一致
测试结果一样
三、测试 glaiveai/glaive-function-calling-v2-small模型,以验证 glaive-function-calling-v2数据集是否支持多轮会话工具识别
两轮会话,第1轮问问题a(对话历史中包含function_call、observation message )、第2轮问问题a(问题中参数不同),2轮均正确识别工具
测试python脚本如下
print output
四、统计data/glaive_toolcall_10k.json数据集中工具调用sample占比情况
单轮工具= 3303
多轮工具 = 1805
totalSample = 10000
一、二 两个测试组,训练参数 max_samples=10000, 训练数据中多轮样本大于1000了,应满足训练需要了
Expected behavior
多轮会话使用不同的参数问相同的话题,正确识别工具
System Info
transformers
version: 4.39.3Others
请教要怎么改进才能达到预期结果
The text was updated successfully, but these errors were encountered: