Stone faces carved into the Bayon temple at Angkor Thom in Siem Reap, Cambodia — the three-tier Khmer architectural icon that inspires the name of Tokkae's multi-stage recommendation engine
Engineering12 min read

Inside Bayon: How Tokkae's Recommendation Engine Decides What Cambodian Shoppers See First

Tokkae's homepage runs on Bayon — a three-stage recommendation engine named after the iconic Khmer temple. Here is how it casts a wide net, scores every candidate, and enforces marketplace fairness before a single product reaches your screen.

Key Takeaways

  • Tokkae's homepage runs on Bayon, a three-stage cascade recommendation engine: retrieval, ranking, and reranking.
  • Stage 1 retrieves candidates from multiple parallel sources tuned for trending, popular, fresh, top-rated, personalized, and search-context products.
  • Stage 2 scores every candidate using a weighted blend of click momentum, sales, Bayesian rating, personal affinity, seller quality, freshness, click-through rate, and discount intensity.
  • Stage 3 enforces marketplace fairness rules — category and seller diversity caps, new-listing boosts, and top-position variety — that protect the long tail from being crushed by any single dominant seller.
  • A separate Discovery algorithm handles cold-start shoppers with variety, exploration, and quality signals instead of relevance against a known profile.
  • The architecture is inspired by Shopee's OnePiece research paper and named after the Bayon temple at Angkor Thom — three tiers, many faces, built to last.

How Does Tokkae Rank Products on the Homepage?

Tokkae's homepage is ranked by Bayon, a three-stage recommendation engine. Stage 1 retrieves a wide candidate pool from multiple parallel sources. Stage 2 scores every candidate through a weighted blend of relevance, popularity, quality, and personalization signals. Stage 3 applies marketplace rules — diversity, fairness, freshness — to the top results before they reach the shopper.

The engine is named after the Bayon temple at Angkor Thom: three tiers of stone, more than 200 carved faces looking out in every direction, and a structure that has stood for more than 800 years because it was built layer by layer rather than as a single monument. The architecture of Tokkae's recommendation engine borrows that exact pattern — three independent layers, each with one job, each replaceable without rebuilding the others.

This article walks through how Bayon decides what every Cambodian shopper sees on the Tokkae homepage, why we built it as a cascade rather than a single AI model, and what each layer is doing behind the scenes the moment a shopper opens the app.

Why Marketplace Ranking Is Hard

Every marketplace has to satisfy three groups whose interests rarely line up:

  • Shoppers want products they would actually consider buying — relevant, high quality, fairly priced.
  • Sellers — especially new ones with no track record — want fair surface area to be discovered.
  • The marketplace itself needs conversion, gross merchandise value, and a healthy long tail of transactions across many sellers.

Design principle: Every stage in Bayon can be swapped from rule-based logic to a learned model — gradient-boosted trees today, transformers tomorrow — without touching the stages above or below it. That is the whole point of cascade.

Why a Simple "Best-Seller" Sort Fails

A naive ORDER BY soldCount DESC query collapses all three concerns into one — and the result is brutal. The top 1% of sellers own every visible slot. New listings never break in, no matter how good they are. Shoppers see the same five items everywhere and quickly stop coming back. Within six months, a marketplace ranked this way ossifies into a Pareto-flooded feed where the rich keep getting richer and the long tail starves.

A monolithic AI model fails the opposite way. It is too expensive to iterate on, too opaque to debug when something goes wrong, and too rigid to swap out a single component. When a shopper complains that they keep seeing irrelevant products, no one inside the company can answer "why" without retraining the entire model.

The Cascade Pattern: Bounded Blast Radius

The cascade pattern threads the needle between these two failure modes. Each stage has a single responsibility, a small surface area, and can be replaced independently as the platform grows. The architecture is borrowed from Shopee's OnePiece research paper — published in 2025, deployed in production at one of Southeast Asia's largest marketplaces — and adapted for Cambodia's e-commerce reality.

Bayon's three stages each answer a different question. Retrieval asks "what could the shopper want?" Ranking asks "in what order?" Reranking asks "what is best for the marketplace as a whole?" Treating these as separate problems makes each one solvable, testable, and upgradable on its own clock.

Stage 1 — Retrieval: Casting a Wide Net

Retrieval is about recall, not precision. The job of this stage is to pull a candidate pool wide enough to give the ranker meaningful choices, but narrow enough to score in milliseconds when a shopper opens the homepage.

Bayon retrieves candidates from several parallel sources, each optimized for a different shopper need. The sources fire concurrently and their results are flattened and deduplicated before reaching the ranker.

  • Trending — products gaining traction in the last 24 hours, weighted by recent click momentum
  • Popular — proven sellers across the catalog, weighted by historical transaction volume
  • New arrivals — fresh inventory entering the marketplace, surfaced before it accumulates click history
  • Top rated — products with verified shopper trust, gated by a minimum review threshold
  • Personalized — items aligned with the shopper's category and brand history (logged-in shoppers only)
  • Search context — products related to the shopper's most recent search queries

Why Logged-In Shoppers See a Richer Pool

Shoppers who have used Tokkae before bring signal with them. Their click history, search queries, and category preferences feed into two of the six retrieval sources — Personalized and Search Context — that simply do not exist for a brand-new shopper. The richer the input signal, the wider and more relevant the candidate pool.

Shoppers without history fall through to a separate cold-start path called the Discovery feed, which we cover further down. Discovery uses different scoring weights designed for variety and quality rather than relevance against a known profile.

Caching by Volatility: Why Trending and Top-Rated Are Cached Differently

Different sources have different freshness profiles, so each gets its own cache window. Trending data decays fast — what was hot an hour ago may already be stale — and is refreshed often. Top-rated products, by contrast, barely change hour-to-hour and can be cached much longer.

Personalized retrieval has the tightest refresh window of any source, because the responsiveness of the personalization loop is bounded by it. The shorter that window, the more "alive" the homepage feels after a shopper interacts.

Stage 2 — Ranking: Scoring Every Candidate

Ranking is where roughly 200 candidates become a sorted list. Bayon scores every candidate through a weighted composite of features, each chosen because it correlates with a different dimension of "good for this shopper, right now."

  • Click momentum — log-normalized so that one viral product with tens of thousands of clicks does not crush every other candidate when scaled against the maximum
  • Sales history — a measure of proven demand, smoothed against catalog-wide volume
  • Bayesian rating — explained below
  • Personal affinity — the heaviest signal for logged-in shoppers
  • Seller quality — a composite of the seller's rating, response rate, ship-on-time rate, and verification status
  • Freshness — newer listings get a graceful boost that fades over weeks rather than days
  • Click-through rate — how often impressions convert to taps
  • Discount intensity — capped, so an aggressive sale does not fully override quality

Why a Single Five-Star Review Does Not Win

One of the subtle decisions in Bayon's ranker is how it treats ratings. A naive average rewards a brand-new product with one five-star review more than an established product with 1,000 reviews at 4.5 stars. That ranking is misleading — it confuses confidence for quality.

Bayon uses a Bayesian average instead. The Bayesian approach pulls low-evidence ratings toward a neutral prior — meaning a single five-star review starts off looking ordinary and only earns its place at the top by accumulating consistent ratings at scale. Products with a thousand 4.5-star reviews outrank lone outliers, which matches what shoppers actually want when they sort by quality.

Personal Affinity: The Heaviest Signal

For logged-in shoppers, personal affinity is the largest single weight in the ranker. It combines several inputs — the shopper's category preferences, their brand history, the price ranges they tend to browse, their recent search queries, and decay-weighted recency so that last week's clicks count for more than last month's.

The result is a single per-candidate score that captures "how much does this specific shopper care about this specific product?" — independent of how popular the product is overall. A niche product the shopper cares about can outrank a bestseller they have ignored, which is exactly what makes the homepage feel personal rather than generic.

Why Ship-On-Time Outweighs Seller Rating

Inside the seller quality composite, ship-on-time rate carries more weight than seller rating itself. The reason is data: across millions of marketplace transactions in comparable Southeast Asian markets, late shipments are the single behavior most strongly correlated with refund requests, dispute escalations, and shopper churn. A seller with a 4.9-star rating who ships late is a future complaint waiting to happen. Bayon weights accordingly.

The ML Seam: Why Ranking Is Built to Be Replaced

The current ranker is rule-based — transparent, fast, easy to audit during launch. But the architecture has a deliberate seam where the entire scoring step can be swapped for a machine-learning model. The candidate set goes in, scores come out. Whatever happens between is replaceable.

In practice, this means today's rule-based weights can be swapped for an XGBoost model once we have enough click data, and eventually for a transformer-based ranker like the one in Shopee's OnePiece paper — without touching retrieval or reranking. That iteration path is intentional. Bayon was designed not for what Tokkae's marketplace is on launch day, but for what it becomes once data starts flowing.

Stage 3 — Reranking: The Marketplace's Conscience

The ranker is good at picking what is "best." It does not know what is best for the marketplace. A pure relevance score, applied without any guardrails, would happily serve a homepage with eight identical electronics products from the same seller in the top ten slots. That is great for that one seller and terrible for everyone else.

Bayon's reranker enforces a small set of business rules on the top of the ranked list before it reaches the shopper.

  • Category diversity — no single category can flood the feed; excess products are deferred and used only as backfill
  • Seller diversity — no single seller can monopolize a row, protecting the long tail of small sellers
  • Complete listing boost — products with strong photography, ratings, and reviews earn small additive bumps
  • New listing boost — recently created products are protected from the cold-start penalty they would otherwise pay on click and sales scores
  • Discount visibility — meaningful discounts surface, but with diminishing returns to prevent a discount-only feed
  • Top-position variety — the top slots must show a mix of categories; the reranker performs targeted swaps if they do not, but only when the swap costs minimal relevance

The fairness guarantee: No matter how dominant a seller becomes in raw ranking score, Bayon's reranker caps how many of their products can appear in the top of any given homepage. That guardrail is structural, not optional.

Why Reranking Is Where the Long Tail Survives

Reranking is the single most important reason Tokkae will not turn into "the same fifty products from the same ten sellers" within a quarter. The diversity rules sit downstream of the ranker specifically so that they cannot be optimized away by a future learned model — they are guardrails, not preferences.

For Cambodian sellers, this matters concretely. In marketplaces where a learned ranker is allowed to dominate end-to-end, small sellers face an impossibility: they need clicks to rank, and they need to rank to get clicks. Bayon's reranker breaks that loop by guaranteeing surface area on quality and freshness signals that small sellers can actually influence — even before they have a transaction history.

The Personalization Loop: From One Click to a New Feed

Personalization is only as good as the user model behind it. Tokkae's model is intentionally simple — a small set of category and brand affinity scores attached to every shopper, updated on every interaction.

Two decay rules keep the model honest over time.

Write-Time Decay: Why Obsessive Clicking Cannot Break the Feed

Every new click slightly discounts past signal before adding new signal. Steady-state, scores converge to a bounded ceiling — meaning a shopper who clicks one category obsessively does not end up with a runaway profile that overwhelms every other signal. The math is built so that no single category can dominate beyond its earned ceiling, even with millions of clicks.

Read-Time Decay: Why Old Interests Fade Naturally

At every homepage request, Bayon ages out affinity scores using exponential decay. A shopper who hasn't touched a category in a few weeks sees that category gracefully fade from their feed. A shopper who hasn't touched it in months sees it disappear almost entirely. This is not a hard cutoff — it is a smooth fade, which means a returning shopper's old preferences are remembered just enough to give them a sense of continuity without locking them into outdated tastes.

Affinity Propagation Up the Category Tree

When a shopper clicks "Wireless Earbuds," the affinity signal propagates up — boosting "Audio" and "Electronics" at decreasing weights. The leaf preference dominates, but the parent context is captured. This means the homepage understands that someone who keeps clicking earbuds probably also wants to see other audio gear, even if they have never explicitly clicked a single speaker or pair of headphones.

Together, these rules give Bayon a live but stable feel. A single click measurably moves the next refresh. A short browsing session reshapes recommendations within minutes. Months of inactivity gently forget themselves. That balance — alive but not jittery, personal but not invasive — is what good personalization looks like.

Cold Start: Welcoming First-Time Shoppers

For shoppers with no history, Bayon hands off to a separate algorithm — the Discovery feed. The main ranker we use for known shoppers is optimized for relevance against a known profile. Discovery is optimized for the opposite goal: variety, quality, and exploration.

  • Strong seller signals (verified, high ship-on-time rate, good ratings)
  • Listing completeness (clear photos, written descriptions, reviews)
  • Round-robin interleaving across categories so the feed feels broad rather than clustered
  • A controlled randomness factor that gives every quality product a non-zero chance to surface
  • A stricter per-seller cap than the main reranker, because a brand-new shopper has no relationship with any single seller yet

Why Discovery Includes Deliberate Randomness

Pure exploration is built into Discovery on purpose. Without a random factor, the cold-start feed would converge to the same products on every refresh — making the marketplace feel small even when it is not. A controlled exploration weight gives every quality product a chance to surface, and creates the slight per-refresh variation that prevents a stale-feeling first impression.

As soon as the shopper interacts even once — a single click, a single search — Bayon's main pipeline takes over. Discovery is the welcome mat, not the destination.

Why "Bayon"? The Cultural Foundation

The Bayon temple, built at the end of the 12th century at the heart of Angkor Thom, is one of the most recognizable monuments in Khmer architecture. It has three tiers. It has more than 200 carved faces looking outward in every direction. It was built layer by layer over generations — each level adding to the structure without replacing what came before.

That architecture is exactly how Tokkae's recommendation engine grew, and how it will keep growing.

  • Three tiers map directly to three cascade stages — retrieval, ranking, reranking
  • Many faces map to multi-source candidate retrieval — the engine looks in every direction at once
  • Built layer by layer maps to the upgrade path — today's rules-based logic can be replaced with learned models without rebuilding the foundation

Why a Cambodia-Rooted Name Matters

For Cambodia's first marketplace built specifically for Cambodian shoppers and sellers, the name of the engine that decides what every shopper sees first should not be a generic Silicon Valley acronym. Naming it after the Bayon temple is a deliberate signal — that this technology was built here, by people who understand the market, drawing on cultural heritage instead of importing a foreign label.

That signal is part of what makes Tokkae different from the regional alternatives that have passed Cambodia over for more than a decade. The infrastructure is built locally. So is the language used to describe it.

The Bayon Roadmap: How Each Stage Gets Smarter

The cascade is built so each stage can be replaced independently. Here is the upgrade path for each layer.

  • Retrieval today uses SQL queries plus a search index. Tomorrow: learned embeddings retrieved through approximate nearest-neighbor search, so candidates are pulled by semantic similarity rather than database joins.
  • Ranking today uses a rule-based weighted composite. Tomorrow: gradient-boosted models trained on click data, then transformer-based rankers that consume sequences of shopper behavior the way OnePiece does at Shopee.
  • Reranking today uses hand-coded business rules. Tomorrow: learned diversity and fairness models that balance shopper relevance with marketplace fairness as a single multi-objective optimization.

Why We Started With Rules Instead of Models

Some marketplaces start by building learned models from day one. We chose the opposite path on purpose. On launch, Tokkae has no click data, no transaction data, no behavioral history to train on. A rule-based ranker built from first principles works correctly on day one with zero data — and produces explanations every time something looks wrong.

Once data starts flowing, the rule-based ranker becomes the baseline that any learned model must beat. That is the right discipline. A learned ranker that fails to outperform clear, transparent rules is not actually adding value, even if it is more impressive on a slide.

What This Means for Cambodian Sellers

For sellers — especially the small businesses, artisans, and family shops that make up most of Cambodia's commerce — Bayon's structure has concrete implications.

  • New listings are protected. A brand-new product cannot pay the cold-start penalty that would otherwise lock it out of the homepage for weeks. The reranker explicitly boosts recent listings.
  • Listing quality is rewarded directly. Strong photos, clear descriptions, accumulating reviews, and a high seller rating all earn additive boosts in reranking — independent of click volume. A small seller can earn surface area through quality alone.
  • No single seller can monopolize. The seller-diversity cap means even the largest, most successful seller cannot crowd out smaller competitors at the top of the homepage. The long tail is structurally protected.
  • Ship-on-time matters more than star count. A small seller with a perfect on-time shipping record can outrank a larger seller with worse fulfillment. Operational discipline is rewarded, not just popularity.

What This Means for Cambodian Shoppers

For shoppers, Bayon is mostly invisible — and that is the point. The homepage just feels right. But there are concrete behaviors a Cambodian shopper can rely on.

  • Your first session matters. Even a single click reshapes the next homepage you see. The personalization loop is designed for minute-scale responsiveness.
  • Variety is guaranteed. No matter how much you click into one category, the diversity rules ensure your homepage stays broad. You will not get trapped in a recommendation echo chamber.
  • New shoppers are not punished. A first-time shopper sees a curated, varied, quality-first feed from the moment they land — not a generic top-seller list.
  • Quality outranks volume. Bayesian rating means a product with thousands of consistent reviews beats a one-hit wonder with a single five-star rating. Sorting by quality reflects actual quality.
  • Old interests fade gracefully. If you stopped shopping for one category months ago, it will stop dominating your homepage on its own — without you needing to clear preferences manually.

The promise: Bayon is built so that every Cambodian shopper, on their first visit and every visit after, sees a homepage that is varied, fair, fresh, and personal — without any of those qualities winning at the expense of the others.

Bayon, In One Sentence

Tokkae's Bayon engine is a three-stage cascade — retrieval, ranking, reranking — that decides what every Cambodian shopper sees first by casting a wide net, scoring every candidate against shopper relevance and seller quality, and then enforcing the marketplace fairness rules that keep the long tail alive.

It is named after a Khmer temple that was built layer by layer eight hundred years ago and still stands. We hope the architecture lasts at least as long.

Frequently Asked Questions

Bayon is the recommendation engine that powers Tokkae's homepage. It is a three-stage cascade — retrieval, ranking, and reranking — that selects, scores, and orders products before they reach a shopper. Bayon is named after the 12th-century Bayon temple at Angkor Thom, whose three-tier architecture mirrors the engine's three layers.

Bayon builds a lightweight profile for every logged-in shopper based on category and brand preferences, recent search queries, and price range behavior. Every click updates the profile with decay-weighted recency, and every homepage refresh applies that profile as the heaviest signal in the ranker. New shoppers without history get a separate Discovery feed designed for variety and quality.

The current Bayon ranker is rule-based, designed for transparency and fast iteration during launch. The architecture has a deliberate seam where the scoring step can be replaced with machine-learning models — gradient-boosted trees first, transformer-based rankers eventually — once Tokkae accumulates enough behavioral data to train them. Rules-first is a deliberate discipline, not a limitation.

Bayon is built for Cambodia from the ground up — its diversity rules, cold-start handling, and seller-quality weights are all calibrated for a market dominated by small sellers, social-commerce-trained shoppers, and limited transaction history. Architecturally, Bayon is inspired by Shopee's OnePiece research paper, but it is rules-first by design, where larger marketplaces run end-to-end learned models.

The personalization layer is designed for minute-scale responsiveness. A shopper's first click measurably reshapes their next homepage refresh — fast enough to feel alive, slow enough to remain stable. The decay constants are tuned so that a single click moves the needle without reshaping the entire feed.

Brand-new shoppers see the Discovery feed — a separate algorithm optimized for variety, quality, and exploration rather than relevance against a known profile. Discovery emphasizes verified sellers, complete listings, round-robin category interleaving, and a controlled randomness factor. As soon as the shopper interacts even once, Bayon's main pipeline takes over.

Bayon's reranking stage enforces hard caps on how many products from any single category or seller can appear in the top of the feed. These rules sit downstream of ranking specifically so they cannot be optimized away — they are structural guardrails, not preferences. The result is a homepage that stays varied no matter how dominant any single seller becomes.

The Bayon temple at Angkor Thom is one of the most recognizable monuments in Khmer architecture. Its three tiers map directly to the engine's three cascade stages, its 200+ carved faces map to multi-source candidate retrieval, and its layer-by-layer construction mirrors how the engine is designed to be upgraded — replacing parts without rebuilding the whole. Naming it after a Cambodian landmark is a deliberate statement that Tokkae's technology was built here.

Marz

Written by

Marz

Co-Founder, Tokkae

Marz is the co-founder of Tokkae, Cambodia's upcoming trusted online marketplace. He leads engineering and product, with a focus on building infrastructure designed for how Cambodians actually shop and sell — not imported from playbooks written for Bangkok or Jakarta.

Share