Function Calling
Function calling is a basic concept in programming, which refers to calling a defined function to perform a specific task during program execution. In LLM, it refers to the ability to connect LLM to external tools to achieve effective tool usage and interaction with external APIs.
LLMs such as GPT-4 and GPT-3.5 have been fine-tuned to detect when a function needs to be called and then output a JSON containing the parameters for calling that function. The functions called by function calls will act as tools in AI applications, and users can define multiple functions in a single request.
Function calls are an important capability for building LLM-driven chatbots or agents that need to retrieve the context of LLM or interact with external tools by converting natural language into API calls.
Function calls enable developers to create:
- Conversational agents can efficiently use external tools to answer questions. For example, the query "What is the weather like in Belize?" is converted into a function call such as
get_current_weather(location: string, unit: 'celsius' | 'fahrenheit')
- LLM solutions for extracting and labeling data (e.g., extracting names of people from Wikipedia articles)
- Applications that help convert natural language into API calls or valid database queries
- A conversational knowledge retrieval engine that interacts with a knowledge base