-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: samadpls <[email protected]>
- Loading branch information
Showing
4 changed files
with
32 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
"""B-RAG""" | ||
"""BestRAG""" | ||
# Authors: Abdul Samad Siddiqui <[email protected]> | ||
|
||
import re | ||
import uuid | ||
from typing import List, Optional | ||
from qdrant_client import QdrantClient, models | ||
from qdrant_client.http.models import Distance, VectorParams | ||
from qdrant_client.http.models import Distance | ||
from fastembed import TextEmbedding | ||
from fastembed.sparse.bm25 import Bm25 | ||
import PyPDF2 | ||
|
@@ -35,6 +35,8 @@ def __init__(self, | |
late_interaction_model_name: Optional[str] = "BAAI/bge-small-en-v1.5" | ||
): | ||
self.collection_name = collection_name | ||
self.api_key = api_key | ||
self.url = url | ||
self.client = QdrantClient(url=url, api_key=api_key) | ||
|
||
self.dense_model = TextEmbedding() | ||
|
@@ -216,7 +218,7 @@ def search(self, query: str, limit: int = 10): | |
models.Prefetch( | ||
query=query_vector["dense-vector"], | ||
using="dense-vector", | ||
limit=50, | ||
limit=20, | ||
) | ||
], | ||
query=query_vector["output-token-embeddings"], | ||
|
@@ -225,3 +227,18 @@ def search(self, query: str, limit: int = 10): | |
) | ||
|
||
return results | ||
|
||
def __str__(self): | ||
""" | ||
Return a string representation of the BestRAG object, including its parameters. | ||
""" | ||
info = ( | ||
"**************************************************\n" | ||
"* BestRAG Object Information *\n" | ||
"**************************************************\n" | ||
f"* URL: {self.url}\n" | ||
f"* API Key: {self.api_key}\n" | ||
f"* Collection Name: {self.collection_name}\n" | ||
"**************************************************" | ||
) | ||
return info |
This file contains 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ fastembed==0.4.1 | |
streamlit | ||
pytest | ||
flake8 | ||
PyPDF2 | ||
PyPDF2==3.0.1 | ||
qdrant-client | ||
onnxruntime==1.19.2 | ||
pytest |
This file contains 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 |
---|---|---|
|
@@ -5,10 +5,8 @@ | |
|
||
setup( | ||
name="bestrag", | ||
version="0.2.0", | ||
description="BestRAG (Best Retrieval Augmented) is a library for storing and" | ||
" searching document embeddings in a Qdrant vector database. It uses a " | ||
"hybrid embedding technique combining dense, late interaction and sparse representations for better performance.", | ||
version="0.2.1", | ||
description="bestrag: Library for storing and searching document embeddings in a Qdrant vector database using hybrid embedding techniques.", | ||
author="samadpls", | ||
author_email="[email protected]", | ||
long_description=long_description, | ||
|
@@ -17,10 +15,7 @@ | |
packages=find_packages(), | ||
install_requires=[ | ||
"fastembed==0.4.1", | ||
"streamlit", | ||
"pytest", | ||
"flake8", | ||
"PyPDF2", | ||
"PyPDF2==3.0.1", | ||
"qdrant-client", | ||
"onnxruntime==1.19.2", | ||
], | ||
|