-
Notifications
You must be signed in to change notification settings - Fork 145
feat: Qdrant external retriever #154
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d5d96a6
feat: Qdrant external retriever
Anush008 70dbfa2
Merge branch 'main' into qdrant
Anush008 76197e0
test: ci updates
Anush008 5a2e27f
Merge branch 'main' into qdrant
Anush008 5cfedee
chore: add qdrant-client to dev deps
Anush008 5394de0
chore: poetry.lock
Anush008 e0dd2e5
Update docs/source/api.rst
Anush008 58e009c
Merge branch 'main' into qdrant
Anush008 d57980c
chore: fix mypy nit
Anush008 2b03d88
Merge branch 'main' into qdrant
Anush008 1af8fe9
Update docs/source/user_guide_rag.rst
Anush008 08ab9ac
Merge branch 'main' into qdrant
willtai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
### Start services locally | ||
|
||
Run the following command to spin up Neo4j and Qdrant containers. | ||
|
||
```bash | ||
docker compose -f tests/e2e/docker-compose.yml up | ||
``` | ||
|
||
### Write data (once) | ||
|
||
Run this from the project root to write data to both Neo4J and Qdrant. | ||
|
||
```bash | ||
poetry run python tests/e2e/qdrant_e2e/populate_dbs.py | ||
``` | ||
|
||
### Install Qdrant client | ||
|
||
```bash | ||
pip install qdrant-client | ||
``` | ||
|
||
### Search | ||
|
||
```bash | ||
# search by vector | ||
poetry run python -m examples.qdrant.vector_search | ||
|
||
# search by text, with embeddings generated locally | ||
poetry run python -m examples.qdrant.text_search | ||
``` |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from langchain_huggingface.embeddings import HuggingFaceEmbeddings | ||
from neo4j import GraphDatabase | ||
from neo4j_graphrag.retrievers import QdrantNeo4jRetriever | ||
from qdrant_client import QdrantClient | ||
|
||
NEO4J_URL = "neo4j://localhost:7687" | ||
NEO4J_AUTH = ("neo4j", "password") | ||
|
||
|
||
def main() -> None: | ||
with GraphDatabase.driver(NEO4J_URL, auth=NEO4J_AUTH) as neo4j_driver: | ||
embedder = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2") | ||
retriever = QdrantNeo4jRetriever( | ||
driver=neo4j_driver, | ||
client=QdrantClient(url="http://localhost:6333"), | ||
collection_name="Jeopardy", | ||
id_property_external="neo4j_id", | ||
id_property_neo4j="id", | ||
embedder=embedder, # type: ignore | ||
) | ||
|
||
res = retriever.search(query_text="biology", top_k=2) | ||
print(res) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from neo4j import GraphDatabase | ||
from neo4j_graphrag.retrievers import QdrantNeo4jRetriever | ||
from qdrant_client import QdrantClient | ||
|
||
from examples.embedding_biology import EMBEDDING_BIOLOGY | ||
|
||
NEO4J_URL = "neo4j://localhost:7687" | ||
NEO4J_AUTH = ("neo4j", "password") | ||
|
||
|
||
def main() -> None: | ||
with GraphDatabase.driver(NEO4J_URL, auth=NEO4J_AUTH) as neo4j_driver: | ||
retriever = QdrantNeo4jRetriever( | ||
driver=neo4j_driver, | ||
client=QdrantClient(url="http://localhost:6333"), | ||
collection_name="Jeopardy", | ||
id_property_external="neo4j_id", | ||
id_property_neo4j="id", | ||
) | ||
res = retriever.search(query_vector=EMBEDDING_BIOLOGY, top_k=2) | ||
print(res) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.