Spaces:
Paused
Download README.md from baiango/embed-compare: direct link, hf CLI and curl.
- Browser
- Download file 3.54 kB
-
https://huggingface.co/spaces/baiango/embed-compare/resolve/main/README.md
- Command line
-
hf download hf://spaces/baiango/embed-compare/README.md
-
curl -L -o README.md https://huggingface.co/spaces/baiango/embed-compare/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.33.0
title: Embed Compare
emoji: 🧭
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 6.14.0
app_file: app.py
pinned: false
license: mit
short_description: Rank place-nouns by embedding similarity
models:
- mradermacher/Octen-Embedding-0.6B-GGUF
preload_from_hub:
- mradermacher/Octen-Embedding-0.6B-GGUF Octen-Embedding-0.6B.Q4_K_M.gguf
Embed Compare
Rank a fixed vocabulary of 627 generic place-nouns by cosine similarity to any
text you type in — a demo for embed_compare.py.
Everything runs from a single GGUF file on CPU: Octen-Embedding-0.6B.Q4_K_M.gguf
(1024 dims, last-token pooling, L2-normalised, no instruction prefix).
Two views
Noun → nearest nouns — start from one noun and see what sits closest to it in embedding space. Useful for checking whether a vocabulary has clusters, or whether a term is really as distinct as it feels. This is the default tab because it is instant: it only does a dot product against the precomputed matrix.
Text vs. nouns — paste one sentence, or two. With two texts it shows which nouns
both of them pull toward, which is a quick way to see where two descriptions share
vocabulary and where they don't. This one must embed your text, which is a single
forward pass — about a minute on this Space's free cpu-basic hardware (1 vCPU).
That cost is the hardware, not the design: the same forward pass takes ~0.07 s per
thread on an M-series laptop core.
Notes on the numbers
Scores are cosine similarities, printed to four decimals. When two nouns come out very close (say 0.4810 and 0.4849), treat the gap as a tie — tiny numeric differences between backends can swap the order, even though the same nouns land at the top.
This Space uses the prebuilt llama-cpp-python wheel and therefore that wheel's
bundled llama.cpp. Ranking was checked against the llama-embedding CLI: top-20
overlap is 20/20 and top-5 order is identical on the sample sentences. Individual
vectors differ by around 1e-3 in cosine, which does not move reasonably-separated
nouns.
How it is built
The 396 MB GGUF is not committed to this repo. It is preloaded from the Hub during
the image build (preload_from_hub above), so it is in the local huggingface_hub
cache before app.py starts.
The noun vectors themselves are committed, as
.embed_cache/: a 627 × 1024 float32 matrix (2.6 MB) plus a small
JSON sidecar. precompute_nouns.py built it from the CLI locally; app.py loads it at
startup, so a cold start is ~23 s (mostly the GGUF download) instead of the ~6.5 min it
took when every boot re-embedded all 627 nouns on 1 vCPU.
The cache key is derived from the model file's SHA-256, the noun list and the pooling settings, so a stale or mismatched matrix is simply a cache miss — the app falls back to computing it and stays correct.
A request then embeds only your text and takes the dot product against the matrix.
embed_compare.py is the original CLI, which computes the same ranking from scratch.
Related files
embed_compare.py— the CLIprecompute_nouns.py— cache buildergeneric_nouns.txt— the vocabulary.embed_cache/— the committed noun matrix
Licenses
- Octen-Embedding-0.6B (base model,
Octen/Octen-Embedding-0.6B) — Apache-2.0. Quantised to GGUF bymradermacher/Octen-Embedding-0.6B-GGUF. - llama-cpp-python / llama.cpp — MIT.