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
-
Generate an SSH key and add the SSH key to your GitHub account.
-
Configure SSH to automatically load your SSH keys:
cat << EOF >> ~/.ssh/config Host * AddKeysToAgent yes IgnoreUnknown UseKeychain UseKeychain yes ForwardAgent yes EOF
-
Install VS Code and VS Code's Dev Containers extension. Alternatively, install PyCharm.
-
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:
-
⭐️ GitHub Codespaces: click on Open in GitHub Codespaces to start developing in your browser.
-
⭐️ 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.
-
⭐️ 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
-
VS Code Dev Container: clone this repository, open it with VS Code, and run Ctrl/⌘ + ⇧ + P → Dev Containers: Reopen in Container.
-
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
poefrom 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 topyproject.tomlanduv.lock. Add--devto install a development dependency. - Run
uv sync --upgradefrom within the development environment to upgrade all dependencies to the latest versions allowed bypyproject.toml. Add--only-devto upgrade the development dependencies only. - Run
cz bumpto bump the app's version, update theCHANGELOG.md, and create a git tag. Then push the changes and the git tag withgit push origin main --tags. - Run
poe mutmutto 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.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| problm_solver-1.6.0.tar.gz | 37.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| problm_solver-1.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 81.3 kB
Release files / problm_solver-1.6.0.tar.gz
| Download URL | problm_solver-1.6.0.tar.gz |
|---|---|
| Size | 37.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
984d74f486d2e092c919e70fdad1c43bd172dc4700a3b72dbab8dd74f7d76a32
|
|
BLAKE2b-256 checksum How to use checksums |
c1c20a4793a9134d9ca2c044b43b6b8b696e50446a08f33b7ed07244eec3c6ca
|
| 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 Sep 2, 2026.
Transparency logRelease files / problm_solver-1.6.0-py3-none-any.whl
| Download URL | problm_solver-1.6.0-py3-none-any.whl |
|---|---|
| Size | 43.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b3b86b2d39987c4dbb32167dfb7f4621f8d79373b8d0feb85f519bf7291b9100
|
|
BLAKE2b-256 checksum How to use checksums |
ae9bfd4c9d4cf8f55e73fb85b8808aa5b1e5f2c9e64444bcc460459a573a4091
|
| 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 Sep 2, 2026.
Transparency log