pawasthy commited on
Commit
c82f009
·
verified ·
1 Parent(s): 595a052

Update README.md

Browse files

Fixed the model name and sparse vector format

Files changed (1) hide show
  1. README.md +6 -2
README.md CHANGED
@@ -68,7 +68,7 @@ client.create_collection(
68
  )
69
 
70
  embeddings_model = model.sparse.SpladeEmbeddingFunction(
71
- model_name="ibm-granite/granite-embedding-30m-sparse/",
72
  device="cpu",
73
  batch_size=2,
74
  k_tokens_query=50,
@@ -81,7 +81,11 @@ docs = [
81
  "Alan Turing was the first person to conduct substantial research in AI.",
82
  "Born in Maida Vale, London, Turing was raised in southern England.",
83
  ]
84
- doc_vector = [{"embeddings": doc_emb, "id": f"item_{i}"} for i, doc_emb in enumerate(embeddings_model.encode_documents(docs))]
 
 
 
 
85
 
86
  client.insert(
87
  collection_name="my_sparse_collection",
 
68
  )
69
 
70
  embeddings_model = model.sparse.SpladeEmbeddingFunction(
71
+ model_name="ibm-granite/granite-embedding-30m-sparse",
72
  device="cpu",
73
  batch_size=2,
74
  k_tokens_query=50,
 
81
  "Alan Turing was the first person to conduct substantial research in AI.",
82
  "Born in Maida Vale, London, Turing was raised in southern England.",
83
  ]
84
+
85
+ # SpladeEmbeddingFunction.encode_documents returns sparse matrix or sparse array depending
86
+ # on the milvus-model version. reshape(1,-1) ensures the format is correct for ingestion.
87
+ doc_vector = [{"embeddings": doc_emb.reshape(1,-1), "id": f"item_{i}"} for i, doc_emb in enumerate(embeddings_model.encode_documents(docs))]
88
+
89
 
90
  client.insert(
91
  collection_name="my_sparse_collection",