To improve model performance in tool calling (inspired by the Gorilla paper), you can use the cot-enhance type to add detailed API documentation and reasoning to existing conversation examples.
Workflow
- Prepare base data: Create a JSON file containing basic API usage examples (e.g., simple Q&A pairs without detailed documentation).
- Enhance: Run the
create command with the --type cot-enhance flag. This uses a custom cot_enhancement prompt to inject relevant API syntax, parameter descriptions, and step-by-step reasoning into the assistant's responses. - Save: Use the
save-as command to export the enhanced dataset in a format like chatml.
Example Configuration
llm:
provider: "vllm"
vllm:
api_base: "http://localhost:8000/v1"
model: "meta-llama/Llama-3.3-70B-Instruct"
generation:
temperature: 0.3
num_pairs: 15
curate:
threshold: 8.0
batch_size: 10
prompts:
# Custom rating prompt for API documentation quality
qa_rating: |\n Rate these API usage examples on a scale from 1-10 based on:\n \n - Documentation quality (0-3): Is the API documentation clear and complete?\n - API call correctness (0-3): Is the syntax and usage correct?\n - Explanation quality (0-2): Is the explanation helpful and accurate?\n - Parameter coverage (0-2): Are parameters well explained and correctly used?\n \n Immediately reject any example where the API call doesn't match the documentation.\n \n Return valid JSON with ratings:\n [\n {"question": "Original question", "answer": "Original answer with documentation", "rating": 8}\n ]\n \n Examples to rate:\n {pairs}\n \n # Custom prompt for enhancing examples with documentation
cot_enhancement: |\n You are enhancing API usage examples by adding detailed documentation.\n \n For each conversation, add the following to the assistant's responses:\n 1. Relevant API documentation with syntax and parameter descriptions\n 2. Clear explanation of why this API is appropriate\n 3. Description of what each parameter does\n \n Return the enhanced conversations as a JSON array matching this format:\n [\n {\n "role": "system", \n "content": "System message"\n },\n {\n "role": "user", \n "content": "How do I use function X?"\n },\n {\n "role": "assistant", \n "content": "Here's the documentation for this API:\n\n```\nfunction X(param1, param2) -> return_type\n param1: description of param1\n param2: description of param2\n returns: what is returned\n```\n\nHere's how you can use it:\n\n```python\nresult = X(value1, value2)\n```\n\nThis works because [detailed explanation]..."\n }\n ]\n \n Original conversations:\n {conversations}\nEOF
# Enhance existing examples with documentation using cot-enhance
# 1. First prepare a JSON file with basic API usage examples (without detailed docs)
# Example: api_examples.json with basic Q&A pairs about APIs
# 2. Enhance these examples by adding detailed documentation
synthetic-data-kit -c gorilla_config.yaml create data/api_examples.json --type cot-enhance
# 3. Save the enhanced dataset
synthetic-data-kit -c gorilla_config.yaml save-as data/generated/api_examples_enhanced.json -f chatml