Skip to main content

A tiny module for combining LLM transformations with scikit-learn

Project description

README

sklearn-llm is a Python module for building data transformation pipelines combining the power of scikit-learn and Large Language Models (LLMs).

Installation

The easiest way to install is with pip:

pip install sklearn-llm

See pyproject.toml for the list of dependencies.

Pre-requisites

You will also need an API key from OpenAI to use its LLM models for your data transformations. Currently it's the only supported LLM provider.

Set the OPENAI_API_KEY variable in a .env file, following the same format as .env_example.

Quick guide

To define a transformation, you need the following:

  • An input class and an output class, both should be Pydantic base models.
  • The prompts (system and user prompt) for the transformation.

See sklearn_llm/example.py for an example.

Benefits

With sklearn-llm, you can do the following:

  • Define data transformations in sklearn's Transformer interface using LLM calls.
  • Use type hints to enhance understanding of the data transformation flows (instead of generic dataframes).
  • Compose flexible transformations using sklearn's Pipeline interface. This is similar to building chain of LLM calls in langchain but simpler if you only require this use case.

Example applications:

  • Create a pipeline to generate synthetic data and evaluate the quality of the data using two transformers.

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

sklearn_llm-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

sklearn_llm-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sklearn_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2322005e06bf22535502468726a9da5524c78ff5ffabdf591156fe26cb48e4a
MD5 de67a37f01a814e03513ae6a377075fd
BLAKE2b-256 6543b9d6141b14b94e6e813018aa43da70b78e2317a38425ac286947293ccee0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for sklearn_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72a196d195a4919d7a114e031775ca93ffdfafb60fa0cdfebd1fa0f9471a5cc6
MD5 e240d1f8969a4b7f5f37f572658617e3
BLAKE2b-256 1ed4d61cd9498008cfe4b5458062501abeab132fbf4f7b291e171bfdb89a2859

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