You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 15-rag-and-vector-databases/README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,9 @@ After completing this lesson, you will be able to:
22
22
23
23
- Explain the significance of RAG in data retrieval and processing.
24
24
25
-
-Setup RAG application and ground your data to an LLM
25
+
-Set up a RAG application and ground your data in an LLM
26
26
27
-
-Effective integration of RAG and Vector Databases in LLM Applications.
27
+
-Effectively integrate RAG and vector databases in LLM applications.
28
28
29
29
## Our Scenario: enhancing our LLMs with our own data
30
30
@@ -36,7 +36,7 @@ For this lesson, we want to add our own notes into the education startup, which
36
36
37
37
-`Azure AI Search` and `Azure Cosmos DB:` vector database to store our data and create a search index
38
38
39
-
Users will be able to create practice quizzes from their notes, revision flash cards and summarize it to concise overviews. To get started, let us look at what is RAG and how works:
39
+
Users will be able to create practice quizzes from their notes, revision flash cards and summarize them into concise overviews. To get started, let us look at what RAG is and how it works:
40
40
41
41
## Retrieval Augmented Generation (RAG)
42
42
@@ -56,9 +56,9 @@ Suppose you want to deploy a chatbot that creates quizzes from your notes, you w
56
56
57
57
-**Augmented Generation:** the LLM enhances its response based on the data retrieved. It allows the response generated to be not only based on pre-trained data but also relevant information from the added context. The retrieved data is used to augment the LLM's responses. The LLM then returns an answer to the user's question.
58
58
59
-

The architecture for RAGs is implemented using transformers consisting of two parts: an encoder and a decoder. For example, when a user asks a question, the input text 'encoded' into vectors capturing the meaning of words and the vectors are 'decoded' into our document index and generates new text based on the user query. The LLM uses both an encoder-decoder model to generate the output.
61
+
The architecture for RAG is implemented using transformers consisting of two parts: an encoder and a decoder. For example, when a user asks a question, the input text is encoded into vectors capturing the meaning of words, the vectors are matched against the document index, and the model generates new text based on the user query. The LLM uses an encoder-decoder model to generate the output.
62
62
63
63
Two approaches when implementing RAG according to the proposed paper: [Retrieval-Augmented Generation for Knowledge intensive NLP (natural language processing software) Tasks](https://arxiv.org/pdf/2005.11401.pdf?WT.mc_id=academic-105485-koreyst) are:
64
64
@@ -76,13 +76,13 @@ Two approaches when implementing RAG according to the proposed paper: [Retrieval
76
76
77
77
## Creating a knowledge base
78
78
79
-
Our application is based on our personal data i.e., the Neural Network lesson on AI For Beginners curriculum.
79
+
Our application is based on our personal data, i.e., the Neural Network lesson from the AI for Beginners curriculum.
80
80
81
81
### Vector Databases
82
82
83
83
A vector database, unlike traditional databases, is a specialized database designed to store, manage and search embedded vectors. It stores numerical representations of documents. Breaking down data to numerical embeddings makes it easier for our AI system to understand and process the data.
84
84
85
-
We store our embeddings in vector databases as LLMs have a limit of the number of tokens they accept as input. As you cannot pass the entire embeddings to an LLM, we will need to break them down into chunks and when a user asks a question, the embeddings most like the question will be returned together with the prompt. Chunking also reduces costs on the number of tokens passed through an LLM.
85
+
We store our embeddings in vector databases as LLMs have a limit of the number of tokens they accept as input. As you cannot pass the entire embeddings to an LLM, we will need to break them down into chunks and when a user asks a question, the embeddings most similar to the question will be returned together with the prompt. Chunking also reduces costs on the number of tokens passed through an LLM.
86
86
87
87
Some popular vector databases include Azure Cosmos DB, Clarifyai, Pinecone, Chromadb, ScaNN, Qdrant and DeepLake. You can create an Azure Cosmos DB model using Azure CLI with the following command:
88
88
@@ -141,9 +141,9 @@ A challenge with retrieval comes in when there is no similar response to the que
141
141
142
142
### Vector Similarity
143
143
144
-
The retriever will search through the knowledge database for embeddings that are close together, the closest neighbour, as they are texts that are similar. In the scenarioa user asks a query, it is first embedded then matched with similar embeddings. The common measurement that is used to find how similar different vectors are is cosine similarity which is based on the angle between two vectors.
144
+
The retriever will search through the knowledge database for embeddings that are close together—the nearest neighbors—as they represent texts that are similar. In this scenario, when a user submits a query, it is first embedded and then matched with similar embeddings. The most common measurement used to compare vector similarity is cosine similarity, which is based on the angle between two vectors.
145
145
146
-
We can measure similarity using other alternatives we can use are Euclidean distance which is the straight line between vector endpoints and dot product which measures the sum of the products of corresponding elements of two vectors.
146
+
Other metrics we can use to measure similarity include Euclidean distance, which is the straight line between vector endpoints, and dot product, which measures the sum of the products of corresponding elements in two vectors.
147
147
148
148
### Search index
149
149
@@ -236,7 +236,7 @@ chatbot(user_input)
236
236
237
237
## Use Cases for using RAG (Retrieval Augmented Generation) and vector databases
238
238
239
-
There are many different use cases where function calls can improve your app like:
239
+
There are many different use cases where RAG can improve your app, such as:
240
240
241
241
- Question and Answering: grounding your company data to a chat that can be used by employees to ask questions.
242
242
@@ -248,7 +248,7 @@ There are many different use cases where function calls can improve your app lik
248
248
249
249
## Summary
250
250
251
-
We have covered the fundamental areas of RAG from adding our data to the application, the user query and output. To simplify creation of RAG, you can use frameworks such as Semanti Kernel, Langchain or Autogen.
251
+
We have covered the fundamental areas of RAG from adding our data to the application, the user query and output. To simplify creation of RAG, you can use frameworks such as Semantic Kernel, LangChain or AutoGen.
0 commit comments