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.1.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.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sklearn_llm-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b41a52563f7eaca43a81a8dcfeeab3c772ea7da86ea6b4656bbfcc324131aa1a
MD5 bde7bbaff18dc1bc2bc7eae72d2f286b
BLAKE2b-256 fbf2e03bedb32ec6ca96a34ca51f776d960d3c26266435403ac51fc6423f2906

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sklearn_llm-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea43d7c60bfe4b5ac1f2354119f4f3cf86c2e05dc71cb1e1e425aeb8b85450c9
MD5 28987ffeb0bdfbfff6282d117ad2fca2
BLAKE2b-256 77e5203a79402a9ecfc6ff88df24082e8a007ee3067f361d2548adda9524c312

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