Skip to main content

A library for running local LLM classification tasks on data

Project description

onetokenpy

A Python library for running local LLM classification tasks on data. Supports both GPU (using vLLM) and CPU (using llama.cpp) inference.

Installation

Basic Installation (CPU only)

Installs the package with CPU support using llama-cpp-python.

pip install onetokenpy

GPU Support

If you have a CUDA-compatible GPU and want to use vLLM for faster inference:

pip install "onetokenpy[gpu]"

Usage

import onetokenpy as ot
import pandas as pd

# Create a sample dataframe
df = pd.DataFrame({
    'postal_codes': ['H2X 1Y1', '12345', 'ABC123', 'K1A 0B1']
})

# Classify the postal codes using the default CPU model
# (google/gemma-3-1b-it-qat-q4_0-gguf)
result = ot.classify(
    df,
    "Classify this {postal_codes} as whether it is a correctly formatted Canadian postal code. Answer only by Yes or No"
)

print(result)

Features

  • Run local LLM classification tasks on pandas DataFrames or lists of strings.
  • Automatic backend selection (GPU if available and [gpu] extra installed, otherwise CPU).
  • Uses vLLM for GPU inference (requires pip install "onetokenpy[gpu]").
  • Uses llama.cpp via llama-cpp-python for CPU inference.
  • Downloads required models (GGUF for llama.cpp, standard HF format for vLLM) automatically via huggingface_hub.
  • Returns results as a pandas DataFrame including original data, classifications, and generated prompts.

Requirements

  • Python 3.8+
  • pandas
  • llama-cpp-python (for CPU support, installed by default)
  • huggingface-hub (for model downloading, installed by default)
  • For GPU support:
    • CUDA-compatible GPU
    • vllm (install via pip install "onetokenpy[gpu]")

License

MIT License

Author

Maxime Rivest (mrive052@gmail.com)

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

onetokenpy-0.1.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

onetokenpy-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file onetokenpy-0.1.0.tar.gz.

File metadata

  • Download URL: onetokenpy-0.1.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for onetokenpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e2c8a6e295503c7e8335cacd20f0e90e1e7f7cd217923b69867b13cf4fb2865
MD5 8d8b3c7b3f665af3e7a5f8a1dfa913a9
BLAKE2b-256 035673d2cab33dae3382d604da45a385928e3ac14664e7fb00de9d3c62c45df2

See more details on using hashes here.

File details

Details for the file onetokenpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: onetokenpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for onetokenpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e85b88693130c83703dc22e9db49751b98c6d68cc3b3757079d274d746f3fdac
MD5 479492a77f86aaecdc53680cca03edca
BLAKE2b-256 af65c5d4454610873a280f05986203b944fc38421bce58c36c8cba570846fe3d

See more details on using hashes here.

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