Anush008 / fastembed-rs

Library for generating vector embeddings, reranking in Rust
https://docs.rs/fastembed
Apache License 2.0
264 stars 36 forks source link

Support users supplying their own HF model cards #93

Closed spikecodes closed 2 months ago

spikecodes commented 2 months ago

I know users can currently provide onnx files but what would be useful, instead of simply hardcoding the model list, is allowing users to add models based on a hugging face repo ID and other model info.

This would avoid having to rewrite the infrastructure to download and cache an onnx file from the huggingface repo based on a HF repo ID.

Something like this:

TextEmbedding::try_new_from_model_info(ModelInfo)

where use can supply a ModelInfo (which is already a pub struct):

pub struct ModelInfo {
    pub model: EmbeddingModel,
    pub dim: usize,
    pub description: String,
    pub model_code: String,
    pub model_file: String,
}
Anush008 commented 2 months ago

The problem I see is, people would expect this to work with every model on HF and raise issues if it doesn't.

Right now, we're able to curate the models by adding them manually and testing.

spikecodes commented 2 months ago

That makes sense, though wouldn't that be equally an issue with users currently loading their own onnx files? I imagined this just being an abstraction over that to make it easier to fetch models' onnx files from HF.

Anush008 commented 2 months ago

When loading files from the hub, the library expects tokenizer/config files to strictly follow this organization. So the chances of some model repo not working increases.

With local files, the file paths will not be problem, since users will specify each.