/ Модель

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

Контекст
32 768 токенов
Параметры
7,1 млрд
Размер весов
14,5 ГБ
Архитектура
mistral · dense
Опубликована
2 апр 2024

LeerooDedicated-Math-7b

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

Математическая модель на базе Mistral, которая генерирует решения задач и может сигнализировать о необходимости передать сложный вопрос более мощной LLM.

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

Бенчмарки

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

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Текст» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

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

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

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

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

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

LeerooDedicated-Math-7b — специализированная на математике модель Leeroo на базе Mistral с плотной архитектурой и 7,1 млрд параметров. В README описан подход Orchestration of Experts: оркестратор оценивает, может ли базовая модель решить задачу, и передаёт генерацию базовой модели-эксперту, если задача ей по силам. Для более сложных вопросов модель выдаёт специальный токен, сигнализирующий о необходимости обратиться к GPT-4 или другой сильной LLM; для получения полного ответа можно подключить OpenAI API.

Модель предназначена для генерации решений математических задач. В оценке GSM8K, приведённой в README, она достигла точности 84,77% в режиме 5-shot, используя GPT-4 примерно для половины вопросов; это результат сценария с привлечением внешней модели, а не автономной работы одного чекпойнта. Размер родительского контекстного окна — 32 768 токенов. Веса опубликованы в формате safetensors. README не сообщает лицензию, поэтому условия использования по доступным данным определить нельзя.

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

  • генерация решений математических задач
  • решение задач формата GSM8K
  • определение, по силам ли задача базовой языковой модели
  • маршрутизация сложных математических вопросов к GPT-4 через интеграцию

Ограничения

Для сложных вопросов модель может выдать специальный токен вместо решения; в описанной оценке около половины вопросов GSM8K обрабатывались с помощью GPT-4, поэтому результат не характеризует автономную точность чекпойнта. README не сообщает лицензию.

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

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

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

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

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

Открыть на Hugging Face

Leeroo Dedidcated Math Expert 🤗

The model is built by applying Orchestration of Expert for the math domain. The dedicated model either generates solutions or, when necessary, utilizes GPT-4 (or similar performing LLM) to fill in gaps in its knowledge base. Specifically, when given an input, the dedicated model first determines if the input question is solvable with the base model. If solvable, the orchestrator is detached, and token generation is invoked using the base LLM expert. If the problem is difficult and requires a larger model like GPT-4, it produces <GPT4> token (i.e., token_id=32000).

The Orchestrator is first trained to estimate the knowledge of the base model, for any given query, then we marge into the base model (MetaMath7b, here).
In general for any domain, you can build it by:

  • Choose a base LLM expert 🤗
  • Train a domain-specific Orchestrator
  • Merge Orchestrator with the base expert

✅ In evaluations using the GSM8k dataset of OpenLLM Leaderboard, Leeroo Math 7b model achieves an accuracy of 84.77% in 5-shot setting, positioning it among the top performers in its class and notably surpassing its base model, which scores 68.84% on the same dataset. This was accomplished while relying on GPT-4 for responses to half of the questions posed by GSM8k.

Sample Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("leeroo/LeerooDedicated-Math-7b", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("leeroo/LeerooDedicated-Math-7b")
device = model.device

# the following question is answered by the leeroo expert
question = "Natalia sold clips to 48 of her friends in April,and then she sold half as many clips in May.How many clips did Natalia sell altogether in April and May?"
encodeds = tokenizer([question], return_tensors="pt")
model_inputs = encodeds['input_ids'].to(device)
generated_ids = model.generate(model_inputs, max_new_tokens=100, do_sample=False)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
# Natalia sold 48 clips in April.\nIn May, she sold half as many clips as in April,
# so she sold 48/2 = 24 clips.\nAltogether, Natalia sold 48 + 24 = 72 clips in April and May.\n#### 72\nThe answer is: 72</s>

# sends the following question to GPT4
question = "James loves to go swimming and has to swim across a 20-mile lake.  He can swim at a pace of 2 miles per hour.  He swims 60% of the distance.  After that, he stops on an island and rests for half as long as the swimming time.  He then finishes the remaining distance while going half the speed.  How long did it take him to get across the lake?"
encodeds = tokenizer([question], return_tensors="pt")
model_inputs = encodeds['input_ids'].to(device)
generated_ids = model.generate(model_inputs, max_new_tokens=100, do_sample=False)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
# <GPT4></s>

You can also add your OpenAI API to get the full answer when <GPT4> token is generated:

from openai import OpenAI
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("leeroo/LeerooDedicated-Math-7b", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("leeroo/LeerooDedicated-Math-7b")
openai_client = OpenAI(
    api_key=  "OPENAI_API_KEY",
    base_url= "https://api.openai.com/v1"
)

def generate(prompt, tokenizer, model, openai_client, max_new_tokens=100, verbose=True):
    inputs = tokenizer(prompt, return_tensors="pt")
    inputs = {k:v.to(model.device) for k,v in inputs.items()}
    gen_tokens = model.generate( **inputs , max_new_tokens=max_new_tokens, do_sample=False, pad_token_id= tokenizer.pad_token_id)
    if gen_tokens[0, inputs['input_ids'].shape[1]] != tokenizer.unk_token_id:
        if verbose: print("\033[94mGenerating using MetaMath7b.\033[0m")
        gen_text = tokenizer.decode(
            gen_tokens[0, inputs['input_ids'].shape[1]:].tolist() )
    else:
        if verbose: print("\033[94mGenerating using gpt4.\033[0m")
        gen_text = openai_client.completions.create(
            model = "gpt-4-1106-preview", # NOTE you can use any bigger mode here having performance similar to gpt4
            prompt = prompt,
            max_tokens = max_new_tokens,
            temperature = 0.0
        ).choices[0].text
    return gen_text

# the following question is answered by the leeroo expert
prompt = "Question: Natalia sold clips to 48 of her friends in April,and then she sold half as many clips in May.How many clips did Natalia sell altogether in April and May?\nAnswer:"
generation = generate(prompt, tokenizer, model, openai_client, max_new_tokens=500)
print(generation)
#> Generating using MetaMath7b.
# Natalia sold 48 clips in April.\nIn May, she sold half as many clips as in April,
# so she sold 48/2 = 24 clips.\nAltogether, Natalia sold 48 + 24 = 72 clips in April and May.\n#### 72\nThe answer is: 72</s>

# sends the following question to GPT4
prompt = "James loves to go swimming and has to swim across a 40-mile lake.  He can swim at a pace of 2 miles per hour.  He swims 60% of the distance.  After that, he stops on an island and rests for half as long as the swimming time.  He then finishes the remaining distance while going half the speed.  How many hours did it take him to get across the lake?"
generation = generate(prompt, tokenizer, model, openai_client, max_new_tokens=500)
print(generation)
#> Generating using gpt4.
#   He swam 40*.6=24 miles
# So he swam for 24/2=12 hours
# He rested for 12/2=6 hours
# He had 40-24=16 miles left to swim
# He swam at 2/2=1 mile per hour
# So he swam for 16/1=16 hours
# So in total, it took him 12+6+16=34 hours
# 34

Learn More

🔍 To a deeper dive into our method and results, refer to HF blog 🤗, publication, and repository.
🌍 Join Leeroo community for further updates: Linkedin, Discord, X, Website.

Citation

@misc{mohammadshahi2024leeroo,
    title={Leeroo Orchestrator: Elevating LLMs Performance Through Model Integration},
    author={Alireza Mohammadshahi and Ali Shaikh and Majid Yazdani},
    year={2024},
    eprint={2401.13979},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

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

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

GPU в ailist

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

Можно запустить

Подбираем GPU…

Класс архитектуры
LeerooDedicatedOOE
Ревизия весов
98cbb06

0 моделей