diff --git a/docs/10-rag/3-components-of-rag.mdx b/docs/10-rag/3-components-of-rag.mdx index 1099d8e..14b6316 100644 --- a/docs/10-rag/3-components-of-rag.mdx +++ b/docs/10-rag/3-components-of-rag.mdx @@ -1,3 +1,3 @@ -# ๐Ÿ“˜ Components of a RAG System +# ๐Ÿ“˜ Components of a RAG system TO-DO \ No newline at end of file diff --git a/docs/60-perform-semantic-search/4-pre-filtering.mdx b/docs/60-perform-semantic-search/4-pre-filtering.mdx new file mode 100644 index 0000000..fc55cfd --- /dev/null +++ b/docs/60-perform-semantic-search/4-pre-filtering.mdx @@ -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 `` 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** + +
+Answer +
+```python +{ + "fields": [ + { + "numDimensions": 1024, + "path": "embedding", + "similarity": "cosine", + "type": "vector", + }, + { + "path": "metadata.language" + "type": "filter", + }, + ] +} +``` +
+
+ +**CODE_BLOCK_17** + +
+Answer +
+```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"}, + } + }, +] +``` +
+
+ +**CODE_BLOCK_18** + +
+Answer +
+```python +{ + "fields": [ + { + "numDimensions": 1024, + "path": "embedding", + "similarity": "cosine", + "type": "vector", + }, + { + "path": "metadata.language" + "type": "filter", + }, + { + "path": "type" + "type": "filter", + }, + ] +} +``` +
+
+ +**CODE_BLOCK_19** + +
+Answer +
+```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"}, + } + }, +] +``` +
+
\ No newline at end of file diff --git a/docusaurus.config.js b/docusaurus.config.js index 22bbafe..f48a747 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -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"