Socraticlm
模型概述
該模型專為教育目的設計,能夠在學生解決數學問題時提供蘇格拉底式引導,也能獨立解決數學問題。支持英文和中文。
模型特點
蘇格拉底式教學
通過啟發式問題引導學生自主思考,培養解決問題的能力
數學問題求解
能夠逐步分析並解決複雜的數學問題
雙語支持
同時支持英文和中文的交互
模型能力
文本生成
數學推理
教育引導
多輪對話
使用案例
教育
數學問題引導
在學生遇到數學難題時,通過提問引導其思考解題路徑
幫助學生理解解題思路而非直接給出答案
獨立解題
直接解決各類數學問題
提供詳細的解題步驟和最終答案
🚀 SocraticLM模型
SocraticLM是一個基於Qwen2.5-Math-7B-Instruct微調的模型,專為教育場景設計。它能以蘇格拉底式引導幫助學生解決數學問題,也可直接解答數學問題,支持中英文。
🚀 快速開始
模型簡介
本模型是在Qwen2.5-Math-7B-Instruct基礎上,使用SocraTeach數據集進行微調得到的,是SocraticLM的具體實現。
預期用途與限制
SocraticLM主要用於教育場景,當學生在學習解決數學問題遇到困難時,它能提供蘇格拉底式的引導。同時,該模型也可以直接解決數學問題。此模型主要支持英文和中文。
安裝指南
此部分文檔未提及具體安裝步驟,因此跳過該章節。
💻 使用示例
基礎用法
使用Huggingface transformers庫
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("CogBase-USTC/SocraticLM")
model = AutoModelForCausalLM.from_pretrained(
"CogBase-USTC/SocraticLM",
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True
)
### 數學問題求解 ###
messages = [
{"role": "system", "content" : "Please analyse and solve the following problem step by step."},
{"role": "user", "content": "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?"},
]
### 蘇格拉底式引導 ###
# messages = [
# {"role": "system", "content" : "You are a Socratic teacher, please guide me to solve the [Problem] with heuristic questions based on the following information. \n"},
# {"role": "user", "content": "[Problem] Debelyn, Christel, and Andrena collect dolls. Debelyn had 20 dolls before she gave Andrena 2 dolls. Christel had 24 dolls before giving Andrena 5 dolls. After all the gifts, Andrena now has 2 more dolls than Christel, how many more dolls does andrena have now than Debelyn? [Answer] 3 [Analysis] Debelyn had 20 - 2 = 18 dolls left after giving out 2 dolls to Christel. Christel had 24 + 2 = 26 dolls after receiving 2 dolls from Debelyn. Christel had 24 - 5 = 19 dolls after giving Andrena 5 dolls. So, Andrena has 19 +2 = 21 dolls now. Therefore, Andrena has 21 - 18 = 3 more dolls than Debelyn."},
# ]
prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer.encode(prompt, return_tensors="pt")
outputs = model.generate(input_ids=inputs.to(model.device), max_new_tokens=4096)
print(tokenizer.decode(outputs[0]))
使用vLLM庫
from vllm import LLM, SamplingParams
llm = LLM(model=r'CogBase-USTC/SocraticLM',
tokenizer=r'CogBase-USTC/SocraticLM',
trust_remote_code=True,
tensor_parallel_size=1,
gpu_memory_utilization=0.99,
enable_chunked_prefill=True,
max_num_batched_tokens=512,
max_num_seqs=128)
sampling_params = SamplingParams(temperature=0, max_tokens=4096, seed=42)
def print_outputs(outputs):
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"Generated text: {generated_text!r}")
print("-" * 80)
print("=" * 80)
### 數學問題求解 ###
conversation = [
{
"role": "system",
"content": "Please analyse and solve the following problem step by step."
},
{
"role": "user",
"content": "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?"
},
]
### 蘇格拉底式引導 ###
# conversation = [
# {
# "role": "system",
# "content": "You are a Socratic teacher, please guide me to solve the [Problem] with heuristic questions based on the following information. \n"
# },
# {
# "role": "user",
# "content": "[Problem] Debelyn, Christel, and Andrena collect dolls. Debelyn had 20 dolls before she gave Andrena 2 dolls. Christel had 24 dolls before giving Andrena 5 dolls. After all the gifts, Andrena now has 2 more dolls than Christel, how many more dolls does andrena have now than Debelyn? [Answer] 3 [Analysis] Debelyn had 20 - 2 = 18 dolls left after giving out 2 dolls to Christel. Christel had 24 + 2 = 26 dolls after receiving 2 dolls from Debelyn. Christel had 24 - 5 = 19 dolls after giving Andrena 5 dolls. So, Andrena has 19 +2 = 21 dolls now. Therefore, Andrena has 21 - 18 = 3 more dolls than Debelyn."
# },
# ]
outputs = llm.chat(conversation,
sampling_params=sampling_params,
use_tqdm=False,
)
print_outputs(outputs)
詳細文檔
訓練超參數
訓練過程中使用的超參數如下:
- 學習率(learning_rate):1e-05
- 訓練批次大小(train_batch_size):8
- 隨機種子(seed):42
- 分佈式類型(distributed_type):多GPU
- 設備數量(num_devices):4
- 總訓練批次大小(total_train_batch_size):32
- 總評估批次大小(total_eval_batch_size):32
- 優化器(optimizer):使用OptimizerNames.ADAMW_TORCH,其中beta1=0.9,beta2=0.999,epsilon=1e-08,無額外優化器參數
- 學習率調度器類型(lr_scheduler_type):餘弦
- 學習率調度器熱身步數(lr_scheduler_warmup_steps):20
框架版本
- Transformers:4.46.2
- Pytorch:2.5.1+cu124
- Datasets:3.1.0
- Tokenizers:0.20.3
📄 許可證
許可證類型:其他(other)
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