-
Notifications
You must be signed in to change notification settings - Fork 184
Phi-4-mini-instruct CPU int4 version produces incorrect output for a tool call prompt #1334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I just tried this using Azure AI inference, and this is the output I get. Note that the departure airport is incorrect, also the formatting is a little bit different. Code:
Sure, I can help you book a hotel and flight tickets for your trip. Here are the tool calls for your trip:
|
Here's how the original Phi-4 mini tool calling example is formatted when JSON pretty-printed compared to your posted example when JSON pretty-printed. Phi-4 mini example: template = """
<|system|>
You are a helpful assistant with some tools.
<|tool|>
[
{
"name": "get_weather_updates",
"description": "Fetches weather updates for a given city using the RapidAPI Weather API.",
"parameters": {
"city": {
"description": "The name of the city for which to retrieve weather information.",
"type": "str",
"default": "London"
}
}
}
]
<|/tool|>
<|end|>
<|user|>
What is the weather like in Paris today?
<|end|>
<|assistant|>
""" Your example: template = """
<|system|>
You are a helpful assistant with some tools. Output the tool calls only.
<|tool|>
{
"booking_fight": {
"name": "booking_fight",
"description": "booking fight",
"parameters": {
"departure": {
"description": "The name of Departure airport code",
"type": "str"
},
"destination": {
"description": "The name of Destination airport code",
"type": "str"
},
"outbound_date": {
"description": "The date of outbound flight",
"type": "str"
},
"return_date": {
"description": "The date of return flight",
"type": "str"
}
}
},
"booking_hotel": {
"name": "booking_hotel",
"description": "booking hotel",
"parameters": {
"query": {
"description": "The name of the city",
"type": "str"
},
"check_in_date": {
"description": "The date of check in",
"type": "str"
},
"check_out_date": {
"description": "The date of check out",
"type": "str"
}
}
}
}
<|/tool|>
<|end|>
<|user|>\n
I have a trip from Beijing to New York in March 21 2025 to March 27 2025. please help me to booking a hotel and flight tickets (use the airport code for the departure and destination,An airport code is an uppercase code)
<|end|>
<|assistant|>'
""" While it's unclear what exactly the issue is, there are some differences that I see.
Resolving these differences may help fix the issue. |
I tried the suggestions made by Kunal, what helped the most in generating the output in right tool_call syntax was removing
The output with Phi4 cookbook example was completely incorrect, here is the output I saw:
As discussed offline, it might be worth looking into Constrained decoding and other tool options for a better result. |
Describe the bug
As above
To Reproduce
Try this prompt with fp32 model and int4 model
Expected behavior
Expected output and output from fp32 model
Output from int4 model
The text was updated successfully, but these errors were encountered: