Top Tweets for #COSine
@causingheadache Embeddings read "don't" as a typo. Your card disagrees 🙂
Don't serve on cosine alone: vector search for recall, then confirm the hit with a duplicate-question cross-encoder that reads both texts. GPTCache ships SbertCrossencoderEvaluation for this. Miss = call the LLM.
Aída a Luisa no le respondería, Luisa es insignificante para ella, muy apagada está, al menos escro se siente orgulloso de lo trabajadora que es Aída y la felicita por sus logros como el sold out de la Lumiere, Wes solo se puede sentir orgulloso de que le cosinen y mantelerla
Pero uy no como va responder un comentario sobre Aida 😭🤣😭

How does a circle create Sine and Cosine?
How Does a Circle Create Sine and Cosine? 🤯 | Unit Circle Explained with Visualization | Trigonometry
https://t.co/Iq7IycnX1b
Turned my EmbeddingGemma-2 decision router into an open-source Python SDK on PyPI:
pip install gemmarouter
Most local intent routers rely on raw cosine similarity—which breaks when you shuffle candidate options or when none of the tools actually fit the user's query.
gemmarouter wraps Google's frozen EmbeddingGemma-2 backbone with an 11.6M Set-Equivariant Transformer head + calibrated 6-feature Null Gate:
- Zero position bias: 0.0% option-order flip rate across 2,500 shuffles
- Calibrated abstention: 0.9934 Null AUROC (cleanly abstains instead of forcing a bad route)
- Fast: 98.93% covered routing accuracy in 53.6 ms median latency (0 ms/req overhead on cached option vectors)
- Scored 7.4 (Tied #60) on the Jev Decision Index 0.4.1 leaderboard with just an adapter head
Here is a quick demo of it running live in Python.
GitHub repo, PyPI package, and open BF16 weights in the reply below 👇
Most lightweight LLM routers use a frozen text encoder and simple cosine similarity to pick the right tool or intent.
I wanted to see where that approach actually works in production—and where it completely falls apart.
So I trained embeddinggemma2-decision-router: an 11.6M parameter decision head + abstention gate sitting on top of Google's frozen 271M embeddinggemma-2 encoder.
Here is what I found after testing it across both simple intent routing and complex agent decisions:
1. Where a small router head works really well:
For fast intent routing (tested on Banking77 with 8 candidate options per query and 15,884 hard-negative episodes), a frozen encoder + a 2-layer Set-Equivariant Transformer head is hard to beat:
- 98.93% accuracy on covered queries (94.79% on hard negatives)
- 0.9934 AUROC on the Null Gate (so the router cleanly abstains when none of the options fit)
- 0.0% option-order flip rate across 2,500 random shuffles (shuffling the order of your tools never changes the router's answer)
- 53.6 ms median latency
2. Where it breaks—and what happens when you unfreeze the encoder:
When I tested this exact setup zero-shot on complex agent states and policies (LocalLLaMA/typed-decisions), accuracy dropped to 39.20% (and raw cosine similarity got 40.95%). A frozen 271M embedding model simply cannot do multi-step state reasoning out of the box.
To see if unfreezing the backbone fixes this, I ran a set of ablations on an A100 (using cross-entropy + teacher KL + Brier loss):
- Frozen encoder + retraining the 11.6M head in-domain: 61.50% accuracy (0.0% flip rate)
- Unfreezing the top 8 encoder layers: 68.20% accuracy (0.0% flip rate, while still keeping 98.54% on Banking77)
- Unfreezing the top 12 layers (passing the state, question, and all options together): 72.05% accuracy (but loses exact order invariance, with a 3.1% flip rate)
The honest catch: even after unfreezing the encoder, those gains only held up on workflow formats the model saw during training. When tested on a completely unseen workflow (agent_trace_observability), accuracy stayed flat at ~27% vs 28.8% for raw cosine.
The takeaway:
If you need fast intent routing with calibrated abstention and zero position bias, an 11.6M head on a frozen encoder gets you 98.9% accuracy in 53ms. But if you are routing complex, unseen agent states, small embedding encoders hit a reasoning wall—which is why I am currently training a 7.9B decision model for deeper state routing.
The BF16 weights (565 MB), evaluation scripts, and hard-negative datasets are all open-source on Hugging Face. Links in the reply below 👇

Routing easy prompts to small models saves a fortune, but watch out for cosine collisions in semantic caches.
https://t.co/Slok8W0AsB
Prompt Caching (#1) and Model Routing (#2) easily slash 80% of your LLM bill on day one.
Semantic Cache (#4) is the dangerous one—one bad cosine match serves the wrong user's answer.
@PythonDvz Cosine similarity isn’t answer equivalence. I’d enforce tenant and permission boundaries independently of similarity scores; even an exact wording match can return a stale answer after the underlying data changes.
@thesimaximalist Exactly. Cosine proximity measures semantic token alignment, not logical equivalence or credential scopes. Treating a vector distance math function as an ad-hoc access control layer is a massive production hazard.
Pure exact-match only?
@PythonDvz Semantic caching is the risk described here. Prompt caching reuses exact-prefix computation; semantic caching reuses answers for similar queries. A high cosine score proves neither that the answer fits nor that the user is allowed to see it.
Hola fallito, mira te hice un dibujito sencillo porque estoy haciendo una novela visual de los domingueros y nesesitaba al cosinero(no vas a ser el único cocinero) espero que te guste
#fallosinsonido #fallofanarts

Day 25 of #100DaysOfCode
oday I learned about embeddings and cosine similarity and built a basic semantic search system using Python.
Understanding how to retrieve relevant information based on a query.
Next step: Building a RAG pipeline.

@causingheadache Useful separation of retrieval from generation. For the next run: real text embeddings, recall@5 against exact cosine search, and p99 at several HNSW search settings. That would show the speed/recall tradeoff on the Pi.
@flaratt_ljos Does this use the blended heading from your locomotion work? With a cosine-sine pair, a straight blend between opposite headings passes through zero. Curious whether you keep a turn direction for that case or interpolate the angle before rebuilding the basis.
New rotation representation: cosine-sine pair--vertex shader reconstructs the other basis vector by swapping the components and negating one (perpendicular). It rotates vertex positions by remapping the basis.
Quick trick for agent-written Playwright suites: embed each test, cluster by cosine similarity, and near-duplicates jump out.
We open-sourced it as semantic-graph (MIT). One npx command, local graph UI:
https://t.co/wav1pi0PCW
#AgenticAI #Playwright
4 of 4: Embeddings
Meaning as numbers. An embedding turns text into a list of numbers, and texts with similar meaning sit close together.
Java parallel: a float[] you compare with cosine similarity. It is the base of search by meaning and RAG.
![AgentWorkshq's tweet photo. 4 of 4: Embeddings
Meaning as numbers. An embedding turns text into a list of numbers, and texts with similar meaning sit close together.
Java parallel: a float[] you compare with cosine similarity. It is the base of search by meaning and RAG. https://t.co/kIOOGoKQaU](https://pbs.twimg.com/media/HVORtEzaAAAUJFl.jpg)
Agreed. Two near-identical instructions can mean opposite things, so a cosine score can't decide which one gets in. Vestige 5.0 dropped vectors for this reason: memories get in by where they came from and who approved them, and an old yes never counts as permission now.
How would you mark whose desire a memory serves when the agent wrote it, not the human?
@_entity002 Sharp edge: similarity is a judgment result; admission is judge logic. Admit by which desire of whom it serves, not by cosine score. Test: feed 0.96-similar opposite instructions; a desire-indexed admission standard keeps both without collision.
72 days until 2027. 🚀
Today I went deeper into PostgreSQL + pgvector.
Learned how pgvector stores embeddings in PostgreSQL and uses cosine distance to find documents with similar meanings, even when their exact words don't match.
Also understood how VECTOR(768) defines the number of dimensions a vector can have, and how SQL compares a query embedding against stored document embeddings to retrieve the closest matches.
Basically: turn text into numbers → compare vectors → rank results → find the most relevant documents.
#BuildInPublic #AIEngineering #PostgreSQL

Every time an AI founder says "we use a Vector Database for agent memory" like they just cured cancer, an actual systems engineer loses a year off their life.
'NEVER run terraform destroy on prod'
and
'ALWAYS run terraform destroy on prod'
have a 0.96 cosine similarity in embedding space.
Cosine similarity is astrology for JSON. It cannot tell a law from a crime, prove causality, and you cannot debug [0.014, -0.089, 0.211] when your agent wipes ~/Downloads for the second time.
Imagine if `git` or your bank used approximate nearest neighbors instead of an append only hash chained log. Zero vectors. Zero RAG. Exact handles, causal edges, and cryptographic receipts.
4 of 4: Embeddings
Meaning as numbers. An embedding turns text into a list of numbers, and texts with similar meaning sit close together.
Java parallel: a float[] you compare with cosine similarity. It is the base of search by meaning and RAG.
![AgentWorkshq's tweet photo. 4 of 4: Embeddings
Meaning as numbers. An embedding turns text into a list of numbers, and texts with similar meaning sit close together.
Java parallel: a float[] you compare with cosine similarity. It is the base of search by meaning and RAG. https://t.co/ub4JCviqzT](https://pbs.twimg.com/media/HU_BIaHaEAALfdS.jpg)
@CcVylree Good catch, and no, it's not pinned. on purpose though. the CPU lane runs the int8 model and the ANE runs fp16, so neither one is "the" exact vector anyway. ANE vs fp32 came out at cosine ≥ 0.99998.
@aakashpawar1999 ane runs in fp16, so i'm guessing 'matching vectors' means close cosine, not identical. fine for ranking, but if one index ever mixes chunks embedded on cpu and on ane, near-ties can flip order. do you pin the backend per index?
Writing notes after almost 4 months of learning embeddings…
I thought understanding embeddings would be easier.
Now I’m sitting here writing about vectors, dimensions, dot products, cosine similarity, normalization, and vector DBs like my brain didn’t already have enough problems 😭
Feels like hell, but at least I’m finally putting everything I learned into one place.

debugging semantic search be like
cosine 0.98 between "cancel subscription" and "subscribe yearly"
same model, same dimensions, completely opposite intent
threw a cross-encoder reranker at it, fixed instantly
Cosine
Trends for you
Most Popular Users

Elon Musk 
@elonmusk
240M followers

Barack Obama 
@barackobama
118.6M followers

Cristiano Ronaldo 
@cristiano
114.4M followers

Donald J. Trump 
@realdonaldtrump
111.7M followers

Narendra Modi 
@narendramodi
106.9M followers

Rihanna 
@rihanna
98.6M followers

NASA 
@nasa
92.1M followers

Justin Bieber 
@justinbieber
91.7M followers

KATY PERRY 
@katyperry
89.9M followers

Taylor Swift 
@taylorswift13
83.9M followers

Lady Gaga 
@ladygaga
75.4M followers

Virat Kohli 
@imvkohli
73.3M followers

Kim Kardashian 
@kimkardashian
70.8M followers

YouTube 
@youtube
68.6M followers

Neymar Jr 
@neymarjr
66.3M followers

Bill Gates 
@billgates
65.2M followers

Selena Gomez 
@selenagomez
63M followers

The Ellen Show
@theellenshow
62.1M followers

CNN 
@cnn
61.7M followers

X 
@x
60.6M followers






















