Ollama Embed
Embeddings as a node, for the RAG-adjacent ComfyUI user
- embeddings_json
Ollama Embed turns text into vectors, right there on the canvas. Feed it a string, get back a JSON array of numbers - the embedding - from a small local model like nomic-embed-text. If you've never wanted embeddings, this node sounds useless. If you have, it's the missing plumbing: the thing that makes "find me the prompts most similar to this one" or "don't generate the same image twice" actually computable inside a workflow.
ComfyUI is increasingly a place where people keep their text too - prompt libraries, LoRA caption sets, conversation history. The moment you want to search or dedupe any of that by meaning instead of by exact string, you need embeddings, and this node is how they arrive without a Python detour.
How it works
It's a thin call to Ollama's client.embed() with your text and model name. The interesting part is split_lines: off (the default), your whole input string is one embedding. On, each non-empty line gets its own embedding, so you can batch - paste a caption file or a list of prompts and get one vector per line in a single call. truncate defaults to true, which cuts input to the model's context length rather than erroring on something too long.
The output is a STRING containing JSON - an array of arrays if you batched, one vector per input. That's a deliberate design choice: it stays a plain text output any node can pass around, and you parse it where you need it.
The inputs that matter
- url - the Ollama server,
http://127.0.0.1:11434by default. - model - an embedding model, not a chat model.
nomic-embed-textis the classic small default;mxbai-embed-largeif you want a bigger, usually better vector. Chat models like llama3.2 won't produce useful embeddings here. - input - the text to embed.
- split_lines - batch mode. Newline-separated inputs, one embedding each.
- truncate - whether to silently cut over-long input to the model's context window.
Output: embeddings_json, the JSON array. To actually use the vectors you'll typically pipe this into a custom python/JSON node, compute a similarity (cosine is the usual one), and feed the result back into your logic.
Install
Same pack, same drill - ComfyUI-OllamaOmni via ComfyUI Manager ("OllamaOmni") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ckinpdx/ComfyUI-OllamaOmni
pip install -r ComfyUI-OllamaOmni/requirements.txt
Restart, then pull an embedding model:
ollama pull nomic-embed-text
The only dependency is the ollama Python package. Embedding models are tiny, so this node is cheap even on a modest card - it's exactly the kind of small-local-tool job the KB's LLM-in-ComfyUI picture says belongs on your own machine rather than an API.
Where it gets fiddly
- The output is JSON text, not a tensor. If you expected a numeric array you can do math on directly, that's not this node. It returns a string you parse - ComfyUI has JSON nodes, or write a tiny custom python node.
- Empty
inputreturns garbage. One vector of whatever the model does with nothing is not useful; guard against blank strings. - Embedding models are picky about format. Many (including nomic) respond differently to a plain string vs. an instruction-style string, and mixing modes pollutes similarity. Pick one format and stick with it for whatever collection you're comparing against.
- Same model, same corpus, or comparisons lie. Cosine similarity between vectors from
nomic-embed-textandmxbai-embed-largeisn't meaningful. Pick one embedding model and use it for everything you intend to compare.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| url | STRING | http://127.0.0.1:11434 | URL of the Ollama server. |
| model | COMBO | Embedding model to use (e.g. nomic-embed-text, mxbai-embed-large). | |
| input | STRING | Text to embed. For multiple inputs, separate with a newline and enable split_lines. | |
| split_lines | BOOLEAN | false | If enabled, splits input on newlines and embeds each line separately (batch embedding). |
| truncate | BOOLEAN | true | Truncate input to the model's context length if it exceeds it. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| embeddings_json | STRING | — |