Skip to content

[Documentation request] Multi-index for hybrid search #9

Description

@marquesafonso

Hi. I really appreciate your project and paper on BMX, as well as the direct integration with HF.

I would like to use it for some projects and found that documentation is lacking on MultiIndex.
I would be happy to help on this if I can get some guidance from your side.

The general idea of what I am trying to achieve is found in the code below:

from baguetter import MultiIndex, BMXSparseIndex, USearchDenseIndex
from baguetter.fuser.config import FuserConfig
import numpy as np

def get_bmx_results(doc_ids:list, docs:list, docs_vectors:np.ndarray, query:str):
    alpha = 0.5
    IndexConfig = [BMXSparseIndex(index_name="bmx"), USearchDenseIndex(index_name="usearch", embedding_dim=256)]
    index = MultiIndex(indices=IndexConfig, fuser_config=FuserConfig(weights=[alpha, 1-alpha], algorithm="weighted"))
    index.add_many(keys=doc_ids, values=list(zip(docs,docs_vectors)))
    res = index.search(query=query)
    return res

I understand that values is of type str | np.ndarray. The docs and docs_vectors (embeddings) are of the same size and the embeddings have been pre-computed, which is why I would not like to pass in an embed_fn, as those computations had already been done. I tried zip to no avail.

Would you be able to help me on this?

Thank you for your time and sharing this project openly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions