Skip to main content

static_embed

static_embed is an educational (but fully operatioal) library and and repository that shows how to use Static Embedding with Rust. Its a library written in Rust (Candle + tokenizers) and exported to Python via PyO3 and maturin.

Features

  • Pure-Rust embedding implementation (no Python runtime dependencies at inference time)
  • High performance embeddings
  • CPU-only, self-contained model weights (downloaded on first use)
  • Python bindings that expose an easy-to-use Embedder class

Installation (for users)

Prerequisites

  • Python ≥ 3.8 (CPython)
  • A Rust toolchain (stable) – install with rustup

Quick install into the current virtual env

pip install maturin  # once
# From the repository root
maturin develop --release

This builds the Rust crate as a Python extension and installs it into the environment.


Usage

from static_embed import Embedder

# 1. Use the default public model (no args)
embedder = Embedder()

# 2. OR specify your own base-URL that hosts the weights/tokeniser
#    (must contain the same two files: ``model.safetensors`` & ``tokenizer.json``)
# custom_url = "https://my-cdn.example.com/static-retrieval-mrl-en-v1"
# embedder = Embedder(custom_url)

texts = ["Hello world!", "Rust + Python via PyO3"]
embeddings = embedder.embed(texts)

print(len(embeddings), "embeddings", "dimension", len(embeddings[0]))

Development workflow

  1. Set up a virtual environment
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest
  1. Build the extension in editable mode
maturin develop                      # or `--release` for optimised builds
  1. Run the Python example
python python_example.py
  1. Run the test-suite
pytest -q

Project layout

.
├── Cargo.toml         # Rust crate manifest
├── src/               # Rust source (embedder logic + PyO3 bindings)
├── models/            # (Auto-downloaded) model weights live here
├── python_example.py  # Minimal demo script
├── test_embed.py      # Pytest verifying the binding
└── pyproject.toml     # Build configuration for maturin

Publishing to PyPI

(Requires an API token in $POETRY_PYPI_TOKEN_PYPI or ~/.pypirc)

maturin build --release --skip-auditwheel  # wheels in target/wheels/
maturin publish --skip-existing           # upload

License

MIT © Your Name

Metadata

Release files for static-embed 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for static-embed 0.1.1
File Interpreter ABI Platform Actions
static_embed-0.1.1-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for static_embed-0.1.1-cp38-abi3-win_amd64.whl
static_embed-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for static_embed-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
static_embed-0.1.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for static_embed-0.1.1-cp38-abi3-macosx_11_0_arm64.whl

Total release size: 10.1 MB

Release files / static_embed-0.1.1-cp38-abi3-win_amd64.whl

Download URL static_embed-0.1.1-cp38-abi3-win_amd64.whl
Size 2.6 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
81edc1d420143d10f3767941624d551142397e63ec2c5c2484e11d19ca00131c
BLAKE2b-256 checksum
How to use checksums
2b42199c81bee92509e5c567cb06747921ce67f66f2234c60b0faed863aa9ca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.6

Release files / static_embed-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL static_embed-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 5.0 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e3517494c2bc5cb077c1dfd747d7b257a0ed75b4607d9b013f9e4583d3ba8fed
BLAKE2b-256 checksum
How to use checksums
d49b1fa1ee3c02860f302982d9d53492953b1397ff58b4b7208a1c355c8146aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.6

Release files / static_embed-0.1.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL static_embed-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
694f8600a595cf3de195f6f9225be2d30e1555123738948e85ffd4bc47ac1d5b
BLAKE2b-256 checksum
How to use checksums
bdaf4279674f78af16e9dd90ca75e2ebf33d01697d975e94fe4fff2fc1ae8833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.6

Security for static-embed 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

3 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page