/ Модель

Характеристики

Контекст
2 048 токенов
Размер весов
5,6 ГБ
Лицензия
MIT
Архитектура
phi-msft · dense
Опубликована
4 янв 2024

dolphin-2_6-phi-2-sft-glaive-function-calling-v2-ep1

Генерация текстаТекст → текст3 профессии

Разговорная Phi-2, дообученная для вызова функций в чат-приложениях.

19скачиваний за 30 дней6лайковвеса обновлены2 мар 2024

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

Yhyu13/dolphin-2_6-phi-2-sft-glaive-function-calling-v2-ep1 — разговорная языковая модель на архитектуре Phi-2, дообученная для вызова функций и объединённая с адаптером SFT для function calling. Модель генерирует вызовы функций в формате XML-обёртки с именем функции и аргументами; ответы функций выделяются в специальном формате, чтобы ассистент мог учитывать их при продолжении диалога.

Модель предназначена для экспериментов с интеграцией вызова функций в чат-приложения, например в системы, которым нужен интерфейс взаимодействия с инструментами. Контекст составляет 2048 токенов. В карточке указаны формат safetensors и лицензия MIT. Автор предупреждает, что ограниченная способность Phi-2 следовать инструкциям делает модель неподходящей для промышленного использования.

Сценарии применения

  • эксперименты с вызовом функций из чат-бота
  • генерация структурированных аргументов для инструментов
  • обработка результатов вызова функции в диалоге
  • подключение function calling в приложениях на базе LLM

Ограничения

Автор не рекомендует использовать модель в production: Phi-2 ограниченно следует инструкциям при вызове функций. Контекст — 2048 токенов.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Phi-2 function calling

This is a merged model of the https://huggingface.co/cognitivecomputations/dolphin-2_6-phi-2 and sft function calling lora here

The sft dataset is https://huggingface.co/datasets/Yhyu13/glaive-function-calling-v2-llama-factory-convert, which I converted for llama_factory from original dataset https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2

This model is acompanied with pr on textgen-webui to enable its function calling ability like GPTs: Add function calling ability to openai extension

Caution

Do not use this model in production, phi-2 has limited prompt following ability in terms of function calling.

Please checkout my best function calling model here https://huggingface.co/Yhyu13/dolphin-2.6-mistral-7b-dpo-laser-function-calling

Detail

The function calling is wrapped in simple xml tag for eaiser identification.

<functioncall> {\"name\": \"calculate_loan_payment\", \"arguments\": '{\"principal\": 50000, \"interest_rate\": 5, \"loan_term\": 10}'} </functioncall>

that can be extracted like this

import re
import json

input_str = "<functioncall> {\"name\": \"calculate_loan_payment\", \"arguments\": '{\"principal\": 50000, \"interest_rate\": 5, \"loan_term\": 10}'} </functioncall>"

# Define the pattern to match the JSON string within the functioncall tags
pattern = r'<functioncall>(.*?)</functioncall>'

# Use re.search to find the matched pattern
match = re.search(pattern, input_str, re.DOTALL)

if match:
    json_str = match.group(1)
    # Remove the single quotes surrounding the inner JSON string
    json_str = json_str.replace("'", "")
    
    # Load the JSON string into a Python dictionary
    json_data = json.loads(json_str)
    print(json_data)
else:
    print("No match found.")

Or, if you want to faithfully keep the single quotes that wrapps the arguments value (where openai does it like this, which makes json.loads fail shortly on the original json_str), use ast.literal_eval for the rescue.

if match:
    import ast
    json_str = match.group(1)
    json_str = json_str.strip()
    """
    https://www.datasciencebyexample.com/2023/03/16/what-to-do-when-single-quotes-in-json-string/
    """
    json_dict = ast.literal_eval(json_str)
    print(json_dict['name'], json_dict['arguments'])
else:
    print("No match found.")

Hopefully, this model can be a drop-in replacement for apps (e.g. memgpt) that require function calling ability from LLMs.

Another note on interpreting function call result:

Function response has been put between <functionresponse> in order to be identified as a function call result (which could be evaluted behind the scene, and its result in principle should be interpreted as part of the user input), which then will be processed by the assistant for form a conversational response.

<functionresponse> jons_str </functionresponse>

Result

Prompt:

SYSTEM: You are a helpful assistant with access to the following functions. Use them if required -\n{\n \"name\": \"get_news_headlines\",\n \"description\": \"Get the latest news headlines\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"country\": {\n \"type\": \"string\",\n \"description\": \"The country for which to fetch news\"\n }\n },\n \"required\": [\n \"country\"\n ]\n }\n}\n\nWhat date is it today?"

img

Prompt:

SYSTEM: You are a helpful assistant with access to the following functions. Use them if required -\n{\n \"name\": \"calculate_median\",\n \"description\": \"Calculate the median of a list of numbers\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"numbers\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"number\"\n },\n \"description\": \"A list of numbers\"\n }\n },\n \"required\": [\n \"numbers\"\n ]\n }\n}\n\nHi, I have a list of numbers and I need to find the median. Can you help me with that?

Function response:

<functionresponse> {"median": 5} </functionresponse>

img

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм

Нельзя запустить

Модели нужен код из репозитория; автор пока не в списке доверенных организаций.

Класс архитектуры
PhiForCausalLM
Ревизия весов
3214995

0 моделей