Skip to main content

BilbyStats

A collection of statistical and machine learning functions for use in the Bilby pipeline

Install the package

Pip installation

The package installs a lightweight core by default, with heavier stacks available as optional extras.

pip install bilbystats

Install only the extras you need:

pip install "bilbystats[llm]"           # LLM API clients: OpenAI, Anthropic, Ollama, Groq, Gemini, tiktoken
pip install "bilbystats[transformers]"  # Transformer training/eval: torch, transformers, datasets, wandb, ... (heavy)
pip install "bilbystats[gcp]"           # Google Cloud / BigQuery
pip install "bilbystats[finance]"       # Finance / backtesting
pip install "bilbystats[scraping]"      # Scraping / HTML processing

Extras can be combined:

pip install "bilbystats[llm,gcp]"

Install every functional extra (llm + transformers + gcp + finance + scraping) with all:

pip install "bilbystats[all]"

Development-only tooling (spacy, geopandas, dspy, litellm, scikit-learn, selenium, ...) lives in the dev extra, which is not part of all:

pip install "bilbystats[dev]"

Quote the brackets ("bilbystats[llm]") so your shell doesn't try to glob them.

Alternative: local installation

To pull the repo run

git clone --depth=1 https://github.com/bilbyai/bilbystats/

Navigate to the root directory of the package and run

uv pip install .

or just

pip install .

if you don't have uv install. Extras work the same way for a local install, e.g. uv pip install ".[all]" or uv pip install -e ".[all]" for an editable install.

Set up API keys

API keys must be added in order to call LLMs. To do so they must be added to the environment. The simplest way to do so is to add lines of the following form to your .bashrc or .zshrc file.

export OPENROUTER_API_KEY=exampleapikey
export OPENAI_API_KEY=exampleapikey
export CLAUDE_API_KEY=exampleapikey

Where you should replace exampleapikey with the corresponding API key in each case.

Importing the package

Then the package can be imported from within python via e.g.

import bilbystats as bs

Setting local defaults

In order to set local defaults. E.g. for checkpoint saving etc. You'll need to navigate to

cp bilbystats/defaults/local_defaults_example.env bilbystats/defaults/local_defaults.env

and then change the default parameters and reinstall the package.

Run local LLMs using Ollama

If you'd like to use the Ollama functions which allow you to call LLMs on your local machine you'll need to install Ollama. Once you've installed ollama you can download LLMs such as llama3.2

ollama run llama3.2

or deepseek-r1:7b

ollama run deepseek-r1:7b

See https://ollama.com/search for a full list of the available models.

To call the LLM programmatically using bilbystats you can run

bs.llm_api('test call', 'you are an llm', 'llama3.2')

or

bs.llm_api('test call', 'you are an llm', 'deepseek-r1:7b')

Or in general use the model name in any llm related function such as bs.translate.

Metadata

Release files for bilbystats 0.2.23

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

Source distribution (sdist)

Source distribution for bilbystats 0.2.23
File Size Uploaded Provenance Actions
bilbystats-0.2.23.tar.gz 6.5 MB Without provenance Details for bilbystats-0.2.23.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bilbystats 0.2.23
File Interpreter ABI Platform Actions
bilbystats-0.2.23-py3-none-any.whl Python 3 none any Details for bilbystats-0.2.23-py3-none-any.whl

Total release size: 13.2 MB

Release files / bilbystats-0.2.23.tar.gz

Download URL bilbystats-0.2.23.tar.gz
Size 6.5 MB
Tags Source
SHA-256 checksum
How to use checksums
cb1952d1ca68e4d2c28ba473b0f1111e1253a9f81c3dc50058b562c0babc9a94
BLAKE2b-256 checksum
How to use checksums
cf7dd7b1e4b65c092d5453e6c7a37fe0707f4caf69a46f86337e0cb09f3449a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Release files / bilbystats-0.2.23-py3-none-any.whl

Download URL bilbystats-0.2.23-py3-none-any.whl
Size 6.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6b54faedb2a62bb152dbdf765be8450c185f51f62edf7eb10a64b01aa794c5b6
BLAKE2b-256 checksum
How to use checksums
9a7b134f47267cfd35cc6e7413e086e6f42736e99e9343a612b516cab0704b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.14

Security for bilbystats 0.2.23

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.23 This release

2 release files No provenance

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