Compare two words side-by-side with local embedding models. Built for RAG prototyping — see cosine similarity, vector previews, and per-dimension diffs in one clean UI.
Two words in, embeddings out — cosine similarity and dimension-level diff at a glance.
Embedding Battle is a lightweight web app that connects to LM Studio and sends two text inputs to an embedding model one after another. It then:
- displays both embedding vectors (preview + full JSON)
- calculates cosine similarity — the standard metric for vector search in RAG
- visualizes per-dimension differences (green = close, red = divergent)
- gives a plain-English RAG relevance verdict (high / moderate / low)
No cloud API keys. Everything runs on your machine.
| Tool | Version | Notes |
|---|---|---|
| Node.js | 18+ | Required to run the UI |
| LM Studio | Latest | Local embedding server |
| Embedding model | GGUF | e.g. nomic-embed-text, bge-m3 |
git clone https://github.com/patonkikh/EmbeddingBattle.git
cd EmbeddingBattlenpm installCopy the example env file and edit it:
cp .env.example .envOpen .env and set your values:
# LM Studio local server URL (default port is 1234)
VITE_LM_STUDIO_URL=http://127.0.0.1:1234
# Comma-separated model IDs — must match names shown in LM Studio
VITE_EMBEDDING_MODELS=text-embedding-nomic-embed-text-v1.5,text-embedding-bge-m3Note: This project does not require API keys or credentials. LM Studio accepts any placeholder key and runs fully offline. All configuration lives in
.env— never commit your local.envfile.
| Variable | Description | Example |
|---|---|---|
VITE_LM_STUDIO_URL |
Base URL of the LM Studio server | http://127.0.0.1:1234 |
VITE_EMBEDDING_MODELS |
Model IDs for the dropdown (comma-separated) | text-embedding-bge-m3 |
Use 127.0.0.1 instead of localhost if you hit connection issues on Windows (IPv6 mismatch).
- Download & install LM Studio.
- Download an embedding model from the Discover tab, for example:
nomic-embed-text-v1.5bge-m3
- Load the model in LM Studio (Developer / My Models → load into memory).
- Start the local server:
- Open the Local Server tab (or Developer → Server)
- Enable the server on port 1234
- Confirm the model identifier matches your
.enventry
Verify the server is running:
curl http://127.0.0.1:1234/v1/embeddings \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-bge-m3",
"input": "hello world"
}'You should get a JSON response with an embedding array.
npm run devOpen the URL shown in the terminal (usually http://localhost:5173).
- Enter Word 1 and Word 2
- Pick a model from the dropdown
- Click Start
npm run build
npm run previewThe static build is output to dist/. Serve it with any static host; the dev proxy is only used during npm run dev.
| Cosine similarity | RAG verdict | Meaning |
|---|---|---|
| ≥ 85% | High | Likely relevant — would rank well in vector search |
| 65–85% | Moderate | Possibly relevant — depends on your threshold |
| < 65% | Low | Unlikely to be retrieved as a match |
Cosine similarity is the primary metric used by most vector databases (Pinecone, Chroma, Qdrant, pgvector, etc.) when retrieving documents for RAG.
EmbeddingBattle/
├── docs/
│ └── screenshot.png # UI preview for README
├── src/
│ ├── App.tsx # Main layout & form
│ ├── components/
│ │ ├── EmbeddingPanel.tsx
│ │ └── SimilarityCard.tsx
│ └── lib/
│ ├── lmStudio.ts # LM Studio API client
│ └── similarity.ts # Cosine / euclidean metrics
├── .env.example # Template for configuration
├── vite.config.ts # Dev proxy → LM Studio
└── README.md
During development, browser requests go to /api/lm/embeddings and Vite proxies them to {VITE_LM_STUDIO_URL}/v1/embeddings.
- Download and load the model in LM Studio.
- Copy its model identifier from the LM Studio UI.
- Append it to
VITE_EMBEDDING_MODELSin.env(comma-separated). - Restart the dev server (
Ctrl+C→npm run dev).
Example:
VITE_EMBEDDING_MODELS=text-embedding-nomic-embed-text-v1.5,text-embedding-bge-m3,text-embedding-my-custom-model| Problem | Fix |
|---|---|
| Connection refused | Ensure LM Studio server is running on port 1234 |
| Model not found | Model ID in .env must exactly match LM Studio |
| Empty embedding response | Load the embedding model into memory first |
| CORS errors | Use npm run dev — the Vite proxy handles CORS |
localhost fails on Windows |
Switch to 127.0.0.1 in .env |
- React 19 + TypeScript
- Vite 6 with dev proxy
- Tailwind CSS 4
- LM Studio OpenAI-compatible
/v1/embeddingsAPI
Issues and pull requests are welcome. For new embedding models, updating .env.example with a commented example is appreciated.
Tags
#embeddings
#rag
#lmstudio
#vectorsearch
#cosinesimilarity
#react
#vite
#typescript
#tailwindcss
#nomic
#bge-m3
#opensource
#machinelearning
#nlp
#localai
⭐ If this helped your RAG experiments, consider starring the repo!
