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, document_id)
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. |
document_id |
Integer |
Optional |
ID of the document to which vectors to be added belong. |
- The shape of dense_embeddings must be 2D. The number of vectors contained in dense_embeddings must be equal to the length of ids.
- The number of vectors contained in sparse_embeddings must be equal to the length of ids. The total number of vectors added at a time is less than 10 million.
Parent topic: OpenGaussDB