Skip to content

Commit

Permalink
Fixing broken code vlock
Browse files Browse the repository at this point in the history
  • Loading branch information
ajosh0504 committed Jul 11, 2024
1 parent 1dd2a4a commit 211ec62
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/10-rag/3-components-of-rag.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 📘 Components of a RAG System
# 📘 Components of a RAG system

TO-DO
121 changes: 121 additions & 0 deletions docs/60-perform-semantic-search/4-pre-filtering.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# 🦹 Combine pre-filtering with vector search

Pre-filtering a technique to optimize vector search by only considering documents that match certain criteria during vector search.

Fill in any `<CODE_BLOCK_N>` placeholders and run the cells under the **🦹‍♀️ Combine pre-filtering with vector search** section in the notebook to get a sense of how to combine pre-filtering with MongoDB Atlas Vector Search.

:::caution
**DO NOT** actually modify the existing vector index definitions in the Atlas UI, or the existing pipeline definitions in the code.
:::

The answers for code blocks in this section are as follows:

**CODE_BLOCK_16**

<details>
<summary>Answer</summary>
<div>
```python
{
"fields": [
{
"numDimensions": 1024,
"path": "embedding",
"similarity": "cosine",
"type": "vector",
},
{
"path": "metadata.language"
"type": "filter",
},
]
}
```
</div>
</details>

**CODE_BLOCK_17**

<details>
<summary>Answer</summary>
<div>
```python
[
{
"$vectorSearch": {
"index": ATLAS_VECTOR_SEARCH_INDEX_NAME,
"queryVector": query_embedding,
"path": "embedding",
"numCandidates": 150,
"limit": 5,
"filter": {"metadata.language": "en"},
}
},
{
"$project": {
"_id": 0,
"page_content": 1,
"score": {"$meta": "vectorSearchScore"},
}
},
]
```
</div>
</details>

**CODE_BLOCK_18**

<details>
<summary>Answer</summary>
<div>
```python
{
"fields": [
{
"numDimensions": 1024,
"path": "embedding",
"similarity": "cosine",
"type": "vector",
},
{
"path": "metadata.language"
"type": "filter",
},
{
"path": "type"
"type": "filter",
},
]
}
```
</div>
</details>

**CODE_BLOCK_19**

<details>
<summary>Answer</summary>
<div>
```python
[
{
"$vectorSearch": {
"index": ATLAS_VECTOR_SEARCH_INDEX_NAME,
"queryVector": query_embedding,
"path": "embedding",
"numCandidates": 150,
"limit": 5,
"filter": {"$and": [{"metadata.language": "en"}, {"type": "Document"}]},
}
},
{
"$project": {
"_id": 0,
"page_content": 1,
"score": {"$meta": "vectorSearchScore"},
}
},
]
```
</div>
</details>
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const workshopName = 'ai-rag-lab';
const organizationName = "mongodb-developer";

// Main page config
const title = "Building RAG Applications using MongoDB";
const title = "Build RAG Applications using MongoDB";
const tagLine = "";
const startButtonTitle = "Start Lab";
const favicon = "img/favicon.svg"
Expand Down

0 comments on commit 211ec62

Please sign in to comment.