Skip to content

Instantly share code, notes, and snippets.

@generall
Created June 8, 2021 23:13
Show Gist options
  • Save generall/ee915ab8aaa1e50c8e88d139b62f009a to your computer and use it in GitHub Desktop.
Save generall/ee915ab8aaa1e50c8e88d139b62f009a to your computer and use it in GitHub Desktop.
import numpy as np
import json
fd = open('./startups.json')
# payload is now an iterator over startup data
payload = map(json.loads, fd)
# Here we load all vectors into memory, numpy array works as iterable for itself.
# Other option would be to use Mmap, if we don't want to load all data into RAM
vectors = np.load('./startup_vectors.npy')
# And the final step - data uploading
qdrant_client.upload_collection(
collection_name='startups',
vectors=vectors,
payload=payload,
ids=None, # Vector ids will be assigned automatically
batch_size=256 # How many vectors will be uploaded in a single request?
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment