mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 11:39:18 +00:00
Bagatur/self query doc update (#12461)
This commit is contained in:
@@ -7,9 +7,33 @@
|
||||
"source": [
|
||||
"# Building hotel room search with self-querying retrieval\n",
|
||||
"\n",
|
||||
"In this example we'll walk through how to build and iterate on a hotel room search service that leverages an LLM to generate structured filter queries that can then be passed to a vector store.\n",
|
||||
"\n",
|
||||
"For an introduction to self-querying retrieval [check out the docs](https://python.langchain.com/docs/modules/data_connection/retrievers/self_query)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d621de99-d993-4f4b-b94a-d02b2c7ad4e0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Imports and data prep\n",
|
||||
"\n",
|
||||
"In this example we use `ChatOpenAI` for the model and `ElasticsearchStore` for the vector store, but these can be swapped out with an LLM/ChatModel and [any VectorStore that support self-querying](https://python.langchain.com/docs/integrations/retrievers/self_query/).\n",
|
||||
"\n",
|
||||
"Download data from: https://www.kaggle.com/datasets/keshavramaiah/hotel-recommendation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "8ecd1fbb-bdba-420b-bcc7-5ea8a232ab11",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install langchain lark openai elasticsearch pandas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
@@ -1142,7 +1166,9 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"results = retriever.get_relevant_documents(\"I want to stay somewhere highly rated along the coast. I want a room with a patio and a fireplace.\")\n",
|
||||
"results = retriever.get_relevant_documents(\n",
|
||||
" \"I want to stay somewhere highly rated along the coast. I want a room with a patio and a fireplace.\"\n",
|
||||
")\n",
|
||||
"for res in results:\n",
|
||||
" print(res.page_content)\n",
|
||||
" print(\"\\n\" + \"-\" * 20 + \"\\n\")"
|
||||
|
Reference in New Issue
Block a user