From 8241183d7ad310ac76dfe1a865be6f667872c850 Mon Sep 17 00:00:00 2001 From: Anush008 Date: Mon, 7 Jul 2025 15:40:07 +0530 Subject: [PATCH 1/4] chore: Disabled scheduled tests due to 429s Signed-off-by: Anush008 --- .github/workflows/test.yml | 2 -- README.md | 10 +++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7a01c9..1a3c434 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,6 @@ name: "Cargo Tests" on: pull_request: - schedule: - - cron: 0 0 * * * env: CARGO_TERM_COLOR: always diff --git a/README.md b/README.md index b65e586..fe4fb58 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ - [**jinaai/jina-reranker-v1-turbo-en**](https://huggingface.co/jinaai/jina-reranker-v1-turbo-en) - [**jinaai/jina-reranker-v2-base-multiligual**](https://huggingface.co/jinaai/jina-reranker-v2-base-multilingual) +## โœŠ Support + +To support the library, please donate to our primary upstream dependency, [`ort`](https://github.com/pykeio/ort?tab=readme-ov-file#-sponsor-ort) - The Rust wrapper for the ONNX runtime. + ## ๐Ÿš€ Installation Run the following in your project directory: @@ -180,10 +184,6 @@ println!("Rerank result: {:?}", results); Alternatively, local model files can be used for inference via the `try_new_from_user_defined(...)` methods of respective structs. -## โœŠ Support - -To support the library, please donate to our primary upstream dependency, [`ort`](https://github.com/pykeio/ort?tab=readme-ov-file#-sponsor-ort) - The Rust wrapper for the ONNX runtime. - ## ๐Ÿ“„ LICENSE -Apache 2.0 ยฉ [2024](https://github.com/Anush008/fastembed-rs/blob/main/LICENSE) +[Apache 2.0](https://github.com/Anush008/fastembed-rs/blob/main/LICENSE) From 48fc2b6e9c120fdbfd8704ae27494832cde17f70 Mon Sep 17 00:00:00 2001 From: Anush Date: Sat, 2 Aug 2025 14:01:15 +0530 Subject: [PATCH 2/4] docs: Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe4fb58..b3509ec 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Or add the following line to your Cargo.toml: ```toml [dependencies] -fastembed = "4" +fastembed = "5" ``` ## ๐Ÿ“– Usage From bbd19090ce95fe69e29c02372d2fafc48829f8c8 Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 8 Aug 2025 12:41:38 +0530 Subject: [PATCH 3/4] fix: Fix nondeterministic output tensor selection (#176) * fix: Fix nondeterministic output tesnor selection behaviour Signed-off-by: Anush008 * ci: Updated test.yml --------- Signed-off-by: Anush008 --- .github/workflows/test.yml | 2 +- src/output/embedding_output.rs | 11 +++++++++-- tests/embeddings.rs | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a3c434..7f7e64c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: env: CARGO_TERM_COLOR: always RUSTFLAGS: "-Dwarnings" - ONNX_VERSION: v1.22.0 + ONNX_VERSION: v1.22.1 jobs: test: diff --git a/src/output/embedding_output.rs b/src/output/embedding_output.rs index 384d918..e94316b 100644 --- a/src/output/embedding_output.rs +++ b/src/output/embedding_output.rs @@ -10,7 +10,7 @@ use super::{OutputKey, OutputPrecedence}; /// pooling etc. This struct should contain all the necessary information for the /// post-processing to be performed. pub struct SingleBatchOutput { - pub outputs: std::collections::HashMap, + pub outputs: std::collections::BTreeMap, pub attention_mask_array: Array2, } @@ -26,7 +26,14 @@ impl SingleBatchOutput { let ort_output: &ort::value::Value = precedence .key_precedence() .find_map(|key| match key { - OutputKey::OnlyOne => self.outputs.values().next(), + // Only select the sole output if and only if there is exactly one. + OutputKey::OnlyOne => { + if self.outputs.len() == 1 { + self.outputs.values().next() + } else { + None + } + } OutputKey::ByOrder(idx) => self.outputs.values().nth(*idx), OutputKey::ByName(name) => self.outputs.get(*name), }) diff --git a/tests/embeddings.rs b/tests/embeddings.rs index 900b57e..70e7772 100644 --- a/tests/embeddings.rs +++ b/tests/embeddings.rs @@ -659,3 +659,24 @@ fn test_allminilml6v2_match_python_counterpart() { assert!((expected - actual).abs() < tolerance); } } + +// Ref: https://github.com/Anush008/fastembed-rs/issues/171#issue-3209484009 +#[test] +fn clip_vit_b32_deterministic_across_calls() { + let q = "red car"; + let mut fe = TextEmbedding::try_new(InitOptions::new(EmbeddingModel::ClipVitB32)).unwrap(); + let mut first: Option> = None; + for i in 0..100 { + let vecs = fe.embed(vec![q], None).unwrap(); + if first.is_none() { + first = Some(vecs[0].clone()); + } else { + assert_eq!( + vecs[0], + *first.as_ref().unwrap(), + "Embedding changed after {} iterations", + i + ); + } + } +} From fe31db325e915be7075b955ef8aef0bd29f34cdc Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 8 Aug 2025 07:13:23 +0000 Subject: [PATCH 4/4] chore(release): 5.0.1 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [5.0.1](https://github.com/Anush008/fastembed-rs/compare/v5.0.0...v5.0.1) (2025-08-08) ### Bug Fixes * Fix nondeterministic output tensor selection ([#176](https://github.com/Anush008/fastembed-rs/issues/176)) ([bbd1909](https://github.com/Anush008/fastembed-rs/commit/bbd19090ce95fe69e29c02372d2fafc48829f8c8)) ## [5.0.1](https://github.com/Anush008/fastembed-rs/compare/v5.0.0...v5.0.1) (2025-08-08) ### ๐Ÿ› Bug Fixes * Fix nondeterministic output tensor selection ([#176](https://github.com/Anush008/fastembed-rs/issues/176)) ([bbd1909](https://github.com/Anush008/fastembed-rs/commit/bbd19090ce95fe69e29c02372d2fafc48829f8c8)) ### ๐Ÿ“ Documentation * Updated README.md ([48fc2b6](https://github.com/Anush008/fastembed-rs/commit/48fc2b6e9c120fdbfd8704ae27494832cde17f70)) ### ๐Ÿงน Chores * Disabled scheduled tests due to 429s ([8241183](https://github.com/Anush008/fastembed-rs/commit/8241183d7ad310ac76dfe1a865be6f667872c850)) --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d3ee71a..6d91e01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fastembed" -version = "5.0.0" +version = "5.0.1" edition = "2021" description = "Library for generating vector embeddings, reranking locally." license = "Apache-2.0"