SlideShare a Scribd company logo
Applying Retrieval-Augmented Generation (RAG)
to Combat Hallucinations in GenAI
Auckland AWS User Group - July 2024
Geethika Guruge
Lead Consultant @ Mantel Group
AWS Ambassador | AWS Community Builder
850+ team members
Offices across Australia and New Zealand
Voted Best Place to Work in 2021 and 2022
Operating at over 150 clients
Changing how the world works for the better.
Agenda
● GenAI Beyond the Buzz
● Customizing Foundation Models
● What is RAG
● The complicated workflow
● Amazon Bedrock to the Rescue
● Demo
Changing how the world works for the better.
Remember this???
Changing how the world works for the better.
GenAI Beyond the Buzz
Changing how the world works for the better.
Why Customize
GPT = Generative Pre-trained Transformers,
Model doesn't know your domain
Changing how the world works for the better.
Why Customize
● Adapt to domain specific language
○ Health care terminology
○ Medical devices
● Enhance Performance
○ Teach the model about the specialised tasks your organization does
● Improve context awareness in responses
○ Provide the model with external data
○ Company intranet
○ Your code base
Changing how the world works for the better.
Customization Options
● Prompt Engineering (Craft and Iterate upon the input)
○ Priming
○ Weigiting
○ Chaining
● RAG
○ Leveraging external knowledge sources
○ NOT changing anything in the foundation model
● Fine-tune
○ Adapt a foundation model on a specialized task set
○ Training the foundation model on labeled examples of tasks
○ Specifying the expected output and outcome
● Re-train
Changing how the world works for the better.
Customization Effort
Changing how the world works for the better.
What is RAG
● Retrieval
○ Fetches the relevant content from the external knowledge base
● Argumentation
○ Argument the retrieved context to the user prompt
● Generation
○ Response from the foundation model based on the augmented prompt
Changing how the world works for the better.
Types of Retrieval
● Rule based
○ Unstructured data
○ Keyword searches
● Structured data
○ Retrieval from a database
○ i.e Select cases where resolution like reboot
● Semantic search
○ Get relevant documents based on text embedding
Changing how the world works for the better.
What are Embeddings
● Numerical representation of text (vectors)
● Captures semantics and relationships between words.
● Embedding models capture features and nuances of the text.
● Rich embeddings can be used to compare text similarity.
● Multilingual Text Embeddings can identify meaning in different languages.
Changing how the world works for the better.
What are Embeddings
Changing how the world works for the better.
Importance of Embedding in RAG
● Powers text retrieval based on semantic meaning.
● Used to augment prompts with more accurate context from vector stores
● High-accuracy embeddings leads to improved context and higher quality responses
Less Hallucinations !!!!!!
Changing how the world works for the better.
RAG in Action
Changing how the world works for the better.
Knowledge Bases for Amazon Bedrock
Changing how the world works for the better.
Retrieval and Generate
Changing how the world works for the better.
RetrieveAndGenerate API
Changing how the world works for the better.
Demo Time!!!!!

More Related Content

Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI

  • 1. Applying Retrieval-Augmented Generation (RAG) to Combat Hallucinations in GenAI Auckland AWS User Group - July 2024 Geethika Guruge Lead Consultant @ Mantel Group AWS Ambassador | AWS Community Builder
  • 2. 850+ team members Offices across Australia and New Zealand Voted Best Place to Work in 2021 and 2022 Operating at over 150 clients
  • 3. Changing how the world works for the better. Agenda ● GenAI Beyond the Buzz ● Customizing Foundation Models ● What is RAG ● The complicated workflow ● Amazon Bedrock to the Rescue ● Demo
  • 4. Changing how the world works for the better. Remember this???
  • 5. Changing how the world works for the better. GenAI Beyond the Buzz
  • 6. Changing how the world works for the better. Why Customize GPT = Generative Pre-trained Transformers, Model doesn't know your domain
  • 7. Changing how the world works for the better. Why Customize ● Adapt to domain specific language ○ Health care terminology ○ Medical devices ● Enhance Performance ○ Teach the model about the specialised tasks your organization does ● Improve context awareness in responses ○ Provide the model with external data ○ Company intranet ○ Your code base
  • 8. Changing how the world works for the better. Customization Options ● Prompt Engineering (Craft and Iterate upon the input) ○ Priming ○ Weigiting ○ Chaining ● RAG ○ Leveraging external knowledge sources ○ NOT changing anything in the foundation model ● Fine-tune ○ Adapt a foundation model on a specialized task set ○ Training the foundation model on labeled examples of tasks ○ Specifying the expected output and outcome ● Re-train
  • 9. Changing how the world works for the better. Customization Effort
  • 10. Changing how the world works for the better. What is RAG ● Retrieval ○ Fetches the relevant content from the external knowledge base ● Argumentation ○ Argument the retrieved context to the user prompt ● Generation ○ Response from the foundation model based on the augmented prompt
  • 11. Changing how the world works for the better. Types of Retrieval ● Rule based ○ Unstructured data ○ Keyword searches ● Structured data ○ Retrieval from a database ○ i.e Select cases where resolution like reboot ● Semantic search ○ Get relevant documents based on text embedding
  • 12. Changing how the world works for the better. What are Embeddings ● Numerical representation of text (vectors) ● Captures semantics and relationships between words. ● Embedding models capture features and nuances of the text. ● Rich embeddings can be used to compare text similarity. ● Multilingual Text Embeddings can identify meaning in different languages.
  • 13. Changing how the world works for the better. What are Embeddings
  • 14. Changing how the world works for the better. Importance of Embedding in RAG ● Powers text retrieval based on semantic meaning. ● Used to augment prompts with more accurate context from vector stores ● High-accuracy embeddings leads to improved context and higher quality responses Less Hallucinations !!!!!!
  • 15. Changing how the world works for the better. RAG in Action
  • 16. Changing how the world works for the better. Knowledge Bases for Amazon Bedrock
  • 17. Changing how the world works for the better. Retrieval and Generate
  • 18. Changing how the world works for the better. RetrieveAndGenerate API
  • 19. Changing how the world works for the better. Demo Time!!!!!