Skip to main content

A library for running local LLM classification tasks on data

Project description

onetokenpy

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

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.1.tar.gz (11.8 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.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: onetokenpy-0.1.1.tar.gz
  • Upload date:
  • Size: 11.8 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.1.tar.gz
Algorithm Hash digest
SHA256 aef66223bf2021f19183d1868223b7d1d6e4710145359e09f67ae44baccd8f78
MD5 47722e2519afde5ed5ac0afb8eace97e
BLAKE2b-256 41f61066fded894034c65740830345a3231cbc6215a5c7c227a9ce117fcbde8f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: onetokenpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fcf772e67daef858e5b058f8d7e113b990dbed225a51d517de46dd812fa536a1
MD5 87ecd2a15c3b40d13b094a7e9bcc7580
BLAKE2b-256 fab4e68ab6df02624475a993547c655aee2177fa18a4870e3003ada782d7b74a

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