Knowledge Graph Completion Models are Few-shot Learners: An Empirical Study of Relation Labeling in E-commerce with LLMs

Jiao Chen, Luyi Ma, Xiaohan Li, Nikhil Thakurdesai, Jianpeng Xu, Jason H. D. Cho, Kaushiki Nag, Evren Korpeoglu, Sushant Kumar, Kannan AchanarXiv 2023

TL;DR

This paper demonstrates that Large Language Models (LLMs) like PaLM and GPT-3.5 can act as highly effective few-shot learners for Knowledge Graph Completion (KGC) in e-commerce. By leveraging prompt engineering, LLMs significantly outperform traditional graph embedding models at labeling product relationships (e.g., complementary or substitutable) and achieve performance competitive enough to potentially replace expensive human annotation.

What Problem Does This Paper Address?

E-commerce platforms rely heavily on Knowledge Graphs (KGs) to map relationships between product types, which directly powers downstream recommendation engines (e.g., suggesting a phone case when you buy a smartphone). However, expanding and completing these KGs through relation labeling is notoriously difficult.

Traditional KGC models require massive amounts of structured training data to learn graph embeddings. In the real world, e-commerce catalogs change dynamically, labeled data is scarce, and human annotation is slow and expensive. Furthermore, traditional models struggle with "cold-start" scenarios where new or rare product types have no prior structural connections in the graph.

Methods

Instead of training specialized graph neural networks, the authors treat relation labeling as a natural language inference task handled by off-the-shelf LLMs (specifically Google's PaLM and OpenAI's GPT-3.5).

The core methodology revolves around systematic Prompt Engineering guided by four principles:

  1. Clarity: Explicitly defining the target relations (is_complementary_to, is_substitutable_for, is_irrelevant_to).
  2. Relevance: Assigning a specific persona to the LLM (e.g., "You are now a customer...").
  3. Format: Structuring inputs and outputs into clean, readable markdown tables.
  4. Few-shot Learning: Providing a minimal set of labeled examples (1 to 5 pairs) within the prompt context to guide the model.

The authors evaluated the models under both independent human labeling conditions and dependent human relabeling conditions, where human annotators were shown the LLM's predictions alongside its generated natural language explanations.

Fig. 1. Prompt examples with different principles.

Datasets

The approach was benchmarked on two distinct datasets:

  • Electronics Dataset: A proprietary dataset sampled from Walmart's Electronics department containing 1,045 product type pairs.
  • Instacart Dataset: A public dataset containing 400 product type pairs sampled based on co-occurrence frequencies from online grocery shopping data.

Ground truth for both datasets was established via crowdsourced human consensus.

Key Insights and Ideas

  • Semantic Knowledge Trumps Graph Structure: LLMs succeed at KGC because they possess deep semantic knowledge about real-world objects from pre-training. They don't need to see a graph structure to know that "canned jarred vegetables" and "milk" are generally irrelevant to each other.
  • Explanations as a Truth Mechanism: In subjective domains like grocery shopping (where dietary habits influence what is considered "complementary"), the LLM's ability to generate text explanations proved invaluable. When human labelers reviewed the LLM's reasoning, they frequently changed their own incorrect or biased labels to match the LLM's predictions.
  • Robustness to Data Scarcity: Traditional KG models suffer severe performance drops when training data is limited. LLMs maintain high accuracy even with zero or few-shot prompts, making them highly scalable for niche or newly introduced product categories.

Key Results

  • Massive Gains Over Baseline KG Models: PaLM outperformed eight state-of-the-art traditional KG completion models (including TransE, DistMult, and CompGCN) by a minimum margin of 40.6% in accuracy across both datasets.
Fig. 2. Comparision of accuracy between KG models and the LLM in the Electornics and Instacart dataset.
  • Prompt Engineering Dividends: Moving from a basic baseline prompt to a few-shot prompt (with 3 examples) boosted PaLM's accuracy on the Electronics dataset from 0.575 to 0.738—a 28.3% relative improvement.
  • Human-Level Performance: In the dependent labeling experiment, providing LLM explanations helped align human-model agreement up to an accuracy score of 0.82 on the Instacart dataset, proving that LLM outputs are high enough quality to augment or replace human workflows.

Limitations and Future Work

  • Class Imbalance: Both datasets suffered from a severe lack of positive substitutable examples (e.g., only 12 pairs in Electronics). As a result, precision and recall scores for substitutable relations remained relatively low and volatile.
  • Data Privacy Constraints: Due to corporate data privacy policies, the authors could only evaluate GPT-3.5 on the public Instacart dataset, preventing a full head-to-head comparison with PaLM on the Walmart Electronics data.
  • Future Directions: The authors suggest expanding the use of LLMs to other complex e-commerce graph tasks, such as automated product taxonomy generation and item description summarization.

Summary updated

BibTeX
@misc{chen2023knowledge,
  author = {Jiao Chen and Luyi Ma and Xiaohan Li and Nikhil Thakurdesai and Jianpeng Xu and Jason H. D. Cho and Kaushiki Nag and Evren Korpeoglu and Sushant Kumar and Kannan Achan},
  title = {{Knowledge Graph Completion Models are Few-shot Learners: An Empirical Study of Relation Labeling in E-commerce with LLMs}},
  year = {2023},
  eprint = {2305.09858},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2305.09858},
}
Figure