Merge pull request #284 from langchain-ai/rlm/adaptive_rag_local

Update local adaptive RAG ntbk
This commit is contained in:
Lance Martin
2024-04-06 17:30:06 -07:00
committed by GitHub
+28 -31
View File
@@ -69,20 +69,18 @@
"\n",
"```\n",
"ollama pull mistral\n",
"ollama pull command-r:35b-v0.1-q2_K\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 64,
"execution_count": 2,
"id": "af8379bd-7eae-4ba6-b632-12e89eab9920",
"metadata": {},
"outputs": [],
"source": [
"# Ollama model name\n",
"local_llm = \"mistral\"\n",
"local_llm = \"command-r:35b-v0.1-q2_K\""
"local_llm = \"mistral\""
]
},
{
@@ -117,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "f9ff6b99-080d-4827-b2cb-f775543d76f5",
"metadata": {},
"outputs": [],
@@ -162,7 +160,7 @@
},
{
"cell_type": "code",
"execution_count": 49,
"execution_count": 4,
"id": "7045e064-e666-4aea-9111-6e9d2007f27e",
"metadata": {},
"outputs": [
@@ -203,7 +201,7 @@
},
{
"cell_type": "code",
"execution_count": 53,
"execution_count": 7,
"id": "813cdcef-8b75-4214-a2ed-b89077b3d287",
"metadata": {},
"outputs": [
@@ -245,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": 8,
"id": "aeb8b373-0289-4dec-bd4b-8b2701200301",
"metadata": {},
"outputs": [
@@ -253,8 +251,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"The agent's memory is supported by a memory stream, which functions as a long-term memory module that records the agents' experiences in natural language. This recorded information is then used to influence the agent's behavior and interaction with other agents.\n",
"Memory is also employed by the agent in reflection mechanisms, which create higher-level summaries of past events, and can be accessed for self-reflection.\n"
" In an LLM-powered autonomous agent system, the Large Language Model (LLM) functions as the agent's brain. The agent has key components including memory, planning, and reflection mechanisms. The memory component is a long-term memory module that records a comprehensive list of agents experience in natural language. It includes a memory stream, which is an external database for storing past experiences. The reflection mechanism synthesizes memories into higher-level inferences over time and guides the agent's future behavior.\n"
]
}
],
@@ -286,7 +283,7 @@
},
{
"cell_type": "code",
"execution_count": 54,
"execution_count": 9,
"id": "38345cff-e2d0-436e-aa09-599522a61eed",
"metadata": {},
"outputs": [
@@ -296,7 +293,7 @@
"{'score': 'yes'}"
]
},
"execution_count": 54,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -326,7 +323,7 @@
},
{
"cell_type": "code",
"execution_count": 55,
"execution_count": 10,
"id": "9771caa1-5542-47c3-8354-aeeafcf51964",
"metadata": {},
"outputs": [
@@ -336,7 +333,7 @@
"{'score': 'yes'}"
]
},
"execution_count": 55,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -366,7 +363,7 @@
},
{
"cell_type": "code",
"execution_count": 56,
"execution_count": 11,
"id": "830ba5f7-9c8d-4c01-83b1-e4d51d40d48f",
"metadata": {},
"outputs": [
@@ -376,7 +373,7 @@
"' What is agent memory and how can it be effectively utilized in vector database retrieval?'"
]
},
"execution_count": 56,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
@@ -409,7 +406,7 @@
},
{
"cell_type": "code",
"execution_count": 57,
"execution_count": 12,
"id": "6c3c1c70-ff84-41e8-bf72-738ed52f2dde",
"metadata": {},
"outputs": [],
@@ -434,7 +431,7 @@
},
{
"cell_type": "code",
"execution_count": 58,
"execution_count": 13,
"id": "6e09087e-b2a9-437a-abee-129e426df799",
"metadata": {},
"outputs": [],
@@ -458,7 +455,7 @@
},
{
"cell_type": "code",
"execution_count": 59,
"execution_count": 14,
"id": "7c5fa507-77ae-426a-a65f-f518b9525bd0",
"metadata": {},
"outputs": [],
@@ -668,7 +665,7 @@
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": 15,
"id": "450eb313-ca75-4a43-b57e-7034bd3f40bf",
"metadata": {},
"outputs": [],
@@ -719,7 +716,7 @@
},
{
"cell_type": "code",
"execution_count": 63,
"execution_count": 16,
"id": "b095c1db-8bd1-4a34-937c-1a9b74ae74ff",
"metadata": {},
"outputs": [
@@ -736,20 +733,20 @@
"\"Node 'web_search':\"\n",
"'\\n---\\n'\n",
"---GENERATE---\n",
"\"Node 'generate':\"\n",
"'\\n---\\n'\n",
"---CHECK HALLUCINATIONS---\n",
"---DECISION: GENERATION IS GROUNDED IN DOCUMENTS---\n",
"---GRADE GENERATION vs QUESTION---\n",
"---DECISION: GENERATION ADDRESSES QUESTION---\n",
"\"Node '__end__':\"\n",
"\"Node 'generate':\"\n",
"'\\n---\\n'\n",
"(' The AlphaCodium paper introduces a new approach called AlphaCodium for code '\n",
" 'generation by Large Language Models (LLMs). It is a test-based, multi-stage '\n",
" 'flow that improves LLM performances on code problems through an iterative '\n",
" 'process of generating and fixing code against input-output tests. The '\n",
" 'authors tested AlphaCodium on the CodeContests dataset and reported improved '\n",
" \"results compared to DeepMind's AlphaCode and AlphaCode2.\")\n"
"(' The AlphaCodium paper introduces a new approach for code generation by '\n",
" 'Large Language Models (LLMs). It presents AlphaCodium, an iterative process '\n",
" 'that involves generating additional data to aid the flow, and testing it on '\n",
" 'the CodeContests dataset. The results show that AlphaCodium outperforms '\n",
" \"DeepMind's AlphaCode and AlphaCode2 without fine-tuning a model. The \"\n",
" 'approach includes a pre-processing phase for problem reasoning in natural '\n",
" 'language and an iterative code generation phase with runs and fixes against '\n",
" 'tests.')\n"
]
}
],
@@ -777,7 +774,7 @@
"source": [
"Trace: \n",
"\n",
"https://smith.langchain.com/public/98f3b8d3-b26d-430d-a434-f25273345f56/r"
"https://smith.langchain.com/public/81813813-be53-403c-9877-afcd5786ca2e/r"
]
},
{