Steering LLMs with Knowledge Graphs
Cognitivo Team
Team
LLMs are trained on a wide corpus of highly general text. Through that process, they are able to build a response that represents the highest statistical probably of words that consitutes a response.
Words are transformed into vector representation which provide a mathematical represenation of the human language where meaning can start to be associated. Word2vec, one of the technologies underpinning LLMs is a technique in natural languageprocessing (NLP) for obtaining vector representations of words. These vectorscapture information about the meaning of the word based on the surroundingwords. The word2vec algorithm estimates these representations by modelling textin a large corpus.

Word2Vec
Since large language models are targeted to be useful for all humans, they are trained with very public data sources, e.g. wikipedia. This means they do not contain industry domain or even company specific data. I use the analogy of an english literature student who's is versed in Shakespeare will not understand anything about the finance industry, even though they may be able to say all the words within the text book.
Fine tuning is an approach where a pre-trained language model can have additional data added that may be domain specific. A commonly cited example is where Bloomberg's supposedly fine-tuned a PLM (ChatGPT 3.5 generation) with their own inhouse financial data and within a very short timeframe the based language model was surpassed by Chat GPT 4.0. Whether the exact details are true or not, what is eveident i sthat the base LLMs are still developing so fast that fine-tuning outside of a large foundational LLM is an expensive move with very limited benefit.
In late 2023, RAG emerged as another way to enhance pretrained language models. Retrieval Augmented Generation is a process where additional, or more up to date information can be added to the response generation and added as context within the prompt.
If you have a conversation with someone, you don't try to remember the entire conversation, you remember the ideas behind it. The process of abstraction is a key component to what allows humans to "think."
LLM's are in effect an interface between computer systems with humans by the use of words or verbal communication. Humans do not need to learn a computer-specific language such as SQL. However while LLMS give the illusion of fluency, however are currently still very poor at reasoning. Language is created by mind, yet, once uttered, words return to the mind, where they are understood. [Language andCognition, Perlovesky and Sakai, 2014]
“Cognitive powers developed in animals and humans, culminating in the invention of language and abstract thinking” [Conciselaws of human nature, Robert Greene]
From a technical standpoint, the process of compressing text into abstract ideas, in otherwords less text has been called token compression.

So what is a knowledge graph?
A knowledge graph is agood way to represent concepts and the relationships between concepts. In knowledge
A knowledge graph is a knowledge base that uses a graph-structured data model or topology to represent and operate on data. Knowledge graphs are often used to store interlinked descriptions of entities – objects, events, situations or abstract concepts – while also encoding the free-form semantics or relationships underlying these entities. A knowledge graph formally represents semantics by describing entities and their relationships.[26] Knowledge graphs may make use of ontologies as a schema layer. By doing this, they allow logical inference for retrieving implicit knowledge rather than only allowing queries requesting explicit knowledge.[27] (Wikipedia)

Knowledge Graph
From the example above, we can evaluate a question such as does the Queen of the UK live in London, without that piece of information being explicitly stated.
So knowledge graphs are an effective way of representing structured human knowledge, without the need to explicitly define every way of representing that knowledge. And LLMs are a very good human-computer verbal interface.
Adding an ontology to a body of text provides a topic structure backbone, that can reduce hullicnations in LLMs caused by ambiguities in language (e.g. homonymns)

By combining Knowledge Graphs with LLMS in RAG pipelines, we have the ability to inject logical deduction using Knowledge Graph Q&A (KGQA) over structured data into a LLM pipeline in a process called Graph-RAG.
In the paper Unifying Large Language Models and Knowledge Graphs: A Roadmap (https://arxiv.org/abs/2306.08302) Pan, Luo et al discuss techniques for integrating Knowledge Graphs with LLMs. Cognitivo is actively working on many applications and techniques to achieve LLM+KG integration in the field.
I will focus on explaining one example of token compression within this article.

In an R&D experiment, working with one of Australia's Major Banks, we an unassisted chatbot, to demonstrate the ability to steer a LLM through Knowledge Graph integration.
The application had the ability to:
- Transcribe digital interviews, where the conversation was processed inreal-time to generate a knowledge graph (semantic map) of abstracted factsdiscussed within the conversation.
- The application could also or fully automate the financial advice interview process based on the information the system wanted to gather within the knowledge graph.
- The knowledge graph was then used to generate an unassisted chatbot interview demonstrating the capability to hold a chain-of-thought conversation
- The knowledge graph had the ability to perform entity alignment which deduplicates similar information offered in different parts of the conversation. i.e. if you told it you had a 1m homeloan or a 1m mortgage, it knew you were talking about the same thing.
Where to next?
- LLM + KG (KGQA) integration is a feature built into Cognitivo's AI Factory platform as part of our NOAI architecture (Not Only AI)
- We are now able to use this technique in subesquent use cases for delivering financial needs analysis within areas such as financial advice and loan origination.
- We have built a product concept called a Client Graph. This is capability is the most fine-grain single customer view capabiltiy developed to date. Old school MDM systems that link customer records to their accounts are very coarse grain. We link a customer down to every conversation and interaction.
- The Client Graph represents a long term memory, providing context into any subsequent agentic process.

We have only scratched the surface, but also only explained the veneer of what has been developed. Reach out to find out more!
https://www.cognitivo.com.au/contact-us
Article by Alan Hsiao, Founder Cognitivo and Senior Visiting Fellow UNSW CSE
Project Engineering Lead, Stephy George, CTO Cognitivo
Credit to Nick Munro for the inspiration.
