Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,7 +156,7 @@ uuids = [str(uuid4()) for _ in range(len(documents))]
|
|
| 156 |
docs = documents
|
| 157 |
|
| 158 |
|
| 159 |
-
|
| 160 |
embeddings = FastEmbedEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
| 161 |
|
| 162 |
client = QdrantClient(path="tmp/langchain_qdrant")
|
|
@@ -165,18 +165,20 @@ client = QdrantClient(path="tmp/langchain_qdrant")
|
|
| 165 |
client.create_collection(
|
| 166 |
collection_name="my_documents",
|
| 167 |
vectors_config={"dense": VectorParams(size=3072, distance=Distance.COSINE)},
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
)
|
| 172 |
|
| 173 |
qdrant = QdrantVectorStore(
|
| 174 |
client=client,
|
| 175 |
collection_name="my_documents",
|
| 176 |
embedding=embeddings,
|
| 177 |
-
|
| 178 |
# retrieval_mode=RetrievalMode.SPARSE,
|
| 179 |
-
|
|
|
|
|
|
|
| 180 |
|
| 181 |
)
|
| 182 |
|
|
|
|
| 156 |
docs = documents
|
| 157 |
|
| 158 |
|
| 159 |
+
sparse_embeddings = FastEmbedSparse(model_name="Qdrant/bm25")
|
| 160 |
embeddings = FastEmbedEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
| 161 |
|
| 162 |
client = QdrantClient(path="tmp/langchain_qdrant")
|
|
|
|
| 165 |
client.create_collection(
|
| 166 |
collection_name="my_documents",
|
| 167 |
vectors_config={"dense": VectorParams(size=3072, distance=Distance.COSINE)},
|
| 168 |
+
sparse_vectors_config={
|
| 169 |
+
"sparse": SparseVectorParams(index=models.SparseIndexParams(on_disk=False))
|
| 170 |
+
},
|
| 171 |
)
|
| 172 |
|
| 173 |
qdrant = QdrantVectorStore(
|
| 174 |
client=client,
|
| 175 |
collection_name="my_documents",
|
| 176 |
embedding=embeddings,
|
| 177 |
+
sparse_embedding=sparse_embeddings,
|
| 178 |
# retrieval_mode=RetrievalMode.SPARSE,
|
| 179 |
+
retrieval_mode=RetrievalMode.HYBRID,
|
| 180 |
+
vector_name="dense",
|
| 181 |
+
sparse_vector_name="sparse",
|
| 182 |
|
| 183 |
)
|
| 184 |
|