Lee Foot

Product Title Optimiser

Rewrite product titles into one consistent word order per category with an LLM, keeping every number.

View the source

#about

Rewrites product titles so each category follows one word order: brand, product type, model or series, key features, specifications, then anything else.

An OpenAI model (GPT Terra by default, or GPT Luna) builds a template for each category, then rewrites the titles in UK English.

Rewrites that change the numbers, or keep under 80% of the original words, revert to the original.

The command-line script adds the new title, an Is Same flag and any dropped words to your CSV.

API key or local model

Platform
Python script (requires Python 3.x)
Input
Product titles CSVOpenAI API key
Output
CSV with original and optimised titles
Category
E-commerce

Use cases

  • Restructuring messy supplier titles at scale
  • Standardising title format across categories
  • Improving title keyword prominence
  • Validating no product info is lost during optimisation

#features

  • GPT Terra by default, or GPT Luna, with local LLM endpoint support
  • Category-based template creation (up to 50 titles)
  • Batch processing (default 20 per request)
  • Numerical validation (all numbers preserved)
  • 80% minimum word overlap verification
  • Missing words flagging in output
  • Rate limit handling with exponential backoff

#how-to-use

  1. Prepare CSV with Name and Categories columns
  2. Run with --input, --model, --batch-size options
  3. Review output with Optimized Title, Is Same, Missing Words columns
  4. Check flagged titles where words were lost

#faq

What must the input CSV look like?
A CSV with a title column and a category column, named Name and Categories by default. Both can be remapped with --title-col and --category-col. Titles are grouped by the exact category string, so if your Categories column holds combined values like 'Lighting, Lamps > Bulbs', each distinct string is treated as its own category with its own template and API calls.
What drives API cost?
One template-creation request per unique category (sent with up to the first 50 titles of that category) plus one optimisation request per batch of 20 titles (configurable with --batch-size). The default model is GPT Terra via your OPENAI_API_KEY (--model gpt-6-luna switches to the cheaper GPT Luna), but --base-url lets you point it at a local OpenAI-compatible endpoint such as LM Studio, in which case no key or spend is needed. Use --limit for a cheap trial run first.
Why do so many titles come back unchanged?
Two safety checks silently revert to the original. First, every number is compared as an exact string: if the set of numbers differs at all, including pure reformatting such as '1,000' becoming '1000', the original is kept. Second, at least 80% of the original title's words must appear in the optimised version, so heavy rewording is rejected. The Is Same column shows which rows were left alone.
What does the Missing Words column mean?
Words present in the original title but absent from the optimised one, for titles that still passed the 80% overlap check. These rows survived validation but lost up to 20% of their words, so they are the ones worth reviewing manually before importing.
What happens on rate limits or API failures?
Rate limit errors trigger exponential backoff starting at 1 second and doubling, with up to 5 retries per batch. If a batch still fails after all retries, the original titles are returned for that batch rather than the run crashing, so a completed run can quietly contain unoptimised batches. Check title_optimization.log for warnings.

/contact

Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.