The business problem
Take a grocery chain with 300 stores and 25,000 products. Not every store stocks every product, but the chain still has several million SKU and store pairs to plan.
Every week it decides how much of each product to order from suppliers. It decides how much to send to each store. It also decides how much stock to set aside for promotions.
Each of these decisions rests on a demand forecast. If the forecast is too low, shelves run empty and sales are lost. If it is too high, fresh food is thrown away and cash is tied up in stock.
What makes it hard
- Most series are sparse. A large share of SKU and store pairs sell only a few units a week, with many days of zero sales.
- The range keeps changing. New products arrive every week and others are dropped. A new product has no sales history.
- Promotions and price changes move demand sharply. A promotion can double the sales of one product and cut the sales of its neighbours on the shelf.
- Stock-outs hide real demand. A day with no stock shows zero sales, even when customers wanted the product.
- Holidays and local events shift demand differently in different stores.
The data a retailer usually has
Most chains already hold everything the forecast needs. It sits in the point-of-sale system, the price and promotion calendar, and the product and store master data.
| Data | Example | When it is known |
|---|---|---|
| Sales | Units sold per SKU, store and day | Past only |
| Prices and promotions | Shelf price, discount, promotion type | Planned in advance |
| Calendar | Public holidays, school holidays, paydays | Known in advance |
| Stock-outs | Days when the shelf was empty | Past only |
| Product details | Category, brand, pack size, product description | Fixed for the product |
| Store details | Format, floor area, region | Fixed for the store |
| Weather | Forecast temperature and rain | Known a few days ahead |
How it is solved today
The usual approach is a classic machine learning pipeline. It is built by a data science team and takes several months to get into production.
- The sales are laid out on a full SKU, store and day grid. Missing days are filled with zeros, and stock-out days are marked.
- Features are built by hand. Typical ones are sales 7, 14 and 28 days ago, rolling averages, promotion depth, price against the regular price, and days to the next holiday. A mature pipeline has a few hundred of them.
- A gradient-boosted tree model, such as LightGBM, is trained for each category or region. Some chains use per-series methods instead, such as exponential smoothing, with Croston's method for slow movers.
- The model gives one number per SKU and store. Safety stock comes from a separate rule or a second set of models.
- New products get the forecast of a similar product picked by hand, or a category average.
- The models are retrained every week or month. When the range, the promotion types or the store formats change, the features are reworked.
Where it falls short
- The first forecast takes weeks of feature work. A new category or a new market repeats much of it.
- Lag features of a new product are empty, so the model has nothing to work with.
- Product and store ids enter the model as codes. A new id has no learned value.
- Point forecasts do not say how much stock is needed to cover a bad week. Ranges built afterwards are often too narrow.
- Every category model is one more thing to monitor, retrain and fix.
How tabSutra solves it
The sales table goes in as it is
You send one row per SKU, store and day, with the columns you already have. You add rows for the days to forecast, with the prices and promotions planned for them. You name the column to predict, the columns that identify a series, the date column and the horizon.
Your sales table
| SKU | Store | Date | Units | Price | Promo |
|---|---|---|---|---|---|
| Whole milk 1 L | 214 | Nov 24 | 182 | 1.19 | 0 |
| Whole milk 1 L | 214 | Nov 25 | 167 | 1.19 | 0 |
| Olive oil 500 ml | 214 | Nov 25 | 0 | 6.49 | 0 |
| Oat granola 400 g | 214 | Nov 25 | 9 | 3.99 | 1 |
| Whole milk 1 L | 214 | Dec 1 | ? | 1.09 | 1 |
Past rows have units. Future rows carry the planned price and promotion.
tabSutra
- Reads all the series of a store or region together
- Represents each product and store by an embedding, not an id
- Uses only what was known before each forecast date
- Treats stock-out days as missing demand, not as zero demand
Forecast for next week
| SKU | Median | 80% | 95% |
|---|---|---|---|
| Whole milk 1 L | 1,240 | 1,330 | 1,410 |
| Olive oil 500 ml | 11 | 16 | 21 |
| Green tea, 100 bags | 260 | 295 | 330 |
| Oat granola 400 g New | 180 | 225 | 270 |
Store 214, units. A forecast comes for every step ahead, not only the total.
What happens inside
tabSutra is pretrained once on a very large number of tables and time series. It does not need to be trained on your data. It reads your history as context and forecasts from it.
All series are read together
The series of one store or one region are read in a single call. A product with a short or noisy history draws on products that behave like it. A store draws on stores like it.
New products and new stores
Each product and store is represented by an embedding. The embedding is computed from the product's own data, such as its category, pack size, price, description and first weeks of sales. It is not tied to an id. So a product launched last week already has an embedding, and its forecast draws on the products closest to it.
Promotions and prices
Planned prices and promotions are sent with the future rows. The model reads how past promotions moved sales for this product and for similar ones. No promotion features have to be designed.
Stock-outs
When stock-out days are marked, the model reads them as days with unknown demand. A run of empty shelves does not pull the forecast down.
A range for every forecast
Every SKU, store and day gets a full predicted distribution. You can read any quantile from it: the median, the 80% level, the 95% level, or any other.
From a forecast to an order
A single number is not enough to set a stock level. The right level depends on the cost of running out against the cost of holding stock. With a full distribution, you pick the quantile that matches that trade-off for each product.
- Fast-moving staples, where a lost sale is costly: order up to a high quantile of demand over the lead time, such as the 95% level.
- Fresh and perishable products, where unsold stock is thrown away: order closer to the median.
- Slow movers: the median is often zero, which does not mean no stock is needed. The 90% level tells you how many units cover nine weeks in ten.
A slow mover that sells in about one week in three. The median forecast is zero. The 90% level says that two units on the shelf cover nine weeks in ten.
The demand over a lead time of several days is a total. Its mean is the sum of the daily means, but its quantiles are not the sums of the daily quantiles. When orders are set on a weekly total, the weekly total is forecast as a series of its own.
Public data with the same shape
These public datasets have the same shape as the problem. They are listed so that the approach can be checked on open data.
| Dataset | Source | What it tests |
|---|---|---|
| M5 | fev-bench | 30,490 Walmart product and store series, with prices and events known ahead |
| Favorita store sales | fev-bench | Grocery sales by product family and store, with promotions |
| Rossmann | fev-bench | Daily sales of 1,115 drugstores, with promotions and store details |
| Walmart | fev-bench | Weekly sales by store and department, with markdowns |
| Rohlik sales | fev-bench | Daily sales of an online grocer, with 13 known-ahead inputs |
| Hierarchical Sales | GIFT-Eval | Daily sales of products in a product hierarchy, from history alone |
New launches can be tested by hiding the full history of a sample of M5 products and forecasting them as if they were new.
Side by side
Classic pipeline compared with tabSutra
| Classic ML pipeline | tabSutra | |
|---|---|---|
| Time to the first forecast | Weeks to months | Hours |
| Features | A few hundred, built and maintained by hand | None. The columns go in as they are. |
| Models to maintain | One per category or region | One pretrained model for all of them |
| New products and new stores | A similar product picked by hand, or a category average | Forecast from day one, from the products and stores closest to it |
| Slow movers | A separate method, or a flat average | The same model, with upper quantiles to set stock |
| Ranges | Built afterwards, often too narrow | A full distribution for every SKU, store and day |
| Changes in the range or promotions | Features reworked, models retrained | New rows sent with the next call |
| Renamed columns or category codes | The pipeline breaks | The forecast does not change |
Benefits
What the business gets
Forecasts in hours
The first forecast does not wait for a feature pipeline. A new category or a new market is one more call.
New launches planned from data
A new product or a new store gets a forecast from day one, drawn from the products and stores it resembles.
Stock set by the cost of running out
Every forecast has a range. Each product's stock level can be set at the quantile that suits it.
Slow movers covered
Items that sell a few units a month get a usable forecast, read from the upper quantiles.
One model to run
There are no per-category models to retrain, monitor and fix. A model update reaches every category at once.
Reasons for each forecast
Each forecast shows which inputs moved it, such as a promotion, a price change or the recent trend. Planners can check it before they act.
Questions
How much sales history does tabSutra need?
There is no minimum per product. A product with a long history is forecast mainly from its own sales. A product with a few weeks, or none, draws more on similar products. A year or more of history for most of the range helps the model read seasonal patterns.
Do we need to train tabSutra on our data?
No. The model is pretrained. It reads your history as context in each call. When you have a long history across many stores, it can also be fine-tuned on your data for higher accuracy.
Can it forecast weekly totals, or by distribution centre?
Yes. Send the data at the level you plan at, such as SKU by week or SKU by distribution centre. Forecast a total as a series of its own, so that its range is correct.
How do we check it before we rely on it?
Run it on past weeks as if they were the future, and compare it with your current method on the same weeks. The check reports the error of the forecast and how often the actual sales fell inside each range.
How is our data handled?
Your rows are used only to answer your request. They are not used to train the model. A context you send is kept for a limited time, so that you can predict again without sending it, and you can delete it at any time.
Try tabSutra on your own sales data
API access is open to teams on request. The documentation has a worked example for item and store demand.