Hybrid AI System for Large-Scale Product Categorization

walmart · E-commerce · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: large-scale e-commerce product categorization and catalog relevance

Walmart needed to map product categories to the right product types across a very large online catalog so customers see relevant items, while avoiding the cost and latency of running generative models over millions of candidate pairs.

Constraints:

Architecture

Walmart built Ghotok as a staged ensemble for product categorization. Predictive AI models trained on domain-specific, human-labeled features first score category/product-type pairs and apply confidence thresholds learned at a fixed false-positive rate, reducing millions of candidate pairs to thousands. Generative AI models then run only on this filtered set, using chain-of-thought prompts and hierarchy-aware symbol tuning to reason about semantic relevance and remove additional false positives. The resulting category-to-product-type mappings are integrated into the backend filtering path through a two-tier LRU cache that serves mappings from L1/L2 cache before falling back to primary storage. A separate exception-handling tool combines ML and human intervention for production edge cases.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Digital_storefront_category_tree["Digital storefront category tree"] --> Category_item_fetcher["Category item fetcher"]
  Digital_storefront_category_tree --> Ghotok_mapping_engine["Ghotok mapping engine"]
  Product_type_hierarchy["Product type hierarchy"] --> Ghotok_mapping_engine
  Human_labeled_training_set["Human-labeled training set"] --> Predictive_AI_models["Predictive AI models"]
  Human_labeled_training_set --> Validation_evaluator["Validation evaluator"]
  Predictive_AI_models --> Generative_AI_relevance_model["Generative AI relevance model"]
  Prompt_engineering_layer["Prompt engineering layer"] --> Generative_AI_relevance_model
  Generative_AI_relevance_model --> Ghotok_mapping_engine
  Predictive_AI_models --> Validation_evaluator
  Generative_AI_relevance_model --> Validation_evaluator
  Ghotok_mapping_engine --> Two_tier_LRU_cache["Two-tier LRU cache"]
  Two_tier_LRU_cache --> Primary_storage["Primary storage"]
  Two_tier_LRU_cache --> Backend_filtering_service["Backend filtering service"]
  Category_item_fetcher --> Backend_filtering_service
  Backend_filtering_service --> Digital_storefront_category_tree
  Ghotok_mapping_engine --> Exception_handling_tool["Exception handling tool"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Digital storefront category tree Customer-facing hierarchy of categories and subcategories used to browse Walmart.com. Category item fetcher, Ghotok mapping engine
Product type hierarchy Internal classification hierarchy that describes the intended use of each item. Ghotok mapping engine
Human-labeled training set Limited curated labels used for hyperparameter selection, threshold learning, and evaluation. Predictive AI models, Validation evaluator
Predictive AI models Cheaper million-parameter models that score domain-specific category/product-type features and filter candidates by confidence thresholds. Generative AI relevance model, Validation evaluator
Generative AI relevance model Billion-parameter model used on pre-filtered candidate pairs for semantic relevance and false-positive reduction. Prompt engineering layer, Ghotok mapping engine
Prompt engineering layer Chain-of-thought and symbol-tuning prompt strategy that uses full category paths and leaf-node emphasis. Generative AI relevance model
Ghotok mapping engine Combines predictive and generative outputs into category-to-product-type mappings for filtering. Two-tier LRU cache, Exception handling tool
Category item fetcher Fetches candidate items based on the category they fall into. Backend filtering service
Two-tier LRU cache L1/L2 cache for Category-to-ProductType mappings used to meet millisecond-range backend SLAs. Primary storage, Backend filtering service
Primary storage Backing storage for offline category/product-type mapping data when cache misses occur. Two-tier LRU cache
Backend filtering service Filters fetched items by the relevant product types returned for a category. Digital storefront category tree
Exception handling tool Production support path that uses machine learning and human intervention to resolve edge cases. Ghotok mapping engine
Validation evaluator Uses precision, recall, F1, TPR, and FPR on human-labeled data to set thresholds and compare ensembles. Predictive AI models, Generative AI relevance model

Data flow

A user request fetches items by category while Ghotok identifies relevant product types for that category. Offline, predictive models learn thresholds over category/product-type candidate pairs from human-labeled data and filter millions of candidates down to thousands. The generative model then evaluates the remaining pairs with chain-of-thought prompting and full path representations. At serving time, the backend stores Category-to-ProductType mappings in L1 and L2 LRU caches, checks those caches before primary storage, and filters fetched items by the approved product types.

"Fetch items based on the category they fall into.

2. In parallel, identify the relevant product types for the category.

3. Filter the items fetched on step 1 based on the product types in step 2."

“This reduces the total number of candidate pairs to select from millions to thousands.”article, stated
“The processor initially searches for data in the L1 cache. If it is not there, the processor checks the L2 cache. If the cache does not contain the data, we query the primary storage.”article, stated

Why this architecture

Walmart chose a hybrid ensemble because predictive models are cheap enough to filter a massive candidate space, while generative models provide semantic understanding for the smaller set where that cost is justified. The constrained GenAI role reduces hallucination risk by using the model to eliminate false positives rather than invent content. The two-tier cache is necessary because the offline mapping data can contain millions of rows, but the backend needs responses in a few milliseconds.

3 supporting quotes
“As ML inference using Generative AI technology is costly, we do not run Generative AI models for all the millions of candidate pairs.”article, stated
“Hallucination in GenAI does not pose a significant issue for us, as we selectively utilized GenAI’s (billion parameter models) advanced semantic comprehension”article, stated
“To meet the typical service level agreement requirements that usually range in a few milliseconds, an effective mechanism is needed to process millions of entries”article, stated

Models used: predictive AI models · generative AI models · ensemble models · million-parameter predictive models · billion-parameter generative models

Scale

Alternatives considered (roads not taken)

Run Generative AI on all candidate pairs

Rejected because: Generative inference was too costly at the millions-of-pairs scale, so predictive filtering runs first.

“As ML inference using Generative AI technology is costly, we do not run Generative AI models for all the millions of candidate pairs.”article, stated

Use one model family for the entire task

Rejected because: The team explicitly uses an ensemble of predictive and generative models to combine cheaper filtering with stronger semantic understanding.

“Instead of choosing one single model for both Predictive and Generative AI, we use an ensemble of models.”article, stated

Train on noisy customer engagement data

Rejected because: Walmart uses limited human-labeled data because clicks can be accidental or curiosity-driven.

“dispenses with the requirement for customer engagement data (which is noisy as sometimes customers might click on items by mistake or out of curiosity)”article, stated

Use only category node names in the prompt

Rejected because: The team found that full root-to-node path representation and leaf-node emphasis improved reasoning quality.

“Utilizing the entire path representation (root-to-the-node) as a string, rather than just context node names, proved essential.”article, stated

Query primary storage for every request

Rejected because: The backend needs millisecond response times over millions of entries, so L1/L2 LRU caches serve mappings before storage is queried.

“If it is not there, the processor checks the L2 cache. If the cache does not contain the data, we query the primary storage.”article, stated

Patterns

cost-aware-routing (operations)

Predictive models cheaply reduce the candidate set before the expensive generative model is invoked.

“As ML inference using Generative AI technology is costly, we do not run Generative AI models for all the millions of candidate pairs.”article, stated
“we first learn confidence thresholds by fixing a certain false positive rate (FPR) and filtering out candidate pairs that do not satisfy this threshold.”article, stated

confidence-thresholding (quality)

The predictive stage learns thresholds at a fixed false-positive rate and passes only higher-confidence candidate pairs to GenAI.

“for each <Category, ProductType> pair, we first learn confidence thresholds by fixing a certain false positive rate (FPR)”article, stated

structured-output-contract (data-modeling)

The system is organized around a structured mapping from Category to ProductType sets, which is cached and used to filter catalog items.

“We store a fixed number of mappings of Category to Set<ProductType> in a two-level cache.”article, stated

latency-optimization (operations)

A two-tier LRU cache keeps category/product-type mappings available within millisecond backend SLA requirements.

“To minimize the time taken to access entries from our primary storage, we use a two-tier caching system with LRU caching mechanism.”article, stated
“The first level (L1) cache is small enough to provide access time of one or two cycles.”article, stated

human-in-the-loop-gate (oversight)

An exception-handling tool uses human intervention for edge cases that the predictive/generative ensemble cannot resolve cleanly.

“we developed an exception handling tool, powered by both machine learning and human intervention, which facilitated swift and seamless resolution of these issues.”article, stated

eval-driven-development (quality)

Human-labeled validation data and metrics such as precision, recall, F1, TPR, and FPR guide hyperparameters, thresholds, and ensemble comparisons.

“For this, we utilize multiple metrics such as precision, recall, f1, true positive rate (TPR) and false positive rates (FPR).”article, stated
“On a validation set, this ensemble of Predictive and Generative AI models showed the best performance.”article, stated

Tradeoffs

Predictive filtering before generative reasoning

Chose cheap predictive models to narrow candidate pairs, then GenAI on the reduced set over running GenAI on all millions of candidate pairs.

Rationale: This preserves semantic reasoning where it matters while controlling inference cost at catalog scale.

“As ML inference using Generative AI technology is costly, we do not run Generative AI models for all the millions of candidate pairs.”article, stated

Human-labeled data instead of click data

Chose limited human-labeled data over customer engagement data.

Rationale: Click data is noisy, while labeled data supports both frequent and rarely visited hierarchy regions.

“dispenses with the requirement for customer engagement data (which is noisy as sometimes customers might click on items by mistake or out of curiosity) by leveraging a limited amount of human-labeled data.”article, stated

Constrain GenAI to false-positive elimination

Chose semantic comprehension over pre-filtered pairs over open-ended generation of product classifications.

Rationale: The constrained role lets Walmart benefit from GenAI semantics while reducing hallucination exposure.

“Hallucination in GenAI does not pose a significant issue for us, as we selectively utilized GenAI’s (billion parameter models) advanced semantic comprehension”article, stated

Full path representation for prompts

Chose root-to-node path string with leaf-node emphasis over context node names only.

Rationale: The full hierarchy path gave the model better semantic context for relevance decisions.

“Utilizing the entire path representation (root-to-the-node) as a string, rather than just context node names, proved essential.”article, stated

Two-level cache for serving mappings

Chose L1 and L2 LRU caches before primary storage over direct primary-storage lookup for each filtering request.

Rationale: The backend must process millions of entries with service-level expectations in a few milliseconds.

“The first level (L1) cache is small enough to provide access time of one or two cycles. The second level (L2) cache is larger and therefore a bit slower”article, stated

Gotchas (what bit them)

Generative inference is too expensive for the raw candidate space.

Root cause: The catalog has millions of candidate category/product-type pairs, and GenAI inference is costly.

Resolution: Use predictive AI thresholds to reduce candidates from millions to thousands before applying generative AI.

“As ML inference using Generative AI technology is costly, we do not run Generative AI models for all the millions of candidate pairs.”article, stated
“This reduces the total number of candidate pairs to select from millions to thousands.”article, stated

Customer engagement data can be a noisy training signal.

Root cause: Customers may click items accidentally or out of curiosity, so click behavior does not reliably indicate category relevance.

Resolution: Use a limited amount of human-labeled data for training and evaluation instead of relying on engagement logs.

“customer engagement data (which is noisy as sometimes customers might click on items by mistake or out of curiosity)”article, stated
“by leveraging a limited amount of human-labeled data. This makes the model effective for both frequently and rarely visited parts of our product hierarchies.”article, stated

Hierarchy representation matters for LLM relevance reasoning.

Root cause: Using only node names loses tree context needed to understand how a product type relates to a category path.

Resolution: Pass the full root-to-node path string and instruct the model to weight the leaf node more heavily.

“Utilizing the entire path representation (root-to-the-node) as a string, rather than just context node names, proved essential.”article, stated
“instructing GenAI to give higher importance to the leaf node during relevance assessment led to a marked improvement in the quality of the generated reasoning.”article, stated

The production backend cannot scan offline mappings on request.

Root cause: Several thousand categories times hundreds of product types produce millions of offline rows, but the service needs millisecond responses.

Resolution: Use L1 and L2 LRU caches for Category-to-ProductType mappings, querying primary storage only on cache miss.

“the resulting data set can lead to several million rows of offline data.”article, stated
“To minimize the time taken to access entries from our primary storage, we use a two-tier caching system with LRU caching mechanism.”article, stated

Automated categorization still encounters production edge cases.

Root cause: Even with lower false-positive rates, deployed systems see cases outside the model's reliable operating envelope.

Resolution: Deploy an exception-handling tool powered by ML and human intervention.

“we still could have faced some challenges after deploying the system in production. To handle any edge case, we developed an exception handling tool”article, stated

Evaluation

Walmart uses human-labeled data to tune predictive-model hyperparameters, set confidence thresholds at a fixed false-positive rate, compare precision/recall/F1/TPR/FPR metrics, and validate that the predictive-plus-generative ensemble performs best on a validation set.

Metrics: precision · recall · F1 · true positive rate · false positive rate · fixed FPR confidence thresholds · validation-set ensemble performance

3 supporting quotes
“For training, we choose the best hyperparameter based on a human-labeled set.”article, stated
“we utilize multiple metrics such as precision, recall, f1, true positive rate (TPR) and false positive rates (FPR).”article, stated
“On a validation set, this ensemble of Predictive and Generative AI models showed the best performance.”article, stated

Outcomes

The article is unusually concrete about production scale: 400 million SKUs, several thousand categories, hundreds of product types, millions of offline rows, and few-millisecond SLA expectations. It does not disclose exact precision/recall numbers for the final ensemble.

3 supporting quotes
“Ghotok harnesses this relationship between a category and a product type.”article, stated
“This method proved instrumental in enhancing the adherence of our generative model to system prompts, thereby improving the quality of the output.”article, stated
“Through this sophisticated categorization system, whether you are shopping for beauty products, electronics, or toys, Walmart’s digital platform makes your search quick, easy, and precise”article, stated