Skip to main content

data-designer-cache-llm-column

A plugin for data-designer that adds cache-enabled LLM column generators.

Why use it?

When building datasets with data-designer using Large Language Models (LLMs), generation can be slow and expensive. When iterating on your data pipelines or prompts, you often end up running the exact same model calls multiple times.

This plugin automatically caches your LLM responses locally so that subsequent runs with identical inputs (prompt, variables, model) are instantaneous. This significantly speeds up dataset generation during development and reduces your overall LLM API costs.

Features

  • Drop-in replacements: Wraps the existing data-designer LLM columns (Text, Structured, Code, Judge) with caching capabilities.
  • Cost and Time Savings: Avoids redundant LLM API calls by saving responses locally.
  • Flexible Cache Control: Independently control whether to load from cache or save to cache for each column.

Installation

Install using pip:

pip install data-designer-cache-llm-column

Or using uv (recommended):

uv pip install data-designer-cache-llm-column

Available Column Types

This plugin exposes four new cache-enabled column configurations:

  • CacheLLMTextColumnConfig (Type: "cache-llm-text")
  • CacheLLMStructuredColumnConfig (Type: "cache-llm-structured")
  • CacheLLMCodeColumnConfig (Type: "cache-llm-code")
  • CacheLLMJudgeColumnConfig (Type: "cache-llm-judge")

Configuration Options

All cached columns inherit from their respective base data-designer column configs, meaning you can still use parameters like name, model_alias, prompt, etc. In addition, you get these caching-specific options:

  • cache_folder (str): The folder path where cache files will be stored. Default is "cache_folder".
  • save_cache (bool): Whether to save new LLM responses to the cache. Default is True.
  • load_cache (bool): Whether to attempt loading from the cache before calling the LLM API. Default is True. By setting this to False and save_cache to True, you can force the model to re-generate and overwrite the cache.

Example Usage

Caching LLM Text Output

import data_designer.config as dd
import pandas as pd
from data_designer.config.seed_source_dataframe import DataFrameSeedSource
from data_designer.interface import DataDesigner

from data_designer_cache_llm_column.cache_llm_text_column.config import CacheLLMTextColumnConfig

# Create seed dataset
seed_df = pd.DataFrame({"language": ["English", "Spanish", "French"]})

config_builder = dd.DataDesignerConfigBuilder()
config_builder.with_seed_dataset(DataFrameSeedSource(df=seed_df))

# Add a cached LLM text column
config_builder.add_column(
    CacheLLMTextColumnConfig(
        name="greeting",
        model_alias="nvidia-text", # Or whatever model alias you have configured
        prompt="Write a casual {{ language }} greeting. One sentence only.",
        cache_folder="./llm_cache_storage",
        save_cache=True,
        load_cache=True, # Hits the API on 1st run, loads from cache on subsequent runs
    )
)

data_designer = DataDesigner()

# First run: Hits the Model API and saves to cache
print("Run 1: Generating...")
results1 = data_designer.preview(config_builder, num_records=3)
print(results1.dataset)

# Second run: Instantly loads from cache
print("Run 2: Loading from cache...")
results2 = data_designer.preview(config_builder, num_records=3)
print(results2.dataset)

Caching Structured Output

import data_designer.config as dd
import pandas as pd
from data_designer.config.seed_source_dataframe import DataFrameSeedSource
from data_designer.interface import DataDesigner
from pydantic import BaseModel

from data_designer_cache_llm_column.cache_llm_structured_column.config import CacheLLMStructuredColumnConfig

# Define your expected output structure
class GreetingInfo(BaseModel):
    greeting: str
    formality: str

seed_df = pd.DataFrame({"language": ["English", "Spanish", "French"]})

config_builder = dd.DataDesignerConfigBuilder()
config_builder.with_seed_dataset(DataFrameSeedSource(df=seed_df))

# Add a cached LLM structured column
config_builder.add_column(
    CacheLLMStructuredColumnConfig(
        name="greeting_info",
        model_alias="nvidia-text",
        prompt="Generate a greeting in {{ language }} and classify its formality level.",
        output_format=GreetingInfo,
        cache_folder="./llm_cache_storage_structured",
        save_cache=True,
        load_cache=True,
    )
)

data_designer = DataDesigner()
results = data_designer.preview(config_builder, num_records=3)
print(results.dataset)

Metadata

Release files for data-designer-cache-llm-column 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for data-designer-cache-llm-column 0.1.3
File Size Uploaded Provenance Actions
data_designer_cache_llm_column-0.1.3.tar.gz 6.2 kB Without provenance Details for data_designer_cache_llm_column-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for data-designer-cache-llm-column 0.1.3
File Interpreter ABI Platform Actions
data_designer_cache_llm_column-0.1.3-py3-none-any.whl Python 3 none any Details for data_designer_cache_llm_column-0.1.3-py3-none-any.whl

Total release size: 21.1 kB

Release files / data_designer_cache_llm_column-0.1.3.tar.gz

Download URL data_designer_cache_llm_column-0.1.3.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1f12c8b80ba33e5cc585956bb2700efd8b546b4056c1ec36b8593b2d1a97781c
BLAKE2b-256 checksum
How to use checksums
be1462e3417157565af5fbbbe0b5110f3de6ce363195925faa9ecb262ae1fd60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release files / data_designer_cache_llm_column-0.1.3-py3-none-any.whl

Download URL data_designer_cache_llm_column-0.1.3-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90be9998d9a8b711ad722db64913f1ba48e39f904e500d0c8e1aa6f824457f31
BLAKE2b-256 checksum
How to use checksums
5f486ec324c5a39150e68035ba44036f2ff43f8f897da6f5d57ba089d978b681
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Security for data-designer-cache-llm-column 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page