Skip to content

Instantly share code, notes, and snippets.

@ljnmedium
Created September 29, 2023 07:29
Show Gist options
  • Save ljnmedium/a9b27ee5ae3ab537204e36972ae46296 to your computer and use it in GitHub Desktop.
Save ljnmedium/a9b27ee5ae3ab537204e36972ae46296 to your computer and use it in GitHub Desktop.
add_data.py
values = embedd_model.encode([b['content'] for b in batch])
sparse_values = sparsed_model.encode([b['content'] for b in batch])
# Create unique IDs
ids = [str(b['metadata']['id']) for b in batch]
# Add all to upsert list
to_upsert = [{'id': i, 'values': v, 'metadata':m , 'sparse_values': sv} for (i,v,m,sv) in zip(ids,values, metas, sparse_values)]
# Upsert/insert these records to pinecone
index.upsert(vectors=to_upsert, namespace="Eiffage")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment