AI Restocking Assistant: Using TabPFN and Gemma to Automate Weekly Restocking for Handmade Shops

An open-source tool predicts sales ranges with TabPFN-2 and writes restocking advice with Gemma, all running locally on CPU.
tidy-predict is a weekly restocking assistant for small shops that keep books by hand, entered in the Hacktoberfest Open Source AI Challenge with the PriorLabs-TabPFN tech stack. It reads messy order export files, cleans them, uses TabPFN-2 to predict sales ranges for 20 regularly stocked products, then has Gemma 4 E2B generate plain-language restocking advice, with code verifying the numbers. Both models run locally on a laptop CPU, so data never leaves the machine. Across 240 product-weeks, TabPFN-2's P10–P90 interval was calibrated at 80.0%, 16% narrower than the tuned baseline, and required no per-shop coefficient fitting. The author proactively discloses the November 28 peak-week failure and clearly lists limitations. MIT-licensed, 28 tests, no GPU or API key needed.
AI Restocking Assistant: Using TabPFN and Gemma to Automate Weekly Restocking for Handmade Shops
A small shop that keeps its books by hand fears two things most: running out of the products that sell, and filling the shelves with products that don't. A developer built a weekly restocking assistant called tidy-predict using two open-source models—it reads messy order export files and outputs cleaned data, predicted sales ranges for each regularly stocked product for the coming week, and a plain-language restocking recommendation.

This project was entered in the second week of the Hacktoberfest Open Source AI Challenge under the "Side Hustle" track, using the PriorLabs-TabPFN tech stack. Notably, it is not a cloud SaaS but a fully local tool that runs on a laptop CPU—the small shop's sales data never leaves the machine.
What It Solves: Turning "Counting Inventory by Hand" into "One Table per Week"
The project's origin is simple: the author knows someone who runs a shop, and everything—how much inventory, what's about to sell out, what customers are asking about—is recorded by hand. The more manual work there is, the more errors creep in: customers arrive to find the best-sellers out of stock, while slow movers fill the shelves.
Unable to access this shop's data, the author substituted a public UK gift shop order export dataset (UCI Online Retail II, over 1 million real anonymized order lines, CC BY 4.0) and deliberately renamed the columns to unconventional labels like "Bill No, Item Code, Maal, Kitne, Tarikh, Rate" to test robustness.
tidy-predict follows a fixed four-step process: clean → predict with TabPFN-2 → write restocking advice with Gemma 4 E2B → verify every number one by one, retry once on failure or fall back to a template. Both models run locally on CPU; orders never pass through any AI API.
The Core of Prediction: TabPFN-2 Gives Ranges, Not Point Estimates
The prediction step uses a single TabPFN-2 regressor covering the shop's 20 regularly stocked products. All features come from historical weekly data: recent weeks' sales, the same week last year, a few averages, and the week number within the year. TabPFN is a tabular foundation model that produces a full distribution from training rows in a single forward pass, yielding a median prediction plus a P10–P90 interval—the range within which actual sales have an 80% chance of falling.
The author deliberately chose TabPFN-2 over the newer TabPFN-3.5. The reason is licensing: the new version is free for research and testing but requires a paid license for commercial use, whereas TabPFN-2's weights are released under Apache 2.0 (with the attribution clause "Built with PriorLabs-TabPFN"). For a zero-budget side project, the license is the business model itself.
TabPFN (Tabular Prior-data Fitted Network) is a Transformer-based tabular foundation model whose core idea is to pretrain on a large number of synthetic tabular tasks so that the model learns the mapping "from training rows to predictive distribution." When used, it requires no gradient training or hyperparameter tuning—just a single forward pass to output a complete predictive distribution for test samples. This "prior-fitted" property makes it excel at small-sample tabular regression tasks, with inference far faster than traditional ensemble models. TabPFN-2 is a version in this series that supports both regression and classification and has released pretrained weights.
An Honest Failure Case: The Week of November 28
The author proactively leads with a prediction failure because it's the most useful part. The model predicted the rabbit night light would drop 58% to 1,249 units; it actually sold 4,452 units—the second-best week in the file, far exceeding the "busy-week ceiling" of 2,592. The small popcorn bucket also exceeded its range (actual 3,271 units, ceiling 2,596).
Overall, 17 of 20 products fell within the predicted range, but the median total was 13,386 units while actual sales were 19,101. The week of November 28 marks the start of the Christmas peak season, breaking the usual pattern. The author's conclusion is measured: the ranges work for most products, the median is low, and one product would stock out—the shop owner should treat the "busy-week ceiling" as a stocking cap to reference, not a promise.
The P10–P90 interval is a common way to express quantile forecasts: P10 means there's a 10% probability the true value falls below it, and P90 means a 90% probability it falls below that, so the probability the true value lies between them is about 80%. In restocking scenarios, P90 (or the "busy-week ceiling") is often used as a stocking cap to reduce stockout risk, while P10 can identify slow movers to avoid overstocking. The interval width reflects prediction uncertainty—narrower means the model is more confident about that product.
Header Recognition and Data Cleaning: Nothing Silently Deleted
Real small-shop export files don't have neat English headers. The first step uses rules to find columns, and only what the rules can't handle goes to the local Gemma 4 E2B, constrained by a JSON schema so it can only choose from actual header names.
The author hit a snag during development: an early Gemma version got 8 of 12 header groups right but made 4 wrong guesses on optional columns (e.g., treating a batch number as a product code). Wrong guesses are worse than no guesses, so the design was changed to let Gemma fill only the three required gaps—date, quantity, and product—resulting in 12/12 correct and 0 errors. However, since the same data was used for debugging, the author cautions that 12/12 should be treated as an optimistic estimate.
Cleaning is equally conservative: of 1,067,371 rows in the demo file, 70,254 were set aside, including 34,335 exact duplicates (of which 22,523 stemmed from two Excel sheets overlapping December 1–9, 2010), 5,869 postage and handling lines, 21,302 returns, 6,180 sales offset by returns, and 2,568 free or negative-price lines. The remaining 997,117 rows served as sales data. Every excluded row is recorded with its reason in issues.csv—nothing is silently deleted.
JSON Schema is a specification for describing the structure of JSON data, defining field names, types, required fields, and value ranges. When calling a large language model, constraining its output to JSON conforming to a specific schema effectively reduces format errors or field hallucinations caused by the model taking liberties. This project uses JSON Schema to restrict Gemma to choosing mappings only from actual header names—essentially giving the model a closed candidate set, turning "guessing" into "selecting" and significantly improving header recognition reliability.
Gemma Writes the Advice, Code Verifies the Numbers
Gemma sees only a small fact table; the largest increase and largest decrease are computed by code. A verifier extracts every number from the draft and rejects it if any number isn't in the fact table; Gemma can retry once, after which it falls back to a template. Across 12 test weeks, all 12 first drafts passed, each taking about 36 seconds.
The author also acknowledges limitations: the verifier can't tell whether a number is paired with the right product, so a human must read through the advice. Early prompts leaked field names into the body text (e.g., "change vs 4wk avg pct of -53"); the verifier let it through, but a human spots the problem at a glance.
Test Results: A Tie with a Tuned Rule, but No Fitting Required
The author selected a configuration on 7 validation weeks (July–August 2011), then ran one test on the final 12 complete weeks (240 product-weeks), against a strong baseline of "4-week average multiplied by a tuned coefficient k."
| 240 test product-weeks | TabPFN-2 (no shop coefficient) | 4-week average × k (k fitted on Jul–Aug) |
|---|---|---|
| Actual sales within P10–P90 (target 80%) | 80.0% | 85.4% |
| Interval width / sales (narrower is better) | 1.50× | 1.78× |
| Stocking to busy-week ceiling: leftover units | 160K | 178K |
| Stocking to busy-week ceiling: shortage units | 19.5K | 13.0K |
| Median: mean error as share of sales | 0.502 | 0.486 |
TabPFN-2's interval is calibrated exactly to the 80% target and is 16% narrower than the tuned rule; stocking by it leaves 17K fewer units but has 6.5K more shortages; median prediction ties, with the tuned average slightly better. The difference: the simple rule requires fitting coefficients on two months of historical data, and every new shop needs refitting; TabPFN-2 doesn't.
Supplementary data shows how close this tie is: against a bare 4-week average with no tuning, TabPFN-2 had lower error in 7 of 12 weeks, leading through the first 11 weeks (0.502 vs. 0.514), with the November 28 peak week deciding the final tie. TabPFN-2 also beat a gradient-boosted model trained on the same features (0.527) and two naive rules (last week 0.631, same week last year 0.884).
What It Can't Do
The author's list of limitations is worth reading closely for anyone building a similar tool: it only predicts regularly stocked products (sold in at least 20 of the past 26 weeks)—new and occasional items get no numbers; it forecasts only one week ahead, so holidays and promotions can only be modeled indirectly through "week number of the year" and the same week last year, as the November 28 miss demonstrates; the "non-product" rule treats codes without digits as postage, which in the demo data incorrectly flagged 50 rows of real products like DCGSSGIRL; and no shop has actually used this tool yet.
The pricing plan is 199 rupees per week, first month free—the author explicitly states this is only a plan, with no one paying and no revenue. The cost side, however, is concrete: running the 1-million-row demo file from the command line on a 2019 laptop CPU took 52 seconds and consumed zero API tokens.
Open Source and Localization: The License Is the Business Model
Besides both TabPFN-2 and Gemma 4 being Apache 2.0, the author verified offline feasibility: the full prediction pipeline runs in a network-less Linux network namespace (eval/results/offline_check.log). No API keys, no per-call billing, and models can be swapped in one line. Gemma's output is constrained to a JSON schema, with "thinking" mode disabled for CPU speed.
The project is MIT-licensed with 28 tests, and every number has a script behind it. Repository: github.com/xexpertai/tidy-predict. Requirements: Python 3.10+, about 3.5 GB of disk, and 3 GB of free memory—no GPU or API key needed.
For small-business owners, the most valuable thing about this project may not be prediction accuracy but its posture: putting the failure case first, spelling out the limitations, and accounting for the costs clearly. An honest tool is closer to a usable tool than a pretty promise.
A Linux network namespace is a network isolation mechanism provided by the kernel; each namespace has its own network interfaces, routing table, and firewall rules. Creating a namespace with no external interfaces configured simulates a fully offline environment. Running the prediction pipeline in that environment strictly verifies that the tool doesn't depend on any network calls or API keys, thereby proving that sales data truly never leaves the machine. This is more convincing than merely claiming "runs locally."
One-line Summary
An open-source tool predicts sales ranges with TabPFN-2 and writes restocking advice with Gemma, all running locally on CPU.
Paragraph Summary
tidy-predict is a weekly restocking assistant for small shops that keep books by hand, entered in the Hacktoberfest Open Source AI Challenge with the PriorLabs-TabPFN tech stack. It reads messy order export files, cleans them, uses TabPFN-2 to predict sales ranges for 20 regularly stocked products, then has Gemma 4 E2B generate plain-language restocking advice, with code verifying the numbers before output. Both models run locally on a laptop CPU, so data never leaves the machine. Across 240 product-weeks, TabPFN-2's P10–P90 interval was calibrated at 80.0%, 16% narrower than the tuned baseline, and required no per-shop coefficient fitting. The author proactively discloses the November 28 peak-week prediction failure and clearly lists the tool's limitations. The project is MIT-licensed with 28 tests, requiring no GPU or API key.
Related articles

Gemini 4 Argon Hands-On: AI Builds Board Games, Constructs Temples, and Trains Robots Autonomously
Gemini 4 Argon hands-on roundup: AI autonomously builds a desk racetrack and temple in Blender, writes a ray tracing engine, trains a humanoid robot to sink 7 shots, plus API pricing and developer access.

The Magic Octagonal Coin: Why Only 9% of People Can Predict Its Flip?
Only 9% of people can correctly predict the Magic Octagon coin flip. This article explains its spatial rotation mechanism, common cognitive pitfalls, and a new hypothesis based on Relevance Theory, exploring the limits of human spatial reasoning.

Sam Altman: AI Is Entering the Era of Scientific Discovery — Math Breakthroughs Will Replicate in Biology and Energy
Sam Altman says AI is entering the era of scientific discovery — math breakthroughs will replicate in biology, materials science, and energy to help develop new drugs and energy sources.