Skip to main content

Open in Dev Containers Open in GitHub Codespaces Documentation

probLM-solver

A Python library enabling researchers to prototype and develop sampling methods in large language models (LLMs) based on internal probabilities. Included are utilities for writing complex sampling functions in Python and running local models (with llama.cpp as a backend) that use them.

This library ensures researchers can sample token-by-token, analyse logits, and assess the probability of given outputs.

An R wrapper around this library is available as problmsolver.

This library is currently in active development, and looking for feature requests. Breaking changes will be kept to a minimum, and loudly declared in the changelog where they are unavoidable.

Usage

Bare Metal

To install this package as a library, please run:

pip install problm-solver

to install the latest release in your desired virtual environment.

For the latest main branch, please clone the repository and install via,

python3 -m pip install /path/to/probLM-solver

If you need the project's working environment as a starting point, see the instructions below:

This project is managed with uv, ensure you have Python, pip, and uv installed. To create and activate the virtual environment, run:

uv sync --python 3.13 --no-dev
source .venv/bin/activate

Conda

An environment.yml is provided for conda users (Miniforge, Miniconda, or Anaconda). To create and activate the environment, run:

conda env create -f environment.yml
conda activate problm-solver

If you have an NVIDIA GPU and want hardware-accelerated inference, reinstall llama-cpp-python with CUDA support after activating the environment:

CMAKE_ARGS="-DGGML_CUDA=on" pip install "llama-cpp-python>=0.3.23" --force-reinstall

On the HEC, and other HPC systems which use Nvidia L40(S) and H200 GPUs, oftentimes the login node won't have native GPUs, so use the command:

CMAKE_ARGS="-DGGML_CUDA=on -DGGML_NATIVE=off -DCMAKE_CUDA_ARCHITECTURES=89;90" pip install --force-reinstall --no-cache-dir "llama-cpp-python>=0.3.23"

For complete and custom installation of llama-cpp-python, see llama.cpp build docs.

Docker

The CLI itself can be run in a docker container for testing the program.

To serve this app, run:

docker compose --profile app run --build app

Within the Dev Container this is equivalent to:

poe serve

Contributing

Prerequisites
  1. Generate an SSH key and add the SSH key to your GitHub account.

  2. Configure SSH to automatically load your SSH keys:

    cat << EOF >> ~/.ssh/config
    
    Host *
      AddKeysToAgent yes
      IgnoreUnknown UseKeychain
      UseKeychain yes
      ForwardAgent yes
    EOF
    
  3. Install Docker Desktop.

  4. Install VS Code and VS Code's Dev Containers extension. Alternatively, install PyCharm.

  5. Optional: install a Nerd Font such as FiraCode Nerd Font and configure VS Code or PyCharm to use it.

Development environments

The following development environments are supported:

  1. ⭐️ GitHub Codespaces: click on Open in GitHub Codespaces to start developing in your browser.

  2. ⭐️ VS Code Dev Container (with container volume): click on Open in Dev Containers to clone this repository in a container volume and create a Dev Container with VS Code.

  3. ⭐️ uv: clone this repository and run the following from root of the repository:

    # Create and install a virtual environment
    uv sync --python 3.13 --all-extras
    
    # Activate the virtual environment
    source .venv/bin/activate
    
    # Install the pre-commit hooks
    pre-commit install --install-hooks
    
  4. VS Code Dev Container: clone this repository, open it with VS Code, and run Ctrl/⌘ + ⇧ + P → Dev Containers: Reopen in Container.

  5. PyCharm Dev Container: clone this repository, open it with PyCharm, create a Dev Container with Mount Sources, and configure an existing Python interpreter at /opt/venv/bin/python.

Developing
  • This project follows the Conventional Commits standard to automate Semantic Versioning and Keep A Changelog with Commitizen.
  • Run poe from within the development environment to print a list of Poe the Poet tasks available to run on this project.
  • Run uv add {package} from within the development environment to install a run time dependency and add it to pyproject.toml and uv.lock. Add --dev to install a development dependency.
  • Run uv sync --upgrade from within the development environment to upgrade all dependencies to the latest versions allowed by pyproject.toml. Add --only-dev to upgrade the development dependencies only.
  • Run cz bump to bump the app's version, update the CHANGELOG.md, and create a git tag. Then push the changes and the git tag with git push origin main --tags.
  • Run poe mutmut to analyze test coverage via mutation.
  • The library can be installed in editable mode using python -m pip install -e ..

Metadata

Release files for problm-solver 1.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for problm-solver 1.7.1
File Size Uploaded
problm_solver-1.7.1.tar.gz 40.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for problm-solver 1.7.1
File Interpreter ABI Platform
problm_solver-1.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 86.6 kB

Release files / problm_solver-1.7.1.tar.gz

Download URL problm_solver-1.7.1.tar.gz
Size 40.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ce8ad556e3090a99564e4dacef3971895367f150382e3467b21fa97cd789859b
BLAKE2b-256 checksum
How to use checksums
893addec31890d3a665e0401a1961d07d831f59f3a8f40516dbf1d895f35c645
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / problm_solver-1.7.1-py3-none-any.whl

Download URL problm_solver-1.7.1-py3-none-any.whl
Size 46.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14fd5f714703422da8bfb8ce14dadbf8d9de826246870a2b684899c1b3e7db79
BLAKE2b-256 checksum
How to use checksums
9da86c4183c40b0c0b5c2c8ec520e8003b54f024cff8c5a7a770ba79cf09e413
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.7.1 This release

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page