The problem
Mann Craft, a made-up home-decor seller in Puducherry, photographs new terracotta, brass and handloom pieces every week. Then someone spends hours typing attributes, guessing prices from memory, writing titles and bullet points, and fixing the marketplace file when the upload rejects it.
Each of those jobs suits a different kind of model, and none of them is enough alone. The value is in joining them: the photo fills the attributes, the attributes drive the price, both drive the words, and rules check the lot before anything is uploaded.
The data
The photos are two openly licensed CC0 pictures from Wikimedia Commons, clay lamps on a street stall and a cup and saucer. You can add your own; they stay on your device.
400 comparable marketplace items across 10 product types (diyas, tea-light holders, planters, vases, cups, bowls, urlis, wall hangings, cushion covers and table runners), each with its material, size, set size, finish, whether it is handmade, the seller's tier and a price. I generated them from a pricing rule with random noise, so the numbers repeat on every visit. They are not market prices.
A lookup table of HSN codes and GST rates by product type and material, and the upload template of Haatline, a made-up marketplace, with 21 columns.
The model
Stage 1, deep learning: Florence-2. A vision-language model with a vision encoder and a text decoder writes a detailed caption of the photo and reads any text on the product. Rules then turn the words into attributes: the first product word decides the type, “clay” or “earthen” means terracotta, a colour is taken only when it is not the background's, and words such as “small”, “set of four” or “hand-painted” set the size, the set and the finish. Each attribute shows the words that decided it, and you can correct any of them.
Stage 2, machine learning: the price. A linear model on log prices captures how prices multiply (brass costs several times terracotta, a set of twelve costs less than twelve singles), and a random forest of 60 trees learns what is left over, such as large brass pieces costing extra by weight. The range comes from the errors the model made on training items it had not seen (four-fold cross-validation), and the five most similar items, by a simple distance, are the evidence.
Stage 3, generative AI: the words. SmolLM2 360M Instruct writes a title, five bullet points and a description from the attributes and the price, in Mann Craft's voice, with a worked example to keep the format. Until it loads, rules write a plain template draft, so the system is useful at once. A fact check (the one from my Copy Writer demo, plus a size-word check) flags any material, number, size or claim the attributes do not back, so a weak or inventive answer is caught before it ships.
Stage 4, automation: the marketplace file. Eight checks run on every change: required fields, the 150-character title limit, five bullet points, banned words such as “best” and “guaranteed”, every detail backed, an image, the HSN code and GST rate, and the price within the predicted range or a reason. Listings that pass go into the CSV in the template's column order, with formula-like text neutralised so a spreadsheet cannot run it.
The pipeline
- 01Photo
Florence-2 captions the photo and reads its text; rules turn the words into attributes you can correct.
- 02Attributes
Type, material, colour, size, set, finish, handmade and tier: the one record every later stage reads.
- 03Price
The linear model and the forest suggest a price and a range; the five nearest items show the evidence.
- 04Words
SmolLM2 (or the template) writes the title, bullets and description from the attributes and the price.
- 05Fact check
Anything in the words that the attributes do not back is flagged in place.
- 06Feed checks
Eight rules decide whether the listing can go in the file, each with its reason.
- 07Export
Every ready listing in the batch goes into one CSV in Haatline's template.
Results
Measured when this page was built, with the same code the demo runs. The linear model alone has a 13.6% error; the forest's correction brings it to 11.7%. On Florence-2's real caption of the cup photo (“A cup of coffee is on a saucer.”), the rules give a cup and saucer in ceramic.
For a client
For a real shop I would train the price model on its own sales and on scraped comparable listings, refreshed weekly, and track the error by category so a person reviews the categories where it drifts.
The photo stage would run on the shop's full photo set (several angles per product) and learn the shop's own product words; Florence-2 or a larger vision model could run on a small server if the photos come in by the hundred.
The writing stage would get a few dozen of the shop's best past listings as examples, and the fact check would stay in front of it: nothing the attributes do not back reaches the marketplace.
The HSN and GST table would come from the client's accountant and the current schedule, not from me; the feed checks would follow the marketplace's real template and its error report, and the export would go straight to its upload API.
Stack
| Part | What it does here | Licence |
|---|---|---|
| Florence-2 base | Captions the photo and reads its text (via transformers.js, in a worker) | MIT |
| SmolLM2 360M Instruct | Writes the title, bullets and description | Apache 2.0 |
| Transformers.js | Runs both models in the browser on WebGPU or WebAssembly | Apache 2.0 |
| My machine-learning library | The linear model, the random forest, cross-validation, the metrics and the sample generator | Mine |
| My rules | Caption to attributes, the fact check, the feed checks, the tax lookup and the CSV | Mine |
| Preact | The interactive demo | MIT |
| Astro | The page, built as static HTML | MIT |
Privacy
Everything runs in your browser. Your photos, attributes and words are never uploaded; the two models download from their public host once and stay in the browser's cache.
Limits
- The catalogue is generated, so the price error shows how well the model recovers my pricing rule, not how well it would price a real product.
- Florence-2 describes what it sees, not what a product is made of: a photo cannot show handmade, a material can be mistaken, and a busy stall photo may be read as a scene. That is why every attribute can be corrected and shows its evidence.
- SmolLM2 is a small model: its words can be flat or miss the format, so the template fills any part it misses and the fact check flags what it invents.
- The HSN codes and GST rates are a sample table, not tax advice; rates change, so check the current schedule before filing.