diff --git a/03-Quering-AOpenAI.ipynb b/03-Quering-AOpenAI.ipynb
index 323c5cbf..6d7a4fa5 100644
--- a/03-Quering-AOpenAI.ipynb
+++ b/03-Quering-AOpenAI.ipynb
@@ -62,12 +62,12 @@
"from langchain.chains.qa_with_sources import load_qa_with_sources_chain\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"\n",
- "from common.prompts import COMBINE_QUESTION_PROMPT, COMBINE_PROMPT\n",
+ "from common.prompts import COMBINE_QUESTION_PROMPT, COMBINE_PROMPT, COMBINE_PROMPT_TEMPLATE\n",
"from common.utils import (\n",
" get_search_results,\n",
- " order_search_results,\n",
" model_tokens_limit,\n",
" num_tokens_from_docs,\n",
+ " num_tokens_from_string\n",
")\n",
"\n",
"from dotenv import load_dotenv\n",
@@ -909,7 +909,8 @@
"outputs": [],
"source": [
"MODEL = \"gpt-35-turbo\" # options: gpt-35-turbo, gpt-35-turbo-16k, gpt-4, gpt-4-32k\n",
- "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0, max_tokens=1000)"
+ "COMPLETION_TOKENS = 1000\n",
+ "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0, max_tokens=COMPLETION_TOKENS)"
]
},
{
@@ -1058,11 +1059,19 @@
"execution_count": 12,
"id": "3bccca45-d1dd-476f-b109-a528b857b6b3",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Number of results: 20\n"
+ ]
+ }
+ ],
"source": [
"k = 10 # Number of results per each text_index\n",
- "agg_search_results = get_search_results(QUESTION, indexes, k=10)\n",
- "ordered_results = order_search_results(agg_search_results, k=10*len(indexes), reranker_threshold=1)"
+ "ordered_results = get_search_results(QUESTION, indexes, k=10, reranker_threshold=1)\n",
+ "print(\"Number of results:\",len(ordered_results))"
]
},
{
@@ -1081,7 +1090,7 @@
"id": "da70e7a8-7536-4688-b30c-01ba28e9b9f8",
"metadata": {},
"source": [
- "Now we can fill up the vector-based index as users lookup documents using the text-based index. This approach although it requires two searches per user query (one on the text-based indexes and the other one on the vector based indexes), it is simpler to implement and will be incrementatly faster as user use the system."
+ "Now we can fill up the vector-based index as users lookup documents using the text-based index. This approach although it requires two searches per user query (one on the text-based indexes and the other one on the vector-based indexes), it is simpler to implement and will be incrementatly faster as user use the system."
]
},
{
@@ -1124,8 +1133,8 @@
"Vectorizing 1 chunks from Document: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5809586/\n",
"Vectorizing 1 chunks from Document: https://www.ncbi.nlm.nih.gov/pubmed/17414124/\n",
"Vectorizing 1 chunks from Document: https://doi.org/10.1111/bjh.14134; https://www.ncbi.nlm.nih.gov/pubmed/27173746/\n",
- "CPU times: user 10.8 s, sys: 165 ms, total: 10.9 s\n",
- "Wall time: 26.7 s\n"
+ "CPU times: user 8.02 s, sys: 174 ms, total: 8.2 s\n",
+ "Wall time: 23.3 s\n"
]
}
],
@@ -1205,19 +1214,28 @@
"execution_count": 16,
"id": "61098bb4-33da-4eb4-94cf-503587337aca",
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Number of results: 3\n"
+ ]
+ }
+ ],
"source": [
"vector_indexes = [index+\"-vector\" for index in indexes]\n",
"\n",
- "agg_search_results = get_search_results(QUESTION, vector_indexes,\n",
- " k=10, # Number of results per vector index\n",
+ "k = 10\n",
+ "similarity_k = 3\n",
+ "ordered_results = get_search_results(QUESTION, vector_indexes,\n",
+ " k=k, # Number of results per vector index\n",
+ " reranker_threshold=1,\n",
" vector_search=True, \n",
+ " similarity_k=similarity_k,\n",
" query_vector = embedder.embed_query(QUESTION)\n",
" )\n",
- "ordered_results = order_search_results(agg_search_results, \n",
- " k=3, # Number of top results combined \n",
- " reranker_threshold=1,\n",
- " vector_search = True)"
+ "print(\"Number of results:\",len(ordered_results))"
]
},
{
@@ -1246,7 +1264,7 @@
"top_docs = []\n",
"for key,value in ordered_results.items():\n",
" location = value[\"location\"] if value[\"location\"] is not None else \"\"\n",
- " top_docs.append(Document(page_content=value[\"chunk\"], metadata={\"source\": location+os.environ['BLOB_SAS_TOKEN']}))\n",
+ " top_docs.append(Document(page_content=value[\"chunk\"], metadata={\"source\": location}))\n",
" \n",
"print(\"Number of chunks:\",len(top_docs))"
]
@@ -1261,8 +1279,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Custom token limit for gpt-35-turbo : 2000\n",
- "Combined docs tokens count: 4123\n",
+ "System prompt token count: 1669\n",
+ "Max Completion Token count: 1000\n",
+ "Combined docs (context) token count: 1938\n",
+ "--------\n",
+ "Requested token count: 4607\n",
+ "Token limit for gpt-35-turbo : 4096\n",
"Chain Type selected: map_reduce\n"
]
}
@@ -1271,10 +1293,19 @@
"# Calculate number of tokens of our docs\n",
"if(len(top_docs)>0):\n",
" tokens_limit = model_tokens_limit(MODEL) # this is a custom function we created in common/utils.py\n",
- " num_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
- " chain_type = \"map_reduce\" if num_tokens > tokens_limit else \"stuff\" \n",
- " print(\"Custom token limit for\", MODEL, \":\", tokens_limit)\n",
- " print(\"Combined docs tokens count:\",num_tokens)\n",
+ " prompt_tokens = num_tokens_from_string(COMBINE_PROMPT_TEMPLATE) # this is a custom function we created in common/utils.py\n",
+ " context_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
+ " \n",
+ " requested_tokens = prompt_tokens + context_tokens + COMPLETION_TOKENS\n",
+ " \n",
+ " chain_type = \"map_reduce\" if requested_tokens > 0.9 * tokens_limit else \"stuff\" \n",
+ " \n",
+ " print(\"System prompt token count:\",prompt_tokens)\n",
+ " print(\"Max Completion Token count:\", COMPLETION_TOKENS)\n",
+ " print(\"Combined docs (context) token count:\",context_tokens)\n",
+ " print(\"--------\")\n",
+ " print(\"Requested token count:\",requested_tokens)\n",
+ " print(\"Token limit for\", MODEL, \":\", tokens_limit)\n",
" print(\"Chain Type selected:\", chain_type)\n",
" \n",
"else:\n",
@@ -1316,8 +1347,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 18.4 ms, sys: 0 ns, total: 18.4 ms\n",
- "Wall time: 11.1 s\n"
+ "CPU times: user 17 ms, sys: 0 ns, total: 17 ms\n",
+ "Wall time: 4.58 s\n"
]
}
],
@@ -1336,7 +1367,7 @@
{
"data": {
"text/markdown": [
- "CLP stands for Constraint Logic Programming. It is a framework that combines logic programming with constraints to solve problems. In CLP, programs are written in a logic programming language and constraints are used to restrict the possible solutions. CLP allows for the specification of constraints on variables and the use of constraint solvers to find solutions that satisfy these constraints[3]."
+ "CLP can refer to different things depending on the context. In the context of the provided information, CLP stands for Consultation-Liaison Psychiatry[2]."
],
"text/plain": [
""
@@ -1355,7 +1386,7 @@
"id": "05e27c75-bfd9-4304-b2fd-c8e30bcc0558",
"metadata": {},
"source": [
- "**Please Note**: There are instances where, despite the answer's high accuracy and quality, the references are not done according to the instructions provided in the COMBINE_PROMPT. This behavior is anticipated when dealing with GPT-3.5 models. We will provide a more detailed explanation of this phenomenon towards the conclusion of Notebook 5."
+ "**Please Note**: There are some instances where, despite the answer's high accuracy and quality, the references are not done according to the instructions provided in the COMBINE_PROMPT. This behavior is anticipated when dealing with GPT-3.5 models. We will provide a more detailed explanation of this phenomenon towards the conclusion of Notebook 5."
]
},
{
diff --git a/04-Complex-Docs.ipynb b/04-Complex-Docs.ipynb
index 98608ed8..89ed759c 100644
--- a/04-Complex-Docs.ipynb
+++ b/04-Complex-Docs.ipynb
@@ -24,7 +24,7 @@
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 28,
"id": "15f6044e-463f-4988-bc46-a3c3d641c15c",
"metadata": {},
"outputs": [],
@@ -50,12 +50,12 @@
"from langchain.chains.qa_with_sources import load_qa_with_sources_chain\n",
"\n",
"from common.utils import parse_pdf, read_pdf_files, text_to_base64\n",
- "from common.prompts import COMBINE_QUESTION_PROMPT, COMBINE_PROMPT\n",
+ "from common.prompts import COMBINE_QUESTION_PROMPT, COMBINE_PROMPT, COMBINE_PROMPT_TEMPLATE\n",
"from common.utils import (\n",
" get_search_results,\n",
- " order_search_results,\n",
" model_tokens_limit,\n",
" num_tokens_from_docs,\n",
+ " num_tokens_from_string\n",
")\n",
"\n",
"\n",
@@ -153,7 +153,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "100%|██████████| 5/5 [00:02<00:00, 1.81it/s]\n"
+ "100%|██████████| 5/5 [00:02<00:00, 1.73it/s]\n"
]
}
],
@@ -192,27 +192,27 @@
"text": [
"Extracting Text from Azure_Cognitive_Search_Documentation.pdf ...\n",
"Extracting text using PyPDF\n",
- "Parsing took: 46.014143 seconds\n",
+ "Parsing took: 35.475175 seconds\n",
"Azure_Cognitive_Search_Documentation.pdf contained 1947 pages\n",
"\n",
"Extracting Text from Boundaries_When_to_Say_Yes_How_to_Say_No_to_Take_Control_of_Your_Life.pdf ...\n",
"Extracting text using PyPDF\n",
- "Parsing took: 2.567787 seconds\n",
+ "Parsing took: 1.757536 seconds\n",
"Boundaries_When_to_Say_Yes_How_to_Say_No_to_Take_Control_of_Your_Life.pdf contained 357 pages\n",
"\n",
"Extracting Text from Fundamentals_of_Physics_Textbook.pdf ...\n",
"Extracting text using PyPDF\n",
- "Parsing took: 133.298196 seconds\n",
+ "Parsing took: 105.944826 seconds\n",
"Fundamentals_of_Physics_Textbook.pdf contained 1450 pages\n",
"\n",
"Extracting Text from Made_To_Stick.pdf ...\n",
"Extracting text using PyPDF\n",
- "Parsing took: 10.385454 seconds\n",
+ "Parsing took: 8.193571 seconds\n",
"Made_To_Stick.pdf contained 225 pages\n",
"\n",
"Extracting Text from Pere_Riche_Pere_Pauvre.pdf ...\n",
"Extracting text using PyPDF\n",
- "Parsing took: 1.258554 seconds\n",
+ "Parsing took: 1.212609 seconds\n",
"Pere_Riche_Pere_Pauvre.pdf contained 225 pages\n",
"\n"
]
@@ -258,22 +258,25 @@
"output_type": "stream",
"text": [
"Azure_Cognitive_Search_Documentation.pdf \n",
- " chunk text: 1. Download sample data consisting of a small file set of different types. Unzi ...\n",
+ " chunk text: What's new in Cognitive Search\n",
+ "Preview features in Cognitive Search ...\n",
"\n",
"Boundaries_When_to_Say_Yes_How_to_Say_No_to_Take_Control_of_Your_Life.pdf \n",
- " chunk text: 21\n",
- "to things that could set him off: lateness, disagreements, and her\n",
- "own anger. ...\n",
+ " chunk text: 22\n",
+ "11:50 P.M.\n",
+ "Lying in bed, Sherrie couldn’t tell which was greater, her lone-\n",
+ "l ...\n",
"\n",
"Fundamentals_of_Physics_Textbook.pdf \n",
- " chunk text: By 1983, however, the demand for higher precision had reached such a pointthat e ...\n",
+ " chunk text: xxiPREFACEINSTRUCTOR SUPPLEMENTSInstructor’s Solutions Manualby Sen-Ben Liao, La ...\n",
"\n",
"Made_To_Stick.pdf \n",
- " chunk text: inforce the need for compactness and to provide a h int about how to \n",
- "cram more ...\n",
+ " chunk text: fare airline\" and the other stories in this chapter aren't simple be- \n",
+ "cause th ...\n",
"\n",
"Pere_Riche_Pere_Pauvre.pdf \n",
- " chunk text: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...\n",
+ " chunk text: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~\n",
+ "~~ ...\n",
"\n"
]
}
@@ -303,8 +306,8 @@
"output_type": "stream",
"text": [
"Extracting text using Azure Document Intelligence\n",
- "CPU times: user 14.4 s, sys: 280 ms, total: 14.7 s\n",
- "Wall time: 1min 6s\n"
+ "CPU times: user 11.6 s, sys: 212 ms, total: 11.8 s\n",
+ "Wall time: 1min 18s\n"
]
}
],
@@ -327,8 +330,7 @@
"output_type": "stream",
"text": [
"Pere_Riche_Pere_Pauvre.pdf \n",
- " chunk text: Le sentier que je n'ai pas emprunté\n",
- "Deux sentiers s'écartaient l'un de l'autre d ...\n",
+ " chunk text: Ces deux cheminements de vie exigeaient de l'instruction mais les matières à étu ...\n",
"\n"
]
}
@@ -358,7 +360,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 10,
"id": "7d46e7c5-49c4-40f3-bb2d-79a9afeab4b1",
"metadata": {},
"outputs": [],
@@ -368,7 +370,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 11,
"id": "1b07e84b-d306-4bc9-9124-e64f252dd7b2",
"metadata": {},
"outputs": [],
@@ -589,7 +591,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 12,
"id": "8b408798-5527-44ca-9dba-cad2ee726aca",
"metadata": {},
"outputs": [],
@@ -604,20 +606,20 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 14,
"id": "1b182ade-0ddd-47a1-b1eb-2cbf435c317f",
"metadata": {},
"outputs": [],
"source": [
"vector_indexes = [book_index_name]\n",
"\n",
- "agg_search_results = get_search_results(QUESTION, vector_indexes, k=10,\n",
+ "ordered_results = get_search_results(QUESTION, vector_indexes, \n",
+ " k=10,\n",
+ " reranker_threshold=1,\n",
" vector_search=True, \n",
+ " similarity_k=10,\n",
" query_vector = embedder.embed_query(QUESTION)\n",
- " )\n",
- "ordered_results = order_search_results(agg_search_results, k=10,\n",
- " reranker_threshold=1,\n",
- " vector_search = True)"
+ " )"
]
},
{
@@ -630,17 +632,18 @@
},
{
"cell_type": "code",
- "execution_count": 18,
+ "execution_count": 23,
"id": "410ff796-dab1-4817-a3a5-82eeff6c0c57",
"metadata": {},
"outputs": [],
"source": [
- "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=1000)"
+ "COMPLETION_TOKENS = 1000\n",
+ "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=COMPLETION_TOKENS)"
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 24,
"id": "744aba20-b3fd-4286-8d58-2ddfccc77734",
"metadata": {},
"outputs": [
@@ -663,7 +666,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 29,
"id": "db1c4d56-8c2d-47d6-8717-810f156f1c0c",
"metadata": {},
"outputs": [
@@ -671,8 +674,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Custom token limit for gpt-35-turbo-16k : 14000\n",
- "Combined docs tokens count: 3529\n",
+ "System prompt token count: 1669\n",
+ "Max Completion Token count: 1000\n",
+ "Combined docs (context) token count: 3529\n",
+ "--------\n",
+ "Requested token count: 6198\n",
+ "Token limit for gpt-35-turbo-16k : 16384\n",
"Chain Type selected: stuff\n"
]
}
@@ -681,19 +688,28 @@
"# Calculate number of tokens of our docs\n",
"if(len(top_docs)>0):\n",
" tokens_limit = model_tokens_limit(MODEL) # this is a custom function we created in common/utils.py\n",
- " num_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
- " chain_type = \"map_reduce\" if num_tokens > tokens_limit else \"stuff\" \n",
- " print(\"Custom token limit for\", MODEL, \":\", tokens_limit)\n",
- " print(\"Combined docs tokens count:\",num_tokens)\n",
+ " prompt_tokens = num_tokens_from_string(COMBINE_PROMPT_TEMPLATE) # this is a custom function we created in common/utils.py\n",
+ " context_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
+ " \n",
+ " requested_tokens = prompt_tokens + context_tokens + COMPLETION_TOKENS\n",
+ " \n",
+ " chain_type = \"map_reduce\" if requested_tokens > 0.9 * tokens_limit else \"stuff\" \n",
+ " \n",
+ " print(\"System prompt token count:\",prompt_tokens)\n",
+ " print(\"Max Completion Token count:\", COMPLETION_TOKENS)\n",
+ " print(\"Combined docs (context) token count:\",context_tokens)\n",
+ " print(\"--------\")\n",
+ " print(\"Requested token count:\",requested_tokens)\n",
+ " print(\"Token limit for\", MODEL, \":\", tokens_limit)\n",
" print(\"Chain Type selected:\", chain_type)\n",
" \n",
"else:\n",
- " print(\"NO RESULTS FROM AZURE SEARCH\")\n"
+ " print(\"NO RESULTS FROM AZURE SEARCH\")"
]
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 30,
"id": "62cf3a3f-2b4d-4806-8b92-eb982c52b0cd",
"metadata": {},
"outputs": [],
@@ -710,7 +726,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 31,
"id": "3b412c56-650f-4ca4-a868-9954f83679fa",
"metadata": {},
"outputs": [
@@ -718,8 +734,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 7.15 ms, sys: 146 µs, total: 7.3 ms\n",
- "Wall time: 10.9 s\n"
+ "CPU times: user 43.3 ms, sys: 18 µs, total: 43.3 ms\n",
+ "Wall time: 13.3 s\n"
]
}
],
@@ -731,37 +747,40 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 32,
"id": "63f07b08-87bd-4518-b2f2-03ee1096f59f",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
- "To push documents with vectors to an index using the Python SDK, you can use the `upload_documents` method of the `SearchClient` class. Here is an example of how to do it:\n",
+ "To push documents with vectors to an index using the Python SDK, you can use the following example:\n",
"\n",
- "```python\n",
+ "Python\n",
+ "```\n",
"from azure.core.credentials import AzureKeyCredential\n",
"from azure.search.documents import SearchClient\n",
"\n",
- "# Set up the search client\n",
+ "# Set up the necessary credentials and endpoint\n",
"endpoint = \"your_search_service_endpoint\"\n",
+ "key = \"your_search_service_api_key\"\n",
"index_name = \"your_index_name\"\n",
- "api_key = \"your_api_key\"\n",
- "search_client = SearchClient(endpoint=endpoint, index_name=index_name, credential=AzureKeyCredential(api_key))\n",
"\n",
- "# Define the documents with vectors\n",
+ "# Create a search client\n",
+ "search_client = SearchClient(endpoint=endpoint, index_name=index_name, credential=AzureKeyCredential(key))\n",
+ "\n",
+ "# Define your documents with vectors\n",
"documents = [\n",
" {\n",
" \"@search.action\": \"upload\",\n",
" \"id\": \"1\",\n",
- " \"name\": \"Document 1\",\n",
+ " \"text\": \"example document\",\n",
" \"vector\": [0.1, 0.2, 0.3]\n",
" },\n",
" {\n",
" \"@search.action\": \"upload\",\n",
" \"id\": \"2\",\n",
- " \"name\": \"Document 2\",\n",
+ " \"text\": \"another document\",\n",
" \"vector\": [0.4, 0.5, 0.6]\n",
" }\n",
"]\n",
@@ -774,9 +793,11 @@
" print(f\"Upload of document {upload_result.key} succeeded: {upload_result.succeeded}\")\n",
"```\n",
"\n",
- "This code sets up the search client using your search service endpoint, index name, and API key. It then defines the documents to be uploaded, including the document ID, name, and vector. Finally, it uses the `upload_documents` method to push the documents to the index. The result of the upload is checked to see if it succeeded.\n",
+ "This example demonstrates how to create a search client, define documents with vectors, and upload them to the specified index using the `upload_documents` method of the search client.\n",
+ "\n",
+ "[1]Source\n",
"\n",
- "[1]Source"
+ "Let me know if there is anything else I can help you with."
],
"text/plain": [
""
diff --git a/05-Adding_Memory.ipynb b/05-Adding_Memory.ipynb
index 937d7af3..ac44c178 100644
--- a/05-Adding_Memory.ipynb
+++ b/05-Adding_Memory.ipynb
@@ -34,9 +34,7 @@
"from langchain.chat_models import AzureChatOpenAI\n",
"from langchain.chains import LLMChain\n",
"from langchain.prompts import PromptTemplate\n",
- "from langchain.chains import ConversationChain\n",
- "from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT\n",
- "from langchain.memory import ConversationBufferMemory, ConversationTokenBufferMemory\n",
+ "from langchain.memory import ConversationBufferMemory\n",
"from openai.error import OpenAIError\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"from langchain.docstore.document import Document\n",
@@ -50,14 +48,14 @@
"#custom libraries that we will use later in the app\n",
"from common.utils import (\n",
" get_search_results,\n",
- " order_search_results,\n",
" update_vector_indexes,\n",
" model_tokens_limit,\n",
" num_tokens_from_docs,\n",
+ " num_tokens_from_string,\n",
" get_answer,\n",
")\n",
"\n",
- "from common.prompts import COMBINE_QUESTION_PROMPT, COMBINE_PROMPT, COMBINE_CHAT_PROMPT\n",
+ "from common.prompts import COMBINE_CHAT_PROMPT_TEMPLATE\n",
"\n",
"from dotenv import load_dotenv\n",
"load_dotenv(\"credentials.env\")\n",
@@ -113,8 +111,9 @@
"source": [
"# Define model\n",
"MODEL = \"gpt-35-turbo\"\n",
+ "COMPLETION_TOKENS = 500\n",
"# Create an OpenAI instance\n",
- "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=500)"
+ "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=COMPLETION_TOKENS)"
]
},
{
@@ -142,29 +141,29 @@
{
"data": {
"text/markdown": [
- "Reinforcement learning (RL) has various applications across different domains. Here are some use cases for reinforcement learning:\n",
+ "Reinforcement learning has a wide range of applications across various domains. Here are some use cases for reinforcement learning:\n",
"\n",
- "1. Game Playing: RL has excelled in game playing tasks, such as AlphaGo and AlphaZero, where it has achieved superhuman performance in complex board games like Go, chess, and shogi.\n",
+ "1. Game Playing: Reinforcement learning has been successfully applied to games like Chess, Go, and Atari games, where the agent learns to make optimal decisions by playing against itself or learning from human experts.\n",
"\n",
- "2. Robotics: RL can be used to train robots for tasks like object manipulation, grasping, locomotion, and navigation in dynamic and uncertain environments.\n",
+ "2. Robotics: Reinforcement learning is used to train robots to perform complex tasks, such as grasping objects, walking, or navigating through dynamic environments, by rewarding desired behaviors and penalizing undesired ones.\n",
"\n",
- "3. Autonomous Vehicles: RL can help in training self-driving cars to make decisions in real-time, such as lane changing, merging, and navigating complex traffic situations.\n",
+ "3. Autonomous Vehicles: Reinforcement learning can be used to train self-driving cars to make decisions in real-time, such as lane changing, merging, and navigating intersections, based on the surrounding environment and traffic conditions.\n",
"\n",
- "4. Resource Management: RL can optimize resource allocation in areas like energy management, traffic control, and supply chain management, ensuring efficient utilization and minimizing costs.\n",
+ "4. Recommendation Systems: Reinforcement learning can be employed to build personalized recommendation systems that learn user preferences and provide relevant suggestions for movies, music, products, or advertisements.\n",
"\n",
- "5. Healthcare: RL can be applied in personalized medicine, treatment optimization, and clinical decision-making, helping doctors determine the best treatment plans for patients.\n",
+ "5. Finance: Reinforcement learning can be used to optimize trading strategies in financial markets by learning to make buy/sell decisions based on historical data and market conditions.\n",
"\n",
- "6. Recommender Systems: RL can be used to build recommendation engines that learn user preferences and make personalized recommendations for movies, music, products, and more.\n",
+ "6. Healthcare: Reinforcement learning can help in optimizing treatment plans by learning from patient data and medical guidelines to recommend personalized therapies or dosage adjustments.\n",
"\n",
- "7. Finance: RL can assist in portfolio management, algorithmic trading, and risk management by learning optimal investment strategies and adapting to market dynamics.\n",
+ "7. Resource Management: Reinforcement learning can be applied to optimize resource allocation and scheduling problems, such as managing energy consumption in smart grids, controlling traffic signals, or optimizing supply chain logistics.\n",
"\n",
- "8. Industrial Control: RL can optimize control systems in manufacturing, energy, and process industries, improving efficiency, reducing energy consumption, and minimizing waste.\n",
+ "8. Natural Language Processing: Reinforcement learning can be used to train chatbots or virtual assistants to interact with users, understand natural language, and provide relevant responses.\n",
"\n",
- "9. Natural Language Processing: RL can be applied to dialogue systems and conversational agents, enabling them to learn how to respond to user queries and carry out meaningful conversations.\n",
+ "9. Education: Reinforcement learning can be employed to create intelligent tutoring systems that adapt to individual student needs, providing personalized feedback and guidance in the learning process.\n",
"\n",
- "10. Education: RL can be used to create intelligent tutoring systems that adapt to individual student needs, providing personalized instruction and feedback.\n",
+ "10. Healthcare Robotics: Reinforcement learning can be utilized to train robotic systems to assist in healthcare tasks, such as patient lifting, medication delivery, or physical therapy, while ensuring safety and patient comfort.\n",
"\n",
- "These are just a few examples, and RL has the potential to be applied in various other domains to solve complex decision-making problems."
+ "These are just a few examples, and the potential applications of reinforcement learning are vast and expanding as research progresses."
],
"text/plain": [
""
@@ -189,7 +188,7 @@
{
"data": {
"text/plain": [
- "\"I'm sorry, but I cannot recall the details of our conversation as I am an AI language model and do not have the capability to remember past interactions. However, if you provide me with specific information or questions, I'll be happy to assist you.\""
+ "\"I'm sorry, but as an AI language model, I don't have the ability to remember or recall past conversations. Once a conversation ends, the information is not retained. Is there anything specific you would like to discuss or ask about?\""
]
},
"execution_count": 7,
@@ -253,18 +252,10 @@
{
"data": {
"text/markdown": [
- "- Reinforcement learning (RL) has various applications across different domains.\n",
- "- Some use cases for RL include game playing, robotics, autonomous vehicles, resource management, healthcare, recommender systems, finance, industrial control, natural language processing, and education.\n",
- "- RL has achieved superhuman performance in game playing tasks like Go, chess, and shogi.\n",
- "- RL can be used to train robots for tasks like object manipulation, grasping, locomotion, and navigation.\n",
- "- RL can help in training self-driving cars to make real-time decisions in complex traffic situations.\n",
- "- RL can optimize resource allocation in areas like energy management, traffic control, and supply chain management.\n",
- "- RL can be applied in personalized medicine, treatment optimization, and clinical decision-making in healthcare.\n",
- "- RL can be used to build recommendation engines for personalized recommendations.\n",
- "- RL can assist in portfolio management, algorithmic trading, and risk management in finance.\n",
- "- RL can optimize control systems in manufacturing, energy, and process industries.\n",
- "- RL can be applied to dialogue systems and conversational agents in natural language processing.\n",
- "- RL can be used to create intelligent tutoring systems for personalized instruction and feedback in education."
+ "- Reinforcement learning has a wide range of applications across various domains.\n",
+ "- Some use cases of reinforcement learning include game playing, robotics, autonomous vehicles, recommendation systems, finance, healthcare, resource management, natural language processing, education, and healthcare robotics.\n",
+ "- Reinforcement learning can be used to train agents to make optimal decisions in games, perform complex tasks in robotics, make real-time decisions in autonomous vehicles, provide personalized recommendations, optimize trading strategies, optimize treatment plans in healthcare, optimize resource allocation and scheduling, train chatbots or virtual assistants, create intelligent tutoring systems, and assist in healthcare tasks.\n",
+ "- The potential applications of reinforcement learning are vast and expanding as research progresses."
],
"text/plain": [
""
@@ -303,7 +294,8 @@
"source": [
"# Since Memory adds tokens to the prompt, we would need a better model that allows more space on the prompt\n",
"MODEL = \"gpt-35-turbo-16k\"\n",
- "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=1000)\n",
+ "COMPLETION_TOKENS = 1000\n",
+ "llm = AzureChatOpenAI(deployment_name=MODEL, temperature=0.5, max_tokens=COMPLETION_TOKENS)\n",
"embedder = OpenAIEmbeddings(deployment=\"text-embedding-ada-002\", chunk_size=1) "
]
},
@@ -331,8 +323,9 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 517 ms, sys: 41.1 ms, total: 558 ms\n",
- "Wall time: 2.87 s\n"
+ "Number of results: 5\n",
+ "CPU times: user 528 ms, sys: 40.4 ms, total: 568 ms\n",
+ "Wall time: 3.02 s\n"
]
}
],
@@ -340,26 +333,26 @@
"%%time\n",
"\n",
"# Search in text-based indexes first and update vector indexes\n",
- "top_k=10\n",
- "agg_search_results = get_search_results(QUESTION, text_indexes, k=top_k, vector_search=False)\n",
- "ordered_results = order_search_results(agg_search_results, k=top_k, reranker_threshold=1, vector_search=False)\n",
+ "k=10 # Top k results per each text-based index\n",
+ "ordered_results = get_search_results(QUESTION, text_indexes, k=k, reranker_threshold=1, vector_search=False)\n",
"update_vector_indexes(ordered_search_results=ordered_results, embedder=embedder)\n",
"\n",
"# Search in all vector-based indexes available\n",
- "agg_search_results = get_search_results(QUESTION, vector_indexes, k=top_k , vector_search=True, \n",
+ "similarity_k = 5 # top results from multi-vector-index similarity search\n",
+ "ordered_results = get_search_results(QUESTION, vector_indexes, k=k, vector_search=True,\n",
+ " similarity_k=similarity_k,\n",
" query_vector = embedder.embed_query(QUESTION))\n",
- "top_similarity_k = 5\n",
- "ordered_results = order_search_results(agg_search_results, k=top_similarity_k,\n",
- " vector_search = True)\n"
+ "print(\"Number of results:\",len(ordered_results))"
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 14,
"id": "ca500dd8-148c-4d8a-b58b-2df4c957459d",
"metadata": {},
"outputs": [],
"source": [
+ "# Uncomment the below line if you want to inspect the ordered results\n",
"# ordered_results"
]
},
@@ -396,8 +389,12 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "Custom token limit for gpt-35-turbo-16k : 14000\n",
- "Combined docs tokens count: 1019\n",
+ "System prompt token count: 2464\n",
+ "Max Completion Token count: 1000\n",
+ "Combined docs (context) token count: 1019\n",
+ "--------\n",
+ "Requested token count: 4483\n",
+ "Token limit for gpt-35-turbo-16k : 16384\n",
"Chain Type selected: stuff\n"
]
}
@@ -406,15 +403,23 @@
"# Calculate number of tokens of our docs\n",
"if(len(top_docs)>0):\n",
" tokens_limit = model_tokens_limit(MODEL) # this is a custom function we created in common/utils.py\n",
- " num_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
- " print(\"Custom token limit for\", MODEL, \":\", tokens_limit)\n",
- " print(\"Combined docs tokens count:\",num_tokens)\n",
+ " prompt_tokens = num_tokens_from_string(COMBINE_CHAT_PROMPT_TEMPLATE) # this is a custom function we created in common/utils.py\n",
+ " context_tokens = num_tokens_from_docs(top_docs) # this is a custom function we created in common/utils.py\n",
+ " \n",
+ " requested_tokens = prompt_tokens + context_tokens + COMPLETION_TOKENS\n",
+ " \n",
+ " chain_type = \"map_reduce\" if requested_tokens > 0.9 * tokens_limit else \"stuff\" \n",
+ " \n",
+ " print(\"System prompt token count:\",prompt_tokens)\n",
+ " print(\"Max Completion Token count:\", COMPLETION_TOKENS)\n",
+ " print(\"Combined docs (context) token count:\",context_tokens)\n",
+ " print(\"--------\")\n",
+ " print(\"Requested token count:\",requested_tokens)\n",
+ " print(\"Token limit for\", MODEL, \":\", tokens_limit)\n",
+ " print(\"Chain Type selected:\", chain_type)\n",
" \n",
"else:\n",
- " print(\"NO RESULTS FROM AZURE SEARCH\")\n",
- " \n",
- "chain_type = \"map_reduce\" if num_tokens > tokens_limit else \"stuff\" \n",
- "print(\"Chain Type selected:\", chain_type)"
+ " print(\"NO RESULTS FROM AZURE SEARCH\")"
]
},
{
@@ -426,14 +431,14 @@
{
"data": {
"text/markdown": [
- "Reinforcement learning can be used in various use cases, including:\n",
- "1. Learning prevention strategies for epidemics of infectious diseases, such as pandemic influenza, in order to automatically learn mitigation policies in complex epidemiological models with a large state space[1].\n",
- "2. Personalized hybrid recommendation algorithm for music based on reinforcement learning, which recommends song sequences that match listeners' preferences better, by simulating the interaction process and continuously updating the model based on preferences[2].\n",
- "3. Learning sparse reward tasks in reinforcement learning by combining self-imitation learning with exploration bonuses, which enhances both exploitation and exploration to reduce sample complexity[3].\n",
- "4. Automatic feature engineering in machine learning projects, where a framework called CAFEM (Cross-data Automatic Feature Engineering Machine) is used to optimize the feature transformation graph and learn fine-grained feature engineering strategies[4].\n",
- "5. Job scheduling in data centers using Advantage Actor-Critic (A2C) deep reinforcement learning, where the A2cScheduler agent learns the scheduling policy automatically and achieves competitive scheduling performance[5].\n",
- "\n",
- "These use cases demonstrate the versatility of reinforcement learning in solving complex problems and optimizing decision-making processes."
+ "Reinforcement learning can be applied in various use cases, including:\n",
+ "1. Learning prevention strategies for epidemics of infectious diseases, such as pandemic influenza, by automatically learning mitigation policies in complex epidemiological models with a large state space[1].\n",
+ "2. Learning sparse reward tasks efficiently by combining self-imitation learning with exploration bonuses, which enhances exploration by producing intrinsic rewards when the agent visits novel states[2].\n",
+ "3. Personalized hybrid recommendation algorithms for music based on reinforcement learning, which consider the simulation of the interaction process to capture changes in listeners' preferences sensitively[3].\n",
+ "4. Automatic feature engineering in machine learning projects, where a framework called CAFEM (Cross-data Automatic Feature Engineering Machine) is used to optimize feature transformation and improve learning performance[4].\n",
+ "5. Job scheduling in data centers, where an Advantage Actor-Critic (A2C) deep reinforcement learning approach called A2cScheduler is used to automatically learn scheduling policies and achieve competitive scheduling performance[5].\n",
+ "\n",
+ "These references provide more details and information about the respective use cases."
],
"text/plain": [
""
@@ -446,8 +451,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "CPU times: user 39.6 ms, sys: 3.5 ms, total: 43.1 ms\n",
- "Wall time: 14.1 s\n"
+ "CPU times: user 9.97 ms, sys: 0 ns, total: 9.97 ms\n",
+ "Wall time: 21.5 s\n"
]
}
],
@@ -468,14 +473,16 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 18,
"id": "5cf5b323-3b9c-479b-8502-acfc4f7915dd",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
- "I'm sorry, but I cannot provide the main points of our conversation as it is not mentioned in the provided extracted parts."
+ "The main points of our conversation are about reinforcement learning in various domains. We discussed the use of deep reinforcement learning to learn prevention strategies in the context of pandemic influenza[1]. We also talked about the Explore-then-Exploit framework, which combines self-imitation learning with exploration bonuses to improve performance in sparse reward tasks[2]. Additionally, we discussed the use of reinforcement learning in personalized music recommendation systems[3]. We also touched upon the topic of automatic feature engineering using a framework called CAFEM[4]. Lastly, we discussed the A2cScheduler, an Advantage Actor-Critic deep reinforcement learning approach for job scheduling in data centers[5].\n",
+ "\n",
+ "Anything else I can help you with?"
],
"text/plain": [
""
@@ -506,7 +513,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 19,
"id": "d98b876e-d264-48ae-b5ed-9801d6a9152b",
"metadata": {},
"outputs": [
@@ -515,15 +522,15 @@
"text/markdown": [
"Reinforcement learning has various use cases across different domains. Here are some examples:\n",
"\n",
- "1. **Epidemic Prevention**: In the context of pandemic influenza, deep reinforcement learning can be used to automatically learn prevention strategies. By constructing epidemiological models and using reinforcement learning techniques, policies can be learned to control the spread of infectious diseases[1].\n",
+ "1. **Epidemic prevention strategies**: Reinforcement learning can be used to automatically learn prevention strategies for infectious diseases. For example, a study used deep reinforcement learning to learn mitigation policies in complex epidemiological models with a large state space[1].\n",
"\n",
- "2. **Sparse Reward Tasks**: Reinforcement learning can be challenging when dealing with tasks that have sparse rewards. One approach is self-imitation learning, where the agent imitates past good trajectories to encourage exploitation. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards for visiting novel states. A novel framework called Explore-then-Exploit (EE) combines these two approaches to strengthen their effects and achieve better performance in episodic reward settings[2].\n",
+ "2. **Sparse reward tasks**: Reinforcement learning can be challenging when dealing with tasks that have sparse rewards. Self-imitation learning and exploration bonuses are two approaches that can address this challenge. A recent framework called Explore-then-Exploit (EE) interleaves self-imitation learning with an exploration bonus to enhance both exploitation and exploration in learning tasks[2].\n",
"\n",
- "3. **Personalized Music Recommendation**: Reinforcement learning can be applied to personalized music recommendation systems. By using reinforcement learning algorithms, such as weighted matrix factorization and convolutional neural networks, the system can learn and update models based on users' preferences for songs and song transitions. This approach improves the accuracy of song sequence recommendations compared to traditional methods[3].\n",
+ "3. **Personalized recommendation systems**: Reinforcement learning can be applied to personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It uses techniques like weighted matrix factorization and convolutional neural networks to learn and extract song feature vectors, and it continuously updates the model based on the preferences of listeners for songs and song transitions[3].\n",
"\n",
- "4. **Automatic Feature Engineering**: Feature engineering is a crucial task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) uses reinforcement learning to optimize the feature transformation process. By learning fine-grained feature engineering strategies and utilizing meta-learning on a collection of datasets, CAFEM can generate effective features and improve learning performance[4].\n",
+ "4. **Automatic feature engineering**: Feature engineering is a crucial task in machine learning projects. Reinforcement learning can be used to automate feature engineering. For example, a framework called Cross-data Automatic Feature Engineering Machine (CAFEM) formalizes the feature engineering problem as an optimization problem over a Feature Transformation Graph (FTG). It includes a feature engineering learner that learns fine-grained strategies on a single dataset and a cross-data component that speeds up feature engineering learning on unseen datasets[4].\n",
"\n",
- "5. **Job Scheduling in Data Centers**: Efficient job scheduling in data centers is crucial for resource allocation. A deep reinforcement learning approach called A2cScheduler uses Advantage Actor-Critic (A2C) to learn scheduling policies automatically. By reducing gradient estimation variance and updating parameters efficiently, A2cScheduler achieves competitive scheduling performance in both simulated and real data center environments"
@@ -544,23 +551,19 @@
},
{
"cell_type": "code",
- "execution_count": 21,
+ "execution_count": 20,
"id": "bf28927b-d9ee-4412-bb07-13e055e832a7",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
- "Based on our conversation, here are the main points we discussed:\n",
+ "Here are the main points of our conversation:\n",
"\n",
"1. Reinforcement learning has various use cases across different domains.\n",
- "2. In the context of pandemic influenza, deep reinforcement learning can be used to automatically learn prevention strategies for controlling the spread of infectious diseases[1].\n",
- "3. Sparse reward tasks in reinforcement learning can be challenging. Approaches like self-imitation learning and exploration bonuses can be used to enhance exploration and exploitation[2].\n",
- "4. Reinforcement learning can be applied to personalized music recommendation systems to improve the accuracy of song sequence recommendations[3].\n",
- "5. Feature engineering is a crucial task in machine learning projects. A framework called CAFEM uses reinforcement learning to optimize the feature transformation process and generate effective features[4].\n",
- "6. Efficient job scheduling in data centers can be achieved using deep reinforcement learning approaches like A2cScheduler[5].\n",
+ "2. Some examples of use cases for reinforcement learning include epidemic prevention strategies, sparse reward tasks, personalized recommendation systems, automatic feature engineering, and job scheduling in data centers.\n",
"\n",
- "Please let me know if there's anything else I can assist you with."
+ "Would you like more information about any of these use cases?"
],
"text/plain": [
""
@@ -579,23 +582,24 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": 21,
"id": "3830b0b8-0ca2-4d0a-9747-f6273368002b",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
- "Based on our conversation, here are the main points we discussed:\n",
+ "The main points of our conversation are as follows:\n",
"\n",
"1. Reinforcement learning has various use cases across different domains.\n",
- "2. In the context of pandemic influenza, deep reinforcement learning can be used to automatically learn prevention strategies for controlling the spread of infectious diseases[1].\n",
- "3. Sparse reward tasks in reinforcement learning can be challenging. Approaches like self-imitation learning and exploration bonuses can be used to enhance exploration and exploitation[2].\n",
- "4. Reinforcement learning can be applied to personalized music recommendation systems to improve the accuracy of song sequence recommendations[3].\n",
- "5. Feature engineering is a crucial task in machine learning projects. A framework called CAFEM uses reinforcement learning to optimize the feature transformation process and generate effective features[4].\n",
- "6. Efficient job scheduling in data centers can be achieved using deep reinforcement learning approaches like A2cScheduler[5].\n",
- "\n",
- "Please let me know if there's anything else I can assist you with."
+ "2. Some examples of use cases for reinforcement learning include:\n",
+ " - Epidemic prevention strategies, where deep reinforcement learning is used to learn prevention strategies for infectious diseases[1].\n",
+ " - Sparse reward tasks, where self-imitation learning and exploration bonuses can be used to address the challenge of sparse rewards[2].\n",
+ " - Personalized recommendation systems, where reinforcement learning can be applied to recommend personalized song sequences[3].\n",
+ " - Automatic feature engineering, where reinforcement learning can be used to automate the process of feature engineering[4].\n",
+ " - Job scheduling in data centers, where reinforcement learning can be applied to optimize job scheduling and resource allocation[5].\n",
+ "\n",
+ "Please let me know if you would like more information about any of these use cases."
],
"text/plain": [
""
@@ -624,17 +628,17 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": 22,
"id": "1279692c-7eb0-4300-8a66-c7025f02c318",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "'Human: Tell me some use cases for reinforcement learning?\\nAI: Reinforcement learning has various use cases across different domains. Here are some examples:\\n\\n1. **Epidemic Prevention**: In the context of pandemic influenza, deep reinforcement learning can be used to automatically learn prevention strategies. By constructing epidemiological models and using reinforcement learning techniques, policies can be learned to control the spread of infectious diseases[1].\\n\\n2. **Sparse Reward Tasks**: Reinforcement learning can be challenging when dealing with tasks that have sparse rewards. One approach is self-imitation learning, where the agent imitates past good trajectories to encourage exploitation. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards for visiting novel states. A novel framework called Explore-then-Exploit (EE) combines these two approaches to strengthen their effects and achieve better performance in episodic reward settings[2].\\n\\n3. **Personalized Music Recommendation**: Reinforcement learning can be applied to personalized music recommendation systems. By using reinforcement learning algorithms, such as weighted matrix factorization and convolutional neural networks, the system can learn and update models based on users\\' preferences for songs and song transitions. This approach improves the accuracy of song sequence recommendations compared to traditional methods[3].\\n\\n4. **Automatic Feature Engineering**: Feature engineering is a crucial task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) uses reinforcement learning to optimize the feature transformation process. By learning fine-grained feature engineering strategies and utilizing meta-learning on a collection of datasets, CAFEM can generate effective features and improve learning performance[4].\\n\\n5. **Job Scheduling in Data Centers**: Efficient job scheduling in data centers is crucial for resource allocation. A deep reinforcement learning approach called A2cScheduler uses Advantage Actor-Critic (A2C) to learn scheduling policies automatically. By reducing gradient estimation variance and updating parameters efficiently, A2cScheduler achieves competitive scheduling performance in both simulated and real data center environments[1].\\n3. Sparse reward tasks in reinforcement learning can be challenging. Approaches like self-imitation learning and exploration bonuses can be used to enhance exploration and exploitation[2].\\n4. Reinforcement learning can be applied to personalized music recommendation systems to improve the accuracy of song sequence recommendations[3].\\n5. Feature engineering is a crucial task in machine learning projects. A framework called CAFEM uses reinforcement learning to optimize the feature transformation process and generate effective features[4].\\n6. Efficient job scheduling in data centers can be achieved using deep reinforcement learning approaches like A2cScheduler[5].\\n\\nPlease let me know if there\\'s anything else I can assist you with.\\nHuman: Thank you\\nAI: Based on our conversation, here are the main points we discussed:\\n\\n1. Reinforcement learning has various use cases across different domains.\\n2. In the context of pandemic influenza, deep reinforcement learning can be used to automatically learn prevention strategies for controlling the spread of infectious diseases[1].\\n3. Sparse reward tasks in reinforcement learning can be challenging. Approaches like self-imitation learning and exploration bonuses can be used to enhance exploration and exploitation[2].\\n4. Reinforcement learning can be applied to personalized music recommendation systems to improve the accuracy of song sequence recommendations[3].\\n5. Feature engineering is a crucial task in machine learning projects. A framework called CAFEM uses reinforcement learning to optimize the feature transformation process and generate effective features[4].\\n6. Efficient job scheduling in data centers can be achieved using deep reinforcement learning approaches like A2cScheduler[5].\\n\\nPlease let me know if there\\'s anything else I can assist you with.'"
+ "'Human: Tell me some use cases for reinforcement learning?\\nAI: Reinforcement learning has various use cases across different domains. Here are some examples:\\n\\n1. **Epidemic prevention strategies**: Reinforcement learning can be used to automatically learn prevention strategies for infectious diseases. For example, a study used deep reinforcement learning to learn mitigation policies in complex epidemiological models with a large state space[1].\\n\\n2. **Sparse reward tasks**: Reinforcement learning can be challenging when dealing with tasks that have sparse rewards. Self-imitation learning and exploration bonuses are two approaches that can address this challenge. A recent framework called Explore-then-Exploit (EE) interleaves self-imitation learning with an exploration bonus to enhance both exploitation and exploration in learning tasks[2].\\n\\n3. **Personalized recommendation systems**: Reinforcement learning can be applied to personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It uses techniques like weighted matrix factorization and convolutional neural networks to learn and extract song feature vectors, and it continuously updates the model based on the preferences of listeners for songs and song transitions[3].\\n\\n4. **Automatic feature engineering**: Feature engineering is a crucial task in machine learning projects. Reinforcement learning can be used to automate feature engineering. For example, a framework called Cross-data Automatic Feature Engineering Machine (CAFEM) formalizes the feature engineering problem as an optimization problem over a Feature Transformation Graph (FTG). It includes a feature engineering learner that learns fine-grained strategies on a single dataset and a cross-data component that speeds up feature engineering learning on unseen datasets[4].\\n\\n5. **Job scheduling in data centers**: Reinforcement learning can be applied to job scheduling in data centers. For example, an Advantage Actor-Critic (A2C) deep reinforcement learning-based approach called A2cScheduler was proposed for job scheduling. It consists of two agents, an actor and a critic, that work together to learn the scheduling policy and reduce estimation errors. The approach showed competitive performance using both simulated workloads and real data from an academic data center[1].\\n - Sparse reward tasks, where self-imitation learning and exploration bonuses can be used to address the challenge of sparse rewards[2].\\n - Personalized recommendation systems, where reinforcement learning can be applied to recommend personalized song sequences[3].\\n - Automatic feature engineering, where reinforcement learning can be used to automate the process of feature engineering[4].\\n - Job scheduling in data centers, where reinforcement learning can be applied to optimize job scheduling and resource allocation[5].\\n\\nPlease let me know if you would like more information about any of these use cases.'"
]
},
- "execution_count": 23,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@@ -658,7 +662,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 23,
"id": "c7131daa",
"metadata": {},
"outputs": [],
@@ -679,7 +683,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 24,
"id": "d87cc7c6-5ef1-4492-b133-9f63a392e223",
"metadata": {},
"outputs": [],
@@ -690,7 +694,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 25,
"id": "27ceb47a",
"metadata": {},
"outputs": [
@@ -699,25 +703,17 @@
"text/markdown": [
"Reinforcement learning has various use cases in different domains. Here are some examples:\n",
"\n",
- "1. **Epidemic Prevention**: Reinforcement learning can be used to automatically learn prevention strategies for infectious diseases. For example, a study used deep reinforcement learning to learn mitigation policies in complex epidemiological models with a large state space[1].\n",
- "\n",
- "2. **Sparse Reward Tasks**: Reinforcement learning can be applied to tasks with sparse rewards. One approach is self-imitation learning, which encourages the agent to exploit past good trajectories. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards for visiting novel states. A novel framework called Explore-then-Exploit (EE) interleaves self-imitation learning with an exploration bonus to strengthen the effect of both algorithms[2].\n",
+ "1. **Epidemic Prevention**: Reinforcement learning can be used to automatically learn prevention strategies for infectious diseases. For example, a study used deep reinforcement learning to learn mitigation policies in complex epidemiological models with a large state space[1].\n",
"\n",
- "3. **Personalized Recommendation Systems**: Reinforcement learning can be used to improve personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It recommends song sequences that match listeners' preferences better by simulating the interaction process and continuously updating the model based on preferences[3].\n",
+ "2. **Sparse Reward Tasks**: Reinforcement learning is used to tackle tasks with sparse rewards, where efficient exploitation and exploration are required. One approach is self-imitation learning, which encourages exploitation by imitating past good trajectories. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards. A novel framework called Explore-then-Exploit (EE) has been introduced, which interleaves self-imitation learning with an exploration bonus to strengthen the effect of these two algorithms[2].\n",
"\n",
- "4. **Feature Engineering**: Reinforcement learning can aid in automating feature engineering, which is a time-consuming task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) formalizes the feature engineering problem as an optimization problem over a Feature Transformation Graph (FTG). CAFEM consists of a FE learner (FeL) and a Cross-data Component (CdC) to speed up feature engineering learning on unseen datasets[4].\n",
+ "3. **Personalized Recommendation Systems**: Reinforcement learning can be used to improve personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It recommends song sequences that match listeners' preferences better by simulating the interaction process and updating the model continuously based on their preferences[3].\n",
"\n",
- "5. **Job Scheduling**: Reinforcement learning can be used for efficient job scheduling in data centers. An innovative Advantage Actor-Critic (A2C) deep reinforcement learning approach called A2cScheduler was proposed for job scheduling. It consists of two agents, the actor and the critic, which learn the scheduling policy and reduce the estimation error, respectively[5].\n",
+ "4. **Feature Engineering**: Reinforcement learning can be used to automate feature engineering, which is a time-consuming and challenging task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) has been proposed, which formalizes the feature engineering problem as an optimization problem and learns fine-grained feature engineering strategies using reinforcement learning[4].\n",
"\n",
- "These are just a few examples of the use cases for reinforcement learning. The applications of reinforcement learning are diverse and continue to expand as researchers explore its potential in various domains.\n",
+ "5. **Job Scheduling**: Reinforcement learning can be used for efficient job scheduling in data centers. An approach called A2cScheduler, based on Advantage Actor-Critic (A2C) deep reinforcement learning, has been proposed for job scheduling. It consists of two agents, the actor and the critic, which learn the scheduling policy and reduce estimation error, respectively[5].\n",
"\n",
- "Let me know if there's anything else I can help with!\n",
- "\n",
- "References:\n",
- "[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\n",
- "[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\n",
- "[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\n",
- "[4]"
@@ -736,34 +732,23 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": 26,
"id": "1a5ff826",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
- "Based on our conversation, here are the main points:\n",
+ "Here are the main points of our conversation:\n",
"\n",
"1. Reinforcement learning has various use cases in different domains.\n",
- "2. Epidemic prevention: Reinforcement learning can be used to learn prevention strategies for infectious diseases[1].\n",
- "3. Sparse reward tasks: Reinforcement learning can be applied to tasks with sparse rewards, using self-imitation learning and exploration bonuses[2].\n",
- "4. Personalized recommendation systems: Reinforcement learning can improve personalized recommendation systems, such as music recommendations[3].\n",
- "5. Feature engineering: Reinforcement learning can automate feature engineering tasks, speeding up machine learning projects[4].\n",
- "6. Job scheduling: Reinforcement learning can be used for efficient job scheduling in data centers[5].\n",
+ "2. One use case is epidemic prevention, where deep reinforcement learning is used to learn prevention strategies for infectious diseases[1].\n",
+ "3. Another use case is tackling tasks with sparse rewards, where self-imitation learning and exploration bonuses are used to enhance exploitation and exploration[2].\n",
+ "4. Reinforcement learning can be used to improve personalized recommendation systems, such as a hybrid recommendation algorithm for music based on reinforcement learning[3].\n",
+ "5. Reinforcement learning can automate feature engineering tasks, such as a framework called CAFEM that learns fine-grained feature engineering strategies using reinforcement learning[4].\n",
+ "6. Reinforcement learning can be used for efficient job scheduling in data centers, such as the A2cScheduler approach based on Advantage Actor-Critic (A2C) deep reinforcement learning[5].\n",
"\n",
- "These points provide an overview of the use cases for reinforcement learning. For more details, you can refer to the corresponding references.\n",
- "\n",
- "Let me know if there's anything else I can help with!\n",
- "\n",
- "References:\n",
- "[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\n",
- "[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\n",
- "[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\n",
- "[4][4] - \"Cross-data Automatic Feature Engineering Machine: Learning Feature Engineering for Unseen Datasets\"\n",
- "[5][5] - \"A2cScheduler: Advantage Actor-Critic Deep Reinforcement Learning for Job Scheduling in Data Centers\"\n",
- "\n",
- "Is there anything else you would like to know?"
+ "These points summarize the main use cases of reinforcement learning that we discussed. Is there anything else I can help you with?"
],
"text/plain": [
""
@@ -782,7 +767,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": 27,
"id": "be1620fa",
"metadata": {},
"outputs": [
@@ -792,24 +777,13 @@
"Based on our conversation, here are the main points:\n",
"\n",
"1. Reinforcement learning has various use cases in different domains.\n",
- "2. Epidemic prevention: Reinforcement learning can be used to learn prevention strategies for infectious diseases[1].\n",
- "3. Sparse reward tasks: Reinforcement learning can be applied to tasks with sparse rewards, using self-imitation learning and exploration bonuses[2].\n",
- "4. Personalized recommendation systems: Reinforcement learning can improve personalized recommendation systems, such as music recommendations[3].\n",
- "5. Feature engineering: Reinforcement learning can automate feature engineering tasks, speeding up machine learning projects[4].\n",
- "6. Job scheduling: Reinforcement learning can be used for efficient job scheduling in data centers[5].\n",
+ "2. One use case is epidemic prevention, where deep reinforcement learning is used to learn prevention strategies for infectious diseases[1].\n",
+ "3. Another use case is tackling tasks with sparse rewards, where self-imitation learning and exploration bonuses are used to enhance exploitation and exploration[2].\n",
+ "4. Reinforcement learning can be used to improve personalized recommendation systems, such as a hybrid recommendation algorithm for music based on reinforcement learning[3].\n",
+ "5. Reinforcement learning can automate feature engineering tasks, such as a framework called CAFEM that learns fine-grained feature engineering strategies using reinforcement learning[4].\n",
+ "6. Reinforcement learning can be used for efficient job scheduling in data centers, such as the A2cScheduler approach based on Advantage Actor-Critic (A2C) deep reinforcement learning[5].\n",
"\n",
- "These points provide an overview of the use cases for reinforcement learning. For more details, you can refer to the corresponding references.\n",
- "\n",
- "Let me know if there's anything else I can help with!\n",
- "\n",
- "References:\n",
- "[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\n",
- "[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\n",
- "[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\n",
- "[4][4] - \"Cross-data Automatic Feature Engineering Machine: Learning Feature Engineering for Unseen Datasets\"\n",
- "[5][5] - \"A2cScheduler: Advantage Actor-Critic Deep Reinforcement Learning for Job Scheduling in Data Centers\"\n",
- "\n",
- "Is there anything else you would like to know?"
+ "These points summarize the main use cases of reinforcement learning that we discussed. Let me know if there's anything else I can assist you with."
],
"text/plain": [
""
@@ -836,7 +810,7 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 28,
"id": "e1d7688a",
"metadata": {},
"outputs": [
@@ -844,14 +818,14 @@
"data": {
"text/plain": [
"[HumanMessage(content='Tell me some use cases for reinforcement learning?', additional_kwargs={}, example=False),\n",
- " AIMessage(content='Reinforcement learning has various use cases in different domains. Here are some examples:\\n\\n1. **Epidemic Prevention**: Reinforcement learning can be used to automatically learn prevention strategies for infectious diseases. For example, a study used deep reinforcement learning to learn mitigation policies in complex epidemiological models with a large state space[1].\\n\\n2. **Sparse Reward Tasks**: Reinforcement learning can be applied to tasks with sparse rewards. One approach is self-imitation learning, which encourages the agent to exploit past good trajectories. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards for visiting novel states. A novel framework called Explore-then-Exploit (EE) interleaves self-imitation learning with an exploration bonus to strengthen the effect of both algorithms[2].\\n\\n3. **Personalized Recommendation Systems**: Reinforcement learning can be used to improve personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It recommends song sequences that match listeners\\' preferences better by simulating the interaction process and continuously updating the model based on preferences[3].\\n\\n4. **Feature Engineering**: Reinforcement learning can aid in automating feature engineering, which is a time-consuming task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) formalizes the feature engineering problem as an optimization problem over a Feature Transformation Graph (FTG). CAFEM consists of a FE learner (FeL) and a Cross-data Component (CdC) to speed up feature engineering learning on unseen datasets[4].\\n\\n5. **Job Scheduling**: Reinforcement learning can be used for efficient job scheduling in data centers. An innovative Advantage Actor-Critic (A2C) deep reinforcement learning approach called A2cScheduler was proposed for job scheduling. It consists of two agents, the actor and the critic, which learn the scheduling policy and reduce the estimation error, respectively[5].\\n\\nThese are just a few examples of the use cases for reinforcement learning. The applications of reinforcement learning are diverse and continue to expand as researchers explore its potential in various domains.\\n\\nLet me know if there\\'s anything else I can help with!\\n\\nReferences:\\n[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\\n[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\\n[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\\n[4][1].\\n\\n2. **Sparse Reward Tasks**: Reinforcement learning is used to tackle tasks with sparse rewards, where efficient exploitation and exploration are required. One approach is self-imitation learning, which encourages exploitation by imitating past good trajectories. Another approach is exploration bonuses, which enhance exploration by providing intrinsic rewards. A novel framework called Explore-then-Exploit (EE) has been introduced, which interleaves self-imitation learning with an exploration bonus to strengthen the effect of these two algorithms[2].\\n\\n3. **Personalized Recommendation Systems**: Reinforcement learning can be used to improve personalized recommendation systems. For example, a personalized hybrid recommendation algorithm for music based on reinforcement learning was proposed. It recommends song sequences that match listeners\\' preferences better by simulating the interaction process and updating the model continuously based on their preferences[3].\\n\\n4. **Feature Engineering**: Reinforcement learning can be used to automate feature engineering, which is a time-consuming and challenging task in machine learning projects. A framework called Cross-data Automatic Feature Engineering Machine (CAFEM) has been proposed, which formalizes the feature engineering problem as an optimization problem and learns fine-grained feature engineering strategies using reinforcement learning[4].\\n\\n5. **Job Scheduling**: Reinforcement learning can be used for efficient job scheduling in data centers. An approach called A2cScheduler, based on Advantage Actor-Critic (A2C) deep reinforcement learning, has been proposed for job scheduling. It consists of two agents, the actor and the critic, which learn the scheduling policy and reduce estimation error, respectively[5].\\n\\nThese are just a few examples of the use cases for reinforcement learning. It', additional_kwargs={}, example=False),\n",
" HumanMessage(content='Give me the main points of our conversation', additional_kwargs={}, example=False),\n",
- " AIMessage(content='Based on our conversation, here are the main points:\\n\\n1. Reinforcement learning has various use cases in different domains.\\n2. Epidemic prevention: Reinforcement learning can be used to learn prevention strategies for infectious diseases[1].\\n3. Sparse reward tasks: Reinforcement learning can be applied to tasks with sparse rewards, using self-imitation learning and exploration bonuses[2].\\n4. Personalized recommendation systems: Reinforcement learning can improve personalized recommendation systems, such as music recommendations[3].\\n5. Feature engineering: Reinforcement learning can automate feature engineering tasks, speeding up machine learning projects[4].\\n6. Job scheduling: Reinforcement learning can be used for efficient job scheduling in data centers[5].\\n\\nThese points provide an overview of the use cases for reinforcement learning. For more details, you can refer to the corresponding references.\\n\\nLet me know if there\\'s anything else I can help with!\\n\\nReferences:\\n[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\\n[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\\n[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\\n[4][4] - \"Cross-data Automatic Feature Engineering Machine: Learning Feature Engineering for Unseen Datasets\"\\n[5][5] - \"A2cScheduler: Advantage Actor-Critic Deep Reinforcement Learning for Job Scheduling in Data Centers\"\\n\\nIs there anything else you would like to know?', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Here are the main points of our conversation:\\n\\n1. Reinforcement learning has various use cases in different domains.\\n2. One use case is epidemic prevention, where deep reinforcement learning is used to learn prevention strategies for infectious diseases[1].\\n3. Another use case is tackling tasks with sparse rewards, where self-imitation learning and exploration bonuses are used to enhance exploitation and exploration[2].\\n4. Reinforcement learning can be used to improve personalized recommendation systems, such as a hybrid recommendation algorithm for music based on reinforcement learning[3].\\n5. Reinforcement learning can automate feature engineering tasks, such as a framework called CAFEM that learns fine-grained feature engineering strategies using reinforcement learning[4].\\n6. Reinforcement learning can be used for efficient job scheduling in data centers, such as the A2cScheduler approach based on Advantage Actor-Critic (A2C) deep reinforcement learning[5].\\n\\nThese points summarize the main use cases of reinforcement learning that we discussed. Is there anything else I can help you with?', additional_kwargs={}, example=False),\n",
" HumanMessage(content='Thank you', additional_kwargs={}, example=False),\n",
- " AIMessage(content='Based on our conversation, here are the main points:\\n\\n1. Reinforcement learning has various use cases in different domains.\\n2. Epidemic prevention: Reinforcement learning can be used to learn prevention strategies for infectious diseases[1].\\n3. Sparse reward tasks: Reinforcement learning can be applied to tasks with sparse rewards, using self-imitation learning and exploration bonuses[2].\\n4. Personalized recommendation systems: Reinforcement learning can improve personalized recommendation systems, such as music recommendations[3].\\n5. Feature engineering: Reinforcement learning can automate feature engineering tasks, speeding up machine learning projects[4].\\n6. Job scheduling: Reinforcement learning can be used for efficient job scheduling in data centers[5].\\n\\nThese points provide an overview of the use cases for reinforcement learning. For more details, you can refer to the corresponding references.\\n\\nLet me know if there\\'s anything else I can help with!\\n\\nReferences:\\n[1][1] - \"Deep Reinforcement Learning for Autonomous Epidemic Prevention in Complex Epidemiological Models\"\\n[2][2] - \"Explore-then-Exploit: A Framework for Efficient Exploration in Reinforcement Learning\"\\n[3][3] - \"Personalized Hybrid Recommendation Algorithm for Music Based on Reinforcement Learning\"\\n[4][4] - \"Cross-data Automatic Feature Engineering Machine: Learning Feature Engineering for Unseen Datasets\"\\n[5][5] - \"A2cScheduler: Advantage Actor-Critic Deep Reinforcement Learning for Job Scheduling in Data Centers\"\\n\\nIs there anything else you would like to know?', additional_kwargs={}, example=False)]"
+ " AIMessage(content='Based on our conversation, here are the main points:\\n\\n1. Reinforcement learning has various use cases in different domains.\\n2. One use case is epidemic prevention, where deep reinforcement learning is used to learn prevention strategies for infectious diseases[1].\\n3. Another use case is tackling tasks with sparse rewards, where self-imitation learning and exploration bonuses are used to enhance exploitation and exploration[2].\\n4. Reinforcement learning can be used to improve personalized recommendation systems, such as a hybrid recommendation algorithm for music based on reinforcement learning[3].\\n5. Reinforcement learning can automate feature engineering tasks, such as a framework called CAFEM that learns fine-grained feature engineering strategies using reinforcement learning[4].\\n6. Reinforcement learning can be used for efficient job scheduling in data centers, such as the A2cScheduler approach based on Advantage Actor-Critic (A2C) deep reinforcement learning[5].\\n\\nThese points summarize the main use cases of reinforcement learning that we discussed. Let me know if there\\'s anything else I can assist you with.', additional_kwargs={}, example=False)]"
]
},
- "execution_count": 29,
+ "execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
diff --git a/09-Smart_Agent.ipynb b/09-Smart_Agent.ipynb
index eb87cd6a..dd6f2486 100644
--- a/09-Smart_Agent.ipynb
+++ b/09-Smart_Agent.ipynb
@@ -61,7 +61,7 @@
"def printmd(string):\n",
" display(Markdown(string))\n",
"\n",
- "MODEL_DEPLOYMENT_NAME = \"gpt-4-32k\" "
+ "MODEL_DEPLOYMENT_NAME = \"gpt-4-32k\" # Reminder: gpt-35-turbo models will create parsing errors and won't follow instructions correctly "
]
},
{
@@ -84,7 +84,7 @@
"source": [
"### Get the Tools - Doc Search, CSV Agent, SQL Agent and Web Search\n",
"\n",
- "In the file `common/utils.py` we created Agent Tools Classes for each of the Functionalities that we developed in prior Notebooks. This means that we are not using `qa_with_sources` chain anymore as we did until notebook 5. Agents that Reason, Act and Reflect is the best way to comunicate with sources."
+ "In the file `common/utils.py` we created Agent Tools Classes for each of the Functionalities that we developed in prior Notebooks. This means that we are not using `qa_with_sources` chain anymore as we did until notebook 5. Agents that Reason, Act and Reflect is the best way to create bots that comunicate with sources."
]
},
{
@@ -234,18 +234,18 @@
"output_type": "stream",
"text": [
"Tool: @docsearch\n",
- "To find the current weather in Dallas, I need to perform a search.\n",
+ "To answer this question, I need to perform a search to find the current weather in Dallas.\n",
"Action: search knowledge base\n",
"Action Input: current weather in Dallas\n",
- "I didn't find any results from the search. I need to try another search with different terms to find the current weather in Dallas.\n",
+ "The search results did not provide the current weather in Dallas. I will need to perform the search again.\n",
"Action: search knowledge base\n",
- "Action Input: Dallas weather now\n"
+ "Action Input: current weather in Dallas\n"
]
},
{
"data": {
"text/markdown": [
- "I'm sorry, but I couldn't find the current weather in Dallas from the search results."
+ "I'm sorry, but I was unable to find the current weather in Dallas."
],
"text/plain": [
""
@@ -271,10 +271,10 @@
"output_type": "stream",
"text": [
"Tool: @docsearch\n",
- "The user is asking about the impact of Covid-19 on obese and elderly people. I will need to perform two separate searches to gather information for each group. First, I'll look up how Covid-19 affects obese people.\n",
+ "The user has asked two questions related to the effects of Covid-19 on specific groups of people: obese individuals and the elderly. I need to perform two separate searches to find the answers to these questions. I'll start with the first question.\n",
"Action: search knowledge base\n",
"Action Input: How does Covid-19 affect obese people?\n",
- "The search results indicate that obesity is a risk factor for increased prevalence, severity, and lethality of COVID-19. Mechanisms such as immune system activity attenuation and chronic inflammation are implicated. Lipid peroxidation creates reactive lipid aldehydes which in a patient with metabolic disorder and COVID-19 will affect its prognosis[1]. Another study found that obesity is a potential risk factor for the severity of COVID-19[2]. Now, I'll search for how COVID-19 affects elderly people.\n",
+ "The search results provide information on how Covid-19 affects obese people. The first source states that obesity is connected with COVID-19 severity, and a number of mechanisms from immune system activity attenuation to chronic inflammation are implicated. It also mentions that lipid peroxidation in patients with metabolic disorders and COVID-19 can affect prognosis[1]. The third source also points out that obesity is a potential risk factor for the severity of COVID-19[3]. Now, I'll perform a search to answer the second part of the user's question regarding the effects of Covid-19 on the elderly.\n",
"Action: search knowledge base\n",
"Action Input: How does Covid-19 affect elderly people?\n"
]
@@ -282,13 +282,11 @@
{
"data": {
"text/markdown": [
- "COVID-19 affects obese and elderly people in significant ways:\n",
+ "Covid-19 affects both obese people and the elderly in specific ways:\n",
"\n",
- "1. **Obese People**: Obesity is a risk factor for increased prevalence, severity, and lethality of COVID-19. Mechanisms such as immune system activity attenuation and chronic inflammation are implicated. Lipid peroxidation creates reactive lipid aldehydes which in a patient with metabolic disorder and COVID-19 will affect its prognosis[1]. Another study found that obesity is a potential risk factor for the severity of COVID-19[2].\n",
+ "1. Obese individuals: Obesity is connected with COVID-19 severity. A number of mechanisms, from immune system activity attenuation to chronic inflammation, are implicated. Lipid peroxidation in patients with metabolic disorders and COVID-19 can affect their prognosis[1].\n",
"\n",
- "2. **Elderly People**: Elderly people are at a higher risk of more serious and possibly fatal illness associated with COVID-19. The risk of mortality increases with age, reaching 14.8% for people over 80 years old[3]. An increase in virus infection among people aged 20 -39 could double the risk of infection among elderly people[4]. Furthermore, the mortality of elderly patients with COVID-19 is higher than that of young and middle-aged patients, and elderly patients are more likely to progress to severe disease[5].\n",
- "\n",
- "It's important to note that these groups should take extra precautions to protect themselves from the virus."
+ "2. Elderly people: The risk of mortality from Covid-19 increases with age, with a risk of mortality of 3.6% for people in their 60s, 8.0% for people in their 70s, and 14.8% for people over 80 years old. An increase of virus infection among people aged 20 -39 could double the risk of infection among elderly people. The global recommendation for older populations includes social isolation[1][2]."
],
"text/plain": [
""
@@ -314,15 +312,15 @@
"output_type": "stream",
"text": [
"Tool: @booksearch\n",
- "I need to find out the acronym that represents the main point of the book \"Made to Stick\". \n",
+ "The user is asking for the acronym that represents the main point of the book \"Made to Stick\". I don't have this information, so I will need to search for it.\n",
"Action: search knowledge base\n",
- "Action Input: main point acronym of the book Made to Stick\n"
+ "Action Input: Main point acronym of the book Made to Stick\n"
]
},
{
"data": {
"text/markdown": [
- "The acronym that represents the main point of the book \"Made to Stick\" is SUCCESs, which stands for Simple, Unexpected, Concrete, Credible, Emotional, and Stories[5]."
+ "The acronym that represents the main point of the book \"Made to Stick\" is SUCCESs, which stands for Simple, Unexpected, Concrete, Credible, Emotional, Stories[5]."
],
"text/plain": [
""
@@ -347,21 +345,21 @@
"output_type": "stream",
"text": [
"Tool: @bing\n",
- "The user is asking for the names of the family members of the current president of India. I need to first find out who the current president of India is, and then search for information about their family.\n",
+ "The user is asking for the names of the family members of the current president of India. I need to first identify the current president of India, and then search for information about their family members.\n",
"Action: @bing\n",
"Action Input: current president of India\n",
- "The current president of India is Droupadi Murmu. Now I need to find information about her family.\n",
+ "The current president of India is Droupadi Murmu. Now, I will search for information about her family members.\n",
"Action: @bing\n",
"Action Input: Droupadi Murmu family members\n",
- "Droupadi Murmu's husband was named Shyam Charan Murmu. She also had two sons and a daughter named Itishree Murmu. However, it is noted that she lost her husband, two sons, mother, and brother between 2009-2015. She also has a granddaughter.\n",
+ "Droupadi Murmu's husband was Shyam Charan Murmu. She had two sons, a mother, and a brother, all of whom passed away between 2009 and 2015.\n",
"Action: @bing\n",
- "Action Input: site:https://en.wikipedia.org/wiki/Droupadi_Murmu Droupadi Murmu family members\n"
+ "Action Input: Droupadi Murmu children names\n"
]
},
{
"data": {
"text/markdown": [
- "Droupadi Murmu, the current president of India, had a husband named Shyam Charan Murmu, and they had two sons and a daughter named Itishree Murmu. She also has a granddaughter. However, it's important to note that she lost her husband, two sons, mother, and brother between 2009 and 2015[1][2]."
+ "The current president of India, Droupadi Murmu, had a husband named Shyam Charan Murmu. They had three children together: two sons and a daughter. One of her sons was named Laxman Murmu, and he passed away in 2009. Her second son also passed away in a road accident in 2012. The name of her daughter is not mentioned in the search results[1][2][3]."
],
"text/plain": [
""
@@ -387,10 +385,10 @@
"output_type": "stream",
"text": [
"Tool: @csvfile\n",
- "Thought: In order to find out the number of rows in the dataframe, I can use the shape attribute which returns a tuple with the number of rows and columns.\n",
+ "Thought: To find the number of rows in the dataframe, we can use the shape attribute which returns a tuple representing the dimensionality of the DataFrame. The first element of the tuple will give the number of rows.\n",
"Action: python_repl_ast\n",
"Action Input: df.shape[0]\n",
- "The shape attribute returns the number of rows in the dataframe as expected. However, to confirm the result, I will use another method.\n",
+ "The shape attribute of the dataframe returned 20780 for the number of rows. Let's verify this by using another method. We can use the len function which returns the number of items in an object.\n",
"Action: python_repl_ast\n",
"Action Input: len(df)\n"
]
@@ -400,7 +398,8 @@
"text/markdown": [
"The dataframe has 20780 rows.\n",
"\n",
- "Explanation: I used the shape attribute and the len function on the dataframe to find out the number of rows. Both methods returned the same result, confirming that the dataframe has 20780 rows."
+ "Explanation:\n",
+ "I used the shape attribute of the dataframe to get a tuple of the dimensionality of the dataframe. The first element of the tuple is the number of rows. I also used the len function on the dataframe to get the number of rows. Both methods returned the same result of 20780 rows."
],
"text/plain": [
""
@@ -428,28 +427,30 @@
"Tool: @sqlsearch\n",
"Action: sql_db_list_tables\n",
"Action Input: \"\"\n",
- "The `covidtracking` table seems to be the most relevant for this question. I should check its schema now.\n",
+ "The 'covidtracking' table seems to be the most relevant one for this query. I should look at the schema for this table to understand what data it contains.\n",
"Action: sql_db_schema\n",
- "Action Input: \"covidtracking\"\n",
- "The `covidtracking` table has the columns `state`, `death`, and `date`, which are all relevant to the question. I can use these columns to find the total number of deaths in each state on the west coast (California, Oregon, and Washington) in July 2020. I will create a SQL query to find this information.\n",
+ "Action Input: \"covidtracking\" \n",
+ "The 'covidtracking' table has a 'state' column, a 'death' column, and a 'date' column. These are relevant to the question. I need to find the total deaths in the states of the west coast (California, Oregon, Washington) in July 2020. I will write a query to sum the 'death' column for these states where the date is in July 2020.\n",
"Action: sql_db_query_checker\n",
- "Action Input: \"SELECT state, SUM(deathIncrease) as total_deaths FROM covidtracking WHERE (state = 'CA' OR state = 'OR' OR state = 'WA') AND date LIKE '2020-07%' GROUP BY state\"\n",
- "The query syntax is correct. Now I will run it to get the total number of deaths in each of the west coast states in July 2020.\n",
+ "Action Input: \"SELECT state, SUM(death) as total_deaths FROM covidtracking WHERE (state = 'CA' OR state = 'OR' OR state = 'WA') AND date LIKE '2020-07%' GROUP BY state\" \n",
+ "The query is correct. I can now run it.\n",
"Action: sql_db_query\n",
- "Action Input: \"SELECT state, SUM(deathIncrease) as total_deaths FROM covidtracking WHERE (state = 'CA' OR state = 'OR' OR state = 'WA') AND date LIKE '2020-07%' GROUP BY state\"\n"
+ "Action Input: \"SELECT state, SUM(death) as total_deaths FROM covidtracking WHERE (state = 'CA' OR state = 'OR' OR state = 'WA') AND date LIKE '2020-07%' GROUP BY state\"\n"
]
},
{
"data": {
"text/markdown": [
- "In July 2020, there were 3025 deaths in California, 112 deaths in Oregon, and 244 deaths in Washington.\n",
+ "In July 2020, the total number of deaths was as follows: \n",
+ "- California: 229,362\n",
+ "- Oregon: 7,745\n",
+ "- Washington: 44,440\n",
"\n",
"Explanation:\n",
- "I queried the `covidtracking` table for the sum of `deathIncrease` for each state (California, Oregon, and Washington) where the date starts with '2020-07' (indicating July 2020). The query returned a list of tuples with the state and the total number of deaths for that state in July 2020. \n",
- "I used the following query\n",
+ "I queried the `covidtracking` table for the sum of the `death` column where the state is 'CA', 'OR', or 'WA' and the date starts with '2020-07', which represents July 2020. The query returned a list of tuples with the state and the total number of deaths for that state in July 2020. I used the following query\n",
"\n",
"```sql\n",
- "SELECT state, SUM(deathIncrease) as total_deaths \n",
+ "SELECT state, SUM(death) as total_deaths \n",
"FROM covidtracking \n",
"WHERE (state = 'CA' OR state = 'OR' OR state = 'WA') AND date LIKE '2020-07%' \n",
"GROUP BY state\n",
@@ -484,33 +485,30 @@
{
"data": {
"text/markdown": [
- "In Python, you can use the `random` module to generate random numbers. Here are some common functions:\n",
+ "In Python, you can use the `random` module to generate random numbers. Here are a few examples:\n",
"\n",
- "1. **random.randint(a, b)**: This function returns a random integer between `a` and `b` (both inclusive).\n",
+ "1. **Generate a random float number between 0.0 and 1.0**\n",
"\n",
- " Example:\n",
- " ```python\n",
- " import random\n",
- " print(random.randint(1, 10)) # This will output a random integer between 1 and 10.\n",
- " ```\n",
+ "```python\n",
+ "import random\n",
+ "print(random.random())\n",
+ "```\n",
"\n",
- "2. **random.random()**: This function returns a random floating point number in the range [0.0, 1.0).\n",
+ "2. **Generate a random integer number between two given endpoints**\n",
"\n",
- " Example:\n",
- " ```python\n",
- " import random\n",
- " print(random.random()) # This will output a random float between 0.0 and 1.0.\n",
- " ```\n",
+ "```python\n",
+ "import random\n",
+ "print(random.randint(1, 10)) # This will generate a random integer between 1 and 10\n",
+ "```\n",
"\n",
- "3. **random.uniform(a, b)**: This function returns a random floating point number between `a` and `b`.\n",
+ "3. **Generate a random float number between two given endpoints**\n",
"\n",
- " Example:\n",
- " ```python\n",
- " import random\n",
- " print(random.uniform(1, 10)) # This will output a random float between 1 and 10.\n",
- " ```\n",
+ "```python\n",
+ "import random\n",
+ "print(random.uniform(1.5, 2.5)) # This will generate a random float between 1.5 and 2.5\n",
+ "```\n",
"\n",
- "Remember to `import random` at the beginning of your code to access these functions."
+ "Remember to always import the `random` module before using these functions."
],
"text/plain": [
""
@@ -744,7 +742,7 @@
{
"data": {
"text/markdown": [
- "I'm an artificial intelligence and don't have feelings, but I'm functioning as expected and ready to assist you. How can I help you today?"
+ "Hello! I'm an AI and don't have feelings, but I'm here and ready to assist you. How can I help you today?"
],
"text/plain": [
""
@@ -768,7 +766,7 @@
{
"data": {
"text/markdown": [
- "My name is Jarvis. I'm an assistant designed to help with a wide range of tasks. How can I assist you today?"
+ "My name is Jarvis. I'm an AI developed by OpenAI to assist with a wide range of tasks. How can I assist you today?"
],
"text/plain": [
""
@@ -794,28 +792,37 @@
"output_type": "stream",
"text": [
"Tool: @bing\n",
- "The user is asking for Italian and Sushi restaurants located in downtown Chicago. I will need to perform a web search to find this information.\n",
+ "The user is asking for Italian and Sushi restaurants located in downtown Chicago. I will use the @bing tool to search for this information.\n",
+ "Action: @bing\n",
+ "Action Input: Italian and Sushi restaurants in downtown Chicago\n",
+ "The search results provide several options for Italian and Sushi restaurants in downtown Chicago. Some of the Sushi restaurants include \"SUSHI-SAN\" in River North and \"Hot Woks Cool Sushi\"[1]. For Italian restaurants, options include \"The Village\" and \"Acanto\" located across from Millennium park[2][3]. I will now use the `site` operand to search for more information about these restaurants on the first two websites from my initial search.\n",
+ "Action: @bing\n",
+ "Action Input: SUSHI-SAN restaurant site:opentable.com\n",
+ "The search results provide more information about the SUSHI-SAN restaurant. It is located at 63 W Grand Ave, Chicago, IL 60654-4801 and offers catering services[1]. Now, I will search for more information about the \"Hot Woks Cool Sushi\" restaurant.\n",
"Action: @bing\n",
- "Action Input: Italian and Sushi restaurants in downtown Chicago\n"
+ "Action Input: Hot Woks Cool Sushi restaurant site:tripadvisor.com\n",
+ "The \"Hot Woks Cool Sushi\" restaurant is located at 30 S Michigan Ave, Chicago, IL 60603-3211. It offers Japanese Sushi and is ranked #165 of 4,381 restaurants in Chicago[1]. There are also other locations of this restaurant, such as the one at Willis Tower and another on Pulaski Rd[2][3]. Now, I will search for more information about the Italian restaurant \"The Village\".\n",
+ "Action: @bing\n",
+ "Action Input: The Village Italian restaurant site:tripadvisor.com\n",
+ "\"The Village\" is Chicago's oldest Italian restaurant and has been family-owned and operated since 1927. They offer traditional Italian American cuisine and have a 35,000-bottle wine collection[1]. Now, I will search for more information about the Italian restaurant \"Acanto\".\n",
+ "Action: @bing\n",
+ "Action Input: Acanto Italian restaurant site:opentable.com\n"
]
},
{
"data": {
"text/markdown": [
- "Here are some Italian and Sushi restaurants located in downtown Chicago:\n",
+ "Here are some Italian and Sushi restaurants in downtown Chicago:\n",
"\n",
- "**Sushi Restaurants**:\n",
- "1. Hot Woks Cool Sushi[1]\n",
- "2. Umai[1]\n",
- "3. Stetson's Modern Steak + Sushi[1]\n",
- "4. SUSHI-SAN - River North[2]\n",
+ "**Sushi Restaurants:**\n",
+ "1. \"SUSHI-SAN\" located at 63 W Grand Ave, Chicago, IL 60654-4801. They also offer catering services[1].\n",
+ "2. \"Hot Woks Cool Sushi\" located at 30 S Michigan Ave, Chicago, IL 60603-3211. It is ranked #165 of 4,381 restaurants in Chicago. They also have other locations, such as the one at Willis Tower and another on Pulaski Rd[2][3][4].\n",
"\n",
- "**Italian Restaurants**:\n",
- "1. The Village[4]\n",
- "2. Exchequer Restaurant & Pub[4]\n",
- "3. Giordano's[4]\n",
+ "**Italian Restaurants:**\n",
+ "1. \"The Village\" is Chicago's oldest Italian restaurant and has been family-owned and operated since 1927. They offer traditional Italian American cuisine and have a 35,000-bottle wine collection[5].\n",
+ "2. \"Acanto Restaurant + Wine Bar\" is located across from Millennium park along Chicago’s Cultural Mile. It is known for its authentic and approachable Italian food and offers seasonally-driven Italian cuisine from both regions of Italy utilizing artisanal ingredients from the Midwest[6].\n",
"\n",
- "Please note that availability and operating hours may vary, especially during this time. It's always a good idea to check the restaurant's official website or contact them directly for the most accurate information. Enjoy your meal!"
+ "Is there anything else you would like to know?"
],
"text/plain": [
""
@@ -838,7 +845,7 @@
{
"data": {
"text/markdown": [
- "The formula for momentum in physics is given by the product of an object's mass and its velocity. It is usually denoted as 'p', and can be written as: p = mv, where 'm' is the mass of the object and 'v' is its velocity."
+ "The formula for momentum in physics is given by **p = mv**, where **p** is the momentum, **m** is the mass of the object, and **v** is its velocity."
],
"text/plain": [
""
@@ -863,23 +870,19 @@
"output_type": "stream",
"text": [
"Tool: @docsearch\n",
- "Markov chains are a statistical model used in various fields. They can be used to model a sequence of possible events, where the probability of each event depends only on the state attained in the previous event. I will perform a search to find more specific applications and use cases of Markov chains.\n",
- "Action: @docsearch\n",
- "Action Input: applications of Markov chains\n"
+ "Markov chains are a mathematical concept used in various fields for modeling sequential or temporal data. They have applications in areas such as physics, chemistry, economics, and computer science. However, to provide a comprehensive answer, I need to perform a search to gather more detailed information.\n",
+ "Action: search knowledge base\n",
+ "Action Input: applications of markov chains\n"
]
},
{
"data": {
"text/markdown": [
- "Markov chains have a wide range of applications, including but not limited to:\n",
+ "Markov chains have various applications in different fields. These include:\n",
"\n",
- "1. **Epidemic Modeling**: Bayesian Markov Chain Monte Carlo-based inference in stochastic models can be used for modeling noisy epidemic data. This approach is beneficial in situations where only partial information about the epidemic process is available[1].\n",
- "\n",
- "2. **Particle Transport Prediction**: Markov chains can be used to predict transient particle transport in enclosed environments. This method can provide faster-than-real-time information about particle transport, and when the source location is changed, it can be used to avoid recalculation of the particle transport equation, thus reducing computing costs[2].\n",
- "\n",
- "3. **Game Theory**: In non-cooperative game theory, Markov chains can be used to compute Nash equilibria. Simulated annealing, a type of Monte Carlo sampling procedure that relies on Markov chains, can be used to compute this refinement[3].\n",
- "\n",
- "These applications showcase the versatility of Markov chains in various fields, from epidemic modeling to game theory."
+ "1. Analysis of stochastic diffusion search, where Markov chains model the evolution of semi-autonomous computational entities or agents. This is particularly useful in machine learning and computer science, as well as in models of economic behavior[1].\n",
+ "2. Bayesian Markov Chain Monte Carlo-based inference in stochastic models, which is suitable for modeling noisy epidemic data. This application uses the uniformization representation of a Markov process to efficiently generate appropriate conditional distributions in the Gibbs sampler algorithm[2].\n",
+ "3. Analysis and understanding of"
],
"text/plain": [
""
@@ -906,28 +909,28 @@
"Tool: @sqlsearch\n",
"Action: sql_db_list_tables\n",
"Action Input: \"\"\n",
- "The database has a table named `covidtracking` which seems relevant to the question. I should check the schema of this table to understand its structure and the data it contains.\n",
+ "The database contains only one table named 'covidtracking'. I should check the schema of this table to identify the structure and the columns available for querying.\n",
"Action: sql_db_schema\n",
"Action Input: \"covidtracking\" \n",
- "The `covidtracking` table has a `state` column and a `death` column, which are relevant to the question. The `date` column can be used to filter the data for the year 2020. However, the `state` values are in the two-letter format (like 'TX' for Texas) instead of the full name format (like 'Texas'). Therefore, I need to change 'Texas' to 'TX' in the query. Next, I will write a query to get the death data for Texas in 2020 and check if it's correct.\n",
+ "The 'covidtracking' table contains columns for 'date', 'state', and 'death'. I can use these columns to construct a query to find the total number of deaths in Texas in 2020.\n",
"Action: sql_db_query_checker\n",
- "Action Input: \"SELECT death FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\"\n",
- "The query seems to be correct. Now I will execute it to get the death data for Texas in 2020.\n",
+ "Action Input: \"SELECT COUNT(*) FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\" \n",
+ "The query syntax is correct. Now I can execute the query to get the count of deaths in Texas in 2020.\n",
"Action: sql_db_query\n",
- "Action Input: \"SELECT death FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\"\n"
+ "Action Input: \"SELECT COUNT(*) FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\" \n"
]
},
{
"data": {
"text/markdown": [
- "There were 27437 people who died of covid in Texas in 2020.\n",
+ "There were 304 entries of recorded deaths in Texas in 2020.\n",
"\n",
- "Explanation:\n",
- "I queried the `covidtracking` table for the `death` column where the state is 'TX' and the date starts with '2020'. The query returned a list of tuples with the number of deaths for each day in 2020. To answer the question, I took the maximum of all the deaths in the list, which is 27437. \n",
+ "Explanation: \n",
+ "I queried the `covidtracking` table for the count of rows where the state is 'TX' and the date starts with '2020'. The query returned a tuple with the count of rows, which is 304. \n",
"I used the following query\n",
"\n",
"```sql\n",
- "SELECT death FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\n",
+ "SELECT COUNT(*) FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\n",
"```"
],
"text/plain": [
@@ -953,27 +956,25 @@
"output_type": "stream",
"text": [
"Tool: @booksearch\n",
- "The user is asking for advice or guidelines on how to set boundaries for children. This could include strategies, reasons for setting boundaries, and the potential benefits of doing so. I'll perform a search to gather comprehensive information on this topic.\n",
- "Action: @docsearch\n",
- "Action Input: how to set boundaries for children\n"
+ "The user is asking for advice or guidelines on how to set boundaries for children. To provide a comprehensive response, I should search for information on best practices, techniques, and the importance of setting boundaries for children.\n",
+ "Action: search knowledge base\n",
+ "Action Input: How to set boundaries for children\n"
]
},
{
"data": {
"text/markdown": [
- "Setting boundaries for children is a crucial aspect of their development and has several important facets:\n",
- "\n",
- "1. **Expressing Feelings**: Encourage children to express their feelings like anger, grief, loss, or sadness. This helps them distinguish between their experiences and those of others, which is a key aspect of setting boundaries[1].\n",
+ "Setting boundaries for children involves several key steps and considerations:\n",
"\n",
- "2. **Discipline and Consequences**: Discipline is an external boundary designed to develop internal boundaries in children. It provides a structure of safety until the child has enough structure in their character and does not need it. Good discipline always moves the child toward more internal structure and more responsibility[2].\n",
+ "1. **Understanding the Purpose of Boundaries**: Boundaries help children to develop internal structure and responsibility. They provide a framework for safety until the child has enough internal structure to not need external enforcement[1].\n",
"\n",
- "3. **Ownership and Responsibility**: Encourage children to take ownership and responsibility. This includes allowing them to express words such as \"mine\", \"my\", and \"me\". This important part of becoming a self is often quite difficult for parents to understand, but it's crucial for the child's development[3].\n",
+ "2. **Use of Discipline**: Discipline is an external boundary, designed to develop internal boundaries in children. Good discipline moves the child towards more internal structure and more responsibility[1].\n",
"\n",
- "4. **Teaching Boundaries**: Teach children about boundaries by setting limits and requiring the child to take ownership and responsibility. This entails a clear understanding of boundaries[4].\n",
+ "3. **Allowing Expression of Feelings**: Allow children to express their feelings and needs. This helps them understand that their experiences are different from others and helps them develop a sense of self[2].\n",
"\n",
- "5. **Avoiding Abusive Relationships**: Teach children to avoid destructive relationships because of fear of abandonment. They should understand that setting boundaries may initially feel like they are alone, but with time and support, they will realize that boundaries are crucial for their wellbeing[5].\n",
+ "4. **Gradual Shift of Responsibility**: Gradually shift the responsibility of meeting needs from the parents to the child. This helps children to develop a sense of ownership and responsibility for their actions[3].\n",
"\n",
- "Remember, setting boundaries for children is not about punishment but about teaching them to become responsible individuals. It's about guiding them towards understanding their needs, expressing their feelings, and taking ownership of their actions."
+ "5. **Practice and Learning from Mistakes**: Allow children to learn from their mistakes. Practice is necessary in all areas of life, including learning boundaries and responsibility. Mistakes can be valuable teachers in this process"
@@ -998,30 +999,51 @@
"output_type": "stream",
"text": [
"Tool: @bing\n",
- "The user is asking for a recipe to cook a chocolate cake. I will use @bing to search for a recipe.\n",
+ "The user is asking for a recipe or instructions on how to cook a chocolate cake. I should search for a simple and popular recipe to provide the user with step-by-step instructions.\n",
"Action: @bing\n",
"Action Input: How to cook a chocolate cake recipe\n",
- "I have found several recipes for a chocolate cake. I will combine the common steps from these recipes to provide a comprehensive answer. However, I need to search again using the `site:` operator to confirm the information from the top two websites.\n",
+ "The search results provided several recipes for a chocolate cake. I will compile the common steps and ingredients from these recipes to provide a comprehensive answer. \n",
"Action: @bing\n",
- "Action Input: How to cook a chocolate cake recipe site:allrecipes.com\n",
- "The information from Allrecipes confirms the steps I found earlier. Now, I need to search the Food Network site to confirm the information from there as well.\n",
+ "Action Input: site:https://www.foodnetwork.com/recipes/food-network-kitchen/basic-chocolate-cake-recipe-2120876\n",
+ "I couldn't find more details on the first link. I will try the second link to gather more information about the recipe.\n",
"Action: @bing\n",
- "Action Input: How to cook a chocolate cake recipe site:foodnetwork.com\n"
+ "Action Input: site:https://www.bhg.com/recipes/how-to/bake/how-to-make-chocolate-cake/\n",
+ "I couldn't find more details on the second link either. I will try the third link to gather more information about the recipe.\n",
+ "Action: @bing\n",
+ "Action Input: site:https://www.kingarthurbaking.com/recipes/chocolate-cake-recipe\n",
+ "I couldn't find more details on the third link either. I will try the fourth link to gather more information about the recipe.\n",
+ "Action: @bing\n",
+ "Action Input: site:https://www.tasteofhome.com/recipes/classic-chocolate-cake/\n"
]
},
{
"data": {
"text/markdown": [
- "Here is a general recipe for a chocolate cake:\n",
+ "Here is a simplified recipe for a chocolate cake:\n",
+ "\n",
+ "**Ingredients**:\n",
+ "- 2/3 cup butter, softened\n",
+ "- 1-2/3 cups sugar\n",
+ "- 3 large eggs, room temperature\n",
+ "- 2 cups all-purpose flour\n",
+ "- 2/3 cup baking cocoa\n",
+ "- 1-1/4 teaspoons baking soda\n",
+ "- 1 teaspoon salt\n",
+ "- 1-1/3 cups 2% milk\n",
+ "- Confectioners' sugar or favorite frosting\n",
"\n",
- "1. Preheat the oven to 350 degrees F (175 degrees C).\n",
- "2. Grease and flour two nine-inch round pans. You can also line a half sheet pan with parchment paper and spray with cooking spray if you want to bake a sheet cake.\n",
- "3. In a large bowl, stir together the sugar, flour, cocoa, baking powder, baking soda, and salt.\n",
- "4. Add the eggs, milk, oil, and vanilla to the dry ingredients.\n",
- "5. Pour batter into the prepared pans.\n",
- "6. Bake in the preheated oven until a toothpick inserted into the center of the cake comes out clean[1][2].\n",
+ "**Instructions**:\n",
+ "1. Allow butter and eggs to stand at room temperature for 30 minutes.\n",
+ "2. Grease the bottom of your cake pan and line it with waxed paper. Grease and flour the bottom and sides of the pan.\n",
+ "3. In a bowl, cream the butter and sugar until light and fluffy, about 5-7 minutes.\n",
+ "4. Add eggs, one at a time, beating well after each addition.\n",
+ "5. Combine flour, cocoa, baking soda, and salt.\n",
+ "6. Add the dry mixture to the creamed mixture alternately with milk, beating until smooth after each addition.\n",
+ "7. Pour the batter into the prepared pan.\n",
+ "8. Bake at 350°F until a toothpick inserted in the center comes out clean, about 35-40 minutes.\n",
+ "9. Allow the cake to cool before applying confectioners' sugar or your favorite frosting.\n",
"\n",
- "Please note that this is a basic recipe and variations may apply depending on the specific type of chocolate cake you want to make. Always refer to the specific recipe for exact measurements and instructions."
+ "Enjoy your homemade chocolate cake! [1]. Anything else I can assist you with?"
],
"text/plain": [
""
@@ -1046,32 +1068,27 @@
"output_type": "stream",
"text": [
"Tool: @bing\n",
- "The user is asking for the best restaurants in downtown Seoul. I'll use the @bing tool to find this information. \n",
+ "The user is asking for recommendations for the best restaurants in downtown Seoul. I need to perform a web search to gather this information.\n",
"Action: @bing\n",
"Action Input: best restaurants in downtown Seoul\n",
- "The search results provided several restaurant options in downtown Seoul. \"Flavors\" and \"New Delhi\" are two options mentioned in the first search result[1]. The fourth search result mentions \"Mingles Restaurant\" as a popular choice[2]. I'll do another search to find more options and details about these restaurants.\n",
+ "The search results provided some restaurant names and a brief description of their offerings. I will now search on the first two websites from the initial search to gather more detailed information about these restaurants.\n",
"Action: @bing\n",
- "Action Input: Flavors restaurant Seoul review\n",
- "\"Flavors\" is a highly rated restaurant in Seoul, specializing in Seafood, Asian, and Korean cuisines. The restaurant is located at 176 Sinbanpo-ro, Seocho-gu, Seoul, South Korea[1]. Now I'll search for reviews on \"New Delhi\" restaurant in Seoul.\n",
+ "Action Input: site:https://www.tripadvisor.com/Restaurants-g294197-Seoul.html best restaurants in downtown Seoul\n",
+ "The search on the specific site did not yield any results. I will try the second site.\n",
"Action: @bing\n",
- "Action Input: New Delhi restaurant Seoul review\n",
- "\"New Delhi\" is another highly rated restaurant in Seoul, offering Indian and Asian cuisines. The restaurant is located at 28, Nonhyeon-ro 176-gil, Gangnam-gu, Seoul, South Korea[2]. Now I'll search for reviews on \"Mingles Restaurant\" in Seoul.\n",
- "Action: @bing\n",
- "Action Input: Mingles restaurant Seoul review\n"
+ "Action Input: site:https://www.eater.com/maps/best-seoul-restaurants-38 best restaurants in downtown Seoul\n"
]
},
{
"data": {
"text/markdown": [
- "Here are some of the best restaurants in downtown Seoul:\n",
- "\n",
- "1. **Flavors**: This restaurant specializes in Seafood, Asian, and Korean cuisines. It is located at 176 Sinbanpo-ro, Seocho-gu, Seoul, South Korea[1].\n",
- " \n",
- "2. **New Delhi**: An Indian and Asian cuisine restaurant located at 28, Nonhyeon-ro 176-gil, Gangnam-gu, Seoul, South Korea[2].\n",
+ "Some of the best restaurants in downtown Seoul include:\n",
"\n",
- "3. **Mingles Restaurant**: A two Michelin-starred establishment located at Dosan-daero 67-gil, Cheongdam-dong, Gangnam-gu, Seoul, South Korea. It has been ranked as number 1 restaurant in Korea since 2016[3][4].\n",
+ "1. **Flavors**: This restaurant has a high rating and offers a variety of seafood and meat dishes. They are particularly known for their lobster tails and snow crab legs[1].\n",
+ "2. **New Delhi**: This is an Indian restaurant known for its Masala Chai and chicken tikka masala[1].\n",
+ "3. **Woo Lae Oak**: This restaurant is recommended for its traditional Korean cuisine and has been awarded the Michelin Guide 2023 Bib Gourmand[2].\n",
"\n",
- "Please note that these are just a few examples and there are many other great restaurants in downtown Seoul."
+ "Please note that the situation may change, so it's always a good idea to check the latest reviews and updates. Enjoy your meal!"
],
"text/plain": [
""
@@ -1095,14 +1112,14 @@
{
"data": {
"text/markdown": [
- "Sure, here is an example of how to trim the spaces at the beginning and end of a sentence in JavaScript:\n",
+ "Sure, here's a simple JavaScript example to trim the spaces at the beginning and end of a sentence:\n",
"\n",
"```javascript\n",
"let sentence = ' Hello, World! ';\n",
"let trimmedSentence = sentence.trim();\n",
- "console.log(trimmedSentence); // Outputs: 'Hello, World!'\n",
+ "console.log(trimmedSentence); // Outputs: 'Hello, World!'\n",
"```\n",
- "The `trim()` function is a built-in JavaScript method that removes whitespace from both ends of a string."
+ "The `trim()` method removes whitespace from both ends of a string. Note that the original string is not modified; instead, a new string is returned."
],
"text/plain": [
""
@@ -1151,7 +1168,7 @@
{
"data": {
"text/markdown": [
- "You're welcome! If you have any other questions in the future, don't hesitate to ask. Have a great day!"
+ "You're welcome! If you have any more questions in the future, don't hesitate to ask. Have a great day!"
],
"text/plain": [
""
@@ -1175,25 +1192,25 @@
"data": {
"text/plain": [
"[HumanMessage(content='what is your name?', additional_kwargs={}, example=False),\n",
- " AIMessage(content=\"My name is Jarvis. I'm an assistant designed to help with a wide range of tasks. How can I assist you today?\", additional_kwargs={}, example=False),\n",
+ " AIMessage(content=\"My name is Jarvis. I'm an AI developed by OpenAI to assist with a wide range of tasks. How can I assist you today?\", additional_kwargs={}, example=False),\n",
" HumanMessage(content='@bing, I need to take my girlfriend to dinner tonight in downtown Chicago. Please give me options for Italian and Sushi as well', additional_kwargs={}, example=False),\n",
- " AIMessage(content='Here are some Italian and Sushi restaurants located in downtown Chicago:\\n\\n**Sushi Restaurants**:\\n1. Hot Woks Cool Sushi[1]\\n2. Umai[1]\\n3. Stetson\\'s Modern Steak + Sushi[1]\\n4. SUSHI-SAN - River North[2]\\n\\n**Italian Restaurants**:\\n1. The Village[4]\\n2. Exchequer Restaurant & Pub[4]\\n3. Giordano\\'s[4]\\n\\nPlease note that availability and operating hours may vary, especially during this time. It\\'s always a good idea to check the restaurant\\'s official website or contact them directly for the most accurate information. Enjoy your meal!', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Here are some Italian and Sushi restaurants in downtown Chicago:\\n\\n**Sushi Restaurants:**\\n1. \"SUSHI-SAN\" located at 63 W Grand Ave, Chicago, IL 60654-4801. They also offer catering services[1].\\n2. \"Hot Woks Cool Sushi\" located at 30 S Michigan Ave, Chicago, IL 60603-3211. It is ranked #165 of 4,381 restaurants in Chicago. They also have other locations, such as the one at Willis Tower and another on Pulaski Rd[2][3][4].\\n\\n**Italian Restaurants:**\\n1. \"The Village\" is Chicago\\'s oldest Italian restaurant and has been family-owned and operated since 1927. They offer traditional Italian American cuisine and have a 35,000-bottle wine collection[5].\\n2. \"Acanto Restaurant + Wine Bar\" is located across from Millennium park along Chicago’s Cultural Mile. It is known for its authentic and approachable Italian food and offers seasonally-driven Italian cuisine from both regions of Italy utilizing artisanal ingredients from the Midwest[6].\\n\\nIs there anything else you would like to know?', additional_kwargs={}, example=False),\n",
" HumanMessage(content='@chatgpt, tell me the formula in physics for momentum', additional_kwargs={}, example=False),\n",
- " AIMessage(content=\"The formula for momentum in physics is given by the product of an object's mass and its velocity. It is usually denoted as 'p', and can be written as: p = mv, where 'm' is the mass of the object and 'v' is its velocity.\", additional_kwargs={}, example=False),\n",
+ " AIMessage(content='The formula for momentum in physics is given by **p = mv**, where **p** is the momentum, **m** is the mass of the object, and **v** is its velocity.', additional_kwargs={}, example=False),\n",
" HumanMessage(content='@docsearch, what can markov chains do?', additional_kwargs={}, example=False),\n",
- " AIMessage(content='Markov chains have a wide range of applications, including but not limited to:\\n\\n1. **Epidemic Modeling**: Bayesian Markov Chain Monte Carlo-based inference in stochastic models can be used for modeling noisy epidemic data. This approach is beneficial in situations where only partial information about the epidemic process is available[1].\\n\\n2. **Particle Transport Prediction**: Markov chains can be used to predict transient particle transport in enclosed environments. This method can provide faster-than-real-time information about particle transport, and when the source location is changed, it can be used to avoid recalculation of the particle transport equation, thus reducing computing costs[2].\\n\\n3. **Game Theory**: In non-cooperative game theory, Markov chains can be used to compute Nash equilibria. Simulated annealing, a type of Monte Carlo sampling procedure that relies on Markov chains, can be used to compute this refinement[3].\\n\\nThese applications showcase the versatility of Markov chains in various fields, from epidemic modeling to game theory.', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Markov chains have various applications in different fields. These include:\\n\\n1. Analysis of stochastic diffusion search, where Markov chains model the evolution of semi-autonomous computational entities or agents. This is particularly useful in machine learning and computer science, as well as in models of economic behavior[1].\\n2. Bayesian Markov Chain Monte Carlo-based inference in stochastic models, which is suitable for modeling noisy epidemic data. This application uses the uniformization representation of a Markov process to efficiently generate appropriate conditional distributions in the Gibbs sampler algorithm[2].\\n3. Analysis and understanding of', additional_kwargs={}, example=False),\n",
" HumanMessage(content='@sqlsearch, How many people died of covid in Texas in 2020?', additional_kwargs={}, example=False),\n",
- " AIMessage(content=\"There were 27437 people who died of covid in Texas in 2020.\\n\\nExplanation:\\nI queried the `covidtracking` table for the `death` column where the state is 'TX' and the date starts with '2020'. The query returned a list of tuples with the number of deaths for each day in 2020. To answer the question, I took the maximum of all the deaths in the list, which is 27437. \\nI used the following query\\n\\n```sql\\nSELECT death FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\\n```\", additional_kwargs={}, example=False),\n",
+ " AIMessage(content=\"There were 304 entries of recorded deaths in Texas in 2020.\\n\\nExplanation: \\nI queried the `covidtracking` table for the count of rows where the state is 'TX' and the date starts with '2020'. The query returned a tuple with the count of rows, which is 304. \\nI used the following query\\n\\n```sql\\nSELECT COUNT(*) FROM covidtracking WHERE state = 'TX' AND date LIKE '2020%'\\n```\", additional_kwargs={}, example=False),\n",
" HumanMessage(content=\"@booksearch, I don't know how to say No to my kids, help me! What kind of boundaries should I set?\", additional_kwargs={}, example=False),\n",
- " AIMessage(content='Setting boundaries for children is a crucial aspect of their development and has several important facets:\\n\\n1. **Expressing Feelings**: Encourage children to express their feelings like anger, grief, loss, or sadness. This helps them distinguish between their experiences and those of others, which is a key aspect of setting boundaries[1].\\n\\n2. **Discipline and Consequences**: Discipline is an external boundary designed to develop internal boundaries in children. It provides a structure of safety until the child has enough structure in their character and does not need it. Good discipline always moves the child toward more internal structure and more responsibility[2].\\n\\n3. **Ownership and Responsibility**: Encourage children to take ownership and responsibility. This includes allowing them to express words such as \"mine\", \"my\", and \"me\". This important part of becoming a self is often quite difficult for parents to understand, but it\\'s crucial for the child\\'s development[3].\\n\\n4. **Teaching Boundaries**: Teach children about boundaries by setting limits and requiring the child to take ownership and responsibility. This entails a clear understanding of boundaries[4].\\n\\n5. **Avoiding Abusive Relationships**: Teach children to avoid destructive relationships because of fear of abandonment. They should understand that setting boundaries may initially feel like they are alone, but with time and support, they will realize that boundaries are crucial for their wellbeing[5].\\n\\nRemember, setting boundaries for children is not about punishment but about teaching them to become responsible individuals. It\\'s about guiding them towards understanding their needs, expressing their feelings, and taking ownership of their actions.', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Setting boundaries for children involves several key steps and considerations:\\n\\n1. **Understanding the Purpose of Boundaries**: Boundaries help children to develop internal structure and responsibility. They provide a framework for safety until the child has enough internal structure to not need external enforcement[1].\\n\\n2. **Use of Discipline**: Discipline is an external boundary, designed to develop internal boundaries in children. Good discipline moves the child towards more internal structure and more responsibility[1].\\n\\n3. **Allowing Expression of Feelings**: Allow children to express their feelings and needs. This helps them understand that their experiences are different from others and helps them develop a sense of self[2].\\n\\n4. **Gradual Shift of Responsibility**: Gradually shift the responsibility of meeting needs from the parents to the child. This helps children to develop a sense of ownership and responsibility for their actions[3].\\n\\n5. **Practice and Learning from Mistakes**: Allow children to learn from their mistakes. Practice is necessary in all areas of life, including learning boundaries and responsibility. Mistakes can be valuable teachers in this process[1][2].\\n\\nPlease note that this is a basic recipe and variations may apply depending on the specific type of chocolate cake you want to make. Always refer to the specific recipe for exact measurements and instructions.', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Here is a simplified recipe for a chocolate cake:\\n\\n**Ingredients**:\\n- 2/3 cup butter, softened\\n- 1-2/3 cups sugar\\n- 3 large eggs, room temperature\\n- 2 cups all-purpose flour\\n- 2/3 cup baking cocoa\\n- 1-1/4 teaspoons baking soda\\n- 1 teaspoon salt\\n- 1-1/3 cups 2% milk\\n- Confectioners\\' sugar or favorite frosting\\n\\n**Instructions**:\\n1. Allow butter and eggs to stand at room temperature for 30 minutes.\\n2. Grease the bottom of your cake pan and line it with waxed paper. Grease and flour the bottom and sides of the pan.\\n3. In a bowl, cream the butter and sugar until light and fluffy, about 5-7 minutes.\\n4. Add eggs, one at a time, beating well after each addition.\\n5. Combine flour, cocoa, baking soda, and salt.\\n6. Add the dry mixture to the creamed mixture alternately with milk, beating until smooth after each addition.\\n7. Pour the batter into the prepared pan.\\n8. Bake at 350°F until a toothpick inserted in the center comes out clean, about 35-40 minutes.\\n9. Allow the cake to cool before applying confectioners\\' sugar or your favorite frosting.\\n\\nEnjoy your homemade chocolate cake! [1]. Anything else I can assist you with?', additional_kwargs={}, example=False),\n",
" HumanMessage(content=\"What's a good place to dine today in downtown Seoul?\", additional_kwargs={}, example=False),\n",
- " AIMessage(content='Here are some of the best restaurants in downtown Seoul:\\n\\n1. **Flavors**: This restaurant specializes in Seafood, Asian, and Korean cuisines. It is located at 176 Sinbanpo-ro, Seocho-gu, Seoul, South Korea[1].\\n \\n2. **New Delhi**: An Indian and Asian cuisine restaurant located at 28, Nonhyeon-ro 176-gil, Gangnam-gu, Seoul, South Korea[2].\\n\\n3. **Mingles Restaurant**: A two Michelin-starred establishment located at Dosan-daero 67-gil, Cheongdam-dong, Gangnam-gu, Seoul, South Korea. It has been ranked as number 1 restaurant in Korea since 2016[3][4].\\n\\nPlease note that these are just a few examples and there are many other great restaurants in downtown Seoul.', additional_kwargs={}, example=False),\n",
+ " AIMessage(content='Some of the best restaurants in downtown Seoul include:\\n\\n1. **Flavors**: This restaurant has a high rating and offers a variety of seafood and meat dishes. They are particularly known for their lobster tails and snow crab legs[1].\\n2. **New Delhi**: This is an Indian restaurant known for its Masala Chai and chicken tikka masala[1].\\n3. **Woo Lae Oak**: This restaurant is recommended for its traditional Korean cuisine and has been awarded the Michelin Guide 2023 Bib Gourmand[2].\\n\\nPlease note that the situation may change, so it\\'s always a good idea to check the latest reviews and updates. Enjoy your meal!', additional_kwargs={}, example=False),\n",
" HumanMessage(content='@chatgpt, can you give me a javascript example of how to trim the spaces of a sentence?', additional_kwargs={}, example=False),\n",
- " AIMessage(content=\"Sure, here is an example of how to trim the spaces at the beginning and end of a sentence in JavaScript:\\n\\n```javascript\\nlet sentence = ' Hello, World! ';\\nlet trimmedSentence = sentence.trim();\\nconsole.log(trimmedSentence); // Outputs: 'Hello, World!'\\n```\\nThe `trim()` function is a built-in JavaScript method that removes whitespace from both ends of a string.\", additional_kwargs={}, example=False),\n",
+ " AIMessage(content=\"Sure, here's a simple JavaScript example to trim the spaces at the beginning and end of a sentence:\\n\\n```javascript\\nlet sentence = ' Hello, World! ';\\nlet trimmedSentence = sentence.trim();\\nconsole.log(trimmedSentence); // Outputs: 'Hello, World!'\\n```\\nThe `trim()` method removes whitespace from both ends of a string. Note that the original string is not modified; instead, a new string is returned.\", additional_kwargs={}, example=False),\n",
" HumanMessage(content='Thank you for the information, have a good day Jarvis!', additional_kwargs={}, example=False),\n",
- " AIMessage(content=\"You're welcome! If you have any other questions in the future, don't hesitate to ask. Have a great day!\", additional_kwargs={}, example=False)]"
+ " AIMessage(content=\"You're welcome! If you have any more questions in the future, don't hesitate to ask. Have a great day!\", additional_kwargs={}, example=False)]"
]
},
"execution_count": 34,
diff --git a/apps/frontend/frontend.zip b/apps/frontend/frontend.zip
index 1058c77d..f65ca358 100644
Binary files a/apps/frontend/frontend.zip and b/apps/frontend/frontend.zip differ
diff --git a/apps/frontend/pages/1_Search.py b/apps/frontend/pages/1_Search.py
index 7d576b2b..436aeeb9 100644
--- a/apps/frontend/pages/1_Search.py
+++ b/apps/frontend/pages/1_Search.py
@@ -11,10 +11,10 @@
from langchain.embeddings import OpenAIEmbeddings
from utils import (
get_search_results,
- order_search_results,
update_vector_indexes,
model_tokens_limit,
num_tokens_from_docs,
+ num_tokens_from_string,
get_answer,
)
st.set_page_config(page_title="GPT Smart Search", page_icon="📖", layout="wide")
@@ -101,17 +101,18 @@ def clear_submit():
# Search in text-based indexes first and update vector indexes
top_k=10
- agg_search_results = get_search_results(query, text_indexes, k=top_k, vector_search=False)
- ordered_results = order_search_results(agg_search_results, k=top_k, reranker_threshold=1, vector_search=False)
+ ordered_results = get_search_results(query, text_indexes, k=top_k,
+ reranker_threshold=1,
+ vector_search=False)
+
update_vector_indexes(ordered_search_results=ordered_results, embedder=embedder)
# Search in all vector-based indexes available
- agg_search_results = get_search_results(query, vector_indexes, k=top_k , vector_search=True,
- query_vector = embedder.embed_query(query))
top_similarity_k = 5
- ordered_results = order_search_results(agg_search_results, k=top_similarity_k,
- vector_search = True)
-
+ ordered_results = get_search_results(query, vector_indexes, k=top_k , vector_search=True,
+ similarity_k=top_similarity_k,
+ query_vector = embedder.embed_query(query))
+
st.session_state["submit"] = True
# Output Columns
diff --git a/common/prompts.py b/common/prompts.py
index 5187f57d..e8fe3786 100644
--- a/common/prompts.py
+++ b/common/prompts.py
@@ -227,8 +227,11 @@
Instructions:
- Create a final answer with references.
-- You can only provide numerical references to documents, using this format: [number].
-- Reference document's url can include query parameters, for example: "https://example.com/search?query=apple&category=fruits&sort=asc&page=1". On these cases, **you must** include que query references on the document url, using this format: [number].
+- You can only provide numerical references to documents, using this html format: `[number]`.
+- The reference must be from the `Source:` section of the extracted parts. You are not to make a reference from the content, only from the `Source:` of the extract parts.
+- Reference (source) document's url can include query parameters, for example: "https://example.com/search?query=apple&category=fruits&sort=asc&page=1". On these cases, **you must** include que query references on the document url, using this html format: [number].
+- **You can only answer the question from information contained in the extracted parts below**, DO NOT use your prior knowledge.
+- Never provide an answer without references.
- If you don't know the answer, just say that you don't know. Don't try to make up an answer.
- Respond in {language}.
@@ -468,6 +471,7 @@
- If you are unable to fully find the answer, try again by adjusting your search terms.
- You can only provide numerical references, using this format: [number]
- You must never generate URLs or links other than those provided in the search results.
+- You must provide the references URLs exactly as shown in the 'location' of each chunk below. Do not shorten it.
- You must always reference factual statements to the search results.
- You must find the answer to the question in the context only.
- If the context has no results found, you must respond saying that no results were found to answer the question.
@@ -507,47 +511,47 @@
OrderedDict([('z4cagypm_0',
{{'title': 'Deep reinforcement learning for large-scale epidemic control_chunk_0',
- 'name': 'metadata.csv',
- 'location': 'https://arxiv.org/pdf/2003.13676v1.pdf',
+ 'name': 'some file name',
+ 'location': 'some url location',
'caption': 'This experiment shows that deep reinforcement learning can be used to learn mitigation policies in complex epidemiological models with a large state space. Moreover, through this experiment, we demonstrate that there can be an advantage to consider collaboration between districts when designing prevention strategies..\x00',
- 'index': 'cogsrch-index-csv-vector',
+ 'index': 'some index name',
'chunk': "Epidemics of infectious diseases are an important threat to public health and global economies. Yet, the development of prevention strategies remains a challenging process, as epidemics are non-linear and complex processes. For this reason, we investigate a deep reinforcement learning approach to automatically learn prevention strategies in the context of pandemic influenza. Firstly, we construct a new epidemiological meta-population model, with 379 patches (one for each administrative district in Great Britain), that adequately captures the infection process of pandemic influenza. Our model balances complexity and computational efficiency such that the use of reinforcement learning techniques becomes attainable. Secondly, we set up a ground truth such that we can evaluate the performance of the 'Proximal Policy Optimization' algorithm to learn in a single district of this epidemiological model. Finally, we consider a large-scale problem, by conducting an experiment where we aim to learn a joint policy to control the districts in a community of 11 tightly coupled districts, for which no ground truth can be established. This experiment shows that deep reinforcement learning can be used to learn mitigation policies in complex epidemiological models with a large state space. Moreover, through this experiment, we demonstrate that there can be an advantage to consider collaboration between districts when designing prevention strategies.",
'score': 0.03333333507180214}}),
('8gaeosyr_0',
{{'title': 'A Hybrid Recommendation for Music Based on Reinforcement Learning_chunk_0',
- 'name': 'metadata.csv',
- 'location': 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7206183/',
+ 'name': 'another file name',
+ 'location': 'another url location',
'caption': 'In this paper, we propose a personalized hybrid recommendation algorithm for music based on reinforcement learning (PHRR) to recommend song sequences that match listeners’ preferences better. We firstly use weighted matrix factorization (WMF) and convolutional neural network (CNN) to learn and extract the song feature vectors.',
- 'index': 'cogsrch-index-csv-vector',
+ 'index': 'some index name',
'chunk': 'The key to personalized recommendation system is the prediction of users’ preferences. However, almost all existing music recommendation approaches only learn listeners’ preferences based on their historical records or explicit feedback, without considering the simulation of interaction process which can capture the minor changes of listeners’ preferences sensitively. In this paper, we propose a personalized hybrid recommendation algorithm for music based on reinforcement learning (PHRR) to recommend song sequences that match listeners’ preferences better. We firstly use weighted matrix factorization (WMF) and convolutional neural network (CNN) to learn and extract the song feature vectors. In order to capture the changes of listeners’ preferences sensitively, we innovatively enhance simulating interaction process of listeners and update the model continuously based on their preferences both for songs and song transitions. The extensive experiments on real-world datasets validate the effectiveness of the proposed PHRR on song sequence recommendation compared with the state-of-the-art recommendation approaches.',
'score': 0.032522473484277725}}),
('7sjdzz9x_0',
{{'title': 'Balancing Exploration and Exploitation in Self-imitation Learning_chunk_0',
- 'name': 'metadata.csv',
- 'location': 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7206262/',
+ 'name': 'another file name',
+ 'location': 'another url location',
'caption': 'Sparse reward tasks are always challenging in reinforcement learning. Learning such tasks requires both efficient exploitation and exploration to reduce the sample complexity. One line of research called self-imitation learning is recently proposed, which encourages the agent to do more exploitation by imitating past good trajectories.',
- 'index': 'cogsrch-index-csv-vector',
+ 'index': 'another index name',
'chunk': 'Sparse reward tasks are always challenging in reinforcement learning. Learning such tasks requires both efficient exploitation and exploration to reduce the sample complexity. One line of research called self-imitation learning is recently proposed, which encourages the agent to do more exploitation by imitating past good trajectories. Exploration bonuses, however, is another line of research which enhances exploration by producing intrinsic reward when the agent visits novel states. In this paper, we introduce a novel framework Explore-then-Exploit (EE), which interleaves self-imitation learning with an exploration bonus to strengthen the effect of these two algorithms. In the exploring stage, with the aid of intrinsic reward, the agent tends to explore unseen states and occasionally collect high rewarding experiences, while in the self-imitating stage, the agent learns to consistently reproduce such experiences and thus provides a better starting point for subsequent stages. Our result shows that EE achieves superior or comparable performance on variants of MuJoCo environments with episodic reward settings.',
'score': 0.03226646035909653}}),
('r253ygx0_0',
{{'title': 'Cross-data Automatic Feature Engineering via Meta-learning and Reinforcement Learning_chunk_0',
- 'name': 'metadata.csv',
- 'location': 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7206177/',
+ 'name': 'another file name',
+ 'location': 'another url location',
'caption': 'CAFEM contains two components: a FE learner (FeL) that learns fine-grained FE strategies on one single dataset by Double Deep Q-learning (DDQN) and a Cross-data Component (CdC) that speeds up FE learning on an unseen dataset by the generalized FE policies learned by Meta-Learning on a collection of datasets.',
- 'index': 'cogsrch-index-csv-vector',
+ 'index': 'another index name',
'chunk': 'Feature Engineering (FE) is one of the most beneficial, yet most difficult and time-consuming tasks of machine learning projects, and requires strong expert knowledge. It is thus significant to design generalized ways to perform FE. The primary difficulties arise from the multiform information to consider, the potentially infinite number of possible features and the high computational cost of feature generation and evaluation. We present a framework called Cross-data Automatic Feature Engineering Machine (CAFEM), which formalizes the FE problem as an optimization problem over a Feature Transformation Graph (FTG). CAFEM contains two components: a FE learner (FeL) that learns fine-grained FE strategies on one single dataset by Double Deep Q-learning (DDQN) and a Cross-data Component (CdC) that speeds up FE learning on an unseen dataset by the generalized FE policies learned by Meta-Learning on a collection of datasets. We compare the performance of FeL with several existing state-of-the-art automatic FE techniques on a large collection of datasets. It shows that FeL outperforms existing approaches and is robust on the selection of learning algorithms. Further experiments also show that CdC can not only speed up FE learning but also increase learning performance.',
'score': 0.031054403632879257}}),
('f3oswivw_0',
{{'title': 'Data Centers Job Scheduling with Deep Reinforcement Learning_chunk_0',
- 'name': 'metadata.csv',
- 'location': 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7206316/',
+ 'name': 'another file name',
+ 'location': 'another url location',
'caption': 'A2cScheduler consists of two agents, one of which, dubbed the actor, is responsible for learning the scheduling policy automatically and the other one, the critic, reduces the estimation error. Unlike previous policy gradient approaches, A2cScheduler is designed to reduce the gradient estimation variance and to update parameters efficiently.',
- 'index': 'cogsrch-index-csv-vector',
+ 'index': 'another index name',
'chunk': 'Efficient job scheduling on data centers under heterogeneous complexity is crucial but challenging since it involves the allocation of multi-dimensional resources over time and space. To adapt the complex computing environment in data centers, we proposed an innovative Advantage Actor-Critic (A2C) deep reinforcement learning based approach called A2cScheduler for job scheduling. A2cScheduler consists of two agents, one of which, dubbed the actor, is responsible for learning the scheduling policy automatically and the other one, the critic, reduces the estimation error. Unlike previous policy gradient approaches, A2cScheduler is designed to reduce the gradient estimation variance and to update parameters efficiently. We show that the A2cScheduler can achieve competitive scheduling performance using both simulated workloads and real data collected from an academic data center.',
'score': 0.03102453239262104}})])
Final Answer:
-Reinforcement learning can be used in various use cases, including:\n1. Learning prevention strategies for epidemics of infectious diseases, such as pandemic influenza, in order to automatically learn mitigation policies in complex epidemiological models with a large state space[1].\n2. Personalized hybrid recommendation algorithm for music based on reinforcement learning, which recommends song sequences that match listeners\' preferences better, by simulating the interaction process and continuously updating the model based on preferences[2].\n3. Learning sparse reward tasks in reinforcement learning by combining self-imitation learning with exploration bonuses, which enhances both exploitation and exploration to reduce sample complexity[3].\n4. Automatic feature engineering in machine learning projects, where a framework called CAFEM (Cross-data Automatic Feature Engineering Machine) is used to optimize the feature transformation graph and learn fine-grained feature engineering strategies[4].\n5. Job scheduling in data centers using Advantage Actor-Critic (A2C) deep reinforcement learning, where the A2cScheduler agent learns the scheduling policy automatically and achieves competitive scheduling performance[5].\n\nThese use cases demonstrate the versatility of reinforcement learning in solving complex problems and optimizing decision-making processes.
+Reinforcement learning can be used in various use cases, including:\n1. Learning prevention strategies for epidemics of infectious diseases, such as pandemic influenza, in order to automatically learn mitigation policies in complex epidemiological models with a large state space[1].\n2. Personalized hybrid recommendation algorithm for music based on reinforcement learning, which recommends song sequences that match listeners\' preferences better, by simulating the interaction process and continuously updating the model based on preferences[2].\n3. Learning sparse reward tasks in reinforcement learning by combining self-imitation learning with exploration bonuses, which enhances both exploitation and exploration to reduce sample complexity[3].\n4. Automatic feature engineering in machine learning projects, where a framework called CAFEM (Cross-data Automatic Feature Engineering Machine) is used to optimize the feature transformation graph and learn fine-grained feature engineering strategies[4].\n5. Job scheduling in data centers using Advantage Actor-Critic (A2C) deep reinforcement learning, where the A2cScheduler agent learns the scheduling policy automatically and achieves competitive scheduling performance[5].\n\nThese use cases demonstrate the versatility of reinforcement learning in solving complex problems and optimizing decision-making processes.
## You have access to the following tools:
diff --git a/common/utils.py b/common/utils.py
index 342dfdd6..21f81b47 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -245,15 +245,15 @@ def num_tokens_from_string(string: str) -> int:
def model_tokens_limit(model: str) -> int:
"""Returns the number of tokens limits in a text model."""
if model == "gpt-35-turbo":
- token_limit = 2000
+ token_limit = 4096
elif model == "gpt-4":
- token_limit = 6000
+ token_limit = 8192
elif model == "gpt-35-turbo-16k":
- token_limit = 14000
+ token_limit = 16384
elif model == "gpt-4-32k":
- token_limit = 30000
+ token_limit = 32768
else:
- token_limit = 2000
+ token_limit = 4096
return token_limit
# Returns num of toknes used on a list of Documents objects
@@ -264,8 +264,13 @@ def num_tokens_from_docs(docs: List[Document]) -> int:
return num_tokens
-def get_search_results(query: str, indexes: list, k: int = 5,
- vector_search: bool = False, query_vector: list = []) -> List[dict]:
+def get_search_results(query: str, indexes: list,
+ k: int = 5,
+ reranker_threshold: int = 1,
+ sas_token: str = "",
+ vector_search: bool = False,
+ similarity_k: int = 3,
+ query_vector: list = []) -> List[dict]:
headers = {'Content-Type': 'application/json','api-key': os.environ["AZURE_SEARCH_KEY"]}
params = {'api-version': os.environ['AZURE_SEARCH_API_VERSION']}
@@ -296,14 +301,6 @@ def get_search_results(query: str, indexes: list, k: int = 5,
search_results = resp.json()
agg_search_results[index] = search_results
-
- return agg_search_results
-
-
-def order_search_results( agg_search_results: dict, k:int = 5, reranker_threshold: int = 1,
- vector_search: bool = False, sas_token: str ="") -> OrderedDict:
-
- """Orders based on score the results from get_search_results function"""
content = dict()
ordered_content = OrderedDict()
@@ -329,11 +326,16 @@ def order_search_results( agg_search_results: dict, k:int = 5, reranker_threshol
content[result['id']]["vectorized"]= result['vectorized']
# After results have been filtered, sort and add the top k to the ordered_content
+ if vector_search:
+ topk = similarity_k
+ else:
+ topk = k*len(indexes)
+
count = 0 # To keep track of the number of results added
for id in sorted(content, key=lambda x: content[x]["score"], reverse=True):
ordered_content[id] = content[id]
count += 1
- if count >= k: # Stop after adding 5 results
+ if count >= topk: # Stop after adding 5 results
break
return ordered_content
@@ -469,7 +471,7 @@ class DocSearchResults(BaseTool):
vector_only_indexes: List[str] = []
k: int = 10
reranker_th: int = 1
- similarity_k: int = 2
+ similarity_k: int = 3
sas_token: str = ""
embedding_model: str = "text-embedding-ada-002"
@@ -479,12 +481,9 @@ def _run(self, query: str) -> str:
if self.indexes:
# Search in text-based indexes first and update corresponding vector indexes
- agg_search_results = get_search_results(query, indexes=self.indexes, k=self.k, vector_search=False)
- ordered_results = order_search_results(agg_search_results,
- k=self.k,
- reranker_threshold=self.reranker_th,
- sas_token=self.sas_token,
- vector_search=False)
+ ordered_results = get_search_results(query, indexes=self.indexes, k=self.k,
+ reranker_threshold=self.reranker_th,
+ vector_search=False)
update_vector_indexes(ordered_search_results=ordered_results, embedder=embedder)
@@ -499,15 +498,13 @@ def _run(self, query: str) -> str:
print("Vector Indexes:",vector_indexes)
# Search in all vector-based indexes available
- agg_search_results = get_search_results(query, indexes=vector_indexes, vector_search=True,
- query_vector = embedder.embed_query(query),
- k=self.similarity_k)
-
- ordered_results = order_search_results(agg_search_results,
- k=self.similarity_k,
- reranker_threshold=self.reranker_th,
- sas_token=self.sas_token,
- vector_search=True)
+ ordered_results = get_search_results(query, indexes=vector_indexes, k=self.k,
+ reranker_threshold=self.reranker_th,
+ vector_search=True,
+ similarity_k=self.similarity_k,
+ query_vector = embedder.embed_query(query),
+ sas_token=self.sas_token,
+ )
return ordered_results
@@ -527,8 +524,7 @@ class DocSearchTool(BaseTool):
vector_only_indexes: List[str] = []
k: int = 10
reranker_th: int = 1
- similarity_k: int = 2
- response_language: str = "English"
+ similarity_k: int = 3
sas_token: str = ""
embedding_model: str = "text-embedding-ada-002"
diff --git a/credentials.env b/credentials.env
index f70fbd61..1fc18e18 100644
--- a/credentials.env
+++ b/credentials.env
@@ -25,3 +25,4 @@ AZURE_COSMOSDB_ENDPOINT="ENTER YOUR VALUE"
AZURE_COSMOSDB_NAME="ENTER YOUR VALUE"
AZURE_COSMOSDB_CONTAINER_NAME="ENTER YOUR VALUE"
AZURE_COMOSDB_CONNECTION_STRING="ENTER YOUR VALUE" # Find this in the Keys section
+