-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support vector index filtering #2
base: main
Are you sure you want to change the base?
Conversation
# The pattern to find Cypher code enclosed in triple backticks | ||
pattern = r"###(.*?)###" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the text get enclosed in ###
?
Also, I think the comment can be corrected here.
@@ -62,6 +64,23 @@ def extract_cypher(text: str) -> str: | |||
return matches[0] if matches else text | |||
|
|||
|
|||
def extract_filter(text: str) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a unit test for this under libs/neo4j/tests/unit_tests/chains/test_graph_qa.py?
@@ -88,6 +107,7 @@ def filter_func(x: str) -> bool: | |||
for r in structured_schema.get("relationships", []) | |||
if all(filter_func(r[t]) for t in ["start", "end", "type"]) | |||
], | |||
"vector_indexes": structured_schema.get("vector_indexes", []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add some test to ensure this field is included in libs/neo4j/tests/unit_tests/chains/test_graph_qa.py ?
"The vector indexes are the following:", | ||
",".join(formatted_vector_indexes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, please write some tests to test this under libs/neo4j/tests/unit_tests/chains/test_graph_qa.py
Sorry for the delay, I've added some comments to clarify the |
Extends/Improves
GraphCypherQAChain
to perform queries based on semantics via vector indexes (listed from auto-generated schema), instead of generating queries with strict/exact matching filters which fail on some use cases.This means having the following user's query:
resulting to:
Embeddings are then computed for generated filter and passed as
search_emb
parameter inqueryNodes
.Without this improvement, the same input resulted to the query below, which fails to respond to user's input.
Change is backward compatible (selection of prompt and further logic is based on passing an
embeddings
model (optional)