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

Is there a way to add a model with ONNX resources from HF to the program? #59

Closed GrisaiaEvy closed 5 months ago

GrisaiaEvy commented 5 months ago

I didn't find a way to add a model by myself. It seems that in the current version(3.5), you can only use the model defined in model.rs. Should we allow the user to add a model (which have ONNX file) on HF by themselves?

Anush008 commented 5 months ago

To use local models, you can use https://docs.rs/fastembed/latest/fastembed/struct.TextEmbedding.html#method.try_new_from_user_defined.

If you want some model from HF to be supported, you can raise a PR similar to #54.

GrisaiaEvy commented 5 months ago

To use local models, you can use https://docs.rs/fastembed/latest/fastembed/struct.TextEmbedding.html#method.try_new_from_user_defined.

If you want some model from HF to be supported, you can raise a PR similar to #54.

I mean not through PR, just pass the EmbeddingModel parameter when creating an EmbeddingText, so that it's flexible to use any model on HF. let model = TextEmbedding::try_new(InitOptions { model_name: EmbeddingModel::new("a model on HF with ONNX file"), show_download_progress: true, ..Default::default() }).unwrap(); I apologise if it's a stupid quetsion because i jsut started learning this project a few days ago :)

Anush008 commented 5 months ago

Currently, only models listed in models.rs are supported directly. If you have the ONNX and tokenizer files locally, you can use the https://docs.rs/fastembed/latest/fastembed/struct.TextEmbedding.html#method.try_new_from_user_defined method.

GrisaiaEvy commented 5 months ago

Currently, only models listed in models.rs are supported directly. If you have the ONNX and tokenizer files locally, you can use the https://docs.rs/fastembed/latest/fastembed/struct.TextEmbedding.html#method.try_new_from_user_defined method.

Ok, thank you for your answer.