Enrich data sources with AI
AI enrichment uses LLMs to generate new semantic content from your existing data tables. You can pass text columns through an LLM to create descriptions, summaries, or cleaned metadata. You can also analyze images to extract text descriptions.
Prerequisites
- A data table with text or image columns to enrich
- Access to the Shaped API
Text enrichment
Text enrichment passes multiple columns from your source table through an LLM to generate new semantic content. Common use cases include creating product descriptions, cleaning up metadata, or generating summaries from structured data.
To create a text enrichment transform:
- Select the source columns to pass to the LLM
- Write a prompt that instructs the LLM how to process these columns
- Specify which source columns to include in the output table (
source_columns_in_output) - Name the output columns that will contain the LLM-generated content (
enriched_output_columns)
The enriched output is materialized as a persistent table in your Shaped database.
Example: Product descriptions
This example generates product summaries for clothing items using multiple metadata columns. The prompt:
You are a retail clothing marketing manager. Using the input columns, generate a product description that contains the product name and describes its unique characteristics, including its colour, appearance, pattern, category, and department. Avoid flowery and salesy language, keep your description factual and concise.
Send a POST request to https://api.shaped.ai/v2/views with the following payload:
{
"name": "hm_items_with_descriptions",
"transform_type": "AI_ENRICHMENT",
"source_dataset": "hm_articles",
"source_columns": [
"prod_name",
"index_name",
"detail_desc",
"section_name",
"department_name",
"index_group_name",
"colour_group_name",
"product_group_name",
"garment_group_name",
"product_type_name",
"graphical_appearance_name",
"perceived_colour_value_name",
"perceived_colour_master_name"
],
"source_columns_in_output": [
"item_id",
"prod_name",
"product_code"
],
"enriched_output_columns": [
"ai_description"
],
"prompt": "You are a retail clothing marketing manager. Using the input columns, generate a product description that contains the product name and describes its unique characteristics, including its colour, appearance, pattern, category, and department. Avoid flowery and salesy language, keep your description factual and concise."
}
Input and output example:
Given an input row with these values:
prod_name: "Regular Fit T-Shirt"colour_group_name: "Black"department_name: "Divided"product_type_name: "T-shirt"graphical_appearance_name: "Solid"garment_group_name: "T-shirt"
The LLM generates this description in the ai_description column:
Regular Fit T-Shirt. Black solid t-shirt from Divided department. Basic t-shirt style with regular fit.
Image enrichment
Image enrichment uses a multimodal LLM to analyze images and generate text descriptions. To enable image processing, include an image_url column in your source_columns.
If your image columns have different names, use an SQL transform to rename them to image_url.
When writing prompts for image enrichment, be specific about what information to extract. Images contain many visual elements, so clearly state which aspects matter for your use case. For example, you might focus on product attributes, scene composition, or text content.
Example: Product image descriptions
This example analyzes product images to extract visual attributes. The prompt:
Analyze the product image and describe the item's visual characteristics, including color, style, pattern, and any visible text or branding. Focus on factual details that would help customers understand what the product looks like.
Input and output example:
Given an input row with:
item_id: "12345"product_name: "Classic Denim Jacket"image_url: "https://example.com/images/jacket-12345.jpg"
The LLM analyzes the image and generates this description in the ai_description column:
Blue denim jacket with a classic fit. Features a button-front closure, two chest pockets, and long sleeves with button cuffs. Light wash finish with subtle fading. Brand logo visible on the left chest pocket.