Embeddings and Vector Databases Explained (Polish Test)
What embeddings and vector databases are, without the math. We tested bge-m3 and nomic-embed-text on Polish sentences and laws: 8 out of 10 hits versus 4.

👁 115 reads
An embedding converts text into a list of numbers (a vector), where texts with similar meanings get similar numbers. A vector database stores these vectors and quickly finds the ones closest to a query. This is the foundation of semantic search, RAG, and AI agent memory. Below, we explain this without math and show a test of two free embedding models on Polish sentences and Polish laws: one found the right provision in 8 out of 10 cases, the other in 4. This article is part of the AI Agents from Scratch learning path.
As of October 4, 2026
- We tested two models running locally in Ollama 0.35.1 on an RTX 4090:
bge-m3(MIT license) andnomic-embed-text(Apache 2.0). Both can be used commercially. - Test: 5 sentences for comparison and 10 queries against 920 fragments from three Polish laws.
- Cost: $0, everything computed on our own machine.
- Test code is in the ai-agents-starter package (
04_rag.py).
What Are Embeddings in Simple Terms
Imagine a map where each sentence is a point. Sentences about rental deposits lie close together, sentences about vacation a bit further away, and sentences about weather on the other side of the map. An embedding is the coordinates of a sentence on such a map. The difference is that the map doesn’t have two dimensions, but several hundred or over a thousand.
Here’s the beginning of the embedding for the sentence “How much is the rental deposit for a flat?” from the bge-m3 model (we tested it in Polish):
[-0.0375, 0.0463, -0.0196, -0.0042, 0.0015, ... ] (1024 numbers total)
Individual numbers mean nothing. What matters is the distance between vectors. It’s most often calculated as cosine similarity: 1 means identical direction (same meaning), around 0 means no relationship.
Test on Five Sentences
We compared the sentence “How much is the rental deposit for a flat?” with four others (we tested it in Polish). A good model should recognize the sentence with the same meaning as closest, even if it uses different words or a different language.
| Compared sentence | bge-m3 | nomic-embed-text |
|---|---|---|
| How much is the rental deposit for a flat? (same in English) | 0.736 | 0.416 |
| Jaki depozyt wpłaca najemca lokalu? (same meaning, different words in Polish) | 0.678 | 0.665 |
| Kaucja za butelki zwrotne w sklepie (same word “deposit”, different meaning - bottle deposit at a store) | 0.569 | 0.713 |
| Ile dni urlopu wypoczynkowego mam w roku? (different topic - vacation days per year) | 0.442 | 0.755 |
bge-m3 ordered the sentences exactly as a human would: translation closest, then paraphrase, then “bottle deposit”, and vacation furthest. nomic-embed-text considered the vacation question most similar to the deposit question, and the English translation least similar. This is a model trained mainly on English, and in Polish it captures sentence structure (“How much is… / How many days…”) rather than meaning.
Test on Polish Laws
In the article RAG Step by Step, we built a search engine over the Labor Code, the Tenant Protection Act, and the Patient Rights Act (920 fragments). We asked 10 questions in colloquial language and checked at what position in the results the correct article appeared.
| Feature | bge-m3 | nomic-embed-text |
|---|---|---|
| Correct article in 1st place | 5 out of 10 | 2 out of 10 |
| Correct article in top 5 | 8 out of 10 | 4 out of 10 |
| Vector dimensions | 1024 | 768 |
| Maximum text length (context in Ollama) | 8192 tokens | 2048 tokens |
| GPU memory after loading | 664 MB | 323 MB |
| Index size for 920 fragments | 8.5 MB | 7.5 MB |
| Indexing time for 920 fragments* | 155 s | 105 s |
| Similarity spread (out-of-scope question vs. correct) | 0.43 vs 0.64-0.72 | 0.69 vs 0.69-0.77 |
| License | MIT | Apache 2.0 |
* The GPU was under load from another task during measurement, so treat times as approximate. On an idle GPU, both models are faster.
The last row is as important as accuracy. In bge-m3, a question about highway speed limits (not in the laws) got a maximum similarity of 0.43, clearly lower than relevant fragments. You can therefore set a threshold and answer “I don’t know” without querying the model. In nomic-embed-text, everything has a similarity around 0.7, and such a threshold cannot be set.
What Is a Vector Database
A vector database is a place where you store embeddings together with text and metadata (file, article number, date) and which can quickly find the nearest vectors. For small collections, a plain numpy array is enough: our 920 vectors are 8.5 MB, and searching them is one matrix multiplication. You need a database when:
- you have hundreds of thousands of fragments and computing everything at once becomes slow;
- you want to filter results by metadata (“only Labor Code”, “only documents from 2026”);
- documents are frequently added and you don’t want to recompute the entire index;
- multiple people use the search engine simultaneously.
| Solution | Where it runs | For whom |
|---|---|---|
| numpy (.npz file) | in your script | learning, up to tens of thousands of fragments |
| Chroma | locally, file on disk or server | first project, prototypes |
| pgvector (PostgreSQL) | your PostgreSQL database | you already have PostgreSQL and want one place for data |
| Qdrant, Weaviate, Milvus | own server or cloud | large collections, many users |
We verified that Chroma 1.5.9 returns exactly the same results as numpy for our data. A vector database doesn’t improve accuracy, it improves convenience and scale. Accuracy depends on the embedding model and how you chunk the text.
How to Choose an Embedding Model for Polish
- Choose a multilingual model. Of the free local models we tested,
bge-m3handles Polish well. - Build a small test set: 10-20 questions for which you know the correct fragment. Without this, choosing a model is guesswork.
- Measure “whether the correct fragment is in the top five”, because that’s typically how many fragments the model gets in RAG.
- Check the similarity spread for off-topic questions. A large difference means you can set an “I don’t know” threshold.
- Remember prefixes:
nomic-embed-textrequires addingsearch_query:before the question andsearch_document:before the document. Without them, results are even worse.
Embeddings are also offered via cloud APIs (OpenAI, Google, Mistral, Cohere). You then pay per token, and send documents to the provider. How to count tokens and cost is described in the article about tokens.
Where Embeddings Are Useful Beyond RAG
- Search in a store or knowledge base that understands “rain shoes” as “waterproof footwear”.
- Duplicate detection of tickets, forum questions, or articles.
- Clustering customer reviews into topics without manual tagging.
- Agent memory: an agent saves conclusions as embeddings and retrieves similar past situations for new tasks. Agent examples: AI Agent: 12 Examples.
Frequently Asked Questions
What is an embedding in one sentence?
A list of numbers describing the meaning of text, allowing a computer to compare texts by meaning rather than by words.
How does an embedding differ from a token?
A token is a piece of text (part of a word) that the model splits text into. An embedding is a vector describing the meaning of an entire fragment. An embedding model first splits text into tokens, then converts them into one vector.
Do embeddings need to be computed on a GPU?
No, small models also work on CPU, just slower. bge-m3 used 664 MB of GPU memory for us, so it will fit on almost any GPU from recent years.
Can I mix embeddings from different models?
No. Each model has its own “map”. A query must be converted to a vector by the same model as the documents. After changing models, you must recompute the entire index.
Vector database or regular database?
A regular database searches by words and values, a vector database by meaning. The best results often come from combining both (hybrid search), because keywords catch proper names and numbers, while vectors catch paraphrases.
How much do embeddings cost?
Locally, nothing beyond electricity. In APIs, they’re among the cheapest AI model queries, usually fractions of a dollar per million tokens. Check current prices in the provider’s pricing.
Google · Your sourcesQuantslant higher in your Google - one clickAdd to preferred sources →Sources and Verification Date
- bge-m3 and nomic-embed-text in Ollama’s library (verified October 4, 2026).
- Chroma documentation.
- Measurements: our computer (RTX 4090, Windows 11, Ollama 0.35.1), October 4, 2026, 2:30-3:00 PM.
More on this from QUANTSLANT
guides·Animated Logos in Leonardo AI - No After Effects NeededLeonardo AI's new animation module lets you create professional animated logos in your browser without Adobe After Effects. Here's how to do it in 15 minutes.

