AWS Bedrock Knowledge Base Tutorial: RAG with OpenSearch & Titan Embeddings

Analytics Vidhya · Beginner ·🔍 RAG & Vector Search ·4mo ago
Skills: RAG Basics90%

Key Takeaways

AWS Bedrock Knowledge Base creation and configuration with OpenSearch and Titan Embeddings for Retrieval-Augmented Generation, connecting Amazon S3 to a vector database without complex ingestion scripts

Full Transcript

Let's go to creating the second thing which is knowledge basis. So on the search I would mention knowledge basis. We can see Amazon bedrock feature knowledge basis. We'll click on it. every time we just have to ensure that we are in the Mumbai region just to make sure everything works otherwise uh we might see errors in our application. All right. So we'll create a knowledge base. I will select the first option which is knowledge base with vector store which takes us up here. We can give it a nice name. Now the knowledge base itself needs permission to access different services and for that it wants to create a service role. We can mention the data source type which is Amazon S3 that that is where all our documents are. But there are different source types that knowledge bases also supports from which it can fetch these documents and work with them. All right. Click on next. Now because we selected Amazon S3, it is asking where the documents are there in Amazon S3. So we'll just give it a nice name. We'll mention our S3 bucket AB demo geni bucket and we have another option called passing strategy. So this is about how these documents when converted after processing into text should actually be split. And so we'd be using the default parser and then we'd also be using the default chunking strategy. So the parsing of the documents would be done by default Amazon Bedrock service. The chunking strategy is about once the documents are passed, how we'd like to break it into. So we'd be breaking these documents into 300 token in size and then every chunk would then be given to embeddings to be created into numerical format. All right. So what embedding model we would be using to convert this text into numerical format? We'd be using one of the Amazon's default Titan embeddings, Titan text embeddings v2 and then vector store which is finally where to store these embeddings. We'll be using one of the service Amazon open search serverless. So bedrock is going to create that as well for us and simply click on next. We can review everything over here and we'll click on create knowledge base. So this is going to take around 5 minutes to create multiple services and knowledge base is now creating the open search vector database and would then also be creating multiple services at the back. And this is going to simplify our rag processing really easy because knowledge basis takes care of both putting these documents into open search and also whenever we ask question it will do all the embedding all the searching and would simply give us the final results. So we'll wait 5 minutes or we'll wait until this is complete. All right, our knowledge base is finally ready. We can have a look at it. Now we'll go into data source. The S3 bucket that we connected have it actually synced which means there is data inside it but nothing is actually created in terms of vector embeddings. So as we discussed this knowledge base is going to create an open search vector DB. So let's have a look. We'll search open search. We're opening it in a new tab. On the left, we can click on collections and we see there's a bedrock knowledge base collection created. We click on it and indexes. We can see that the whole vector DB is empty. Which means we have to sync these documents and this is very easy in knowledge bases. So if you're in the knowledge base in data source we can select multiple data sources. In this one we just have S3. We click on it and we simply have to click on sync. And now these documents are being fetched. So the PDF that we had is being fetched converted into text using parser. The text is then split by the chunking strategy which is 300 tokens each. Then Titan embeddings are called into every chunk. They are conver converted into numerical formats and along with the numerical format and the text for which those numerical format is generated is then saved into AWS open search. So all of this process is happening at the back. This shows sync complete. Let's refresh the page. And as we can see that the sync history shows that the syncing was done at this time and it is complete. We can also go to the open search vector and we can see that there is index and multiple documents which are present. All right. So this means that all of the right portion over here which is for the rack pipeline is complete. The ingestion of documents is also done and then we have a filled vector DB. We can now start using it into our application. So let's copy the knowledge base ID. So the knowledge base ID is not the name uh but the ID that we can see in the dashboard. So if we click on our knowledge base, we have the knowledge base name and then the knowledge base ID. So I'll just copy the knowledge base ID over here. All right. So now I want to connect to this knowledge base and ask it questions so it can give me back some related relevant documents based on that question. So let's head on to our code and in ENV we'll add this missing piece of knowledge base ID which completes our ENV file end to end. All right.

Original Description

Description In this part of our GenAI series, we dive deep into the heart of the RAG pipeline: AWS Bedrock Knowledge Bases. You will learn how to automate the heavy lifting of Retrieval-Augmented Generation by connecting Amazon S3 to a vector database without writing complex ingestion scripts. In this video, we cover: Knowledge Base Creation: Setting up Bedrock in the Mumbai region (ap-south-1). Data Ingestion: Connecting S3 buckets and configuring parsing strategies. Chunking Logic: How to split documents into 300-token chunks for optimal retrieval. Vector Database Setup: Automatically provisioning Amazon OpenSearch Serverless. Titan Embeddings v2: Using Amazon's latest embedding models to convert text into numerical formats. The Sync Process: A look behind the scenes at how Bedrock parses, chunks, and stores data. App Integration: Locating and using your Knowledge Base ID in your .env file. This setup simplifies the entire RAG process, handling everything from document storage to similarity searching behind the scenes. 🛠 Tech Stack: Amazon Bedrock Amazon OpenSearch Serverless Amazon Titan Text Embeddings v2 Amazon S3
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Analytics Vidhya · Analytics Vidhya · 0 of 60

← Previous Next →
1 The DataHour: Data Science in Retail
The DataHour: Data Science in Retail
Analytics Vidhya
2 The DataHour: Anomaly detection using NLP and Predictive Modeling
The DataHour: Anomaly detection using NLP and Predictive Modeling
Analytics Vidhya
3 The DataHour: Energy Data Science Project from Scratch
The DataHour: Energy Data Science Project from Scratch
Analytics Vidhya
4 The DataHour: Explainable AI Need and Implementation
The DataHour: Explainable AI Need and Implementation
Analytics Vidhya
5 The DataHour: Google Cloud AI/ML
The DataHour: Google Cloud AI/ML
Analytics Vidhya
6 Prediction to Production in Machine Learning #machinelearning #prediction
Prediction to Production in Machine Learning #machinelearning #prediction
Analytics Vidhya
7 Practical Applications of Data science in Ecommerce
Practical Applications of Data science in Ecommerce
Analytics Vidhya
8 How to tackle Overfitting?#machinelearning #overfitting
How to tackle Overfitting?#machinelearning #overfitting
Analytics Vidhya
9 Building Data Pipelines on GCP #googlecloud #datapipelines #data
Building Data Pipelines on GCP #googlecloud #datapipelines #data
Analytics Vidhya
10 Hands-on with A/B Testing #abtesting #datascience
Hands-on with A/B Testing #abtesting #datascience
Analytics Vidhya
11 Efficient Implementations of Transformers #transformers #cnn  #machinelearning
Efficient Implementations of Transformers #transformers #cnn #machinelearning
Analytics Vidhya
12 Modern Deep Learning Architecture #deeplearning  #architecture #deeplearningtutorial
Modern Deep Learning Architecture #deeplearning #architecture #deeplearningtutorial
Analytics Vidhya
13 Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Analytics Vidhya
14 5 things you should know about Azure SQL #azure #sql #datahour #datascience
5 things you should know about Azure SQL #azure #sql #datahour #datascience
Analytics Vidhya
15 AI & ML in the Automotive Industry #machinelearning #ai
AI & ML in the Automotive Industry #machinelearning #ai
Analytics Vidhya
16 Building Machine Learning Models in BigQuery
Building Machine Learning Models in BigQuery
Analytics Vidhya
17 NLP aspects in Telecommunication Industry
NLP aspects in Telecommunication Industry
Analytics Vidhya
18 Practical Time Series Analysis
Practical Time Series Analysis
Analytics Vidhya
19 Fundamentals of Quantum Computing
Fundamentals of Quantum Computing
Analytics Vidhya
20 A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
Analytics Vidhya
21 Classification Machine Learning Model from Scratch
Classification Machine Learning Model from Scratch
Analytics Vidhya
22 Knowledge Graph Solutions using Neo4j
Knowledge Graph Solutions using Neo4j
Analytics Vidhya
23 Model Guesstimation (MLOps)
Model Guesstimation (MLOps)
Analytics Vidhya
24 ETL Pipelines in Google Cloud Platform
ETL Pipelines in Google Cloud Platform
Analytics Vidhya
25 Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Analytics Vidhya
26 Getting Started with AWS EC2 #amazon #aws
Getting Started with AWS EC2 #amazon #aws
Analytics Vidhya
27 How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
Analytics Vidhya
28 Certified AI & ML BlackBelt Plus Program #shorts
Certified AI & ML BlackBelt Plus Program #shorts
Analytics Vidhya
29 Visualizing Data using Python #machinelearning #visualization #python
Visualizing Data using Python #machinelearning #visualization #python
Analytics Vidhya
30 DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
Analytics Vidhya
31 M in ML stands for Math & Magic
M in ML stands for Math & Magic
Analytics Vidhya
32 An Unsupervised ML approach using Clustering
An Unsupervised ML approach using Clustering
Analytics Vidhya
33 Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Analytics Vidhya
34 Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Analytics Vidhya
35 Practical MLOps #mlops #datascience
Practical MLOps #mlops #datascience
Analytics Vidhya
36 Data Engineering with Databricks #dataengineering #databricks
Data Engineering with Databricks #dataengineering #databricks
Analytics Vidhya
37 Multi-Objective Optimisation
Multi-Objective Optimisation
Analytics Vidhya
38 When Airflow Meets Kubernetes
When Airflow Meets Kubernetes
Analytics Vidhya
39 AI in Banking
AI in Banking
Analytics Vidhya
40 Learn Convolutional Neural Network for Image Recognition
Learn Convolutional Neural Network for Image Recognition
Analytics Vidhya
41 Extracting Value from Data
Extracting Value from Data
Analytics Vidhya
42 How to measure Marketing Channel Effectiveness
How to measure Marketing Channel Effectiveness
Analytics Vidhya
43 Transforming Lives | Data Science Immersive Bootcamp
Transforming Lives | Data Science Immersive Bootcamp
Analytics Vidhya
44 Stock Market Analysis - AI driven approach
Stock Market Analysis - AI driven approach
Analytics Vidhya
45 Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Analytics Vidhya
46 Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Analytics Vidhya
47 The Power of Visualization | Tableau Full Course | Analytics Vidhya
The Power of Visualization | Tableau Full Course | Analytics Vidhya
Analytics Vidhya
48 Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Analytics Vidhya
49 Data Visualization in Data Science | DataHour | Analytics Vidhya
Data Visualization in Data Science | DataHour | Analytics Vidhya
Analytics Vidhya
50 Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Analytics Vidhya
51 Solving any Machine Learning Problem | Approach and Steps Involved
Solving any Machine Learning Problem | Approach and Steps Involved
Analytics Vidhya
52 Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Analytics Vidhya
53 Data Engineering in E-Commerce | The Best Case Study
Data Engineering in E-Commerce | The Best Case Study
Analytics Vidhya
54 Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Analytics Vidhya
55 Introduction to Federated Learning | DataHour | Analytics Vidhya
Introduction to Federated Learning | DataHour | Analytics Vidhya
Analytics Vidhya
56 Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Analytics Vidhya
57 Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Analytics Vidhya
58 Learn Hypothesis Testing | DataHour | Analytics Vidhya
Learn Hypothesis Testing | DataHour | Analytics Vidhya
Analytics Vidhya
59 A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
Analytics Vidhya
60 Making AI work for Business | DataHour | Analytics Vidhya
Making AI work for Business | DataHour | Analytics Vidhya
Analytics Vidhya

This video tutorial covers the setup and configuration of AWS Bedrock Knowledge Base with OpenSearch and Titan Embeddings for Retrieval-Augmented Generation, simplifying the RAG process by handling document storage and similarity searching behind the scenes. By following this tutorial, viewers can automate the heavy lifting of RAG and connect Amazon S3 to a vector database without writing complex ingestion scripts. The tutorial provides a step-by-step guide on how to create a Knowledge Base, con

Key Takeaways
  1. Set up Bedrock in the Mumbai region (ap-south-1)
  2. Connect S3 buckets and configure parsing strategies
  3. Split documents into 300-token chunks for optimal retrieval
  4. Automatically provision Amazon OpenSearch Serverless
  5. Use Amazon's latest embedding models (Titan Embeddings v2) to convert text into numerical formats
  6. Locate and use your Knowledge Base ID in your .env file
💡 The AWS Bedrock Knowledge Base simplifies the entire RAG process by handling everything from document storage to similarity searching behind the scenes, making it easier to automate the heavy lifting of Retrieval-Augmented Generation

Related Reads

📰
Building Trustworthy Production RAG Systems Through Continuous Evaluation
Learn to build trustworthy production RAG systems through continuous evaluation to catch retrieval failures and performance drift
Towards Data Science
📰
Most RAG Hallucinations Are Retrieval Failures: How the Retrieval Brick Decides What the Model Can Invent
Learn how RAG hallucinations are often caused by retrieval failures and how fixing retrieval can reduce model inventions
Towards Data Science
📰
Beyond Search: Building Knowledge Nexus — The Future of AI-Powered Enterprise Intelligence
Learn how to build an enterprise-grade RAG platform that turns static PDFs into an interactive Knowledge Graph, enabling AI-powered enterprise intelligence
Medium · Machine Learning
📰
From Documents to Intelligent Answers: Building a RAG Agent from Scratch & Lessons Learned
Learn to build a RAG agent from scratch and discover key lessons for creating intelligent answer systems
Dev.to · Sri Deevi
Up next
4. Indexing PDF using Vector + Semantic Search in Azure AI Search with Document Intelligence | Chunk
Dewiride Technologies
Watch →