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

Unable to download models on Android #45

Closed harshakhmk closed 6 months ago

harshakhmk commented 6 months ago

Hi, I built the fastembed crate for Android by building onnxruntime from source and correspondingly setting the environment variable for libonnxruntime.so library, but while running, it is giving following error

hf_hub: Token file not found "token"
ureq:::stream connecting to huggingface.co 

This behaviour is not observed in linux, it built fine and is also working

Anush008 commented 6 months ago

Can you try runing https://github.com/huggingface/hf-hub?tab=readme-ov-file#how-to-use after an Android build?

harshakhmk commented 6 months ago

I tried running it, it didn't work, app is crashing because of the code


use hf_hub::api::sync::Api;

let api = Api::new().unwrap();

let repo = api.model("bert-base-uncased".to_string());
let _filename = repo.get("config.json").unwrap();

// filename  is now the local location within hf cache of the config.json file
Anush008 commented 6 months ago

So the hf-hub lib that FastEmbed-rs uses in incompatible with your build.

Anush008 commented 6 months ago

I recommend raising an issue there to see if they could help.

harshakhmk commented 6 months ago

Sure, will raise an issue there too, but do you have any idea why its unable to run It is failing at Api object creation, there they are loading the token from cache, in linux it is able to load, but in Android, it is unable to load from cache

Anush008 commented 6 months ago

I am not aware of the hf-hub internals.

Maybe hf-hub's cache directory retrieval isn't compatible with Android.

harshakhmk commented 6 months ago

Ok , thanks for the update Any other crate do you suggest to get vector embeddings for text input which works for Android

Anush008 commented 6 months ago

I am not aware. I think you should set up an embedding service as an API and use it from your Android application instead. It would be much better.