Algorithmic code embeddings — TF-IDF + pretrained nomic-embed-code vectors. No GPU, no API keys, no model download.
Project description
fast-code-embed (Python)
Pythonic interface to the fast-code-embed C library: algorithmic code embeddings using TF-IDF + pretrained nomic-embed-code token vectors (with optional Reflective Random Indexing).
- No GPU, no API keys, no model download — the 30 MB vector table is compiled into the wheel.
- Sub-millisecond scoring — lookup-based, no transformer inference.
Status: sketch / not yet published. This package mirrors the Java binding's surface. The wheel links the prebuilt C static library, so
make libmust run before building (cibuildwheel handles this in CI).
Install (once published)
pip install fast-code-embed
Usage
import fast_code_embed as fce
# Global config (maps to the C library's process-state toggles; set once).
fce.set_dim(768) # 256 or 768
fce.set_idf_weighting(True)
fce.set_abbrev_expansion(False)
with fce.Corpus() as corpus:
corpus.add_doc("parse_config", "def parse_config(path): ...")
corpus.add_doc("retry_request", "def retry_request(url, attempts): ...")
# or: corpus.add_files(["a.py", "b.py"]) # chunk + tokenize in C
corpus.finalize()
for hit in corpus.search("load configuration from disk", k=10):
print(f"{hit.score:.3f} {hit.label}")
# Persist while the corpus is still open (same-build cache, not portable
# across dim / byte-order).
corpus.save("index.fce")
# Reload later into a fresh corpus.
with fce.Corpus.load("index.fce") as reloaded:
hits = reloaded.search("retry with backoff", k=5)
Search modes
from fast_code_embed import Mode
corpus.search("retry with backoff", k=5, mode=Mode.BRUTEFORCE) # exhaustive
corpus.search("retry with backoff", k=5, mode=Mode.FAST) # inverted index
corpus.search("retry with backoff", k=5, mode=Mode.TFIDF) # tf-idf + rerank
# Mode.DEFAULT == AUTO (fast path, brute fallback)
Mode.FAST/TFIDF/AUTO only retrieve documents sharing a literal token with
the query; use Mode.BRUTEFORCE when exhaustive recall matters.
Building locally
cd .. # repo root
make lib # produces build/libfast_code_embed.a (with embedded blob)
cd python
pip install -e . # compiles the cffi extension against the archive
Building wheels
pip install cibuildwheel
cibuildwheel --output-dir wheelhouse python
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 19.5 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6c22b8b0264a89c3d1b3533565a3dc056b045cca16b008512cc4a33b0faa623
|
|
| MD5 |
ec00296e8ece4293d2c9cf5cc695f8fd
|
|
| BLAKE2b-256 |
adf7d06e0ed50cc140fae6a664b6da9e8b56151f428472bf8297512a2a6cd05b
|
Provenance
The following attestation bundles were made for fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl:
Publisher:
python-release.yml on nilsonsfj/fast-code-embed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
f6c22b8b0264a89c3d1b3533565a3dc056b045cca16b008512cc4a33b0faa623 - Sigstore transparency entry: 1954722466
- Sigstore integration time:
-
Permalink:
nilsonsfj/fast-code-embed@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nilsonsfj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl.
File metadata
- Download URL: fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl
- Upload date:
- Size: 19.4 MB
- Tags: CPython 3.9+, manylinux: glibc 2.34+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d9ee3d386d4ae5c53fded75735e689b5b5f356c0dfe75ef73f28a47d5505f9f
|
|
| MD5 |
0ddfea434ec83080dcbb544ff141baca
|
|
| BLAKE2b-256 |
f9466312f3e0810506d5bbab70b10769060d29c1477131264c3c9b02dae838bf
|
Provenance
The following attestation bundles were made for fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl:
Publisher:
python-release.yml on nilsonsfj/fast-code-embed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_code_embed-0.1.2-cp39-abi3-manylinux_2_34_aarch64.whl -
Subject digest:
4d9ee3d386d4ae5c53fded75735e689b5b5f356c0dfe75ef73f28a47d5505f9f - Sigstore transparency entry: 1954722085
- Sigstore integration time:
-
Permalink:
nilsonsfj/fast-code-embed@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nilsonsfj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl.
File metadata
- Download URL: fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl
- Upload date:
- Size: 19.3 MB
- Tags: CPython 3.9+, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f69cc578dc1904269a0e0a77c50083c83b1331d536aa3794dd72c2af27e78149
|
|
| MD5 |
73d112b6b63af41ecf6409b267e3d087
|
|
| BLAKE2b-256 |
b3cda17ad685c836ca387fc3724d3a61c6dc807e462bceb05558390dc6c7da3d
|
Provenance
The following attestation bundles were made for fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl:
Publisher:
python-release.yml on nilsonsfj/fast-code-embed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_x86_64.whl -
Subject digest:
f69cc578dc1904269a0e0a77c50083c83b1331d536aa3794dd72c2af27e78149 - Sigstore transparency entry: 1954722788
- Sigstore integration time:
-
Permalink:
nilsonsfj/fast-code-embed@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nilsonsfj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 19.5 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b719b516a994f265f2a4eb0ffb07ece7660a57a0d962f6925f024001be3e6be4
|
|
| MD5 |
596d0c689598cf27c6d86b84a167bcb3
|
|
| BLAKE2b-256 |
3ba9fe868130e20cdfdec1363831fd86ea72bce4b4d47f637154bce934025ec0
|
Provenance
The following attestation bundles were made for fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
python-release.yml on nilsonsfj/fast-code-embed
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fast_code_embed-0.1.2-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
b719b516a994f265f2a4eb0ffb07ece7660a57a0d962f6925f024001be3e6be4 - Sigstore transparency entry: 1954722964
- Sigstore integration time:
-
Permalink:
nilsonsfj/fast-code-embed@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/nilsonsfj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yml@f3ae8d09903fbe8c222ab3e4abd0397dd1f68650 -
Trigger Event:
push
-
Statement type: