Prompt
How do I keep recommendations fresh when inventory changes fast?
Latest observation
To keep recommendations fresh when inventory changes fast, use a system that updates on both a schedule and on events.
1) Trigger updates from inventory events
When stock changes, fire events such as:
- item back in stock
- item sold out
- price changed
- new item added
- item removed or discontinued
Use those events to:
- remove unavailable items from candidate lists
- boost newly available items
- retrain or refresh features tied to inventory state
2) Separate “candidate generation” from “final ranking”
A good pattern is:
- Candidate generation: broad pool of potentially relevant items
- Ranking/filtering: apply live inventory, price, and availability constraints right before showing results
This way, even if your model is a little stale, the final layer keeps recommendations current.
3) Cache smartly, not blindly
Cache:
- static features like category, brand, embeddings
- user preference vectors
- precomputed candidate sets
Avoid caching:
- live stock availability
- current price
- delivery estimates
Use short TTLs for volatile data.
4) Add real-time business rules
Before displaying recommendations, apply rules like:
- exclude out-of-stock items
- prefer items with higher stock
- down-rank items with low remaining inventory
- prioritize items that need to be cleared
- avoid recommending items unlikely to ship quickly
5) Refresh features often
If your model uses inventory-dependent features, update them frequently:
- stock count
- days of supply
- sales velocity
- replenishment ETA
- popularity over last hour/day
For very fast-moving catalogs, use micro-batches or streaming feature updates.
6) Blend long-term preferences with short-term trends
Use:
- long-term user history for relevance
- short-term signals for freshness:
- recent clicks
- trending items
- newly stocked items
- seasonal demand
This helps recommendations stay current without forgetting user taste.
7) Use fallbacks
If inventory changes too fast:
- show similar substitute items
- recommend available alternatives in the same category
- surface “back in stock” alerts for items users wanted
8) Monitor freshness metrics
Track:
- out-of-stock recommendation rate
- recommendation latency vs inventory updates
- click-through on newly stocked items
- conversion after stock changes
- stale-item exposure rate
These tell you whether freshness is actually improving.
Simple practical setup
A common architecture is:
- Inventory system emits events
- Feature store updates volatile attributes
- Candidate cache refreshes frequently
- Final ranking service filters by live availability
- Monitoring alerts if stale items leak through
If you want, I can also give you:
- a reference architecture
- a real-time ML pipeline design
- or sample rules/code for inventory-aware recommendations.