Skip to main content

A Python library for inference-time scaling LLMs

Project description

A Python library for inference-time scaling LLMs

Tests codecov

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

its_hub-0.1.2a1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

its_hub-0.1.2a1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file its_hub-0.1.2a1.tar.gz.

File metadata

  • Download URL: its_hub-0.1.2a1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for its_hub-0.1.2a1.tar.gz
Algorithm Hash digest
SHA256 66d51be6ba5f9d0bce7df3dc097d450a36d37f41d352b19cabab8925f3eb465d
MD5 643c49b2da21ede489b715e407f3ff7d
BLAKE2b-256 8c6bbc3538e87dc4cf0d97e3f5dab4e830a798f5fc204fed6ae042dbc4b1c905

See more details on using hashes here.

Provenance

The following attestation bundles were made for its_hub-0.1.2a1.tar.gz:

Publisher: release.yaml on Red-Hat-AI-Innovation-Team/its_hub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file its_hub-0.1.2a1-py3-none-any.whl.

File metadata

  • Download URL: its_hub-0.1.2a1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for its_hub-0.1.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 d9c1e02edb0fc20098811f1ab61a74d8f36137204850769cf5b32374b56fcc53
MD5 eb6f11cdc98eef9184d7312b3d979499
BLAKE2b-256 3472ab3bc4c599f33703f80aad9b58fac922ca4b62dc0cac2913a32aca51a1fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for its_hub-0.1.2a1-py3-none-any.whl:

Publisher: release.yaml on Red-Hat-AI-Innovation-Team/its_hub

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page