You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
langchain/docs/docs/integrations/retrievers/azure_ai_search.ipynb

292 lines
34 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

{
"cells": [
{
"cell_type": "markdown",
"id": "1edb9e6b",
"metadata": {},
"source": [
"# Azure AI Search\n",
"\n",
">[Microsoft Azure AI Search](https://learn.microsoft.com/en-us/azure/search/search-what-is-azure-search) (formerly known as `Azure Cognitive Search`or Azure Search) is a cloud search service that gives developers infrastructure, APIs, and tools for building a rich search experience over private, heterogeneous content in web, mobile, and enterprise applications.\n",
"\n",
">Search is foundational to any app that surfaces text to users, where common scenarios include catalog or document search, online retail apps, or data exploration over proprietary content. When you create a search service, you'll work with the following capabilities:\n",
">- A search engine for full text search over a search index containing user-owned content\n",
">- Rich indexing, with lexical analysis and optional AI enrichment for content extraction and transformation\n",
">- Rich query syntax for text search, fuzzy search, autocomplete, geo-search and more\n",
">- Programmability through REST APIs and client libraries in Azure SDKs\n",
">- Azure integration at the data layer, machine learning layer, and AI (AI Services)\n",
"\n",
"This notebook shows how to use Azure AI Search (AAS) within LangChain."
]
},
{
"cell_type": "markdown",
"id": "074b0004",
"metadata": {},
"source": [
"## Set up Azure AI Search\n",
"\n",
"To set up AAS, please follow the instructions [here](https://learn.microsoft.com/en-us/azure/search/search-create-service-portal).\n",
"\n",
"Please note you will need\n",
"1. the name of your AAS service, \n",
"2. the name of your AAS index,\n",
"3. your API key.\n",
"\n",
"Your API key can be either Admin or Query key, but as we only read data it is recommended to use a Query key."
]
},
{
"cell_type": "markdown",
"id": "0474661d",
"metadata": {},
"source": [
"## Using the Azure AI Search Retriever"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "39d6074e",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain_community.retrievers import (\n",
" AzureAISearchRetriever,\n",
")"
]
},
{
"cell_type": "markdown",
"id": "b7243e6d",
"metadata": {},
"source": [
"Set Service Name, Index Name and API key as environment variables (alternatively, you can pass them as arguments to `AzureAISearchRetriever`). The search index name you use determines which documents are queried, so be sure to select the right one. \n",
"\n",
"*You may also use `AzureCognitiveSearchRetriever` however this will soon be depreciated. Please switch to `AzureAISearchRetriever` where possible. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "33fd23d1",
"metadata": {},
"outputs": [],
"source": [
"os.environ[\"AZURE_AI_SEARCH_SERVICE_NAME\"] = \"<YOUR_AAS_SERVICE_NAME>\"\n",
"os.environ[\"AZURE_AI_SEARCH_INDEX_NAME\"] = \"<YOUR_AAS_INDEX_NAME>\"\n",
"os.environ[\"AZURE_AI_SEARCH_API_KEY\"] = \"<YOUR_API_KEY>\""
]
},
{
"cell_type": "markdown",
"id": "057deaad",
"metadata": {},
"source": [
"Create the Retriever\n",
"\n",
"`content_key` is the key in the retrieved result to set as the Document page_content.\n",
"`top_k` is the number of number of results you'd like to retrieve. Setting it to None (the default) returns all results. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c18d0c4c",
"metadata": {},
"outputs": [],
"source": [
"retriever = AzureAISearchRetriever(content_key=\"content\", top_k=10)"
]
},
{
"cell_type": "markdown",
"id": "e94ea104",
"metadata": {},
"source": [
"Now you can use it to retrieve documents from Azure AI Search. \n",
"This is the method you would call to do so. It will return all documents relevant to the query. "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c8b5794b",
"metadata": {},
"outputs": [],
"source": [
"retriever.invoke(\"what is langchain?\")"
]
},
{
"cell_type": "markdown",
"id": "48649d37",
"metadata": {},
"source": [
"## Example \n",
"\n",
"First let's create an Azure vector store and upload some data to it."
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "0b313473",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"from langchain.document_loaders import DirectoryLoader, TextLoader\n",
"from langchain.text_splitter import TokenTextSplitter\n",
"from langchain.vectorstores import AzureSearch\n",
"from langchain_openai import OpenAIEmbeddings\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"youropenaiapikey\"\n",
"os.environ[\"AZURE_AI_SEARCH_SERVICE_NAME\"] = \"yourazureaisearchservicename\"\n",
"os.environ[\"AZURE_AI_SEARCH_API_KEY\"] = \"yourazureaisearchapikey\""
]
},
{
"cell_type": "markdown",
"id": "e889d1dd",
"metadata": {},
"source": [
"We'll use an embedding model from openai to turn our documents into embeddings stored in the Azure AI Search vector store. We'll also set the index name to `langchain-vector-demo`. This will create a new vector store associated with that index name. "
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "27af8cdb",
"metadata": {},
"outputs": [],
"source": [
"embeddings = OpenAIEmbeddings(model=\"text-embedding-ada-002\")\n",
"\n",
"vector_store = AzureSearch(\n",
" embedding_function=embeddings.embed_query,\n",
" azure_search_endpoint=os.getenv(\"AZURE_AI_SEARCH_SERVICE_NAME\"),\n",
" azure_search_key=os.getenv(\"AZURE_AI_SEARCH_API_KEY\"),\n",
" index_name=\"langchain-vector-demo\",\n",
")"
]
},
{
"cell_type": "markdown",
"id": "76c86a34",
"metadata": {},
"source": [
"Next we'll load data into our newly created vector store. \n",
"For this example we load all the text files from a folder named `qna`. We'll split the text in 1000 token chunks with no overlap. Finally the documents are added to our vector store as emeddings."
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "f4830b14",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['YWY0NzY1MWYtMTU1Ni00YmEzLTlhNTQtZDQxNWFkMTlkNjMx',\n",
" 'MTUzM2EyOGYtYWE0My00OTIyLWJkNWUtMjVjNTgwMzZlMjcx',\n",
" 'ZGMyMjQ3N2EtNTQ5NC00ZjZhLWIyMzctYjRlZDYzMWUxNGQ4',\n",
" 'OWM5MWQ3YzUtZjFkZS00MGI2LTg1OGMtMmRlYzUwMDc2MzZi',\n",
" 'ZmFiYWVkOGQtNTcwYi00YTVmLWE3ZDEtMWQ3MTAxYjI2NTJj',\n",
" 'NTUwM2ExMjItNTk4Zi00OTg0LTg1ZDItZTZlMGYyMjJiNTIy']"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"loader = DirectoryLoader(\n",
" \"qna/\",\n",
" glob=\"*.txt\",\n",
" loader_cls=TextLoader,\n",
" loader_kwargs={\"autodetect_encoding\": True},\n",
")\n",
"documents = loader.load()\n",
"text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=0)\n",
"docs = text_splitter.split_documents(documents)\n",
"\n",
"vector_store.add_documents(documents=docs)"
]
},
{
"cell_type": "markdown",
"id": "ebb4c433",
"metadata": {},
"source": [
"Next we'll create a retriever similar to the one we created above but we're using the index name associated with our new vector store. In this case that's `langchain-vector-demo`."
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "7ba2e413",
"metadata": {},
"outputs": [],
"source": [
"retriever = AzureAISearchRetriever(content_key=\"content\", top_k=1)"
]
},
{
"cell_type": "markdown",
"id": "8f497f09",
"metadata": {},
"source": [
"Now we can retrieve the data that is relevant to our query from the documents we uploaded. "
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "7edb45e8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Document(page_content='\\n# What is Azure OpenAI?\\n\\nThe Azure OpenAI service provides REST API access to OpenAI\\'s powerful language models including the GPT-3, Codex and Embeddings model series. These models can be easily adapted to your specific task including but not limited to content generation, summarization, semantic search, and natural language to code translation. Users can access the service through REST APIs, Python SDK, or our web-based interface in the Azure OpenAI Studio.\\n\\n### Features overview\\n\\n| Feature | Azure OpenAI |\\n| --- | --- |\\n| Models available | GPT-3 base series <br> Codex series <br> Embeddings series <br> Learn more in our [Models](./concepts/models.md) page.|\\n| Fine-tuning | Ada <br> Babbage <br> Curie <br> Cushman* <br> Davinci* <br> \\\\* available by request. Please open a support request|\\n| Price | [Available here](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/) |\\n| Virtual network support | Yes | \\n| Managed Identity| Yes, via Azure Active Directory | \\n| UI experience | **Azure Portal** for account & resource management, <br> **Azure OpenAI Service Studio** for model exploration and fine tuning |\\n| Regional availability | East US <br> South Central US <br> West Europe |\\n| Content filtering | Prompts and completions are evaluated against our content policy with automated systems. High severity content will be filtered. |\\n\\n## Responsible AI\\n\\nAt Microsoft, we\\'re committed to the advancement of AI driven by principles that put people first. Generative models such as the ones available in the Azure OpenAI service have significant potential benefits, but without careful design and thoughtful mitigations, such models have the potential to generate incorrect or even harmful content. Microsoft has made significant investments to help guard against abuse and unintended harm, which includes requiring applicants to show well-defined use cases, incorporating Microsofts <a href=\"https://www.microsoft.com/ai/responsible-ai?activetab=pivot1:primaryr6\" target=\"_blank\">principles for responsible AI use</a>, building content filters to support customers, and providing responsible AI implementation guidance to onboarded customers.\\n\\n## How do I get access to Azure OpenAI?\\n\\nHow do I get access to Azure OpenAI Service?\\n\\nAccess is currently limited as we navigate high demand, upcoming product improvements, and <a href=\"https://www.microsoft.com/ai/responsible-ai?activetab=pivot1:primaryr6\" target=\"_blank\">Microsofts commitment to responsible AI</a>. For now, we\\'re working with customers with an existing partnership with Microsoft, lower risk use cases, and those committed to incorporating mitigations. In addition to applying for initial access, all solutions using the Azure OpenAI service are required to go through a use case review before they can be released for production use.\\n\\nMore specific information is included in the application form. We appreciate your patience as we work to responsibly enable broader access to the Azure OpenAI service.\\n\\nApply here for initial access or for a production review:\\n\\n<a href=\"https://aka.ms/oaiapply\" target=\"_blank\">Apply now</a>\\n\\nAll solutions using the Azure OpenAI service are also required to go through a use case review before they can be released for production use, and are evaluated on a case-by-case basis. In general, the more sensitive the scenario the more important risk mitigation measures will be for approval.\\n\\n## Comparing Azure OpenAI and OpenAI\\n\\nAzure OpenAI Service gives customers advanced language AI with OpenAI GPT-3, Codex, and DALL-E models with the security and enterprise promise of Azure. Azure OpenAI co-develops the APIs with OpenAI, ensuring compatibility and a smooth transition from one to the other.\\n\\nWith Azure OpenAI, customers get the security capabilities of Microsoft Azure while running the same models as OpenAI. Azure OpenAI offers private networking, regional availability, and responsible AI content filtering. \\n\\n## Key concepts\\n\\n### Prompts & Completions\\n\\nThe completions endpoint is the core component of the API service. This API provides access to the model\\'s text-in, text-out interface. Users simply need to provide an input **prompt** containing the English text command, and the model will generate a text **completion**.\\n\\nHere\\'s an example of a simple prompt and completion:\\n\\n>**Prompt', metadata={'@search.score': 2.3721094, 'id': 'MDEyNzU0ZDEtOTlmMy00YjE0LWE2YzMtNWI2ZGYxZjBkYzIx', 'content_vector': [3.636302e-05, -0.014039703, -0.0011298007, -0.005913462, -0.016717235, 0.0152605465, -0.003933059, 0.0037596438, -0.026900182, -0.035265736, 0.035598695, 0.0051747127, -0.030132644, -0.014116006, -0.025956802, 0.004467178, 0.022696596, -0.008871927, 0.013366852, -0.0060591307, -0.017272165, 0.00086967775, -0.01308245, -0.0144559, 0.00079510914, 0.004588569, 0.015759982, -0.029882925, 0.0006828228, -0.012666253, 0.018118432, 0.0032931566, -0.013137943, 0.0011601484, 0.02465272, 0.01996357, 0.016606249, -0.009489286, 0.015690617, 0.00049466715, 0.016606249, 0.028662082, 0.019325402, 0.0052891667, -0.015343786, 0.010522841, -0.009385237, -0.01054365, 0.00014501855, 0.01768836, 0.001506979, 0.04580939, 0.0037908584, -0.00047515793, -0.015080195, -0.022016807, -0.02938349, 0.03226912, 0.012943719, 0.013054704, 0.011743684, -0.0012052364, -0.022238778, 0.004588569, -0.008386364, -0.0002640248, -0.010085834, 0.015038575, 0.0128119225, -0.01893695, 0.029438982, 0.015440899, 0.018770473, -0.008566716, 0.032074895, -0.01099453, -0.015399279, -0.021656103, -0.016966954, 0.0090245325, 0.011986466, -0.015440899, -0.009628017, 0.02289082, 0.019311529, 0.017868713, 0.007172457, 0.007845309, 0.015676744, -0.011022277, 0.011722875, 0.008760941, 0.0127980495, 0.026456239, -0.011882417, 0.015981954, -0.008518159, 0.011639635, -0.005334255, -0.01832653, -0.016897587, 0.019311529, -0.028634336, -0.012492838, -0.029855179, 0.021517372, 0.023806453, -0.008219886, 0.04164742, 0.04134221, -0.0060140425, 0.002322031, -0.016800474, -0.024014551, -0.024916312, -0.0011193958, 0.010939037, -0.018007446, -0.022308145, 0.016814347, 0.0045920373, 0.0418139, -0.0013457028, 0.011868543, -0.0019318465, -0.0047411746, 0.0019769345, -0.0114870295, 0.0144836465, -0.013762238, 0.004293763, 0.0063331267, 0.027385745, -0.0028648209, -0.02254399, 0.046641782, -0.034183625, 0.0056602755, -0.015121815, -0.01359576, 0.009614144, 0.012624634, -0.00763721, -0.007214077, 0.0043804706, 0.02125378, 0.009655764, 0.0034318888, 0.009891609, 0.031159261, 0.016675616, -0.029022785, -0.025138283, 0.011355234, -0.0016136294, -0.0047307694, 0.007692703, 0.020615611, -0.040731788, -0.012666253, 0.016842095, 0.030965036, -0.023737086, -0.014927589, 0.008226822, 0.017910333, 0.015857095, -0.022488497, -0.012492838, -0.02395906, -0.0059238668, 0.022086173, -0.03451658, 0.015107941, -0.0010691053, 0.007491541, 0.03626461, -0.0057400465, -0.012728684, -0.005192054, 0.029327996, 0.010231503, 0.011327487, 0.021878075, -0.0029324528, -0.024777578, 0.006853373, -0.0030295653, 0.007588654, -0.008199075, -0.005278762, 0.027552223, -0.007255696, -0.018825965, -0.6055385, -0.0324356, 0.017868713, -0.024694338, 0.018049065, 0.008809498, 0.012770303, 0.00029458923, 0.009447666, 0.03157546, -0.0011436739, 0.0059203985, -0.03343447, -0.0120488955, 0.01936702, -0.01406745, -2.3519451e-05, -0.01232636, 0.009843052, 0.0011774899, -0.02844011, 0.01359576, -0.023140538, 0.0051816492, -0.022682723, 0.0101552, -0.0038359466, 0.022016807, 0.0022630696, 0.021808708, -0.014428154, 0.006558567, 0.016855968, -0.016259419, 0.047668397, 0.002223184, -0.018382022, 0.019325402, -0.006360873, 0.025401874, -0.013137943, -0.016633997, 0.01961674, -0.0047134277, 0.014941462, -0.009073089, 0.013658189, -0.0071239006, -0.01914505, -0.01017601, 0.015981954, 0.016231673, 0.009662701, -0.021420259, 0.004841755, 0.0048556286, 0.037762918, -0.026581097, 0.018354276, -0.020088429, -0.01056446, 0.0097875595, -0.03221363, -0.052718252, -0.0367363, 0.02438913, 0.0030625144, 0.011806114, 0.0001495707, -0.034821793, 0.013068577, 0.016314913, 0.015288293, -0.0029428578, -0.009593335, 0.024944058, 0.0261649, 0.002639381, 0.00448452, 0.020421386, 0.029411236, -0.02508279, 0.013692873, -0.017091813, -0.001201768, 0.012666253, -0.013429281, 0.0034648378, 0.019852584, -0.010460411, 0.02495793, 0.006662616, -0.0347663, -0.03748545, 0.023154411, -0.014247801, -0.0061943945, -0.016939206, 0.014955336, -0.011917099, 0.013054704, -0.005313445, 0.01570449, 0.020504626, 0.037901647, 0.016190052, -0.030465601, 0.0076580197, -0.006073004, -0.01351252, -0.009523968, -0.014317168, -0.006322722, -0.017286038, 0.003693746, -0.027690956, 0.011903226, -0.0016136294, 0.00050160376, -0.02547124, 0.0049943607, 0.0012858745, -0.01707794, 0.009392173, 0.02090695, 5.581805e-05, 0.011958719, -0.030604333, -0.0086499555, 0.02099019, 0.006707704, -0.036375593, 0.010654637, -0.017230544, 0.031825177, 0.011570269, 0.028967293, -0.0018503413, 0.022322018, -0.010592206, -0.014553012, 0.0073458725, 0.012007276, -0.009260377, -0.029189264, -0.0058857156, -0.012825795, -0.002675798, -0.014074386, -0.01820167, -0.0035133942, -0.021669976, -0.009329744, 0.017757727, 0.0027278226, -0.0058198175, -0.0105367135, -0.029855179, -0.009967912, -0.02387582, -0.019422514, 0.029106025, -0.006763197, 0.019699978, 0.006638338, -0.002717418, 0.004134221, 0.022960186, -0.03135349, -0.018062938, 0.015413152, -0.007921611, 0.0068082847, 0.00061172247, 0.011944846, 0.011008403, -0.039150238, 0.005212864, 0.014774984, -0.017216671, -0.0017965826, 0.020199414, -0.00067848735, -0.02241913, 0.008233759, -0.00076129317, 0.04375615, 0.039816152, -0.011306678, 0.00612156, 0.004418622, 0.029577713, -0.0118477335, 0.04461629, -0.011924036, 0.017008573, -0.0043249778, 0.010980657, 0.0036209116, 0.035432216, 0.02727476, -0.010224566, 0.022488497, 0.010980657, -0.009135518, 0.0086638285, 0.0038012634, -0.016384277, 0.021364765, -0.009475412, 0.01893695, -0.002878694, -0.004609379, -0.015954208, -0.009558652, 0.00841411, 0.012159881, -0.00020549714, -0.03815137, 0.0055666314, 0.006378215, 0.016703362, 1.2294874e-05, 0.013817731, -0.0009719928, 0.03804038, 0.011889353, 0.005889184, 0.01181305, -0.02938349, 0.014636252, 0.029577713, 0.0045712274, 0.005299572, 0.015357659, -0.0058995886, 0.016495263, -0.015690617, 0.022405257, -0.015954208, -0.011050023, -0.0064926688, -0.012430409, -0.033323485, 0.033711936, -0.0033382445, 0.02452786, 0.008136646, -0.02495793, 0.004213992, -0.0378739, 0.0031023999, -0.008004851, -0.0038290098, 0.004782794, -0.009260377, 0.0038602247, -0.00081635255, -0.008691575, 0.030410107, 0.003138817, 0.004678745, 0.019949697, 0.018271036, -0.0012477231, 0.009870799, -0.012291676, -0.02250237, -0.00064553844, -0.025526732, -0.007651083, -0.02422265, 0.015940335, -0.026775323, 0.02495793, 0.026262013, -0.0028943014, 0.023931311, 0.010495095, 0.04392263, -0.007318126, -0.059710357, 0.032990526, -0.007963231, -0.0037527073, 0.011632699, -0.03257433, -0.012014212, -0.025693212, 0.022294272, -0.008032597, 0.014747238, -0.021822581, 0.0110847065, -0.01146622, 0.006364342, 0.012187627, -0.015565758, -0.0010370235, -0.022835327, 0.00896904, -0.0025075853, -0.019602867, 0.0021937035, 0.018728852, -0.00092430355, -0.0169947, -0.004862565, -0.018173924, -0.04750192, 0.0006242951, 0.008767878, 0.010286996, -0.013443154, 0.0327963, 0.010293933, -0.010446538, -0.018257163, 0.0017142103, 0.015399279, 0.0010734408, -0.012749493, -0.0029948824, 0.010293933, 0.059599373, 0.014150688, -0.014761111, -0.009392173, -0.015205054, 0.015648996, -0.0177716, -0.00081115006, 0.0039226543, 0.02327927, -0.025748704, -0.008525096, 0.021281525, 0.024708213, 0.03249109, 0.0029029723, -0.0012858745, -0.035598695, 0.00011038968, -0.034072638, 0.0006503074, 0.020795964, 0.007873055, 0.0062152045, 0.015205054, 0.002380992, 0.033046022, 0.008171329, -0.017230544, -0.025485113, 0.0037700487, -0.008823371, -0.002641115, 0.00638862, 0.0005813748, 0.027912928, 0.009947102, 0.017910333, -0.0029307187, 0.013325232, 0.014677871, 0.013762238, -0.015496392, -0.023903565, -0.009461539, -0.021531245, -0.014261674, 0.014102132, -0.01639815, -0.019464133, -0.034405597, 0.012881288, -0.04530995, -0.002889099, 0.0043561924, 0.01570449, -0.0246111, -0.009801433, -0.012250057, -0.05610332, -0.020171668, -0.018909205, -0.025637718, -0.0056394655, -0.016342659, -0.031464472, 0.0027052788, 0.010557524, -0.020976314, 0.020282654, 0.009371363, -0.023265397, -0.051691633, 0.0065446934, 0.006041789, 0.024264269, 0.0021815645, -0.025762577, -0.005472987, -0.007422175, 0.022974059, -0.021239907, 0.018215543, -0.025124408, 0.020241035, -0.020795964, -0.0008358618, 0.002479839, -0.002015086, 0.01871498, -0.006919271, -0.007373619, -0.0057747294, 0.009288124, 0.021448005, 0.0281349, 0.016203927, 0.016328786, 0.0017965826, -0.03593165, -0.016661743, -0.03446109, -0.009523968, -0.021531245, 0.014220055, -0.0005570967, 0.01738315, 0.0065204157, 0.012707873, -0.021059554, 0.005972423, 0.013096324, 0.00853897, -0.011750621, 0.00027963216, -0.021350892, 0.013276676, 0.02551286, -0.017244417, -0.022613356, 0.0071100276, -0.04586488, 0.034655314, 0.0054417723, -0.026650464, 0.03587616, 0.010973721, -0.002878694, -0.041147985, 0.013117134, 0.0037527073, 0.004373534, -0.008518159, -0.0020827178, 0.003874098, -0.007096154, -0.015857095, 0.0053446596, 0.0017861776, -0.009225694, -0.013394598, -0.0064128977, -0.010120518, 0.008601399, -0.0070441295, -0.037235733, -0.00048036038, 0.0010665042, 0.0007738658, 0.025138283, -0.0030104897, -3.9858423e-05, -0.043228965, -0.032158133, -0.025568353, -0.00015152163, 0.0005345527, -0.0056464025, 0.02839849, 0.017050192, 0.038068127, -0.0045053298, 0.033406723, 0.021198288, -0.008150519, -0.013803858, 0.010890481, -0.0067493236, 0.015482518, -0.020587865, -0.0040197666, 0.0046926183, 0.027260887, -0.0012659318, 0.0040440448, 0.014074386, -0.008941293, -0.033240244, -0.005042917, -0.046669528, -0.0013751833, 0.019283783, -0.002176362, 0.016592376, -0.03998263, -0.007741259, 0.025845816, 0.0009390439, 0.016606249, 0.012451218, 0.013810795, -0.002380992, 0.017674487, 0.0144975195, 0.0054868604, -0.017951952, 0.027011167, -0.023307016, -0.0008904876, 0.030992784, 0.0051885857, 0.020463007, 0.019089557, -0.007512351, -0.013325232, 0.024375254, -0.02641462, -0.011709001, -0.017951952, -0.038761787, -0.011521713, -0.015912589, 0.0065134787, 0.001801785, -0.032685317, 0.0066105914, 0.011549459, 0.028856307, -0.007873055, -0.011674318, 0.025498986, 0.0021347424, 0.052357547, 0.020504626, 0.02090695, 0.012617698, 0.02504117, -0.018118432, 0.013894035, -0.037957143, -0.0025006486, 0.010619953, 0.014594632, 0.0011627496, -0.0015720098, 0.02452786, -0.025915183, -0.0128119225, -0.017840967, 0.018395895, 0.011521713, 0.0127841765, -0.019852584, -0.024624974, 0.0069400803, 0.02762159, -0.027233139, 0.0052891667, 0.0077898153, -0.010779495, 8.4594154e-05, -0.016190052, 0.022779834, 0.020865329, 0.023681594, 0.0139634, -0.0042001186, 0.002063642, -0.0031457536, -0.009184075, -0.00034357907, 0.016120687, -0.022322018, 0.01949188, 0.030687572, 0.0079008015, 0.008032597, 0.009461539, 0.014428154, 0.034655314, -0.04625333, -0.003150956, 0.009364426, -0.009732067, 0.013394598, -0.013928717, -0.002925516, 0.012097452, -0.0082753785, 0.012118261, 0.015995828, 0.0056498707, -0.048806004, 0.008545906, 0.0049562096, -0.038928267, -0.00037869567, 0.02684469, 0.009829179, -0.022349764, -0.00896904, 0.0015390608, -0.020573992, 0.0063920883, 0.018257163, 0.013394598, -0.009648828, 0.024694338, -0.007137774, -0.021434132, 0.003228993, 0.033046022, -0.018132305, 0.025526732, -0.021891948, -0.015829349, 0.02319603, -0.002380992, -0.026581097, -0.01750801, -0.012666253, 0.010918228, 0.009135518, 0.005042917, 0.008310061, 0.0015685414, -0.018076811, -0.008795625, -0.0032914225, 0.023168284, 0.012978401, -0.0005844096, 0.03501602, -0.011493966, 0.020865329, -0.0144559, 0.017133432, 0.0013110196, -0.03562644, -0.013346042, 0.016453644, 0.0063157855, 0.00072487595, 0.0001522803, -0.0047897305, -0.01099453, -0.037790664, 0.006562035, 0.010085834, 0.008684638, 0.0037561755, 0.0077759423, 0.012992275, 0.0022682722, -0.024097791, -0.0035966334, -0.023834199, -0.007075344, -0.023778707, 0.009419919, -0.0127980495, 0.029244756, 0.026830817, -0.042979248, -0.040065873, -0.0006520415, -0.030826304, 0.009433793, -0.02719152, 0.04431108, 0.013519458, 0.03382292, 0.01596808, 0.012832733, 0.004623252, 0.0028492135, -0.025762577, 0.015843222, -0.014955336, -0.017674487, -0.013970337, -0.014053577, -0.033545457, -0.014344914, 0.0026255078, -0.013796922, -0.0081089, 0.03851207, -0.0071863304, -0.015510265, -0.0063851513, -0.01054365, 0.0065759085, 0.013179563, 0.02473596, -0.03665306, 0.006537757, 0.010821115, -0.018465262, -0.00011553794, 0.003034768, 0.018271036, 0.0076788296, 0.012721746, -0.0052614203, -0.008858054, -0.0054660505, 0.013214246, 0.047307696, 0.015413152, -0.013866288, 0.026178773, 0.013789985, -0.014386534, -0.005223269, 0.016120687, 0.009662701, 0.010814179, 0.042452067, -0.02594293, -0.0025873564, -0.03296278, 0.022266526, -0.021933567, -0.019977443, -0.011043087, 0.0144975195, -0.023376383, 0.013491711, 0.016606249, -0.008268442, 0.024860818, -0.005133093, 0.0068152216, 0.0034821793, -0.03171419, -0.009267313, -0.013089387, -0.01570449, 0.022349764, -0.014358787, -0.022127792, 0.029522222, 0.019242162, -0.015316039, 0.009371363, 0.19444712, -0.016439771, -0.011278931, 0.009544779, 0.008698512, 0.0017220139, 0.014136815, 0.016675616, -0.019935824, 0.012395726, -0.0046301885, 0.0144836465, -0.0030052871, -0.0045365444, -0.00550767, -0.032130387, -0.018090684, -0.014053577, -0.013214246, -0.002096591, 0.0034769769, -0.007331999, 0.0040856646, -0.0025145218, -0.0040440448, 0.024319762, -0.0047307694, -0.01596808, 0.009267313, 0.012638507, 0.0034422937, 0.018007446, 0.004859097, 0.041619673, -0.026525605, -0.00681869, -0.012416536, -0.0044775833, 0.015759982, 0.017133432, 0.03024363, 0.019921951, 0.005254484, -0.02598455, -0.006659148, 0.018257163, -0.0031578927, -0.029660953, 0.0013049502, 0.023223778, -0.034100384, 0.01400502, 0.0054070894, -0.0026636592, -0.0065100105, 0.019269908, -0.020365894, 0.01185467, 0.017674487, 0.020768216, -0.013692873, 0.01028006, -0.023182157, 0.029855179, -0.016925333, -0.010210693, -0.021045681, -0.014608505, 0.006856841, 0.01863174, 0.004109943, 0.008830307, -0.012478965, -0.011930973, -0.02413941, -0.029494476, 0.053106703, 0.030382361, 0.01441428, 0.032546584, 0.022904694, 0.012534458, 0.013713682, -0.0025110536, -0.014941462, -0.028939545, 0.029466728, -0.03804038, -0.018173924, -0.00021481821, -0.010980657, -0.034710806, 0.010613017, 0.009829179, -0.009177138, 0.004168904, 0.017494136, -0.0037665805, -0.0045053298, -0.016106814, -0.0060175112, 0.0750264, -0.009267313, 0.0031873733, -0.014969209, 0.010328615, -0.027399618, 0.03390616, 0.0024278143, -0.007581717, -0.003613975, -0.009468475, -0.010370235, 0.010460411, -0.011833861, -0.009156328, -0.006738919, 0.0037908584, 0.008656892, -0.010037278, -0.023681594, -0.02078209, -0.022835327, 0.007977104, -0.01605132, -0.03335123, -0.0169947, -0.011514776, -0.03815137, -0.018784346, 0.022682723, -0.023931311, 0.00222145, 0.017549628, -0.0014774984, 0.013026957, 0.03157546, 0.004383939, 0.0036868094, 0.017133432, 0.0030122239, 0.008150519, 0.0019908077, 0.004172372, 0.01185467, -0.016925333, 0.008192139, 0.012534458, 0.0072418232, -0.008989849, -0.017494136, -0.0041446257, 0.000651608, 0.013013084, 0.03188067, -0.0012815391, -0.010661573, 0.007949358, -0.00018425376, 0.022322018, -0.053078957, -0.007845309, -0.00015368931, -0.0073042526, -0.019214416, -0.009301997, -0.1758015, 0.0031249437, 0.0057400465, -0.05141417, 0.047085725, 0.015440899, -0.0032480687, -0.018603994, -0.0032168538, 0.004973551, 0.018493008, -0.0062360144, -0.02198906, -0.00845573, -0.00233417, 0.005060259, -0.024680465, 0.009662701, 0.040204603, -0.0012919441, 0.00896904, -0.009204884, 0.015288293, -0.012576078, 0.004609379, 0.0007521889, -0.04014911, 0.025679339, 0.005608251, -0.033961654, -0.008858054, -0.020213287, 0.033489965, -0.0049874242, 0.014199245, -0.0048660333, 0.04170291, -0.026081663, -0.040648546, 0.031214755, -0.0015095802, 0.024416875, 0.028065532, -0.0047203647, 0.0036694678, 0.013443154, 0.015024702, -0.013283612, 0.012083578, -0.00158675, 0.033157006, -0.022086173, 0.0018052533, 0.0019023659, -0.012069705, 0.015440899, 0.020032937, 0.010786432, -0.02839849, -0.030687572, 0.01979709, -0.0177716, 0.01228474, -0.009662701, 0.0026705957, -0.00061345665, -0.029577713, 0.028287504, -0.030104896, 0.014955336, 0.00972513, 0.003953869, -0.01316569, 0.0014757642, 0.002028959, 0.025027297, -0.033101514, 0.02190582, 0.039621927, 0.01656463, 0.00056143204, 0.010973721, -0.040759534, 0.011833861, -0.014032766, 0.00078513776, 0.0016127623, 0.010286996, -0.013068577, 0.013831604, 0.0105367135, -0.013769175, -0.00014989586, 0.016176179, -0.0068152216, 0.026428493, 0.02530476, -0.020296527, -0.0007244424, -0.0077898153, 0.013096324, 0.016869841, -0.008303124, 0.0036209116, 0.03798489, 0.011882417, -0.021864202, 0.0026237736, 0.01850688, -0.0017237482, -0.016578503, 0.017799348, 0.004227865, 0.022058427, -0.04483826, 0.017993571, -0.015954208, -0.014747238, 0.0114870295, 0.015413152, 0.04764065, -0.0015806805, -0.0076441467, 0.012173754, -0.02344575, -0.023764834, -0.113482974, -0.017355403, 0.005968955, 0.002028959, -0.013283612, 0.004269485, -0.0047550476, 0.036986016, -0.023265397, 0.02844011, -0.024944058, -0.014171499, 0.0054903287, -0.0144975195, -0.008296188, -0.028315252, -0.013380725, -0.01949188, -0.012527522, 0.0063400636, 0.016925333, -0.01138298, 0.023404129, -0.0045955055, -0.032130387, -0.017286038, -0.03382292, 0.008400237, -0.0055111386, -0.010730939, 0.026220394, -0.02215554, -0.0067909434, -0.011480093, -0.0013474369, -0.0036174431, -0.011105516, -0.020837583, 0.00972513, -0.030104896, -0.017757727, -0.017466389, 0.0056810854, -0.011022277, -0.009482349, 0.00804647, -0.0055909096, 0.0024330167, -0.016661743, -0.014344914, -0.01596808, 0.0029029723, -0.015551885, -0.007859182, 0.015107941, 0.027482858, 0.007158584, 0.009121645, -0.016467517, -0.024583353, -0.0007955427, -0.0063053803, -0.010266186, 0.006062599, 0.007158584, 0.014955336, -0.025415746, -0.014802731, -0.014553012, -0.012444282, -0.005968955, 0.030410107, 0.010980657, 0.0047966675, -0.024125537, -0.004623252, 0.00047559149, -0.02938349, 0.013866288, 0.011223438, -0.022863073, -0.013228119, -0.017147304, -0.029744193, -0.0028596183, 0.0033711935, 0.0025058512, -0.010314742, 0.0014688276, -0.046808258, 0.015551885, 0.027288632, 0.019921951, 0.00722795, -0.0021468815, -0.011688191, -0.030659826, -0.0052302056, 0.008532033, 0.03890052, 0.004928463, -0.0062498874, -0.075137384, 0.012028085, -0.0021676912, -0.022904694, 0.004609379, -0.01441428, 0.0032550052, -0.005656807, -0.009988721, 0.017050192, -0.012485902, 0.0069747637, -0.0028284036, 0.0050359806, -0.0030399703, -0.0067458553, 0.02530476, -0.022044554, 0.008060344, -0.0077135125, -0.0032879543, -0.019158922, 0.00841411, 0.0027486326, -0.0036070384, -0.010640763, -0.030410107, 0.029716447, -0.007893865, -0.011147136, 0.01095291, -0.018354276, 0.0031735, 0.034433343, -0.018146178, 0.010717066, 0.014580758, 0.018104557, 0.0021174008, 0.017785473, -0.041064743, -0.030632079, 0.027718702, -0.026858563, -0.010453475, -0.0116604455, 0.00014350117, -0.014594632, 0.012208438, 0.0062533556, 0.031741936, 0.0047758576, -0.03976066, -0.045948118, -0.005882247, -0.002391397, 0.03701376, 0.0027625058, -0.001801785, 0.01441428, 0.04875051, 0.002686203, 0.0060383207, -0.0060348525, 0.014705618, -0.0050671953, -0.014650125, -0.019644486, 0.0046059103, 0.0009164999, -0.0177716, -0.008747068, 0.00033230707, -0.008053407, 0.025929056, -0.002627242, 0.028065532, -0.008795625, -0.01988033, 0.02056012, 0.021142794, -0.00974594, -0.006187458, 0.013672062, 0.028634336, -0.0067944117, -0.02594293, -0.019436387, -0.025374128, -0.022211032, 0.024458494, -0.0033018275, 0.0061735846, 0.03820686, 0.0027503667, -0.008344744, -0.0029862116, -0.0030382362, 0.016592376, 0.016703362, 0.023376383, -0.005219801, 0.004907653, -0.023043426, -0.033046022, 0.001496574, -0.025831943, -0.033739682, 0.024944058, 0.02215554, 0.01664787, 0.00030022525, 0.0014558214, 0.013887097, -0.012215374, 0.042951502, -0.0065655033, -0.012596888, -0.028204264, 0.008858054, 0.0077343225, 0.01824329, 0.019200543, -0.024597228, 0.03859531, 0.010592206, 0.019810963, -0.015177308, 0.023848072, 0.017452516, -0.029771939, -0.012319423, -0.019630613, -0.021753216, -0.01781322, -0.01863174, -0.04478277, 0.02465272, 0.006378215, 0.10454862, 0.0074846046, -0.0053203814, -0.004057918, -0.015940335, 0.0025457367, 0.0029185796, -0.003525533, -0.011154072, -0.011771431, -0.008143582, -0.0017237482, -0.015690617, -0.01574611, -0.011480093, -0.027122153, -0.0022856137, 0.0021382107, 0.016259419, 0.006992105, 0.024458494, -0.0051677763, 0.014733364, -0.026456239, -0.04211911, 0.019269908, 0.010432664, -0.0048937798, -0.009662701, -0.031436726, 0.04727995, 0.006527352, -0.026664337, -0.010529777, -0.01871498, 0.013110197, -0.00054322346, -0.02749673, 0.007172457, 0.00025730496, 0.020005189, 0.0027607717, -0.02405617, -0.03490503, -0.011771431, 0.010127454, 0.008733194, -0.020435259, -0.014275548], 'metadata': '{\"source\": \"qna/overview_openai.txt\"}'})]"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"retriever.invoke(\"What is Azure OpenAI?\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}