Skip to content
Merged
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
42 changes: 24 additions & 18 deletions docs/examples_notebooks/local_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
" LocalSearchMixedContext,\n",
")\n",
"from graphrag.query.structured_search.local_search.search import LocalSearch\n",
"from graphrag_vectors import IndexSchema, LanceDBVectorStore"
"from graphrag_vectors import (\n",
" IndexSchema,\n",
" VectorStoreConfig,\n",
" VectorStoreType,\n",
" create_vector_store,\n",
")"
]
},
{
Expand All @@ -41,7 +46,7 @@
"source": [
"## Local Search Example\n",
"\n",
"Local search method generates answers by combining relevant data from the AI-extracted knowledge-graph with text chunks of the raw documents. This method is suitable for questions that require an understanding of specific entities mentioned in the documents (e.g. What are the healing properties of chamomile?)."
"Local search method generates answers by combining relevant data from the AI-extracted knowledge-graph with text chunks of the raw documents. This method is suitable for questions that require an understanding of specific entities mentioned in the documents (e.g. What are the healing properties of chamomile?).\n"
]
},
{
Expand All @@ -50,14 +55,14 @@
"source": [
"### Load text units and graph data tables as context for local search\n",
"\n",
"- In this test we first load indexing outputs from parquet files to dataframes, then convert these dataframes into collections of data objects aligning with the knowledge model."
"- In this test we first load indexing outputs from parquet files to dataframes, then convert these dataframes into collections of data objects aligning with the knowledge model.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load tables to dataframes"
"### Load tables to dataframes\n"
]
},
{
Expand All @@ -82,7 +87,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Read entities"
"#### Read entities\n"
]
},
{
Expand All @@ -99,10 +104,11 @@
"\n",
"# load description embeddings to an in-memory lancedb vectorstore\n",
"# to connect to a remote db, specify url and port values.\n",
"description_embedding_store = LanceDBVectorStore(\n",
" index_schema=IndexSchema(index_name=\"default-entity-description\")\n",
"description_embedding_store = create_vector_store(\n",
" config=VectorStoreConfig(type=VectorStoreType.LanceDB, uri=LANCEDB_URI),\n",
" index_schema=IndexSchema(index_name=\"default-entity-description\"),\n",
")\n",
"description_embedding_store.connect(db_uri=LANCEDB_URI)\n",
"description_embedding_store.connect()\n",
"\n",
"print(f\"Entity count: {len(entity_df)}\")\n",
"entity_df.head()"
Expand All @@ -112,7 +118,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Read relationships"
"#### Read relationships\n"
]
},
{
Expand Down Expand Up @@ -148,7 +154,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Read community reports"
"#### Read community reports\n"
]
},
{
Expand All @@ -168,7 +174,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Read text units"
"#### Read text units\n"
]
},
{
Expand Down Expand Up @@ -221,7 +227,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create local search context builder"
"### Create local search context builder\n"
]
},
{
Expand All @@ -248,7 +254,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create local search engine"
"### Create local search engine\n"
]
},
{
Expand Down Expand Up @@ -314,7 +320,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Run local search on sample queries"
"### Run local search on sample queries\n"
]
},
{
Expand Down Expand Up @@ -342,7 +348,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Inspecting the context data used to generate the response"
"#### Inspecting the context data used to generate the response\n"
]
},
{
Expand Down Expand Up @@ -396,14 +402,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Question Generation"
"### Question Generation\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This function takes a list of user queries and generates the next candidate questions."
"This function takes a list of user queries and generates the next candidate questions.\n"
]
},
{
Expand Down Expand Up @@ -440,7 +446,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "graphrag",
"display_name": "graphrag-monorepo (3.12.10)",
"language": "python",
"name": "python3"
},
Expand Down
Loading