How Gorilla brings APIs to Large Language Models

Why Trust Techopedia

The integration of APIs with LLMs serves as a transformative force, enhancing their problem-solving capabilities. APIs empower LLMs with access to up-to-date information, resulting in more effective and relevant solutions for real-world problems. LLMs' collaboration with APIs redefined how people interact with technology, simplifying complex tasks. The showcased Gorilla model stands out for its exceptional API call generation and ability to adapt through evolving API documentation. This integration signifies a notable advancement in problem-solving, bridging language understanding with dynamic data for more versatile and precise solutions.

Large language models (LLMs) have demonstrated impressive capabilities, ranging from engaging in natural conversations to solving math problems and even generating computer programs.

However, these strengths come with certain limitations.

Language models are trained using data from a particular period, which implies that they may lack information about current events and can offer inaccurate information when queried about them, particularly in the realm of artificial intelligence (AI).

They also lack the ability to learn on their own or adapt to changing situations. As a result, as the world changes, LLMs require resource-intensive retraining to keep their knowledge and problem-solving skills current.

Additionally, as language models evolve from their conventional role of understanding human language to becoming problem-solving agents, relying solely on natural language processing is inadequate; they would also need access to problem-solving tools.

Gorilla looks to be changing the field, an API-enhanced LLM that excels in generating precise API calls, outperforming even top models like GPT-4.


Gorilla’s strength lies in its seamless adaptation to changing API documentation, ensuring up-to-date accuracy. This fusion of language understanding and real-time data marks a transformative step towards versatile problem-solving LLMs.

Advantages of Augmenting LLMs with APIs

Enhancing LLMs through API integration offers numerous benefits. Some of the key advantages are mentioned below:

Accessing Real-Time Information: Enhancing large language models (LLMs) with additional resources grants them the ability to access the most current information from sources that are continuously updating.

This is achieved by enabling them to utilize search technologies and databases. Consequently, LLMs can effectively access a much broader and constantly changing range of knowledge, rather than relying solely on the fixed information they initially learned during their training.

Solving Complex Real-World Problems: APIs are essential in modern software development. They enable different software parts to communicate and perform various tasks. Adding APIs to language models empower them with the abilities to solve complex real-world problems beyond natural language processing.

Transforming Interactions: Enabling the use of a wide variety of dynamically evolving cloud APIs has the potential to make LLMs the primary means through which people interact with computer systems and the internet. This has the potential to reshape tasks like booking a complete vacation or organizing a conference, making them as effortless as having a conversation with an LLM that can access flight, car rental, hotel, catering, and entertainment web APIs.

Reshaping Program Synthesis: Harnessing LLMs for program synthesis has been historically tough due to the complexity of low-level implementation. However, API integration now allows LLMs to create complex programs through simplified API calls, expanding their capabilities without dealing with intricate implementation details.

Introducing Gorilla – an API-Augmented LLM

Gorilla is an advanced LLM specifically trained to excel in generating API calls and can adapt to changes in API documentation.

This model was developed in response to the challenges faced by LLMs like GPT-4 in accurately generating input arguments for API calls, which sometimes leads to generating incorrect API usage.

To train Gorilla, researchers curated a diverse collection of API calls from platforms such as HuggingFace, TorchHub, and TensorHub, forming the APIBench dataset.

This dataset was then utilized to fine-tune the LLaMA-based model – an open-source Large Language Model developed by Meta AI – ultimately transforming it into Gorilla. The training process involved generating pairs of instructions and corresponding responses through the application of self-instruction techniques.

Gorilla exhibits superior performance compared to other LLMs like GPT-4 and GPT-3.5-turbo when it comes to generating API calls from natural language prompts.

Its remarkable capability lies in its seamless adaptation to changes in API documentation; a feat achieved through its retrieval-aware training approach. This unique approach enables Gorilla to consistently stay updated with evolving API documentation and effectively adhere to various constraints. As a result, Gorilla stands out as a dependable and precise tool for the generation of API calls.

The Gorilla model is an open-source resource accessible through Hugging Face, allowing the public to utilize it for various purposes.

How Does Gorilla Generate API Calls?

Gorilla employs a multi-step procedure to establish a connection with an API, a process that unfolds as follows:

1. User Input and Inference: During the inference phase, users provide prompts in natural language. These prompts can range from straightforward tasks (“Can you help me identify the elements in this photograph?”) to more general objectives (“I’m going for a nature walk and want to identify various kinds of trees”). Gorilla performs inference in two distinct modes, namely zero-shot and retrieval.

2. Zero-Shot Inference: In the zero-shot mode, the provided prompt (without any additional prompt tuning) is input to the Gorilla LLM model. The model then composes an API call that aligns with the given task or goal. This streamlined approach requires no further adjustment of the prompt.

3. Retrieval Mode: In the retrieval mode, Gorilla incorporates a retriever mechanism that utilizes either BM25 or GPT – techniques analogous to those employed by search engines to assess the relevance of documents.

This retriever initially retrieves the latest API documentation stored in the API Database. Following this, the retrieved documentation is combined with the user’s prompt and extended by the instruction “Refer to this API documentation.” The combined instruction is then fed into Gorilla’s system for further processing.

4. Concatenation and Output: The outcome generated by Gorilla is a fully prepared API call, ready for execution. Even though the API documentation and user prompt are combined, it’s crucial to emphasize that Gorilla doesn’t involve any additional prompt adjustments.

The Bottom Line

Language models, while impressive, have limitations due to fixed training data and an inability to adapt.

Augmenting large language models (LLMs) with APIs empowers them with real-time information access and problem-solving abilities beyond language processing.

This integration has the potential to reshape interactions with technology, simplifying tasks and enabling complex program synthesis.

Gorilla, an API-augmented LLM, addresses challenges in accurate API call generation. Gorilla’s adaptive training approach makes it proficient in generating precise API calls, providing a seamless connection between users and evolving APIs for diverse tasks.


Related Reading

Related Terms

Dr. Tehseen Zia
Tenured Associate Professor
Dr. Tehseen Zia
Tenured Associate Professor

Dr. Tehseen Zia has Doctorate and more than 10 years of post-Doctorate research experience in Artificial Intelligence (AI). He is Tenured Associate Professor and leads AI research at Comsats University Islamabad, and co-principle investigator in National Center of Artificial Intelligence Pakistan. In the past, he has worked as research consultant on European Union funded AI project Dream4cars.