From f42484ea5c1de7ea3d54cf47d455fc761f95105c Mon Sep 17 00:00:00 2001 From: Daehee Kim <76981513+DayNice@users.noreply.github.com> Date: Tue, 21 Oct 2025 23:45:07 +0900 Subject: [PATCH 1/2] Support `HF_HOME` and `HF_ENDPOINT` --- rust/src/embeddings/local/bert.rs | 4 ++-- rust/src/embeddings/local/clip.rs | 2 +- rust/src/embeddings/local/jina.rs | 2 +- rust/src/embeddings/local/modernbert.rs | 2 +- rust/src/embeddings/local/qwen3.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/src/embeddings/local/bert.rs b/rust/src/embeddings/local/bert.rs index cf8d29c6..22fcf80d 100644 --- a/rust/src/embeddings/local/bert.rs +++ b/rust/src/embeddings/local/bert.rs @@ -77,7 +77,7 @@ impl BertEmbedder { }; let (config_filename, tokenizer_filename, weights_filename) = { - let api = ApiBuilder::new() + let api = ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build() .unwrap(); @@ -299,7 +299,7 @@ pub struct SparseBertEmbedder { impl SparseBertEmbedder { pub fn new(model_id: String, revision: Option, token: Option<&str>) -> Result { let (config_filename, tokenizer_filename, weights_filename) = { - let api = ApiBuilder::new() + let api = ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build() .unwrap(); diff --git a/rust/src/embeddings/local/clip.rs b/rust/src/embeddings/local/clip.rs index 84775731..34e5c7a5 100644 --- a/rust/src/embeddings/local/clip.rs +++ b/rust/src/embeddings/local/clip.rs @@ -64,7 +64,7 @@ impl Default for ClipEmbedder { impl ClipEmbedder { pub fn new(model_id: String, revision: Option<&str>, token: Option<&str>) -> Result { - let api = hf_hub::api::sync::ApiBuilder::new() + let api = hf_hub::api::sync::ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build()?; diff --git a/rust/src/embeddings/local/jina.rs b/rust/src/embeddings/local/jina.rs index 9d47e512..b8c7d3c4 100644 --- a/rust/src/embeddings/local/jina.rs +++ b/rust/src/embeddings/local/jina.rs @@ -50,7 +50,7 @@ impl Default for JinaEmbedder { impl JinaEmbedder { pub fn new(model_id: &str, revision: Option<&str>, token: Option<&str>) -> Result { - let api = hf_hub::api::sync::ApiBuilder::new() + let api = hf_hub::api::sync::ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build()?; let api = match revision { diff --git a/rust/src/embeddings/local/modernbert.rs b/rust/src/embeddings/local/modernbert.rs index 2814094a..ae6d2801 100644 --- a/rust/src/embeddings/local/modernbert.rs +++ b/rust/src/embeddings/local/modernbert.rs @@ -41,7 +41,7 @@ impl ModernBertEmbedder { dtype: Option, ) -> Result { let (config_filename, tokenizer_filename, weights_filename) = { - let api = ApiBuilder::new() + let api = ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build() .unwrap(); diff --git a/rust/src/embeddings/local/qwen3.rs b/rust/src/embeddings/local/qwen3.rs index bbce4480..668d14d8 100644 --- a/rust/src/embeddings/local/qwen3.rs +++ b/rust/src/embeddings/local/qwen3.rs @@ -35,7 +35,7 @@ impl Qwen3Embedder { token: Option<&str>, dtype: Option, ) -> Result { - let api = ApiBuilder::new() + let api = ApiBuilder::from_env() .with_token(token.map(|s| s.to_string())) .build() .unwrap(); From 6a0e94a2dcbc27071f57a9dcd71ebf31d2e75b3a Mon Sep 17 00:00:00 2001 From: akshayballal Date: Tue, 21 Oct 2025 21:36:31 +0200 Subject: [PATCH 2/2] Fix input shape assertion in CLIP tests from [2, 8] to [2, 77] --- rust/src/embeddings/local/clip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/embeddings/local/clip.rs b/rust/src/embeddings/local/clip.rs index 34e5c7a5..fa56e900 100644 --- a/rust/src/embeddings/local/clip.rs +++ b/rust/src/embeddings/local/clip.rs @@ -372,7 +372,7 @@ mod tests { "EmbedAnything is the best!".to_string(), ] ); - assert_eq!(input_ids.shape().clone().into_dims(), &[2, 8]); + assert_eq!(input_ids.shape().clone().into_dims(), &[2, 77]); } // Tests the load_image method.