-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
tool-call
: Phi-4 support
#12288
base: master
Are you sure you want to change the base?
tool-call
: Phi-4 support
#12288
Conversation
- Add system message if needed (per template requirement) - Add tools to system message (req'd by template) - Parse output: -- add tools to response when there is valid JSON between <|tool_call|> and </|tool_call|> -- content outside of tool_call tags is added to the text portion of the response -- if there is no valid JSON, the entire content is added to the text portion of the response
if (!found_system_msg && !adjusted_messages.empty()) { | ||
json system_msg = { | ||
{"role", "system"}, | ||
{"content", "You are a helpful assistant with access to tools.\nTo use a tool, respond in this format: <|tool_call|>{\"name\": \"foo\", \"arguments\": {\"a\": 1}}<|/tool_call|>"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch <|/tool_call|> to </|tool_call|>
Well, rather: quadruple check which one is correct via the special tokens, & make sure its consistent here and @ 1379
Hey @jpohhhh, thanks a lot for preparing this! The official template from Microsoft is quite disappointing tbh, and while your changes work around some/most of its limitations, we might need a bit more / might be worth going full jinja (see below) Show original template
The "sins" of their template are:
Despite these issues, I seem to be getting good outputs w/ the generic handling on master: cmake -B build -DLLAMA_CURL=1 && cmake --build build --config Release -j -t llama-server
export LLAMA_SERVER_BIN_PATH=$PWD/build/bin/llama-server
export LLAMA_CACHE=${LLAMA_CACHE:-$HOME/Library/Caches/llama.cpp}
./scripts/tool_bench.py run --n 10 --temp -1 --temp 0 --temp 1 --test-calc-result --model "Phi 4 mini instruct Q4_K_M" --output phi4_master.jsonl --hf bartowski/microsoft_Phi-4-mini-instruct-GGUF
./scripts/tool_bench.py plot phi4_master.jsonl This is just a smoke test / not a proper benchmark (trying to get BFCL running, see here), but I'm getting less success w/ your branch. I sent you Telosnex#1 which fixes a couple of issues. I think we should also remove much of the code in Show proposed template (still unclear how to provide `<|tool_response|>` and if `<|tag|>` should be involved)
|
Make sure to read the contributing guidelines before submitting a PR
(cc @ochafik)