KLARNA - Language Models and Knowledge Graphs: A Systems Approach
neo4j
248 views
32 slides
May 22, 2024
Slide 1 of 32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
About This Presentation
Lucas Smedley, Product Manager, Klarna
Tales from explorations into the synergies of LLMs and Knowledge Graphs.
Size: 72.51 KB
Language: en
Added: May 22, 2024
Slides: 32 pages
Slide Content
Unlocking the Potential of Knowledge
Graphs and LLMs: A Systems Approach
Lucas Smedley | Applied AI at Klarna
LLMs and knowledge graphs are currently
in a state of purgatory
Heaven*Hell
KGs x LLMs
* heaven = production grade applications and systems
Rebuild our knowledge graph stack from the ground up with LLMs embedded
throughout, in order to maximise their potential.
We must take a systems approach to integrating
LLMs with knowledge graphs
●Knowledge is patterns
○LLMs and patterns
○Knowledge graphs and patterns
●Current state of integration between knowledge graphs and LLMs
○The challenges of production use cases
●The future and how we can get there
○Taking a systems approach
○Helpful tips
Today we will cover:
Knowledge and intelligence is just pattern
recognition
Knowledge| Current State | Future State
How do we know a dog is a dog?
Knowledge| Current State | Future State
Pattern: Four legs, a tail, barking, a wet nose, arguing with a cat.
How do we know a dog is a dog?
Knowledge| Current State | Future State
How do we know when someone likes us?
Knowledge| Current State | Future State
Pattern: Eye contact, making time for you and showing interest. Laughing at our bad
jokes.
How do we know when someone likes us?
Knowledge| Current State | Future State
How do we detect fraud in financial transactions?
Knowledge| Current State | Future State
Pattern: Unusual spending patterns; transactions across multiple geographies in a short
space of time, transactions at unusual times, transactions on unexpected good or
services.
How do we detect fraud in financial transactions?
Knowledge| Current State | Future State
For LLMs pattern prediction is grounded in predicting the next token accurately. In
order to do this, they in turn develop intelligence.
LLMs are just large scale pattern recognition and
prediction engines
Knowledge| Current State | Future State
Knowledge graphs are our opinionated version of the
patterns in the world we care about
Our knowledge graph schemas, ontologies and taxonomies are effectively the data
points and patterns in the world we care about within a certain context.
Knowledge| Current State | Future State
Pattern in a regular DB:
DogCat
Knowledge| Current State | Future State
Graphs are much richer:
DogCat
Eats
Knowledge| Current State | Future State
Graphs are much richer:
DogCat
Loves
Knowledge| Current State | Future State
By focusing on patterns, we can design systems where LLMs and knowledge graphs are
interoperable and intrinsically connected.
Both technologies are complementary. LLMs are very good at at synthesizing large
quantities of unstructured data. Knowledge graphs provide frameworks for structured,
easily navigable representations of that information.
Knowledge Graphs and LLMs are similar in their focus
on patterns
Knowledge| Current State | Future State
Knowledge Graphs and LLM’s:
The Current State of the Play
Knowledge | Current State| Future State
Typically involves turning a natural language query into a structured cypher query,
which is executed against a graph. The result is then turned into a natural language
answer.
Use Case 1: Using LLMs to Query graphs
Knowledge | Current State| Future State
Involves taking unstructured information and processing to into more structured
information of a knowledge graph.
Use Case 2: Using LLM’s to build knowledge graphs
Knowledge | Current State| Future State
●Often results don’t work at production scale and complexity graphs
But we are encountering a lot issues
Knowledge | Current State| Future State
●Often results don’t work at production scale and complexity graphs
●Querying graphs
○LLMs don’t receive enough information to generate correct cypher queries
○Schemas have not been designed with querying in mind
○Infrastructure is not optimised for LLMs
But we are encountering a lot issues
Knowledge | Current State| Future State
●Often results don’t work at production scale and complexity graphs
●Querying graphs
○LLMs don’t receive enough information to generate correct cypher queries
○Schemas have not been designed with querying in mind
○Infrastructure is not optimised for LLMs
●Building Graphs
○Examples are often shown with ‘schemaless’ graphs
○Unable to handle edge cases
○Unreliable output when populating graphs
○Generated schemas are of low quality
But we are encountering a lot issues
Knowledge | Current State| Future State
Current solution space for KGs and LLMs
BuildingQuerying
Knowledge | Current State| Future State
BuildingQuerying
Informs
To reach production we need to have a greater focus
on building the system
Knowledge | Current State| Future State
So how do we get there?
SolutionsSystems
Knowledge | Current State| Future State
Objective: building schemas effectively
We should treat our LLM like a new employee in terms of the context we provide
Building and populating graphs
Knowledge | Current State| Future State
Node 1:
* Supplier name: Firenze Inc
* Location: Italy
Building and populating graphs with the system
in mind
Node 2:
* Supplier name: Firenze Inc
* Location: Italy
* Desc: Producer of high
quality knitwear and wool
garments
Query: find me a jumper supplier in italy?
Knowledge | Current State| Future State
Objective: turn the messy into structured
Let’s lean into our better documentation and structured frameworks like Pydantic to do
better extraction.
Populating graphs
Knowledge | Current State| Future State
Objective: use queries and responses to feedback and improve the system
Cache queries and cypher and pass as few-shot examples to the LLM
Adjust schemas or add descriptions and relationships based on querying difficulties.
Querying and improving the system
Knowledge | Current State| Future State
Today we covered:
●Knowledge is patterns
○LLMs and patterns
○Knowledge graphs and patterns
●Current state of integration between knowledge graphs and LLMs
○The challenges of production use cases
●The future and how we can get there
○Taking a systems approach
○Helpful tips
Knowledge | Current State| Future State
●Intro to LLMS
●Pydantic is all you need
●Ilya on Dwarkesh podcast
Essential reading:
SolutionsSystems