LLM-Reasoner:讓任何大模型都能像DeepSeek R1一樣深入思考
LLM-Reasoner 是一個(gè)庫,它讓任何 LLM(大模型)都能像 OpenAI o1 和 DeepSeek R1 一樣深入思考。
? 主要特點(diǎn)
?? 循序漸進(jìn)的推理:不再有黑箱答案!準(zhǔn)確了解 LLM 是如何思考的,類似于 O1 的系統(tǒng)方法
?? 實(shí)時(shí)進(jìn)度:通過流暢的動(dòng)畫觀看推理的展開
?? 多提供商支持:與 LiteLLM 支持的所有提供商兼容
?? 精美的 UI:一個(gè)漂亮的 Streamlit 界面可供使用
??? 高級(jí)用戶 CLI:無縫嵌入你的代碼
?? 信心跟蹤:了解 LLM 對(duì)每個(gè)步驟的確定程度
?? 快速開始
首先安裝:
pip install llm-reasoner
設(shè)置 OpenAI key:
export OPENAI_API_KEY="sk-your-key"
對(duì)于國內(nèi)用戶可以選擇提供了與 OpenAI 接口兼容的模型或者是使用 llama_cpp_python 啟動(dòng)一個(gè)本地的 LLM 服務(wù),這個(gè)服務(wù)接口與 OpenAI 接口兼容。
以下是一些簡(jiǎn)單的用法:
# 列當(dāng)前所有可用模型
llm-reasoner models
# 生成一個(gè)推理鏈
llm-reasoner reason "How do planes fly?" --min-steps 5
#啟動(dòng) UI 界面
llm-reasoner ui
或者直接在你的代碼中使用:
from llm_reasoner import ReasonChain
import asyncio
async def main():
# Create a chain with your preferred settings
chain = ReasonChain(
model="gpt-4", # Choose your model
min_steps=3, # Minimum reasoning steps
temperature=0.2, # Control creativity
timeout=30.0 # Set your timeout
)
# Watch it think step by step!
async for step in chain.generate_with_metadata("Why is the sky blue?"):
print(f"\nStep {step.number}: {step.title}")
print(f"Thinking Time: {step.thinking_time:.2f}s")
print(f"Confidence: {step.confidence:.2f}")
print(step.content)
asyncio.run(main())
??https://github.com/harishsg993010/LLM-Reasoner??
本文轉(zhuǎn)載自??PyTorch研習(xí)社??,作者:南七無名式
贊
收藏
回復(fù)
分享
微博
QQ
微信
舉報(bào)

回復(fù)
相關(guān)推薦