[GH-ISSUE #6061] [Feature Request] Force function calling for a model #29549

Closed
opened 2026-04-22 08:31:59 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @mak448a on GitHub (Jul 29, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6061

Not sure if this belongs in ollama-python or here, but I'll open it here. Could you add a way to use function calling on any model, or is this something that the model itself has to support?

Originally created by @mak448a on GitHub (Jul 29, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6061 Not sure if this belongs in ollama-python or here, but I'll open it here. Could you add a way to use function calling on any model, or is this something that the model itself has to support?
GiteaMirror added the feature request label 2026-04-22 08:31:59 -05:00
Author
Owner

@Cephra commented on GitHub (Jul 29, 2024):

AFAIK it has to be supported by the model. Also smaller models are generally worse at function calling than larger ones due to more inconsistencies in their output.

<!-- gh-comment-id:2257034243 --> @Cephra commented on GitHub (Jul 29, 2024): AFAIK it has to be supported by the model. Also smaller models are generally worse at function calling than larger ones due to more inconsistencies in their output.
Author
Owner

@rick-github commented on GitHub (Jul 29, 2024):

Any model can be used for function calling, but if it's not been trained for it, results can be poor. For models that don't explictly support tools, you can pass through the tools and instructions in the system message, see https://github.com/ollama/ollama/issues/5793#issuecomment-2238938100.

<!-- gh-comment-id:2257075560 --> @rick-github commented on GitHub (Jul 29, 2024): Any model can be used for function calling, but if it's not been trained for it, results can be poor. For models that don't explictly support tools, you can pass through the tools and instructions in the system message, see https://github.com/ollama/ollama/issues/5793#issuecomment-2238938100.
Author
Owner

@Cephra commented on GitHub (Jul 29, 2024):

Any model can be used for function calling, but if it's not been trained for it, results can be poor. For models that don't explictly support tools, you can pass through the tools and instructions in the system message, see #5793 (comment).

I see you're using llama3 in that example you've linked. Did you use the 8B or 40B version?

<!-- gh-comment-id:2257094145 --> @Cephra commented on GitHub (Jul 29, 2024): > Any model can be used for function calling, but if it's not been trained for it, results can be poor. For models that don't explictly support tools, you can pass through the tools and instructions in the system message, see [#5793 (comment)](https://github.com/ollama/ollama/issues/5793#issuecomment-2238938100). I see you're using llama3 in that example you've linked. Did you use the 8B or 40B version?
Author
Owner

@rick-github commented on GitHub (Jul 29, 2024):

llama3:8b-instruct-q4_0, but that was just because the original poster was trying to use that model. Results:

{
  "functionName": "get_weather",
  "parameters": [
    {
      "parameterName": "query",
      "parameterValue": "Beijing"
    }
  ]
}

phi3:3.8b-mini-128k-instruct-q4_0 results, wrapped in a JSON markdown block so the client would post-process to get the function call:

\```json
{
  "functionName": "get_weather",
  "parameters": [
    {
      "parameterName": "query",
      "parameterValue": "Beijing"
    }
  ]
}
\```

gemma2:9b-instruct-q4_K_M also wraps it in a JSON block:

\```json
{
 "functionName": "get_weather",
 "parameters": [
  {
   "parameterName": "query",
   "name of parameter": "location",
   "parameterValue": "Beijing"
  }
 ]
}
\```

qwen2:7b-instruct-q4_K_M, which has been trained for tool use, although the current template doesn't support it:

{
  "functionName": "get_weather",
  "parameters": [
    {
      "parameterName": "query",
      "parameterValue": "Beijing"
    }
  ]
}

nous-hermes:7b-llama2-q4_0, one of the oldest models in the ollama library and based on llama2:

{
  "functionName": "get_weather",
  "parameters": [
    {
      "parameterName": "location",
      "name": "location or city",
      "parameterValue": "beijing"
    },
    {
      "required": true
    }
  ]
}
<!-- gh-comment-id:2257137350 --> @rick-github commented on GitHub (Jul 29, 2024): llama3:8b-instruct-q4_0, but that was just because the original poster was trying to use that model. Results: ``` { "functionName": "get_weather", "parameters": [ { "parameterName": "query", "parameterValue": "Beijing" } ] } ``` phi3:3.8b-mini-128k-instruct-q4_0 results, wrapped in a JSON markdown block so the client would post-process to get the function call: ``` \```json { "functionName": "get_weather", "parameters": [ { "parameterName": "query", "parameterValue": "Beijing" } ] } \``` ``` gemma2:9b-instruct-q4_K_M also wraps it in a JSON block: ``` \```json { "functionName": "get_weather", "parameters": [ { "parameterName": "query", "name of parameter": "location", "parameterValue": "Beijing" } ] } \``` ``` qwen2:7b-instruct-q4_K_M, which has been trained for tool use, although the current template doesn't support it: ``` { "functionName": "get_weather", "parameters": [ { "parameterName": "query", "parameterValue": "Beijing" } ] } ``` nous-hermes:7b-llama2-q4_0, one of the oldest models in the ollama library and based on llama2: ``` { "functionName": "get_weather", "parameters": [ { "parameterName": "location", "name": "location or city", "parameterValue": "beijing" }, { "required": true } ] } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#29549