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
langchainbut 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2322005e06bf22535502468726a9da5524c78ff5ffabdf591156fe26cb48e4a
|
|
| MD5 |
de67a37f01a814e03513ae6a377075fd
|
|
| BLAKE2b-256 |
6543b9d6141b14b94e6e813018aa43da70b78e2317a38425ac286947293ccee0
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72a196d195a4919d7a114e031775ca93ffdfafb60fa0cdfebd1fa0f9471a5cc6
|
|
| MD5 |
e240d1f8969a4b7f5f37f572658617e3
|
|
| BLAKE2b-256 |
1ed4d61cd9498008cfe4b5458062501abeab132fbf4f7b291e171bfdb89a2859
|