LLMs Can Use Tools, Just Like You and I

The video explains how large language models (LLMs) can enhance their accuracy and functionality by dynamically integrating external tools, such as simple and advanced string manipulation programs, during their reasoning process. Through examples and code demonstrations, the presenter shows how tool calling enables LLMs to delegate specific tasks to specialized functions, improving performance and flexibility beyond their internal capabilities.

The video discusses how large language models (LLMs) can use external tools to enhance their problem-solving capabilities, much like humans use tools for physical and mental tasks. The presenter emphasizes that while LLMs can perform many tasks internally, they often make mistakes, especially with tasks like string manipulation. By integrating tools, LLMs can leverage computing power to provide more accurate results. The concept of tool calling allows LLMs to dynamically select and invoke appropriate external tools during their reasoning process, improving their overall performance.

To illustrate this, the presenter introduces a simple string manipulation tool written in C that reverses a string. This tool serves as a basic example of how an external function can be integrated with an LLM. The tool checks for a specific command (“reverse”) and then outputs the reversed string. The presenter assumes some familiarity with C programming but highlights the simplicity of the tool, which is designed solely to reverse strings without additional functionality.

The integration of the tool with the LLM is achieved through a Python script that interacts with the OpenAI API. The tool is described to the LLM using JSON, specifying its function, name, and parameters. A system prompt instructs the LLM to always use the tool for string manipulations rather than attempting to answer from its own knowledge, ensuring accuracy. When the LLM receives a query, it decides whether to call the tool and sends the appropriate request, then incorporates the tool’s output into its final response.

The presenter also showcases a more advanced string tool capable of performing multiple operations such as substring extraction, replacements, and case transformations. This tool provides a JSON schema that can be used to inform the LLM of its capabilities, allowing for more complex interactions. A demonstration shows the LLM using this tool to split a string at a specified separator and correctly returning the desired substring, illustrating the power and flexibility of tool calling in enhancing LLM functionality.

All the source code for both the simple and advanced string tools, along with the Python scripts for interacting with the LLM, are available on the presenter’s GitHub repository. The video encourages viewers to explore the code, starting with the simple example to understand the basics of tool calling. The presenter concludes by inviting feedback and discussion on the topic, highlighting the potential of combining LLMs with external tools to improve AI capabilities.