Skip to content

Instantly share code, notes, and snippets.

View kacperlukawski's full-sized avatar

Kacper Łukawski kacperlukawski

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import multiprocessing
import tempfile
import time
from pathlib import Path
from urllib.request import urlretrieve
import h5py
from qdrant_client import QdrantClient
from qdrant_client.conversions.common_types import VectorParams
from qdrant_client.http.models import Distance, SearchRequest
from qdrant_client import QdrantClient
from qdrant_client.conversions.common_types import VectorParams
client = QdrantClient("localhost", 6333)
client.recreate_collection(
collection_name="test_collection",
vectors_config=VectorParams(size=4, distance=Distance.EUCLID),
)
vectors = [
[.1, .0, .0, .0],
[.0, .1, .0, .0],
[.0, .0, .1, .0],
[.0, .0, .0, .1],
[.1, .0, .1, .0],
[.0, .1, .0, .1],
[.1, .1, .0, .0],
[.0, .0, .1, .1],
[.1, .1, .1, .1],
results = client.search_batch(
collection_name="test_collection",
requests=[
SearchRequest(
vector=[0., 0., 2., 0.],
limit=1,
),
SearchRequest(
vector=[0., 0., 0., 0.01],
with_vector=True,
@kacperlukawski
kacperlukawski / qdrant-0.10-multiple-vectors.ipynb
Last active October 14, 2024 18:26
Using multiple vectors in Qdrant 0.10
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from qdrant_client import QdrantClient
from qdrant_client.http.models import VectorParams, Distance
client = QdrantClient()
client.recreate_collection(
collection_name="multiple_vectors",
vectors_config={
"title": VectorParams(
size=100,
distance=Distance.EUCLID,
client.recreate_collection(
collection_name="single_vector",
vectors_config=VectorParams(
size=100,
distance=Distance.COSINE,
)
)
from datasets import load_dataset
dataset = load_dataset("ChristophSchuhmann/MS_COCO_2017_URL_TEXT")
import pandas as pd
dataset_df = pd.DataFrame(dataset["train"])