A Python library for inference-time scaling LLMs
Project description
A Python library for inference-time scaling LLMs
Example: Using the particle filtering from [1] for inference-time scaling
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
# NOTE launched via `CUDA_VISIBLE_DEVICES=0 vllm serve Qwen/Qwen2.5-Math-1.5B-Instruct --dtype float16`
lm = OpenAICompatibleLanguageModel(
endpoint="http://0.0.0.0:8000/v1",
api_key="NO_API_KEY",
model_name="Qwen/Qwen2.5-Math-1.5B-Instruct",
system_prompt=SAL_STEP_BY_STEP_SYSTEM_PROMPT,
)
prompt = r"Let $a$ be a positive real number such that all the roots of \[x^3 + ax^2 + ax + 1 = 0\]are real. Find the smallest possible value of $a.$" # question from MATH500
budget = 8
sg = StepGeneration("\n\n", 32, r"\boxed")
prm = LocalVllmProcessRewardModel(
model_name="Qwen/Qwen2.5-Math-PRM-7B", device="cuda:1", aggregation_method="prod"
)
scaling_alg = ParticleFiltering(sg, prm)
scaling_alg.infer(lm, prompt, budget, show_progress=True) # => gives output
[1]: Isha Puri, Shivchander Sudalairaj, Guangxuan Xu, Kai Xu, Akash Srivastava. “A Probabilistic Inference Approach to Inference-Time Scaling of LLMs using Particle-Based Monte Carlo Methods”, 2025.
Installation
Latest release from PyPI
pip install its_hub
Latest main branch
pip install git+https://github.com/Red-Hat-AI-Innovation-Team/its_hub.git
Benchmark
There is a script at scripts/benchmark.py that can be used to benchmark inference-time scaling algorithms.
The CLI of the script is self-contained so the usage can be checked via python scripts/benchmark.py --help.
Example command:
python scripts/benchmark.py --benchmark aime-2024 --model_name Qwen/Qwen2.5-Math-1.5B-Instruct --alg particle-filtering --rm_device cuda:1 --endpoint http://0.0.0.0:8000/v1 --shuffle_seed 1110 --does_eval --budgets 1,2,4,8,16,32,64 --rm_agg_method model
Development
git clone https://github.com/Red-Hat-AI-Innovation-Team/its_hub.git
cd its_hub
pip install -e ".[dev]"
pytest tests
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.1.3a2.tar.gz.
File metadata
- Download URL: its_hub-0.1.3a2.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9906117be0ea0e84bd25b8bd735a46c07977344002198c78e2e718b813a72e9e
|
|
| MD5 |
e502bc580c3d12fb86238ccd0be896b3
|
|
| BLAKE2b-256 |
f2d5826d3cae56de245b1d9c23c5dd94704c07a184f460e1f89044f3437e7948
|
Provenance
The following attestation bundles were made for its_hub-0.1.3a2.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.1.3a2.tar.gz -
Subject digest:
9906117be0ea0e84bd25b8bd735a46c07977344002198c78e2e718b813a72e9e - Sigstore transparency entry: 214133380
- Sigstore integration time:
-
Permalink:
Red-Hat-AI-Innovation-Team/its_hub@f80b338ed1d1c2f861c44a638f09822d1bdd3584 -
Branch / Tag:
refs/tags/v0.1.3a2 - 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@f80b338ed1d1c2f861c44a638f09822d1bdd3584 -
Trigger Event:
release
-
Statement type:
File details
Details for the file its_hub-0.1.3a2-py3-none-any.whl.
File metadata
- Download URL: its_hub-0.1.3a2-py3-none-any.whl
- Upload date:
- Size: 18.6 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 |
d7088e181f0f70be6deaed1ee67232a79bb39886f47ed5a4ba1c3f82807ba932
|
|
| MD5 |
81fcd30622dbe29d4ef434a5b3969575
|
|
| BLAKE2b-256 |
9228a3368b6670774d87bde16e4c49d41f2c50cb819e699e054ba38488d645da
|
Provenance
The following attestation bundles were made for its_hub-0.1.3a2-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.1.3a2-py3-none-any.whl -
Subject digest:
d7088e181f0f70be6deaed1ee67232a79bb39886f47ed5a4ba1c3f82807ba932 - Sigstore transparency entry: 214133382
- Sigstore integration time:
-
Permalink:
Red-Hat-AI-Innovation-Team/its_hub@f80b338ed1d1c2f861c44a638f09822d1bdd3584 -
Branch / Tag:
refs/tags/v0.1.3a2 - 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@f80b338ed1d1c2f861c44a638f09822d1bdd3584 -
Trigger Event:
release
-
Statement type: