Edit model card

You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Access to this model requires the purchase of a license from here

Log in or Sign Up to review the conditions and access this model content.

Function Calling Yi Models

The function calling Yi series of models offers 200k context length in a 6B (here) and 34B (here) parameter model.

  • The 6B model is recommended if you want a faster model for function calling on long context.
  • The 34B model is more accurate in handling responses requiring a combination of of function calls and standard responses.

Recent Updates

  • Nov 15th 2023 -> added Yi 200k context models in 6B and 34B form.
  • Nov 8th 2023 -> added Zephyr beta, an improved version of Mistral 7B (achieved via DPO)
  • November 6th 2023 -> added Deepseek Coder 1.3B, 6.7B and 33B
  • October 11th 2023 -> added Mistral 7B with function calling
  • October 11th 2023 -> new models pushed, trained on an improved underlying dataset

Improvements with v2

  1. Shortened syntax: Only function descriptions are needed for inference and no added instruction is required.
  2. Function descriptions are moved outside of the system prompt. This avoids the behaviour of function calling being affected by how the system prompt had been trained to influence the model.

Latest Models:

Other Models:

Performance and Tips

  1. Larger models are better at handling function calling. The cross entropy training losses are approximately 0.5 for 7B, 0.4 for 13B, 0.3 for 70B. The absolute numbers don't mean anything but the relative values offer a sense of relative performance.
  2. Provide very clear function descriptions, including whether the arguments are required or what the default values should be.
  3. Make sure to post-process the language model's response to check that all necessary information is provided by the user. If not, prompt the user to let them know they need to provide more info (e.g. their name, order number etc.)

Check out this video overview of performance here

Licensing

Llama-7B with function calling is licensed according to the Meta Community license.

Mistral-7B, Llama-13B, Code-llama-34b, Llama-70B and Falcon-180B with function calling require the purchase of access.

  • Commercial license purchase required per user.
  • Licenses are not transferable to other users/entities.

Use of all Llama models with function calling is further subject to terms in the Meta license.

Yi models are subject to the Yi license, which permits commercial use as of Nov 15th 2023.

Zephr models were generated using Ultrachat, which relies on openai. OpenAI does not permit the use of it's models to train competitive models. This makes it unclear as to whether Zephyr may be used commercial. Buyers/users do so at their sole risk.

Dataset

The dataset used for training this model can be found at Trelis Function Calling Extended Dataset.

Inference

!!! Make sure to check the prompt format below and adjust inference accordingly !!!

Quick Start in Google Colab Try out this notebook fLlama_Inference notebook

Commercial Applications You can this model with text-generation-interface and chat-ui

Here is the github for setup

And here is a video showing it working with llama-2-7b-chat-hf-function-calling-v2 (note that we've now moved to v2)

Note that you'll still need to code the server-side handling of making the function calls (which obviously depends on what functions you want to use).

Run on your laptop Run on your laptop video and juypter notebook

After running llama.cpp server, you can call the server with this command, with thanks to @jdo300:

import requests
import json

# Define the roles and markers
B_FUNC, E_FUNC = "<FUNCTIONS>", "</FUNCTIONS>\n\n"
B_INST, E_INST = "[INST] ", " [/INST]" #Llama style
# B_INST, E_INST = "\n### Instruction:\n", "\n### Response:\n" #DeepSeek Coder Style
# B_INST, E_INST = "Human: ", " Assistant: " #Yi Style

# Define the function metadata
function_metadata = {
    "function": "search_bing",
    "description": "Search the web for content on Bing. This allows users to search online/the internet/the web for content.",
    "arguments": [
        {
            "name": "query",
            "type": "string",
            "description": "The search query string"
        }
    ]
}

# Define the user prompt
user_prompt = 'Search for the latest news on AI.'

# Format the function list and prompt
function_list = json.dumps(function_metadata, indent=4)
prompt = f"{B_FUNC}{function_list.strip()}{E_FUNC}{B_INST}{user_prompt.strip()}{E_INST}\n\n"

# Define the API endpoint
url = "http:/localhost:8080/completion"

# Send the POST request to the API server
response = requests.post(url, json={"prompt": prompt})

# Print the response
print(response.json())

Syntax

Prompt Templates

The function descriptions must be wrapped within a function block. You can put this function below before or after the system message block.

Example without a system message:

  # Define the roles and markers
  B_FUNC, E_FUNC = "<FUNCTIONS>", "</FUNCTIONS>\n\n"
  B_INST, E_INST = "[INST] ", " [/INST]" #Llama style
  # B_INST, E_INST = "\n### Instruction:\n", "\n### Response:\n" #DeepSeek Coder Style
  # B_INST, E_INST = "Human: ", " Assistant: " #Yi Style

  functionList = {function_1_metadata}{function_2_metadata}...
  user_prompt = '...'

  # Format your prompt template
  prompt = f"{B_FUNC}{functionList.strip()}{E_FUNC}{B_INST}{user_prompt.strip()}{E_INST}\n\n"

Example with a system message:

  # Define the roles and markers
  B_FUNC, E_FUNC = "<FUNCTIONS>", "</FUNCTIONS>\n\n"
  B_INST, E_INST = "[INST] ", " [/INST]" #Llama style
  # B_INST, E_INST = "\n### Instruction:\n", "\n### Response:\n" #DeepSeek Coder Style
  # B_INST, E_INST = "Human: ", " Assistant: " #Yi Style
  B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n"

  # assuming functionList is defined as above
  system_prompt = '...'
  user_prompt = '...'

  # Format your prompt template
  prompt = f"{B_FUNC}{functionList.strip()}{E_FUNC}{B_INST}{B_SYS}{system_prompt.strip()}{E_SYS}{user_prompt.strip()}{E_INST}\n\n"

Notice that the function block is placed at the very start of the sequence, before 'B_INST'.

Function Metadata Template

functionMetadata should be a string representation of a JSON object, like this:

"functionMetadata": {
        "function": "search_bing",
        "description": "Search the web for content on Bing. This allows users to search online/the internet/the web for content.",
        "arguments": [
            {
                "name": "query",
                "type": "string",
                "description": "The search query string"
            }
        ]
    }
'''

and the language model should respond with a json object formatted like this:

{
    "function": "function_name",
    "arguments": {
        "argument1": "argument_value",
        "argument2": "argument_value"
    }
}

It is recommended to handle cases where:

  • There is no json object in the response
  • The response contains text in addition to the json response

Sample functionList

{
    "function": "search_bing",
    "description": "Search the web for content on Bing. This allows users to search online/the internet/the web for content.",
    "arguments": [
        {
            "name": "query",
            "type": "string",
            "description": "The search query string"
        }
    ]
}

{
    "function": "search_arxiv",
    "description": "Search for research papers on ArXiv. Make use of AND, OR and NOT operators as appropriate to join terms within the query.",
    "arguments": [
        {
            "name": "query",
            "type": "string",
            "description": "The search query string"
        }
    ]
}

Training Set Argument Types

Models were fine-tuned on argument types including strings, numbers and arrays. The training set includes function calls with 0, 1, 2 or 3 arguments. The larger the model the better it will generalise beyond these types.

Here is a function call with an array:

{ "function": "delete_file", "arguments": { "fileNames": [ "Dissecting Transformer Length Extrapolation via The Lens of Receptive Field Analysis", "Luna- Linear Unified Nested Attention", "Substack_Inc_2021_2020_GAAP_Audited_Financials" ] } }

Here is a function call with three arguments:

{ "function": "save_chat", "arguments": { "fileName": "KiteDiscussion", "fileDescription": "Notes on one and two stringed kites", "fileContent": "--- **Types of Kite** There are one and two string kites. The two string ones are easier to control, although you can get the cords tangled. The one-stringed ones are sometimes used for kite fights, and you lose the kite and have to run after it if the string breaks. ---" } }

~

The original model card follows below.

~

Introduction

The Yi series models are large language models trained from scratch by developers at 01.AI. The first public release contains two bilingual(English/Chinese) base models with the parameter sizes of 6B(Yi-6B) and 34B(Yi-34B). Both of them are trained with 4K sequence length and can be extended to 32K during inference time. The Yi-6B-200K and Yi-34B-200K are base model with 200K context length.

News

Model Performance

Model MMLU CMMLU C-Eval GAOKAO BBH Common-sense Reasoning Reading Comprehension Math & Code
5-shot 5-shot 5-shot 0-shot 3-shot@1 - - -
LLaMA2-34B 62.6 - - - 44.1 69.9 68.0 26.0
LLaMA2-70B 68.9 53.3 - 49.8 51.2 71.9 69.4 36.8
Baichuan2-13B 59.2 62.0 58.1 54.3 48.8 64.3 62.4 23.0
Qwen-14B 66.3 71.0 72.1 62.5 53.4 73.3 72.5 39.8
Skywork-13B 62.1 61.8 60.6 68.1 41.7 72.4 61.4 24.9
InternLM-20B 62.1 59.0 58.8 45.5 52.5 78.3 - 30.4
Aquila-34B 67.8 71.4 63.1 - - - - -
Falcon-180B 70.4 58.0 57.8 59.0 54.0 77.3 68.8 34.0
Yi-6B 63.2 75.5 72.0 72.2 42.8 72.3 68.7 19.8
Yi-6B-200K 64.0 75.3 73.5 73.9 42.0 72.0 69.1 19.0
Yi-34B 76.3 83.7 81.4 82.8 54.3 80.1 76.4 37.1
Yi-34B-200K 76.1 83.6 81.9 83.4 52.7 79.7 76.6 36.3

While benchmarking open-source models, we have observed a disparity between the results generated by our pipeline and those reported in public sources (e.g. OpenCompass). Upon conducting a more in-depth investigation of this difference, we have discovered that various models may employ different prompts, post-processing strategies, and sampling techniques, potentially resulting in significant variations in the outcomes. Our prompt and post-processing strategy remains consistent with the original benchmark, and greedy decoding is employed during evaluation without any post-processing for the generated content. For scores that were not reported by the original authors (including scores reported with different settings), we try to get results with our pipeline.

To evaluate the model's capability extensively, we adopted the methodology outlined in Llama2. Specifically, we included PIQA, SIQA, HellaSwag, WinoGrande, ARC, OBQA, and CSQA to assess common sense reasoning. SquAD, QuAC, and BoolQ were incorporated to evaluate reading comprehension. CSQA was exclusively tested using a 7-shot setup, while all other tests were conducted with a 0-shot configuration. Additionally, we introduced GSM8K (8-shot@1), MATH (4-shot@1), HumanEval (0-shot@1), and MBPP (3-shot@1) under the category "Math & Code". Due to technical constraints, we did not test Falcon-180 on QuAC and OBQA; the score is derived by averaging the scores on the remaining tasks. Since the scores for these two tasks are generally lower than the average, we believe that Falcon-180B's performance was not underestimated.

Usage

Please visit our github repository for general guidance on how to use this model.

Disclaimer

Although we use data compliance checking algorithms during the training process to ensure the compliance of the trained model to the best of our ability, due to the complexity of the data and the diversity of language model usage scenarios, we cannot guarantee that the model will generate correct and reasonable output in all scenarios. Please be aware that there is still a risk of the model producing problematic outputs. We will not be responsible for any risks and issues resulting from misuse, misguidance, illegal usage, and related misinformation, as well as any associated data security concerns.

License

The Yi series models are fully open for academic research and free commercial usage with permission via applications. All usage must adhere to the Model License Agreement 2.0. To apply for the official commercial license, please contact us (yi@01.ai).

Downloads last month
0
Safetensors
Model size
34.4B params
Tensor type
FP16
·
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.