Building a Commonsense Knowledge Graph for E-commerce Product Recommendations

amazon · E-commerce · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (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: E-commerce recommendation with commonsense reasoning

Amazon needed recommendation models to infer commonsense relationships between customer queries, products, audiences, functions, and contexts, such as understanding why slip-resistant shoes might fit a query for pregnant women.

Constraints:

Architecture

Amazon built COSMO, a recursive LLM and human-in-the-loop framework for generating e-commerce commonsense knowledge graphs. An LLM proposes hypotheses from query-purchase and co-purchase data, machine learning and heuristics filter candidates, human annotators assess plausibility and typicality, reviewers extract guiding principles, and refined instructions prompt the LLM to produce higher-quality entity-relation-entity triples used by recommendation models.

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

flowchart LR
  customer-interaction-pairs[Customer interaction pairs] --> noise-pruning[Noise pruning]
  noise-pruning --> llm-hypothesis-generator[LLM hypothesis generator]
  llm-hypothesis-generator --> human-ml-filter[Human ML filter]
  human-ml-filter --> guiding-principles[Guiding principles]
  guiding-principles --> knowledge-graph[Knowledge graph]
  knowledge-graph --> recommendation-model[Recommendation model]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Customer interaction pairs Query-purchase and co-purchase data mined from the Amazon Store. Noise pruning
Noise pruning Filters low-quality co-purchase pairs such as distant product categories. Customer interaction pairs, LLM hypothesis generator
LLM hypothesis generator Generates candidate commonsense relationship hypotheses. Noise pruning, Human ML filter
Human ML filter Combines human annotation and machine learning to remove low-quality hypotheses. LLM hypothesis generator, Guiding principles
Guiding principles Reviewer-derived instructions used to improve later LLM prompts. Human ML filter, Knowledge graph
Knowledge graph Entity-relation-entity triples encoding product commonsense. Guiding principles, Recommendation model
Recommendation model Bi-encoder or cross-encoder relevance model augmented with COSMO relationships. Knowledge graph

Data flow

Query-purchase and co-purchase pairs are pruned for noise, passed to an LLM to generate commonsense relationship hypotheses, filtered by machine learning models and human annotation, converted into entity-relation-entity triples, assembled into a knowledge graph, and supplied to cross-encoder product-query relevance models.

3 supporting quotes
“COSMO involves a recursive procedure in which an LLM generates hypotheses about the commonsense implications of query-purchase and co-purchase data”article, stated
“a combination of human annotation and machine learning models filters out the low-quality hypotheses”article, stated
“The result is a set of entity-relation-entity triples, such as <co-purchase of camera case and screen protector_, capableOf, _protecting camera>, from which we assemble a knowledge graph.”article, stated

Why this architecture

The architecture converts implicit behavior into explicit commonsense relationships while keeping humans in the loop for plausibility. Feeding these relationships into cross-encoder relevance models helps product search match queries that require reasoning beyond lexical similarity.

“we’re building a knowledge graph that encodes relationships between products in the Amazon Store and the human contexts in which they play a role”article, stated
“In the cross-encoder, all the relevant features of both the query and the product description pass to the same encoder.”article, stated

Models used: large language model · bi-encoder · cross-encoder

Scale

Alternatives considered (roads not taken)

Use query-product pairs without COSMO relationships

Rejected because: The COSMO-seeded cross-encoder outperformed the baseline when relevant triples were added.

“a second cross-encoder received query-product pairs, along with relevant triples from the COSMO knowledge graph”article, stated

Rely only on model-generated hypotheses

Rejected because: Human annotation and reviewer-derived principles filter and improve low-quality hypotheses.

“human reviewers extract guiding principles from the high-quality hypotheses”article, stated

Patterns

human-in-the-loop-gate (data-quality)

Human annotators assess plausibility and typicality of candidate commonsense relationships.

“we send to human annotators for assessment according to two criteria: plausibility”article, stated

synthetic-data-generation (knowledge-generation)

LLMs generate commonsense hypotheses and triples from behavior-derived pairs.

“an LLM generates hypotheses about the commonsense implications”article, stated

retrieval-ranking (ranking)

COSMO relationships are evaluated by product-query relevance ranking models.

“were tasked with finding the products most relevant to each query.”article, stated

Tradeoffs

Model architecture for evaluation

Chose cross-encoder with COSMO relationships over bi-encoder or cross-encoder without graph relationships.

Rationale: The COSMO-seeded model produced stronger F1 results.

“the COSMO-based model dramatically outperformed the best-performing baseline”article, stated

Knowledge generation loop

Chose recursive LLM plus human/ML filtering over one-pass LLM graph generation.

Rationale: Guiding principles from high-quality hypotheses refine subsequent LLM prompts.

“instructions based on those principles are used to prompt the LLM.”article, stated

Gotchas (what bit them)

Customer behavior data contains noisy co-purchase relationships.

Root cause: Some co-purchases are too far apart in the product graph to imply useful commonsense.

Resolution: Prune pairs and filter candidate hypotheses with ML and human annotation.

“removing co-purchase pairs in which the product categories of the purchased products are too far apart in the Amazon product graph.”article, stated

Commonsense relationships need both plausibility and typicality.

Root cause: A relationship can be reasonable but not commonly associated with the query or source product.

Resolution: Ask human annotators to assess both criteria.

“plausibility, or whether the posited inferential relationship is reasonable, and typicality”article, stated

Evaluation

Amazon evaluated COSMO on the Shopping Queries Data Set with bi-encoder, cross-encoder, and COSMO-augmented cross-encoder models, using macro-F1 and micro-F1 in frozen and fine-tuned settings.

Metrics: macro F1 · micro F1 · 60% macro-F1 improvement · 28% macro-F1 edge · 22% micro-F1 edge

“We measured performance using two different F1 scores: macro F1 is an average of F1 scores in different categories”article, stated

Outcomes

The work is evaluated on Amazon's Shopping Queries Data Set and presented as a SIGMOD 2024 framework.

“the COSMO model maintained an edge of more than 20% on both F1 measures.”article, stated