Transform any LLM into a methodical thinker that excels at systematic reasoning like OpenAI o1 and DeepSeek R1
Project description
🤔 LLM-Reasoner
Transform any LLM into a methodical thinker that excels at systematic reasoning like OpenAI o1 and DeepSeek R1
- Step-by-step reasoning with detailed explanations
- Dynamic confidence scoring and self-reflection
- Multiple reasoning strategies and approaches
- Robust error handling and recovery
- Support for mathematical notation using LaTeX
- Comprehensive thought process visualization
- Integration with multiple LLM providers
✨ What Makes It Special?
LLM-Reasoner enhances any Language Model with advanced reasoning capabilities:
- Think out loud and show its work (no more mysterious answers!)
- Double-check its own thinking
- Consider different angles before making up its mind
- Tell you how confident it is at each step
- Actually explain why it believes what it believes
🚀 Getting Started
Install LLM-Reasoner with pip:
pip install llm-reasoner
Configure your API keys:
# Using OpenAI? Pop this in:
export OPENAI_API_KEY="your-key"
# Team Google? Here you go:
export VERTEX_PROJECT="your-project"
export VERTEX_LOCATION="your-location"
# Claude fan? Got you covered:
export ANTHROPIC_API_KEY="your-key"
🎮 Quick Play
Try these commands to get started:
# Check out what models you can use
llm-reasoner models
# Ask it something cool
llm-reasoner reason "Why do planes stay up in the air?"
# Want a nice UI to play with?
llm-reasoner ui
🔧 Custom Models
You can register custom models with LLM-Reasoner in three ways:
1. Using the Web UI (Easiest):
- Launch the UI with
llm-reasoner ui - Click on "Register Custom Model" in the top section
- Fill in your model details:
- Model Name (e.g., "my-azure-gpt4")
- Provider (e.g., "azure")
- Context Window Size (optional)
- Click "Register Model" to add it to your available models
- Your new model will appear in the model selection dropdown
2. Using the CLI:
# Register a new model
llm-reasoner register-model my-custom-model azure --context-window 16384
# Set it as default
llm-reasoner set-model my-custom-model
# View all registered models
llm-reasoner models
3. Using Python:
from reasonchain import model_registry
# Register a custom model
model_registry.register_model(
name="my-custom-model",
provider="custom-provider",
context_window=4096 # Optional
)
# Use your custom model
chain = ReasonChain(model="my-custom-model")
This allows you to use any LLM provider supported by LiteLLM. See LiteLLM's documentation for the full list of supported providers.
🎨 Interactive UI
Launch the visual interface with:
llm-reasoner ui
The UI provides:
- Model selection and registration via an easy-to-use form
- Parameter adjustment with intuitive sliders
- Real-time reasoning visualization
- Interactive exploration
- Custom model registration interface
🛠️ Using It In Your Code
Here's the simplest way to use LLM-Reasoner:
from reasonchain import ReasonChain
import asyncio
async def main():
chain = ReasonChain()
async for step in chain.generate("How does evolution work?"):
print(f"🤔 Step {step.number}: {step.title}")
print(step.content)
asyncio.run(main())
Want more control? Here's an advanced example:
chain = ReasonChain(
model="gpt-4", # Pick your favorite model
max_tokens=1000, # Let it think deeper
temperature=0.3, # Control creativity
prompt_template="Let's explore: {prompt}" # Make it your own
)
# Get all the details about its thinking process
async for step in chain.generate_with_metadata("How do computers learn?"):
print(f"💭 Step {step.number}: {step.title}")
print(f"🎯 Confidence: {step.confidence}")
print(f"⏱️ Thinking time: {step.thinking_time}s")
print(step.content)
🌟 Features in Detail
Each reasoning step includes:
- Step number (keeping things organized)
- Clear title (what it's pondering)
- Detailed thoughts (the good stuff)
- Confidence score (how sure it is)
- Thinking time (we track speed too!)
- Timestamp (when each thought happened)
- Next action (what it's planning)
Development
To contribute to LLM-Reasoner:
- Clone the repository
- Install development dependencies:
pip install -e ".[dev]" - Run tests:
pytest
🤝 Contributing
Found a bug or have ideas? We'd love to hear from you:
- Open an issue on GitHub
- Email us at harishsg99@gmail.com
- Check out our examples
📜 License
MIT License - See LICENSE file for details.
Made with ❤️ for those who believe AI should show its work! ✍️
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_reasoner-0.1.3-py3-none-any.whl.
File metadata
- Download URL: llm_reasoner-0.1.3-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27fd638181c572ef6ed25b9cbc4210c735c3ad8370043f73f10833ef6438adf2
|
|
| MD5 |
be9ce1ff4705d011bd6921a46921b50d
|
|
| BLAKE2b-256 |
f2bbf694281529bdda0b1fe37970c1f90226eb5894db521fcf6ff0692dee0130
|