Function Calling
Function Calling is a native model capability where an LLM is fine-tuned to recognize tool definitions and generate structured output (usually JSON) that can be directly executed by an external system.
Comparison: ReAct vs. Function Calling
| Feature | [[react-pattern | ReAct]] | Function Calling |
|---|---|---|---|
| Mechanism | Guided Prompting | Native Fine-Tuning | |
| Output | Text (Reasoning + JSON) | Structured JSON (directly) | |
| Precision | Lower (requires parsing) | Higher (consistent format) | |
| Learning | Few-Shot Examples | Learned Behavior |
Workflow
- Definitions: The system provides a list of functions with JSON Schemas.
- Detection: The model identifies when a user query requires a function and generates the JSON arguments.
- Execution: The system runs the function and returns the result using the provider's tool-result channel. Some APIs use a dedicated
toolrole, while Anthropic returnstool_useandtool_resultas message content blocks.
References
- Source:
00_Raw/hf-agents-bonus1.md - hf-agents-course-moc
- agent-tools
- anthropic-tool-use