Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files238 unmodified lines2392402412422422432442452462472462472482492502512522532542552562572582592602612622632512522662672682532542552567 unmodified lines264265266267268269270271272273274275276277278279280281282238 unmodified lines
with gr.Blocks(title="Embed Compare — place nouns") as demo: gr.Markdown( "# Explore 627 place nouns by embedding similarity\n" "# Where does your sentence land among 627 place nouns?\n" "Every noun in `generic_nouns.txt` is embedded with " "**Octen-Embedding-0.6B** (Qwen3-Embedding base, Q4_K_M, llama.cpp) — " "the same model, pooling and ranking as the `embed_compare.py` CLI in " "this repo. Find a noun's nearest neighbours, or rank all of them " "against your own sentence.\n\n" "this repo. Paste a sentence to rank all 627 against it, or start from " "a single noun to see its nearest neighbours.\n\n" "*Similarity is a rough signal: with last-token pooling, a long " "sentence mostly reflects how it ends.*" ) with gr.Tab("Noun → nearest nouns"): gr.Markdown("Pick a noun to see which other place nouns sit closest " "to it in embedding space. Instant: this is a dot product " "against the precomputed matrix.") with gr.Row(): pick = gr.Dropdown(choices=noun_choices(), value="valley", label="Noun", filterable=True, scale=3) k2 = gr.Slider(5, 50, value=15, step=1, label="Neighbours", scale=2) btn2 = gr.Button("Find neighbours", variant="primary") out2 = gr.HTML() summary2 = gr.Markdown() btn2.click(lookup, [pick, k2], [out2, summary2], api_name="lookup")
with gr.Tab("Text vs. nouns"): gr.Markdown( "Embeds your sentence and ranks all 627 nouns against it. This runs " "one forward pass on a single CPU core, so expect **about a " "minute** per request on this Space's free hardware." "Embeds your sentence and ranks all 627 nouns against it." ) a = gr.Textbox(label="Text A", lines=3, placeholder="We hiked along the ridge above the fjord…")7 unmodified lines btn.click(compare, [a, b, k], [out, summary], api_name="compare") a.submit(compare, [a, b, k], [out, summary])
with gr.Tab("Noun → nearest nouns"): gr.Markdown("Pick a noun to see which other place nouns sit closest " "to it in embedding space. Instant: this is a dot product " "against the precomputed matrix.") with gr.Row(): pick = gr.Dropdown(choices=noun_choices(), value="valley", label="Noun", filterable=True, scale=3) k2 = gr.Slider(5, 50, value=15, step=1, label="Neighbours", scale=2) btn2 = gr.Button("Find neighbours", variant="primary") out2 = gr.HTML() summary2 = gr.Markdown() btn2.click(lookup, [pick, k2], [out2, summary2], api_name="lookup")
with gr.Accordion("How it works", open=False): gr.Markdown( f"- **Model:** `Octen-Embedding-0.6B.Q4_K_M.gguf` — 1024 dims, "app.py+17-19