---
topic: ai-technology
author: Crashtech Editorial
published: Nov 17, 2026 · read: 4 min
---

Inside Amazon COSMO: Commonsense Knowledge Graphs for E-Commerce Intent

How Amazon built COSMO, using LLMs to construct a commonsense knowledge graph that decodes implicit customer intent beyond literal keyword search.

– –

Consider a classic e-commerce search failure: A customer types “shoes for pregnant women” into an online store.

Traditional search engines rely on lexical keyword matching (BM25) and basic collaborative filtering. They scan product titles and descriptions for words like “shoes” and “pregnant”. But shoe manufacturers rarely write “pregnant” on their product packaging; they write “slip-on”, “low arch support”, “breathable mesh”, and “anti-slip rubber sole”.

As a result, traditional search returns either zero results or irrelevant pregnancy clothing that happens to mention shoes.

To bridge this semantic canyon, Amazon developed COSMO (Commonsense Knowledge Generation and Alignment). Rather than relying on surface-level keyword overlap or opaque vector embeddings, COSMO uses Large Language Models to construct a massive, grounded Commonsense Knowledge Graph that decodes implicit human intent.

This article examines how COSMO works, how Amazon mines commonsense relationships from billions of user interactions, and how the system serves real-time recommendations under strict latency budgets.


The Semantic Gap in E-Commerce

Human purchase decisions are governed by real-world causal context:

  • A pregnant woman needs shoes that are easy to slip on without bending over and provide shock absorption for swollen feet.
  • Someone buying a “tent for cold weather” needs high thermal retention, wind-resistant poles, and waterproof seams.
  • Someone searching “camping with toddlers” needs child-safe bug spray, packable travel cribs, and low-profile camp chairs.

Traditional catalog metadata describes the attributes of the object (color, material, dimensions). It completely ignores the context of the human user (life stage, physiological constraints, physical environment).

Customer Search: "camping with toddler"
         │
         ▼ (The Vocabulary Chasm)
Product Catalog: "Collapsible nylon chair, 1.2kg, aluminum frame"

Amazon COSMO: Commonsense Knowledge Graph for E-Commerce


The COSMO Architecture

COSMO operates as a two-stage system: Offline Commonsense Knowledge Mining and Online Real-Time Serving.

1. Offline Knowledge Graph Construction

To extract commonsense relationships without drowning in hallucinations, Amazon prompts instruction-tuned LLMs with user co-purchase sessions, search reformulations, and product descriptions.

The knowledge graph is modeled around standardized predicate relationships:

  • (User Condition: Pregnant) ──[Causes Constraint]──► (Swollen Feet / Limited Mobility)
  • (Constraint: Limited Mobility) ──[Demands Feature]──► (Hands-Free Slip-On)
  • (Product: Loafers) ──[Satisfies Feature]──► (Hands-Free Slip-On)

To eliminate noisy or factually incorrect relationships generated by LLMs, Amazon runs a multi-tier filtering pipeline:

  1. Semantic Alignment Verification: Checks whether human evaluators and co-purchase behavior support the extracted relationship.
  2. Frequency Grounding: Discards long-tail hallucinated edges that lack empirical support in behavioral click logs.
  3. Graph Consolidation: Embeds millions of entities into a shared knowledge graph containing billions of directed edges.

2. Online Serving: Real-Time Intent Reranking

A knowledge graph containing billions of nodes cannot be traversed with multi-hop graph queries during a 30-millisecond search request.

To meet Amazon’s strict search latency SLAs:

  1. Query Intent Extraction: When a customer searches “shoes for pregnant women”, an offline-distilled neural classifier identifies the latent user condition (Pregnancy) and maps it to target graph nodes in under 5 milliseconds.
  2. Pre-Materialized Graph Neighborhoods: The target graph nodes point directly to pre-computed attribute vectors stored in high-performance in-memory key-value caches.
  3. Multi-Task Scoring: Candidate products retrieved by the base search engine are rescored by adding a COSMO compatibility bonus:
Final Score = Lexical Match Score + Vector Similarity + COSMO Intent Bonus

If a pair of loafers possesses attributes that satisfy the commonsense needs of the identified user condition, its score increases, promoting it to the top of the search results page.


Production Impact at Amazon Scale

The deployment of COSMO across Amazon’s production infrastructure delivered historic business and relevance improvements:

  • Search Relevance Lift: Improved global search relevance by over +0.7%, a massive gain for an e-commerce platform operating at hundreds of billions of dollars in gross merchandise value.
  • Cold-Start Elimination: New products entering the catalog that lack sales history can immediately rank for complex queries if their physical attributes match commonsense intent nodes.
  • Explainable Recommendations: Because COSMO operates on an explicit knowledge graph rather than a black-box vector dot product, the system can explain its decisions to consumers (“Recommended because you searched for hands-free slip-on shoes”).

Key Takeaways for Machine Learning Engineers

  1. Attributes Must Meet Intent: Describing what an item is is insufficient for search; platforms must model why a customer needs it.
  2. LLMs as Knowledge Compilers: Use high-capacity LLMs offline to compile unstructured behavioral logs into structured, verified graph triples.
  3. Serve Graphs via Distilled Projections: Never query live LLMs or traverse deep graph pointers in the hot path. Project graph insights into in-memory feature vectors to maintain sub-50ms latency.
Advertisement

/* Comments */