Leeroodedicated Math 7b
该模型通过专家协同方法构建,专注于数学问题求解,能自主生成解决方案或在需要时调用GPT-4级别的大模型。
下载量 63
发布时间 : 4/2/2024
模型简介
Leeroo专属数学专家模型结合了基础专家模型(MetaMath7b)和协调器,用于解决数学问题,在简单问题上自主生成答案,在复杂问题上调用GPT-4级别的大模型。
模型特点
专家协同方法
结合基础专家模型和协调器,动态判断问题难度并决定是否调用GPT-4级别的大模型。
高性能数学求解
在GSM8k数据集上取得84.77%的准确率,显著超越基础模型的表现。
智能调用GPT-4
对于超出基础模型能力的问题,自动生成<GPT4>标记并调用GPT-4级别的大模型进行解答。
模型能力
数学问题求解
动态调用大模型
多步推理
使用案例
教育
数学问题解答
解答各类数学问题,包括基础算术、应用题等。
在GSM8k数据集上取得84.77%的准确率。
研究
数学推理研究
用于研究大语言模型在数学推理方面的能力。
🚀 Leeroo Dedidcated Math Expert 🤗
该模型是通过将专家编排(Orchestration of Expert)应用于数学领域而构建的。这个专用模型既可以生成解决方案,也可以在必要时利用 GPT - 4(或性能类似的大语言模型)来填补其知识库中的空白。具体而言,当给定一个输入时,专用模型首先判断输入的问题是否可以由基础模型解决。如果可以解决,则分离编排器,并使用基础大语言模型专家进行令牌生成。如果问题较难,需要像 GPT - 4 这样的更大模型,则会生成 <GPT4>
令牌(即 token_id = 32000)。
编排器首先经过训练,以估计基础模型对于任何给定查询的知识,然后将其合并到基础模型(这里是 MetaMath7b)中。
一般来说,对于任何领域,你可以通过以下步骤构建它:
- 选择一个基础大语言模型专家 🤗
- 训练一个特定领域的编排器
- 将编排器与基础专家合并
✅ 在 OpenLLM 排行榜的 GSM8k 数据集评估中,Leeroo Math 7b 模型在 5 - shot 设置下达到了 84.77% 的准确率,使其在同类模型中名列前茅,并且显著超过了其基础模型,该基础模型在同一数据集上的得分是 68.84%。这一成绩是在依靠 GPT - 4 回答 GSM8k 提出的一半问题的情况下取得的。
✨ 主要特性
- 采用专家编排技术,结合基础模型和大语言模型,提升数学问题解决能力。
- 能够根据问题难度自动选择使用基础模型或借助 GPT - 4 进行解答。
- 在 GSM8k 数据集上表现优异,准确率较高。
📦 安装指南
文档未提及安装步骤,故跳过该章节。
💻 使用示例
基础用法
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>
高级用法
你还可以添加你的 OpenAI API,以便在生成 <GPT4>
令牌时获得完整答案:
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
📚 详细文档
🔍 若要深入了解我们的方法和结果,请参考 HF 博客 🤗、出版物和 代码仓库。
🌍 加入 Leeroo 社区以获取更多更新:领英、Discord、X、网站。
📄 许可证
文档未提及许可证信息,故跳过该章节。
📖 引用
@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}
}
Phi 2 GGUF
其他
Phi-2是微软开发的一个小型但强大的语言模型,具有27亿参数,专注于高效推理和高质量文本生成。
大型语言模型 支持多种语言
P
TheBloke
41.5M
205
Roberta Large
MIT
基于掩码语言建模目标预训练的大型英语语言模型,采用改进的BERT训练方法
大型语言模型 英语
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基础模型的蒸馏版本,在保持相近性能的同时更轻量高效,适用于序列分类、标记分类等自然语言处理任务。
大型语言模型 英语
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一个多语言大语言模型,针对多语言对话用例进行了优化,在常见的行业基准测试中表现优异。
大型语言模型 英语
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基于100种语言的2.5TB过滤CommonCrawl数据预训练的多语言模型,采用掩码语言建模目标进行训练。
大型语言模型 支持多种语言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基于Transformer架构的英语预训练模型,通过掩码语言建模目标在海量文本上训练,支持文本特征提取和下游任务微调
大型语言模型 英语
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI发布的开放预训练Transformer语言模型套件,参数量从1.25亿到1750亿,旨在对标GPT-3系列性能,同时促进大规模语言模型的开放研究。
大型语言模型 英语
O
facebook
6.3M
198
1
基于transformers库的预训练模型,适用于多种NLP任务
大型语言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多语言大语言模型系列,包含8B、70B和405B参数规模,支持8种语言和代码生成,优化了多语言对话场景。
大型语言模型
Transformers 支持多种语言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基础版是由Google开发的文本到文本转换Transformer模型,参数规模2.2亿,支持多语言NLP任务。
大型语言模型 支持多种语言
T
google-t5
5.4M
702
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98