Skip to content

Commit

Permalink
Rename Embedding in ElasticSearch Notebook (#1051)
Browse files Browse the repository at this point in the history
* rename notebook

* add install name
  • Loading branch information
karanataryn authored Dec 3, 2024
1 parent c2e6672 commit 9220d7a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions notebooks/elasticsearch-writer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"You can also run the Aryn Partitioner locally by setting `use_partitioning_service` to `False`. Though you can use CPU to run the Aryn Partitioner, it is recommended to use an NVIDIA GPU for good performance."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If any of the packages below are missing, you can install them using the following command:\n",
"```bash\n",
"!pip install -q PACKAGE_NAME\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -237,7 +247,7 @@
"response = client.search(\n",
" index = index_name,\n",
" knn={\n",
" \"field\": \"embeddings\",\n",
" \"field\": \"embedding\",\n",
" \"query_vector\": embedder.embed_query(\"How do I prevent accidents?\"),\n",
" \"k\": 10,\n",
" \"num_candidates\": 10\n",
Expand Down Expand Up @@ -327,7 +337,7 @@
"from langchain.chains import RetrievalQAWithSourcesChain \n",
"import os\n",
"\n",
"vector_store = ElasticsearchStore(index_name=index_name, es_connection=client, vector_query_field=\"embeddings\", \n",
"vector_store = ElasticsearchStore(index_name=index_name, es_connection=client, vector_query_field=\"embedding\", \n",
" query_field=\"text_representation\", embedding=embedder)\n",
"\n",
"llm = ChatOpenAI( \n",
Expand All @@ -342,11 +352,18 @@
") \n",
"qa.invoke({\"question\": \"How many accidents happened?\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -360,7 +377,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 9220d7a

Please sign in to comment.