Skip to content

Commit 9f07621

Browse files
Merge branch 'main' into dev
2 parents a29c2a8 + 4c1db2a commit 9f07621

8 files changed

Lines changed: 685 additions & 270 deletions

File tree

Cargo.lock

Lines changed: 615 additions & 260 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ version = "0.7.0"
2020

2121
[workspace.dependencies]
2222
pdf-extract = "0.9.0"
23-
candle-nn = { version = "0.9.1" }
24-
candle-transformers = { version = "0.9.1" }
25-
candle-core = { version = "0.9.1" }
26-
candle-flash-attn = { version = "0.9.1" }
23+
candle-nn = { version = "0.9.2" }
24+
candle-transformers = { version = "0.9.2" }
25+
candle-core = { version = "0.9.2" }
26+
candle-flash-attn = { version = "0.9.2" }
2727
processors-rs = { path = "processors", version = "=0.7.0" }
2828

2929
strum = "0.27.1"

python/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ strum = {workspace = true}
1717
strum_macros = {workspace = true}
1818

1919
[features]
20+
default = ["extension-module", "ort", "audio", "aws"]
2021
extension-module = ["pyo3/extension-module"]
2122
mkl = ["embed_anything/mkl"]
2223
accelerate = ["embed_anything/accelerate"]
@@ -25,4 +26,4 @@ cudnn = ["embed_anything/cudnn"]
2526
metal = ["embed_anything/metal"]
2627
ort = ["embed_anything/ort"]
2728
audio = ["embed_anything/audio"]
28-
video = ["embed_anything/video"]
29+
aws = ["embed_anything/aws"]

python/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# embed_anything Python extension
2+
3+
This crate is the Rust/PyO3 extension for the `embed_anything` Python package. It is **not** built with plain `cargo`.
4+
5+
## Building
6+
7+
From the **repository root** (not from this directory), use maturin so the extension links against your Python installation:
8+
9+
```bash
10+
# From repository root
11+
maturin develop # build and install in the current environment (editable)
12+
# or
13+
maturin build # build a wheel
14+
```
15+
16+
Or install the package (maturin is the build backend in `pyproject.toml`):
17+
18+
```bash
19+
pip install -e .
20+
```
21+
22+
Do **not** run `cargo build` in this directory or `cargo build -p embed_anything_python` from the root—the linker will fail with undefined Python symbols because cargo does not link libpython.

python/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pub mod config;
22
pub mod models;
3+
#[cfg(feature = "aws")]
34
pub mod s3_client;
45
use embed_anything::embeddings::embed::{TextEmbedder, VisionEmbedder};
56
use embed_anything::{

rust/Cargo.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rayon = "1.8.1"
3030

3131
# Natural Language Processing
3232
tokenizers = {version="0.22.1", default-features = false, features=["http"]}
33-
text-splitter = {version= "0.28.0", features=["tokenizers", "markdown"]}
33+
text-splitter = {version= "0.29.0", features=["tokenizers", "markdown"]}
3434

3535
tracing = "0.1.41"
3636

@@ -47,7 +47,7 @@ anyhow = "1.0.98"
4747
tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }
4848

4949
chrono = "0.4.38"
50-
rand = "0.9.0"
50+
rand = "0.10.0"
5151
itertools = "0.14.0"
5252

5353
# Image processing
@@ -72,9 +72,9 @@ model2vec-rs = "0.1.4"
7272

7373
# Logging
7474
log = "0.4"
75-
aws-sdk-s3 = {version = "1.110.0", features = ["rt-tokio"]}
76-
aws-config = {version = "1.8.10", features = ["behavior-version-latest"]}
77-
aws-credential-types = "1.2.8"
75+
aws-sdk-s3 = {version = "1.110.0", features = ["rt-tokio"], optional= true}
76+
aws-config = {version = "1.8.10", features = ["behavior-version-latest"], optional = true}
77+
aws-credential-types = {version = "1.2.8", optional = true}
7878

7979
[dev-dependencies]
8080
tempdir = "0.3.7"
@@ -98,6 +98,7 @@ metal = ["candle-core/metal", "candle-nn/metal"]
9898
audio = ["dep:symphonia"]
9999
video = ["processors-rs/video"]
100100
ort = ["dep:ort",]
101+
aws = ["dep:aws-sdk-s3", "dep:aws-config", "dep:aws-credential-types"]
101102
rustls-tls = [
102103
"reqwest/rustls-tls",
103104
"hf-hub/rustls-tls",

rust/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,33 @@
6767
//! # Ok(())
6868
//! # }
6969
//! ```
70+
//! //! # Feature flags
71+
//!
72+
//! The crate can be configured with the following [Cargo features](https://doc.rust-lang.org/cargo/reference/features.html):
73+
//!
74+
//! | Feature | Description |
75+
//! |---------|-------------|
76+
//! | **default** | Enables `rustls-tls` for TLS. Keep this unless you need a different TLS backend. |
77+
//! | **rustls-tls** | Use [Rustls](https://github.com/rustls/rustls) for TLS in HTTP clients (reqwest, hf-hub, tokenizers). |
78+
//! | **mkl** | Intel [MKL](https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl.html) (Math Kernel Library) for CPU-accelerated linear algebra. |
79+
//! | **accelerate** | Apple [Accelerate](https://developer.apple.com/documentation/accelerate) framework for optimized math on macOS. |
80+
//! | **cuda** | [NVIDIA CUDA](https://developer.nvidia.com/cuda-toolkit) support for GPU-accelerated inference. |
81+
//! | **cudnn** | [cuDNN](https://developer.nvidia.com/cudnn) for CUDA-accelerated deep learning (enables `cuda`-related optimizations). |
82+
//! | **flash-attn** | [Flash Attention](https://github.com/Dao-AILab/flash-attention) for faster attention on CUDA GPUs. Implies **cuda**. |
83+
//! | **metal** | Apple [Metal](https://developer.apple.com/metal/) for GPU-accelerated inference on macOS. |
84+
//! | **audio** | Audio embedding via [Symphonia](https://github.com/pdeljanov/Symphonia): transcribe and embed audio files (e.g. `emb_audio`). |
85+
//! | **ort** | [ONNX Runtime](https://onnxruntime.ai/) for running ONNX models (e.g. reranker and ONNX-based embedders). |
86+
//! | **aws** | [AWS SDK](https://aws.amazon.com/sdk-for-rust/) for loading objects from S3 (e.g. `s3_loader` module). |
87+
//!
88+
//! ## Example
89+
//!
90+
//! Enable only the features you need to reduce build time and binary size:
91+
//!
92+
//! ```toml
93+
//! [dependencies]
94+
//! embed_anything = { path = "rust", default-features = false, features = ["rustls-tls", "audio", "aws"] }
95+
//! ```
96+
//!
7097
7198
pub mod chunkers;
7299
pub mod config;
@@ -77,6 +104,7 @@ pub mod models;
77104
#[cfg(feature = "ort")]
78105
pub mod reranker;
79106
pub mod text_loader;
107+
#[cfg(feature = "aws")]
80108
pub mod s3_loader;
81109

82110
use anyhow::{Error, Result};

rust/src/models/idefics3/model.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ impl CustomOp1 for NonZero {
5555
CpuStorage::F16(vs) => self.nonzero(vs, layout),
5656
CpuStorage::F32(vs) => self.nonzero(vs, layout),
5757
CpuStorage::F64(vs) => self.nonzero(vs, layout),
58+
CpuStorage::I16(vs) => self.nonzero(vs, layout),
59+
CpuStorage::I32(vs) => self.nonzero(vs, layout),
60+
CpuStorage::F8E4M3(vs) => self.nonzero(vs, layout),
61+
CpuStorage::F6E2M3(vs) => self.nonzero(vs, layout),
62+
CpuStorage::F6E3M2(vs) => self.nonzero(vs, layout),
63+
CpuStorage::F4(vs) => self.nonzero(vs, layout),
64+
CpuStorage::F8E8M0(vs) => self.nonzero(vs, layout)
5865
};
5966
let index_len = layout.dims().len();
6067
let result_len = result.len() / index_len;

0 commit comments

Comments
 (0)