Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions 03_RAG_Agent_Basic_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"- Retrieve answers based on our documents using the RAG agent and LLM\n",
"\n",
"\n",
"RAG stands for Retrieval-Augmented Generation (RAG). It's a novel approach that combines information retrieval and natural language generation techniques to improve the efficiency of knowledge graph-based systems, such as question-answering models and text summarization. The core idea is to leverage pre-trained language models to retrieve relevant information from a knowledge base or database, and then use this retrieved information to generate high-quality responses. \n",
"RAG stands for Retrieval-Augmented Generation (RAG). It's a novel approach that combines information retrieval and natural language generation techniques to improve the efficiency of knowledge graph-based systems, such as question-answering models and text summarization. The core idea is to retrieve relevant information from a knowledge base or database, and then leverage pre-trained language models to use this retrieved information to generate high-quality responses. \n",
"\n",
"In simple terms, RAG allows us to take documents (PDF, Markdown, Websites or other) that are not availble within our model and allow our agent to provide answers based on the content of those documents. Here are a few examples of what enterprise companies might use RAG: \n",
"\n",
Expand Down Expand Up @@ -180,7 +180,7 @@
"id": "24dfc89d-a581-4a0d-91dc-849e9849b822",
"metadata": {},
"source": [
"Now that our client is set up, let's go through some very simple code snippets, to get you familiar with the syntex. If you used other AI Frameworks, this will soon feel very familiar, as Llamastack follows similar principals and terminology, while allowing a standard to help you quickly shift different components in and out "
"Now that our client is set up, let's go through some very simple code snippets, to get you familiar with the syntax. If you used other AI Frameworks, this will soon feel very familiar, as Llamastack follows similar principals and terminology, while allowing a standard to help you quickly shift different components in and out "
]
},
{
Expand All @@ -196,7 +196,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "8ff36145",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -227,13 +227,13 @@
}
],
"source": [
"# Get provider list and print it out \n",
"# Get provider list and print it out\n",
"\n",
"print(\"List of providers available in our LlamaStack Server:\")\n",
"providers = client.providers.list()\n",
"for provider in providers:\n",
" print(provider)\n",
" \n",
"\n",
"\n",
"vector_providers = []\n",
"for provider in client.providers.list():\n",
Expand All @@ -242,9 +242,7 @@
" vector_providers.append(provider)\n",
"\n",
"# In this example, we only have one provider, but on other server we might have many. here, we simply select the first one.\n",
"selected_vector_provider = vector_providers[0]\n",
"\n",
"\n"
"selected_vector_provider = vector_providers[0]\n"
]
},
{
Expand All @@ -255,7 +253,7 @@
"### Register and Initialize a new VectorDB on our LlamaStack Server\n",
"\n",
"In this step, you will register a new vector database with the client. This process involves creating a unique identifier for the database and associating it with an embedding model.\n",
"We will use the built-in \"all-MiniLM-L6-v2\" LLM to embed documetns into our VLLM."
"We will use the built-in \"all-MiniLM-L6-v2\" transformer model to embed documents into our vector DB."
]
},
{
Expand Down Expand Up @@ -355,7 +353,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "4143d6dc",
"metadata": {},
"outputs": [],
Expand All @@ -379,8 +377,7 @@
" \"name\": \"builtin::rag\",\n",
" \"args\": {\"vector_db_ids\": [vector_db_id],\"query_config\": query_config },\n",
" }],\n",
")\n",
"\n"
")\n"
]
},
{
Expand Down Expand Up @@ -444,7 +441,7 @@
"\n",
"This step will get 4 separate responses from our agent, allowing us to manually evaluate its capabilities. \n",
"> **Note:**\n",
"> You might have a quick laugh as the initial results will be hit and miss. This is an initial implementation and tuning, scoring, and tuning will be the next steps in a real-world scenario.\n",
"> You might have a quick laugh as the initial results will be hit and miss. This is an initial implementation, scoring and tuning will be the next steps in a real-world scenario.\n",
">"
]
},
Expand Down Expand Up @@ -651,7 +648,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "0b8af31c",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -867,7 +864,7 @@
"for session in rag_agent.sessions:\n",
" session_response = client.agents.session.retrieve(agent_id=rag_agent.agent_id, session_id=rag_agent.sessions[i])\n",
" print(i,\"\\t\\t\\t\",session_response.turns[0].input_messages[0])\n",
" i=i+1 \n",
" i=i+1\n",
"\n",
"## Set this to whichever session you want to review:\n",
"session_to_debug=0\n",
Expand Down Expand Up @@ -901,7 +898,7 @@
"metadata": {},
"outputs": [],
"source": [
"THIS WILL DELETE ALL OF YOUR DATABASES ONLY DO THIS IF YOU MEAN TOOOOO \n",
"THIS WILL DELETE ALL OF YOUR DATABASES ONLY DO THIS IF YOU MEAN TOOOOO\n",
"#Unregister all vector databases (THIS IS FOR DEBUG NOT FOR LAB)\n",
"for vector_db_id in client.vector_dbs.list():\n",
" print(f\"Unregistering vector database: {vector_db_id.identifier}\")\n",
Expand Down