llm-foundry
llm-foundry copied to clipboard
MPT-30B Functions support
Hi, I'm working on fine-tuning the MPT-30B for function calling. Currently still preparing the fine-tuning dataset. AFAIK there is no open-source fine-tuned model for function support(let me know if you know).
I'm not sure about the format and wanted to get some advice. Basically proposing to add "function" and "tool" role to the original ChatML format. And putting the function schema to the system prompt. Here is the starting context. Functions are converted to a schema and have been put as a system prompt. (we can change this to something like "function_definitions" etc) The model should start generating either "assistant" or "function" with after this exact context:
<|im_start|>system
// Plugin for managing a TODO list, you can add, remove and view your TODOs.
namespace todo {
// Add a todo to the list
type addTodo = (_: {
// The todo to add to the list.
todo: string,
}) => any;
} // namespace todo<|im_end|>
<|im_start|>system
You are a helpful assistant<|im_end|>
<|im_start|>user
Add X to my todo list<|im_end|>
If it starts with "function", it'll generate the namespace.function definition. Like this:
<|im_start|>function
todo.addTodo("X")<|im_end|>
Then we'll give this to the user. OR as a library, we can actually call the function too. The function response's role can be named as "tool" like this:
<|im_start|>tool
{"status": "OK"}
<|im_start|>assistant
Okay, I've added!.<|im_end|>
Full raw format:
<|im_start|>system
// Plugin for managing a TODO list, you can add, remove and view your TODOs.
namespace todo {
// Add a todo to the list
type addTodo = (_: {
// The todo to add to the list.
todo: string,
}) => any;
} // namespace todo<|im_end|>
<|im_start|>system
You are a helpful assistant<|im_end|>
<|im_start|>user
Add X to my todo list<|im_end|>
<|im_start|>function
todo.addTodo("X")<|im_end|>
<|im_start|>tool
{"status": "OK"}
<|im_start|>assistant
Okay, I've added!.<|im_end|>
What do you think?