add_dense_and_sparse
Function
Adds a document index to a vector database. Specifically, this API first performs embedding on a document chunk to obtain dense vectors and sparse vectors, and then stores the vectors into a vector database.
Prototype
def add_dense_and_sparse(ids, dense_embeddings, sparse_embeddings, docs, metadatas, **kwargs)
Parameters
Parameter |
Data Type |
Required/Optional |
Description |
|---|---|---|---|
ids |
List[int] |
Required |
Index ID list of vectors to be added. Its length range is [0, 10 million). |
dense_embeddings |
ndarray |
Required |
NumPy array object. |
sparse_embeddings |
List[Dict[int, float]] |
Required |
Sparse vector object. |
docs |
List[str] |
Optional |
Document to which vectors will be added. |
metadatas |
List[dict] |
Optional |
Metadata of the document to which vectors will be added. |
kwargs |
Dict |
Optional |
Keyword parameter, which can only be document_id, to specify the ID of the document to which vectors are to be added. Other keyword parameters are invalid. |
The shape of dense_embeddings must be 2D. The number of vectors contained in dense_embeddings and sparse_embeddings must be equal to the length of ids. The number of documents contained in docs must be equal to the length of ids. The total number of vectors added at a time must be less than 10 million.