Skip to content

Commit 9575c6c

Browse files
committed
Update rag.md
1 parent 4fac883 commit 9575c6c

File tree

1 file changed

+15
-15
lines changed
  • articles/cosmos-db/mongodb/vcore

1 file changed

+15
-15
lines changed

articles/cosmos-db/mongodb/vcore/rag.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ In the fast-evolving realm of generative AI, Large Language Models (LLMs) like G
1616

1717
This tutorial explores how to use Azure Cosmos DB for MongoDB (vCore), LangChain, and OpenAI to implement Retrieval-Augmented Generation (RAG) for superior AI performance alongside discussing LLMs and their limitations. We explore the rapidly adopted paradigm of "retrieval-augmented generation" (RAG), and briefly discuss the LangChain framework, Azure OpenAI models. Finally, we integrate these concepts into a real-world application. By the end, readers will have a solid understanding of these concepts.
1818

19-
## Understanding Large Language Models (LLMs) and Their Limitations
19+
## Understand Large Language Models (LLMs) and their limitations
2020

2121
Large Language Models (LLMs) are advanced deep neural network models trained on extensive text datasets, enabling them to understand and generate human-like text. While revolutionary in natural language processing, LLMs have inherent limitations:
2222

@@ -25,7 +25,7 @@ Large Language Models (LLMs) are advanced deep neural network models trained on
2525
- **No Access to User’s Local Data**: LLMs don't have direct access to personal or localized data, restricting their ability to provide personalized responses.
2626
- **Token Limits**: LLMs have a maximum token limit per interaction, constraining the amount of text they can process at once. For example, OpenAI’s gpt-3.5-turbo has a token limit of 4096.
2727

28-
## Leveraging Retrieval-Augmented Generation (RAG)
28+
## Leverage Retrieval-Augmented Generation (RAG)
2929

3030
Retrieval-augmented generation (RAG) is an architecture designed to overcome LLM limitations. RAG uses vector search to retrieve relevant documents based on an input query, providing these documents as context to the LLM for generating more accurate responses. Instead of relying solely on pretrained patterns, RAG enhances responses by incorporating up-to-date, relevant information. This approach helps to:
3131

@@ -36,21 +36,21 @@ Retrieval-augmented generation (RAG) is an architecture designed to overcome LLM
3636

3737
This tutorial demonstrates how RAG can be implemented using Azure Cosmos DB for MongoDB (vCore) to build a question-answering application tailored to your data.
3838

39-
## Application Architecture Overview
39+
## Application architecture overview
4040

4141
The architecture diagram below illustrates the key components of our RAG implementation:
4242

4343
![Architecture Diagram](./media/vector/architecture-diagram.png)
4444

45-
## Key Components and Frameworks
45+
## Key components and frameworks
4646

4747
We'll now discuss the various frameworks, models, and components used in this tutorial, emphasizing their roles and nuances.
4848

4949
### Azure Cosmos DB for MongoDB (vCore)
5050

5151
Azure Cosmos DB for MongoDB (vCore) supports semantic similarity searches, essential for AI-powered applications. It allows data in various formats to be represented as vector embeddings, which can be stored alongside source data and metadata. Using an approximate nearest neighbors algorithm, like Hierarchical navigable small world (HNSW), these embeddings can be queried for fast semantic similarity searches.
5252

53-
### LangChain Framework
53+
### LangChain framework
5454

5555
LangChain simplifies the creation of LLM applications by providing a standard interface for chains, multiple tool integrations, and end-to-end chains for common tasks. It enables AI developers to build LLM applications that leverage external data sources.
5656

@@ -61,15 +61,15 @@ Key aspects of LangChain:
6161
- **Modularity**: Simplifies development, debugging, and maintenance.
6262
- **Popularity**: An open-source project rapidly gaining adoption and evolving to meet user needs.
6363

64-
### Azure App Services Interface
64+
### Azure App Services interface
6565

6666
App services provide a robust platform for building user-friendly web interfaces for Gen-AI applications. This tutorial uses Azure App services to create an interactive web interface for the application.
6767

68-
### OpenAI Models
68+
### OpenAI models
6969

7070
OpenAI is a leader in AI research, providing various models for language generation, text vectorization, image creation, and audio-to-text conversion. For this tutorial, we'll use OpenAI’s embedding and language models, crucial for understanding and generating language-based applications.
7171

72-
### Embedding Models vs. Language Generation Models
72+
### Embedding models vs. Language generation models
7373

7474
| | **Text Embedding Model** | **Language Model** |
7575
|---------------------------|----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
@@ -85,7 +85,7 @@ OpenAI is a leader in AI research, providing various models for language generat
8585
| **Dimensionality** | The length of the array corresponds to the number of dimensions in the embedding space, for example, 1536 dimensions. | Typically represented as a sequence of tokens, with the context determining the length. |
8686

8787

88-
### Main Components of the Application
88+
### Main components of the application
8989

9090
- **Azure Cosmos DB for MongoDB vCore**: Storing and querying vector embeddings.
9191
- **LangChain**: Constructing the application’s LLM workflow. Utilizes tools such as:
@@ -97,7 +97,7 @@ OpenAI is a leader in AI research, providing various models for language generat
9797
- **text-embedding-ada-002**: A text embedding model that converts text into vector embeddings with 1536 dimensions.
9898
- **gpt-3.5-turbo**: A language model for understanding and generating natural language.
9999

100-
### Setting up the environment
100+
### Set up the environment
101101

102102
To get started with optimizing retrieval-augmented generation (RAG) using Azure Cosmos DB for MongoDB (vCore), follow these steps:
103103

@@ -118,7 +118,7 @@ In this tutorial, we will be loading a single text file using [Document](https:/
118118
},
119119
```
120120

121-
### Loading documents
121+
### Load documents
122122
1. Set the Cosmos DB for MongoDB (vCore) connection string, Database Name, Collection Name, and Index:
123123
```python
124124
mongo_client = MongoClient(mongo_connection_string)
@@ -152,7 +152,7 @@ vector_store: AzureCosmosDBVectorSearch = AzureCosmosDBVectorSearch.from_documen
152152
)
153153
```
154154

155-
4. Create the following [HNSW vector Index](./vector-search.md) on the collection, (Note the name of the index is same as above).
155+
4. Create the following [HNSW vector Index](./vector-search.md) on the collection (Note the name of the index is same as above).
156156
```python
157157
num_lists = 100
158158
dimensions = 1536
@@ -166,7 +166,7 @@ vector_store.create_index(
166166
)
167167
```
168168

169-
### Performing Vector search using Cosmos DB for MongoDB (vCore)
169+
### Perform Vector search using Cosmos DB for MongoDB (vCore)
170170

171171
1. Connect to your vector store.
172172
```python
@@ -245,12 +245,12 @@ The screenshot below illustrates the outputs for various questions. A purely sem
245245

246246
![Rag Comic App](./media/vector/rag-cosmic-screenshot.png)
247247

248-
### Conlusion
248+
### Conclusion
249249
In this tutorial, we explored how to build a question-answering app that interacts with your private data using Cosmos DB as a vector store. By leveraging the retrieval-augmented generation (RAG) architecture with LangChain and Azure OpenAI, we demonstrated how vector stores are essential for LLM applications.
250250

251251
RAG is a significant advancement in AI, particularly in natural language processing, and combining these technologies allows for the creation of powerful AI-driven applications for various use cases.
252252

253-
## Next Steps
253+
## Next steps
254254

255255
For a detailed, hands-on experience and to see how RAG can be implemented using Azure Cosmos DB for MongoDB (vCore), LangChain, and OpenAI models, visit our GitHub repository.
256256

0 commit comments

Comments
 (0)