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