Building a knowledge graph with ChatGPT

Written byCapria Value-Add
November 4, 2024

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /home/u876752588/domains/capria.vc/public_html/wp-content/plugins/jet-engine/includes/components/blocks-views/dynamic-content/manager.php on line 113

Constructing a knowledge graph from raw text data using OpenAI’s GPT-3.5-turbo enables us to visualize and analyze relationships between entities such as products, brands, and features. This example focuses on extracting structured data from Amazon product descriptions and organizing it into a knowledge graph, leveraging Schema.org’s ontology for standardized definitions.

Capria Ventures - artificial intelligence concept picture id1160995648 100855293 large 100912931 orig 1

Key Concepts of Knowledge Graphs

A knowledge graph represents entities and their relationships through triplets, structured as:

  • Triplet Structure: Each triplet consists of a head (subject) → relation (predicate) → tail (object), allowing us to capture details like product attributes or brand relationships.
  • Ontology: A knowledge graph often includes an ontology to define concepts, relationships, and properties within a domain. Here, Schema.org provides standardized labels for product data, like “Product,” “Brand,” and “Color.”

Building a Knowledge Graph from Product Data

  1. Dataset Preparation:
    • Product descriptions are compiled into a single column containing titles, bullet points, and full descriptions, forming the raw input for ChatGPT to analyze.
  2. Entity and Relation Extraction with ChatGPT:
    • Using prompts, ChatGPT is guided to identify and extract specific entity types and relations from the product text, outputting data as JSON objects with fields such as head, head_type, relation, tail, and tail_type.
    • Predefined entity types (e.g., “product,” “brand,” “color”) and relation types (e.g., “hasBrand,” “hasColor”) align with Schema.org properties, ensuring compatibility with standard web data formats.
  3. Entity Resolution for Consistency:
    • To reduce redundancies, entity resolution merges similar entities (e.g., “Microsoft” and “Microsoft Inc.”) by comparing their semantic similarity. This step is crucial for maintaining a consistent and concise knowledge graph.
  4. Visualization of Knowledge Graph:
    • The extracted entities and relations are organized into a graph structure, where nodes represent entities, and edges represent relationships.
    • Visualizing this graph reveals products connections based on shared features, enabling insights into product attributes, commonalities, and potential relationships within the data.

Benefits and Applications

Creating a knowledge graph from unstructured product descriptions helps unlock value from data that would otherwise remain hidden. This approach organizes product information for quick reference, trend analysis, or recommendation systems. By structuring data with a common ontology, knowledge graphs allow easier integration with web-based systems and other applications using standardized data formats.

This method demonstrates how large language models can automate data structuring from raw text, offering a straightforward approach to transforming unstructured data into usable insights.

Subscribe to GAIN Newsletter

Be the first to hear the latest investment updates, AI tech trends, and partner insights from Capria Ventures by subscribing to our monthly newsletter. 

Report a Grievance

Capria Ventures and its related entities are committed to the highest standards of ethics and strictly enforce a zero-tolerance anti-corruption policy. Please report any suspicious activity to grievance@capria.vc. All reports will be treated with utmost urgency and resolved appropriately.

Unitus Ventures is now Capria India

Unitus Ventures, a leading venture capital firm in India, is joining forces with its US affiliate Capria Ventures, a Global South specialist, to operate with a unified global strategy under a single brand, Capria Ventures. 

Chat with Capria GainBot
Hello! I'm GAINBOT, here to share interesting insights from Capria's webpages. Feel free to search for anything you'd like to learn about.