Scaling Product Categorization with Batch Inference and Prompt Engineering

godaddy · E-commerce · 2025 · source Agentic: no · promotional bias: high · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: ecommerce product category generation

GoDaddy needed to categorize millions of products from product names with higher coverage and lower cost than an existing per-product Llama 2 approach that produced incomplete or mislabeled categories.

Constraints:

Architecture

GoDaddy and AWS built a Bedrock batch-inference pipeline. Product JSONL files uploaded to S3 trigger Lambda; Bedrock batch processing reads prompts, generates categorized outputs, writes JSONL output to S3; a second Lambda monitors the job and shuts down the endpoint; LangChain PydanticOutputParser and OutputFixingParser turn model JSON into CSV. N-packing shares prompt instructions across multiple SKUs, and model/prompt comparisons selected Claude-Instant zero-shot for latency, cost, and coverage.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  A["S3 input bucket"] --> B["Start Lambda"]
  B --> C["Bedrock batch job"]
  D["Claude and Llama models"] --> C
  C --> E["S3 output bucket"]
  C --> F["Monitor Lambda"]
  E --> G["Parsing layer"]
  G --> H["Evaluation framework"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
S3 input bucket Stores JSONL product input files. Start Lambda
Start Lambda Triggered by S3 upload and starts a Bedrock batch processing job. S3 input bucket, Bedrock batch job
Bedrock batch job Runs model invocations over JSONL rows and writes categorized output. Start Lambda, S3 output bucket, Claude and Llama models
Claude and Llama models Candidate Bedrock models evaluated for category generation and parsing. Bedrock batch job
S3 output bucket Stores generated JSONL output and batch job result files. Bedrock batch job, Parsing layer
Monitor Lambda Monitors Bedrock job status and shuts down endpoint resources when complete. Bedrock batch job
Parsing layer Uses PydanticOutputParser and OutputFixingParser to produce structured CSV categories. S3 output bucket, Evaluation framework
Evaluation framework Measures coverage, parsing metrics, and human quality review. Parsing layer

Data flow

A JSONL product file lands in S3, Lambda starts a Bedrock batch job, Bedrock reads product names and prompts, writes categorized JSONL output back to S3, a second Lambda monitors/cleans up the job, and the output file is parsed with PydanticOutputParser and OutputFixingParser into structured category data.

3 supporting quotes
“A JSONL file containing product data is uploaded to an S3 bucket, triggering the first Lambda function.”article, stated
“Amazon Bedrock batch processes this single JSONL file, where each row contains input parameters and prompts.”article, stated
“We then process the jsonl.out file in Amazon S3. This file is parsed using LangChain’s PydanticOutputParser”article, stated

Why this architecture

Batch inference and n-packing reduce cost/latency by sharing prompt instructions across SKUs and avoiding per-product calls, while structured parsing and model comparison improved coverage and reliability.

3 supporting quotes
“employing an LLM for individual product categorization proved to be a costly endeavor.”article, stated
“We combined multiple SKU and product names into one LLM query, so that some prompt instructions can be shared across different SKUs”article, stated
“Anthropic’s Claude-Instant with zero-shot is the clear winner”article, stated

Models used: Llama2-13b · Llama2-70b · Claude-Instant · Claude-v2

Scale

Alternatives considered (roads not taken)

Out-of-the-box Llama 2 per-product categorization

Rejected because: It produced incomplete/mislabeled categories and was costly when called individually.

“The generated categories were often incomplete or mislabeled.”article, stated

Individual LLM calls for each product

Rejected because: It would increase inference time far more than batch processing at 100,000 products.

“individual LLM calls for each product would have increased the inference time for 100,000 products by approximately 40 times”article, stated

Use the same LLM for both generation and parsing in all cases

Rejected because: The team observed Llama 2 was weaker at format parsing and Claude was more suitable for parsing.

“Llama 2 didn’t perform well in format parsing but was relatively capable in output generation.”article, stated

Patterns

batch-offline-processing (cost-optimization)

Amazon Bedrock batch jobs process large JSONL product categorization workloads asynchronously.

“With batch inference, you can run multiple inference requests asynchronously to process a large number of requests efficiently.”article, stated

structured-output-contract (output-control)

A Pydantic schema and parsers enforce structured category fields from LLM outputs.

“The PydanticOutputParser requires a schema to be able to parse the JSON generated by the LLM. We created a CCData class that contains the list of categories to be generated for each product as shown in the following code example.”article, stated

model-routing (model-operations)

The team compared Llama and Claude variants and identified where each model family performed better.

“For Llama 2, the model choices were meta.llama2-13b-chat-v1 or meta.llama2-70b-chat-v1. We used the following LLM parameters:”article, stated

eval-driven-development (evaluation)

Coverage, parsing, exact-match, and human SME evaluation guided model/prompt selection.

“The framework includes evaluation metrics that can be extended further to accommodate changes in accuracy requirements.”article, stated

Tradeoffs

Inference mode

Chose Bedrock batch inference over per-product online calls.

Rationale: Batch scaling made 100,000-product categorization far more time-efficient and cost-effective.

“With batch inference, you can run multiple inference requests asynchronously to process a large number of requests efficiently. You can also use batch inference to improve the performance of model inference on large datasets.”article, stated

Packing strategy

Chose n-packing multiple SKUs per query over one product per prompt.

Rationale: Shared prompt instructions reduce latency and cost.

“* Use packing techniques – We combined multiple SKU and product names into one LLM query, so that some prompt instructions can be shared across different SKUs for cost and latency optimization. In this use case, 1–10 packing numbers were tested for both Llama 2 and Anthropic’s Claude models.”article, stated

Prompt examples

Chose limit large-scale testing to at most 5-shot over 10-shot everywhere.

Rationale: More examples may improve performance but increase cost around 30%.

“increasing to 10-shot may further improve performance, as observed in small-scale science experiments, but also increase the cost by around 30%.”article, stated

Gotchas (what bit them)

JSON formatting is a production failure mode, not a cosmetic issue.

Root cause: Models can produce malformed or hard-to-parse outputs, especially weaker format-following models.

Resolution: Use PydanticOutputParser, OutputFixingParser, and prompt-engineered JSON instructions.

“We also use OutputFixingParser to handle situations where the initial parsing attempt fails. The following screenshot shows a sample generated .csv file.”article, stated

Packing changes model behavior.

Root cause: Some models generalize poorly as packing number varies across 1, 5, and 10.

Resolution: Evaluate packing per model family and prefer Claude for stable generalization.

“* Llama 2 shows clear performance drops and instability when the packing number varies among 1, 5, and 10, indicating poorer generalizability compared to the Anthropic’s Claude model family.”article, stated

Ground truth with missing values limits downstream utility.

Root cause: Some labeled fields contained N/A or missing values, but GoDaddy wanted high coverage.

Resolution: Optimize final coverage and recommend larger/cleaner ground-truth datasets.

“As shown in the following screenshot of the sample ground truth, some fields have N/A or missing values, which isn’t ideal because GoDaddy wants a solution with high coverage for downstream predictive modeling.”article, stated

Evaluation

GoDaddy evaluated content coverage, parsing coverage, parsing recall/precision on product name, final coverage, human SME quality, latency, cost, and scaling from 5k to 100k samples.

Metrics: content coverage · parsing coverage · parsing recall · parsing precision · final coverage · latency · cost · human SME quality

“* Content coverage – Measures portions of missing values in the output generation step.”article, stated
“* Parsing precision on product name – For an exact match, we use a similar metric to parsing recall, but use precision instead of recall.”article, stated

Outcomes

The source is an AWS customer story and should be read as a vendor-supported case study, but it provides concrete latency, coverage, and cost metrics.

“* Enhanced accuracy – The deliverable produces 97% category coverage on both the 5,000 and 100,000 hold-out test set, exceeding GoDaddy’s needs at 90%. The comprehensive framework is able to facilitate future iterative improvements over the current model parameters and prompt templates.”article, stated
“The solution built by the Generative AI Innovation Center using Anthropic’s Claude-Instant is 8% more affordable”article, stated