A Python library for inference-time scaling LLMs
Project description
its-hub: A Python library for inference-time scaling
its_hub is a Python library for inference-time scaling of LLMs, focusing on mathematical reasoning tasks.
📚 Documentation
For comprehensive documentation, including installation guides, tutorials, and API reference, visit:
https://ai-innovation.team/its_hub
Installation
Choose the installation option based on which algorithms you need:
# Core installation - includes:
# - Best-of-N with LLM Judge
# - Self-Consistency
# - OpenAI-compatible language models
pip install its_hub
# Process Reward Model installation - adds:
# - Particle Filtering Algorithms
# - Beam Search
# - LocalVllmProcessRewardModel
# - Required for step-by-step reasoning with process reward models
pip install its_hub[prm]
# Development installation
git clone https://github.com/Red-Hat-AI-Innovation-Team/its_hub.git
cd its_hub
pip install -e ".[dev]"
Quick Start
Example 1: Best-of-N with LLM Judge
Installation required: pip install its_hub (core)
Use Best-of-N algorithm with an LLM judge for response selection - works with any OpenAI-compatible API:
from its_hub.lms import OpenAICompatibleLanguageModel
from its_hub.algorithms import BestOfN
from its_hub.integration.reward_hub import LLMJudgeRewardModel
# Initialize language model
lm = OpenAICompatibleLanguageModel(
endpoint="https://api.openai.com/v1",
api_key="your-api-key",
model_name="gpt-4o-mini",
)
# Set up LLM judge for scoring
judge = LLMJudgeRewardModel(
model="gpt-4o-mini",
criterion="overall_quality",
judge_type="groupwise",
api_key="your-api-key",
)
scaling_alg = BestOfN(judge)
# Generate multiple responses and select the best
result = scaling_alg.infer(lm, "Explain quantum entanglement in simple terms", budget=4)
print(result)
Example 2: Particle Filtering with Process Reward Model
Installation required: pip install its_hub[prm]
Use Particle Filtering for step-by-step reasoning with process reward models:
from its_hub.utils import SAL_STEP_BY_STEP_SYSTEM_PROMPT
from its_hub.lms import OpenAICompatibleLanguageModel, StepGeneration
from its_hub.algorithms import ParticleFiltering
from its_hub.integration.reward_hub import LocalVllmProcessRewardModel
# Initialize language model (requires vLLM server running)
lm = OpenAICompatibleLanguageModel(
endpoint="http://localhost:8100/v1",
api_key="NO_API_KEY",
model_name="Qwen/Qwen2.5-Math-1.5B-Instruct",
system_prompt=SAL_STEP_BY_STEP_SYSTEM_PROMPT,
)
# Set up step generation and process reward model
sg = StepGeneration(step_token="\n\n", max_steps=32, stop_token=r"\boxed")
prm = LocalVllmProcessRewardModel(
model_name="Qwen/Qwen2.5-Math-PRM-7B",
device="cuda:0",
aggregation_method="prod"
)
scaling_alg = ParticleFiltering(sg, prm)
# Solve with step-by-step reasoning
result = scaling_alg.infer(lm, "Solve x^2 + 5x + 6 = 0", budget=8)
print(result)
Key Features
- 🔬 Multiple Algorithms: Particle Filtering, Best-of-N, Beam Search, Self-Consistency
- 🚀 OpenAI-Compatible API: Easy integration with existing applications
- 🧮 Math-Optimized: Built for mathematical reasoning with specialized prompts
- 📊 Benchmarking Tools: Compare algorithms on MATH500 and AIME-2024 datasets
- ⚡ Async Support: Concurrent generation with limits and error handling
For detailed documentation, visit: https://ai-innovation.team/its_hub
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 its_hub-0.3.5.tar.gz.
File metadata
- Download URL: its_hub-0.3.5.tar.gz
- Upload date:
- Size: 114.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1a68ee79c2ff2c261605e1869272c6d00a0df3b8bd87c97c017fc44d5f38419
|
|
| MD5 |
bd8c320c309c2a5eba49f480b2c01fcf
|
|
| BLAKE2b-256 |
2750af741f1fa30cbf2e70f66470984491be7235d179a6e66f38d57c425e3137
|
Provenance
The following attestation bundles were made for its_hub-0.3.5.tar.gz:
Publisher:
release.yaml on Red-Hat-AI-Innovation-Team/its_hub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
its_hub-0.3.5.tar.gz -
Subject digest:
c1a68ee79c2ff2c261605e1869272c6d00a0df3b8bd87c97c017fc44d5f38419 - Sigstore transparency entry: 728276121
- Sigstore integration time:
-
Permalink:
Red-Hat-AI-Innovation-Team/its_hub@6e9df100b0a53b43513c759013f06ef668498265 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/Red-Hat-AI-Innovation-Team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6e9df100b0a53b43513c759013f06ef668498265 -
Trigger Event:
release
-
Statement type:
File details
Details for the file its_hub-0.3.5-py3-none-any.whl.
File metadata
- Download URL: its_hub-0.3.5-py3-none-any.whl
- Upload date:
- Size: 46.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
663e5b400ea6893d7568dab1113717752fba026c96ccda15709e1093b20380dd
|
|
| MD5 |
fdb9470190a3889c145f035545ff1c29
|
|
| BLAKE2b-256 |
f9b4b8a0ac132271271b430f4b67e9f4f574a53da1752315dee4b59ac23ce9f4
|
Provenance
The following attestation bundles were made for its_hub-0.3.5-py3-none-any.whl:
Publisher:
release.yaml on Red-Hat-AI-Innovation-Team/its_hub
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
its_hub-0.3.5-py3-none-any.whl -
Subject digest:
663e5b400ea6893d7568dab1113717752fba026c96ccda15709e1093b20380dd - Sigstore transparency entry: 728276140
- Sigstore integration time:
-
Permalink:
Red-Hat-AI-Innovation-Team/its_hub@6e9df100b0a53b43513c759013f06ef668498265 -
Branch / Tag:
refs/tags/v0.3.5 - Owner: https://github.com/Red-Hat-AI-Innovation-Team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@6e9df100b0a53b43513c759013f06ef668498265 -
Trigger Event:
release
-
Statement type: