# Gorilla Inference ## Get Started You can either run Gorilla through our hosted [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1DEBPsccVLF_aUnmD0FwPeHFrtdC0QIUP?usp=sharing) or [chat with it using cli](#inference-using-cli). We also provide instructions for [evaluating batched prompts](#optional-batch-inference-on-a-prompt-file). Here, are the instructions to run it locally. `gorilla-7b-hf-v0` is the first set of weights we released :tada: It chooses from 925 HF APIs in a 0-shot fashion (without any retrieval). Update: We released `gorilla-7b-th-v0` with 94 (exhaustive) APIs from Torch Hub and `gorilla-7b-tf-v0` with 626 (exhaustive) APIs from Tensorflow. In spirit of openess, we do not filter, nor carry out any post processing either to the prompt nor response :gift: Keep in mind that the current `gorilla-7b-*` models do not have any geenric chat capability. We do have a model with all the 1600+ APIs which also has chat capability, which we release slowly to accomodate server demand. All delta weights hosted at [https://huggingface.co/gorilla-llm/](https://huggingface.co/gorilla-llm/). ### Install Dependencies You should install dependencies using the following command: ```bash conda create -n gorilla python=3.10 conda activate gorilla pip install -r requirements.txt ``` ### Downloading Gorilla Delta Weights We release the delta weights of Gorilla to comply with the LLaMA model license. You can prepare the Gorilla weights using the following steps: 1. Get the original LLaMA weights using the link [here](https://huggingface.co/docs/transformers/main/model_doc/llama). 2. Download the Gorilla delta weights from our [Hugging Face](https://huggingface.co/gorilla-llm/gorilla-7b-hf-delta-v0). ### Applying Delta Weights Run the following python command to apply the delta weights to your LLaMA model: ```python python3 apply_delta.py --base-model-path path/to/hf_llama/ --target-model-path path/to/gorilla-7b-hf-v0 --delta-path path/to/models--gorilla-llm--gorilla-7b-hf-delta-v0 ``` ### Inference using CLI Simply run the command below to start chatting with Gorilla: ```bash python3 serve/gorilla_cli.py --model-path path/to/gorilla-7b-{hf,th,tf}-v0 ``` ### [Optional] Batch Inference on a Prompt File After downloading the model, you need to make a jsonl file containing all the question you want to inference through Gorilla. Here is [one example](https://github.com/ShishirPatil/gorilla/tree/main/inference/questions/example.jsonl): ``` {"question_id": 1, "text": "I want to generate image from text."} {"question_id": 2, "text": "I want to generate text from image."} ``` After that, using the following command to get the results: ```bash python3 gorilla_eval.py --model-path path/to/gorilla-7b-hf-v0 --question-file path/to/questions.jsonl ----answer-file path/to/answers.jsonl ``` You could use your own questions and get Gorilla responses. We also provide a set of [questions](https://github.com/ShishirPatil/gorilla/tree/main/eval/eval-data/questions/huggingface) that we used for evaluation.