--- license: apache-2.0 language: - en tags: - api datasets: - gorilla-llm/APIBench --- # Gorilla: Large Language Model Connected with Massive APIs By Shishir G. Patil, Tianjun Zhang, Xin Wang, and Joseph E. Gonzalez ([Project Website](https://shishirpatil.github.io/gorilla/)) [![arXiv](https://img.shields.io/badge/arXiv-2305.15334-.svg?style=flat-square)](https://arxiv.org/abs/2305.15334) [![Discord](https://img.shields.io/discord/1111172801899012102?label=Discord&logo=discord&logoColor=green&style=flat-square)](https://discord.gg/3apqwwME) [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1DEBPsccVLF_aUnmD0FwPeHFrtdC0QIUP?usp=sharing) `Gorilla` enables LLMs to use tools by invoking APIs. Given a natural language query, Gorilla can write a semantically- and syntactically- correct API to invoke. With Gorilla, we are the first to demonstrate how to use LLMs to invoke 1,600+ (and growing) API calls accurately while reducing hallucination. We also release APIBench, the largest collection of APIs, curated and easy to be trained on! Join us, as we try to expand the largest API store and teach LLMs how to write them! Hop on our Discord, or open a PR, or email us if you would like to have your API incorporated as well. ## Model Details Gorilla can be either trained via standard finetuning or using our novel retriever-aware training pipeline. We release `gorilla-7b-hf-delta-v1`, a 0-shot finetuned LLM that can reliably use Hugging Face APIs. It can be prompted through simply natural language (e.g., "I want to generate an image from text."). Checkour our website, github and paper for more information. Thank you for the feedback, with `gorilla-llm/gorilla-7b-hf-delta-v1` Gorilla now ouput's code snippet that can be directly integrated into your workflow! Now with `gorilla-llm/gorilla-7b-hf-delta-v1` Example prompt1: "I would like to translate 'I feel very good today.' from English to Chinese." 🦍 Response: ``` from transformers import pipeline def load_model(): translation_model = pipeline(‘translation_en_to_zh’, model=‘Helsinki-NLP/opus-mt-en-zh’) return translation_model def process_data(text_to_translate, translation_model): response = translation_model(text_to_translate)[0][‘translation_text’] return response text_to_translate = ‘I feel very good today’ # Load the model translation_model = load_model() # Process the data translated_text = process_data(text_to_translate, translation_model) print(translated_text) ``` Example prompt2: "I want to build a robot that can detecting objects in an image ‘cat.jpeg’. Input: [‘cat.jpeg’]" 🦍 Response: ``` from transformers import ConvNextFeatureExtractor, ConvNextForImageClassification from PIL import Image def load_model(): feature_extractor = ConvNextFeatureExtractor.from_pretrained(‘facebook/convnext-large-224’) model = ConvNextForImageClassification.from_pretrained(‘facebook/convnext-large-224’) return feature_extractor, model def process_data(image_path, feature_extractor, model): image = Image.open(image_path) inputs = feature_extractor(images=image, return_tensors=‘pt’) logits = model(**inputs).logits predicted_label = logits.argmax(-1).item() response = model.config.id2label[predicted_label] return response image_path = ‘/content/cat.jpeg’ # Load the model and feature extractor feature_extractor, model = load_model() # Process the data response = process_data(image_path, feature_extractor, model) print(response) ``` ### Model Type Gorilla is an open-source API caller trained by fine-tuning LLaMA weights. It is an auto-regressive language model, based on the transformer architecture. Gorilla also has Apache 2.0 models trained on MPT-7B and Falcon-7B base, which cab be used commercially with no obligations. ### Model Date 06/15/2023 ### Organization Gorilla LLM (UC Berkeley) --- license: apache-2.0 ---