mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-09 21:08:31 +02:00
Automated snippet conversion by scripts
These changes are purely mechanical to differentiate them from manual fixes/adjustments made in the next commit. This results in broken code as some snippets contain errors. Made in four steps: 1. Run ./migrate-snippet.py that converts `.md` files to code files and perhaps adds missing lines under `// @hide` comments. 2. Sort Java imports. 3. Remove old `.md` files. 4. Run ./generate.md to produce `*/generated/*.md` files.
This commit is contained in:
+1
-1
@@ -7,4 +7,4 @@ client.create_collection(
|
||||
)
|
||||
}
|
||||
)
|
||||
```
|
||||
```
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
from qdrant_client import QdrantClient, models # @hide
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333") # @hide
|
||||
|
||||
client.create_collection(
|
||||
collection_name="{minicoil_collection_name}",
|
||||
sparse_vectors_config={
|
||||
"minicoil": models.SparseVectorParams(
|
||||
modifier=models.Modifier.IDF #Inverse Document Frequency
|
||||
)
|
||||
}
|
||||
)
|
||||
+1
-1
@@ -10,4 +10,4 @@ client.query_points(
|
||||
using="minicoil",
|
||||
limit=1
|
||||
)
|
||||
```
|
||||
```
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
from qdrant_client import QdrantClient, models # @hide
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333") # @hide
|
||||
|
||||
query = "Vectors in Medicine"
|
||||
|
||||
client.query_points(
|
||||
collection_name="{minicoil_collection_name}",
|
||||
query=models.Document(
|
||||
text=query,
|
||||
model="Qdrant/minicoil-v1"
|
||||
),
|
||||
using="minicoil",
|
||||
limit=1
|
||||
)
|
||||
+1
-1
@@ -24,4 +24,4 @@ client.upsert(
|
||||
for i in range(len(documents))
|
||||
],
|
||||
)
|
||||
```
|
||||
```
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
from qdrant_client import QdrantClient, models # @hide
|
||||
|
||||
client = QdrantClient(url="http://localhost:6333") # @hide
|
||||
|
||||
#Estimating the average length of the documents in the corpus
|
||||
avg_documents_length = sum(len(document.split()) for document in documents) / len(documents)
|
||||
|
||||
client.upsert(
|
||||
collection_name="{minicoil_collection_name}",
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=i,
|
||||
payload={
|
||||
"text": documents[i]
|
||||
},
|
||||
vector={
|
||||
# Sparse miniCOIL vectors
|
||||
"minicoil": models.Document(
|
||||
text=documents[i],
|
||||
model="Qdrant/minicoil-v1",
|
||||
options={"avg_len": avg_documents_length}
|
||||
#Average length of documents in the corpus
|
||||
# (a part of the BM25 formula on which miniCOIL is built)
|
||||
)
|
||||
},
|
||||
)
|
||||
for i in range(len(documents))
|
||||
],
|
||||
)
|
||||
Reference in New Issue
Block a user