Embedding
Authorship and approval
[Written with AI] [Approved by a human]
Updated
28.10.2026
An embedding (meaning vector) is a list of numbers that an AI model converts text, images, or audio into, so similar meanings yield similar numbers. "Dog" and "puppy" land close to each other, while "dog" and "invoice" end up far apart. Semantic search, vector databases, and document-answering chats (RAG) all rely on embeddings.
18/18
hits in top 5
768
numbers per text in chat
40/h
our Gemini rate limit
How does it work?
- Text goes to the embedding model, which is a Transformer trained to map similar meanings close together.
- The model returns a vector of fixed length, e.g., 768 or 1536 numbers, regardless of text length.
- Vectors are compared using cosine similarity: the closer to 1, the closer the meaning.
- An embedding does not generate text. It describes it. This is a different model than the one answering in chat.
How does our lab do it?
- Two models, two tasks: Gemini (1536 numbers) calculates vectors for all papers and entries in our database, which power the knowledge map, reels, and AI Research Index; EmbeddingGemma (768 numbers) runs locally on our server for free and powers the chat.
- Choosing the chat model by testing, not rankings: we compared candidates using 18 questions from our database. EmbeddingGemma found the right text in the top five 18 times out of 18 (MRR 0.917).
- Free limits are still limits: Gemini treats every text in a batch as a separate request. With a daily limit of 1,000, we process 40 texts per hour, and a backlog of ~850 summaries once blocked our reel for over a day.
- Local has a cost too: the server processes one request at a time, so 128 texts took 58.5s, while chat questions had to wait. That is why we compute chat vectors in small hourly batches.
Which model when?
- Local model (e.g., EmbeddingGemma, Qwen3-Embedding, bge-m3): data stays in-house, 0 PLN cost, but requires a server and runs slower.
- Cloud model (Gemini, OpenAI): fast setup and no hardware needed, but has limits, costs at scale, and data is sent externally.
- Always: the question and documents must go through the same model. Vectors from different models cannot be compared.
Common pitfalls
- Choosing a model from someone else's benchmark instead of 20–30 of your own questions.
- Changing the model without recomputing the entire database.
- Short, casual questions ("what about vectors?") yield poor matches. We add context to them before vectorizing, which boosted hits from 24 to 30 out of 30.
Related terms
Vector database · RAG · Attention Is All You Need · Tokens and Context Window
Questions and answers
Embedding vs token, what's the difference?
A token is a piece of text (a word or part of a word). An embedding is a numerical description of the entire fragment's meaning.
How much do embeddings cost?
Locally 0 PLN plus electricity and server costs. In the cloud, fractions of a cent per thousand texts, often with a free daily tier.
Do embeddings understand Polish?
New multilingual models do, but test them on your own questions. Our chat answers in Polish about English papers.
Sources
- Mikolov et al.: Efficient Estimation of Word Representations in Vector Space (word2vec), arXiv:1301.3781
- Reimers, Gurevych: Sentence-BERT, arXiv:1908.10084
- Lab measurements: chat model selection (21.10.2026), supplementing short questions (24.10.2026)
Next