Skip to content

Commit 7287da9

Browse files
Updated the README and the ARM template
1 parent 9057282 commit 7287da9

File tree

5 files changed

+48
-18
lines changed

5 files changed

+48
-18
lines changed

README.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
99
<br/>
1010

11+
1112
> **Note:**
12-
> Please sign up here for the vector store feature (private preview) in Cognitive Search: [aka.ms/VectorSearchSignUp](aka.ms/VectorSearchSignUp)
13+
> Redis is not used to store embeddings anymore, but now the Vector Store in Cognitive Search is used for the embeddings. Redis is still needed to store the user conversation history (chat session). Therefore, a Redis container (ACI) can be used instead of Redis Enterprise. The user can use redis.yml in the repo to create a Redis container.
1314
1415
<br/>
1516

@@ -24,13 +25,13 @@
2425
<br/>
2526
<br />
2627
<p align="center">
27-
<img src="images/km-openai.png" />
28+
<img src="images/km-openai v2.jpg" />
2829
</p>
2930
<br/>
3031
<br/>
3132

3233
# Purpose
33-
The purpose of this repo is to accelerate the deployment of a Python-based Knowledge Mining solution with OpenAI that will ingest a Knowledge Base, generate embeddings using the contents extracted, store them in a vector search engine (Redis), and use that engine to answer queries / questions specific to that Knowledge Base.
34+
The purpose of this repo is to accelerate the deployment of a Python-based Knowledge Mining solution with OpenAI that will ingest a Knowledge Base, generate embeddings using the contents extracted, store them in a vector search engine (Cognitive Search), and use that engine to answer queries / questions specific to that Knowledge Base.
3435

3536
The Cognitive Search component serves to make it easier to ingest a Knowledge Base with a variety of document formats. The Cognitive Services component connected to the Search makes it possible to have an enrichment pipeline. This pipeline can generate information based on images for example, which can be included at the time of generating embeddings.
3637

@@ -46,9 +47,9 @@ The below are the features of this solution:
4647

4748
1. Improved prompts and workflow handling with LangChain. The user should see improved search results in the form of better answers.
4849

49-
1. Using both Redis and Cognitive Search (Semantic Search) as tools for the LangChain Agent. Also, added Bing as a third search tool, which can be enabled or disabled.
50+
1. Using Cognitive Search (Semantic Search and Vector Search) as tools for the LangChain Agent. Also, added Bing as a another search tool, which can be enabled or disabled.
5051

51-
1. The user can choose to skip Redis provisioning completely by keeping `REDIS_ADDR` blank in the configuration. However, that means that the session history cannot be cached, and each query/question is independent of the previous ones.
52+
1. Redis is used only to cache some intermediate results, as well as caching the user conversation history. However, the user can choose to skip Redis provisioning completely by keeping `REDIS_ADDR` blank in the configuration. This means that the session history cannot be cached, and each query/question is independent of the previous ones.
5253

5354
1. Added filtering support in the Bot HTTP request API. This would be useful for things like multi-tenant demos, and filtering on docuemnts with an original source language. Use `"filter":"@field:value"` in the HTTP request e.g. `"filter":"@orig_lang:en"`.
5455

@@ -68,7 +69,7 @@ The below are the features of this solution:
6869

6970
1. Automatic translation from/to English using Cognitive Services, since OpenAI works best with English
7071

71-
1. The Cognitive Search ecosystem provides the potential to add a wide variety of custom skills, as well as access the native search capabilities which can complement the embedding search in Redis.
72+
1. The Cognitive Search ecosystem provides the potential to add a wide variety of custom skills, as well as access the native search capabilities which can complement the embedding search.
7273

7374
1. Automatic deployment of the Azure Functions from this repo to the Function App
7475

@@ -89,7 +90,7 @@ Multiple Search Parameters have been added to control the behavior of the agent.
8990

9091
1. `enable_redis_search`: enables search with embeddings in Redis
9192

92-
1. `enable_cognitive_search`: enables semantic search and lookup in Cognitive Search.
93+
1. `enable_cognitive_search`: enables vector search, semantic search and lookup in Cognitive Search.
9394

9495
1. `evaluate_step`: search text results sometimes have the answer to the question but the results might be so long that OpenAI completion call might miss that information (too much noise). `evaluate_step` was created to address this problem. This is a separate call to the OpenAI Completion API to identify the facts that are relevant only to the question.
9596

@@ -122,11 +123,11 @@ The below is a simple illustrative example. The knowledge base consists of the s
122123

123124
Here are the results:
124125

125-
1. The One-Pass Agent searched Redis (or Cognitive Search) for the full question, and got all the top ranking results about Sherlock Holmes. The final answer is `"I'm sorry, I could not find any information about the Volcano Hotel in the provided context."`
126+
1. The One-Pass Agent searched Cognitive Search for the full question, and got all the top ranking results about Sherlock Holmes. The final answer is `"I'm sorry, I could not find any information about the Volcano Hotel in the provided context."`
126127

127-
1. The Conversational-Chat-ReAct Agent gave a mixed bag of results. Because it has not been explicitly instructed in the prompt how many iterations it can do, sometimes it did one search in Redis (or Cognitive Search), and sometimes two searches. The first search is almost always about Sherlock Holmes, with the search string `"Sherlock Holmes country"`. If it did go for a second search iteration, then it looks for `"Volcano hotel country"`. The final answer is either `"Sherlock Holmes is a fictional character from the United Kingdom. However, I do not have information about the location of the Volcano hotel."` or, when it does 2 searches, then it gets `"The Volcano Hotel is located in Las Vegas, United States. Sherlock Holmes lived in London, England . Therefore, Sherlock Holmes did not live in the same country as the Volcano Hotel."`.
128+
1. The Conversational-Chat-ReAct Agent gave a mixed bag of results. Because it has not been explicitly instructed in the prompt how many iterations it can do, sometimes it did one search in Cognitive Search, and sometimes two searches. The first search is almost always about Sherlock Holmes, with the search string `"Sherlock Holmes country"`. If it did go for a second search iteration, then it looks for `"Volcano hotel country"`. The final answer is either `"Sherlock Holmes is a fictional character from the United Kingdom. However, I do not have information about the location of the Volcano hotel."` or, when it does 2 searches, then it gets `"The Volcano Hotel is located in Las Vegas, United States. Sherlock Holmes lived in London, England . Therefore, Sherlock Holmes did not live in the same country as the Volcano Hotel."`.
128129

129-
1. The Zero-Shot-ReAct Agent really shines here because it is explicitly told that it can do multiple searches in the context of answering a single query. It first searches Redis (or Cognitive Search) for `"Sherlock Holmes country"`, and then searches again for `"Volcano hotel location"`, and gives the right answer every time: `"Sherlock Holmes lived in London, England, while the Volcano Hotel is located in Las Vegas, United States. They are not in the same country."`.
130+
1. The Zero-Shot-ReAct Agent really shines here because it is explicitly told that it can do multiple searches in the context of answering a single query. It first searches Cognitive Search for `"Sherlock Holmes country"`, and then searches again for `"Volcano hotel location"`, and gives the right answer every time: `"Sherlock Holmes lived in London, England, while the Volcano Hotel is located in Las Vegas, United States. They are not in the same country."`.
130131

131132

132133
<br />
@@ -208,7 +209,7 @@ Then install the required packages using the following command:
208209
1. ARM: Adding Application Insights to the ARM template
209210
1. Code: Adding a custom skill that processes csv files
210211
1. Code: Adding a demo for HTML crawling
211-
1. Code: Adding an embedding match filtering (in Redis) for filtering on metadata
212+
1. Code: Adding an embedding match filtering (in Cognitive Search) for filtering on metadata
212213
1. Integrating the features of the new repo from CogSearch PG into this one
213214

214215

experiment.ipynb

+34-5
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,18 @@
5454
},
5555
{
5656
"cell_type": "code",
57-
"execution_count": 1,
57+
"execution_count": 2,
5858
"metadata": {},
59-
"outputs": [],
59+
"outputs": [
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"The autoreload extension is already loaded. To reload it, use:\n",
65+
" %reload_ext autoreload\n"
66+
]
67+
}
68+
],
6069
"source": [
6170
"import os\n",
6271
"from dotenv import load_dotenv\n",
@@ -80,6 +89,26 @@
8089
"%autoreload 2"
8190
]
8291
},
92+
{
93+
"cell_type": "code",
94+
"execution_count": 2,
95+
"metadata": {},
96+
"outputs": [
97+
{
98+
"data": {
99+
"text/plain": [
100+
"'https://searchseh000000.search.windows.net'"
101+
]
102+
},
103+
"execution_count": 2,
104+
"metadata": {},
105+
"output_type": "execute_result"
106+
}
107+
],
108+
"source": [
109+
"COG_SEARCH_ENDPOINT"
110+
]
111+
},
83112
{
84113
"attachments": {},
85114
"cell_type": "markdown",
@@ -92,15 +121,15 @@
92121
},
93122
{
94123
"cell_type": "code",
95-
"execution_count": 2,
124+
"execution_count": 3,
96125
"metadata": {},
97126
"outputs": [
98127
{
99128
"name": "stdout",
100129
"output_type": "stream",
101130
"text": [
102-
"Index km-openai-sem Deleted\n",
103-
"Index km-openai-sem created\n",
131+
"Index vec-index Deleted\n",
132+
"Index vec-index created\n",
104133
"Index km-openai Deleted\n",
105134
"Index km-openai created\n",
106135
"Deleted Skillset - km-openai-skills\n",

images/km-openai v2.jpg

157 KB
Loading

template.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@
893893
},
894894
{
895895
"name": "USE_REDIS_CACHE",
896-
"value": "0"
896+
"value": "1"
897897
},
898898
{
899899
"name": "USE_COG_VECSEARCH",

utils/env_vars.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
DATABASE_MODE = int(os.environ.get("DATABASE_MODE", "0"))
3030

31-
USE_REDIS_CACHE = int(os.environ.get("USE_REDIS_CACHE", "0"))
31+
USE_REDIS_CACHE = int(os.environ.get("USE_REDIS_CACHE", "1"))
3232

3333
PROCESS_IMAGES = int(os.environ.get("PROCESS_IMAGES", "0"))
3434

0 commit comments

Comments
 (0)