Skip to content

feat: add Ollama text vectorizer#617

Merged
nkanu17 merged 5 commits into
redis:mainfrom
s-agbede:feat/add-ollamatextvectorizer
May 27, 2026
Merged

feat: add Ollama text vectorizer#617
nkanu17 merged 5 commits into
redis:mainfrom
s-agbede:feat/add-ollamatextvectorizer

Conversation

@s-agbede
Copy link
Copy Markdown
Contributor

@s-agbede s-agbede commented May 20, 2026

Summary

Adds OllamaTextVectorizer support for local Ollama embedding models.

This PR includes Ollama optional dependency wiring, a sync/async OllamaTextVectorizer implementation, vectorizer registry/from-dict support for type: "ollama", mocked unit tests, and opt-in real Ollama integration tests guarded by REDISVL_TEST_OLLAMA=1.

Usage

from redisvl.utils.vectorize import OllamaTextVectorizer

vectorizer = OllamaTextVectorizer(model="nomic-embed-text")
embedding = vectorizer.embed("hello world")

To run the real Ollama integration tests locally:

ollama pull nomic-embed-text
REDISVL_TEST_OLLAMA=1 uv run pytest tests/integration/test_ollama_vectorizer_integration.py

Testing:

uv run pytest tests/unit/test_ollama_vectorizer.py tests/integration/test_ollama_vectorizer_integration.py -q
REDISVL_TEST_OLLAMA=1 uv run pytest tests/integration/test_ollama_vectorizer_integration.py -q
uv run black --check ./redisvl ./tests
uv run isort ./redisvl ./tests --check-only --profile black
uv lock --check
uv run mypy redisvl
make test

Full repo test result:
image


Note

Low Risk
Additive embedding provider with optional install; no changes to auth, Redis core, or existing vectorizer behavior beyond new enum and factory branch.

Overview
Adds local Ollama as a first-class text embedding provider in RedisVL.

A new OllamaTextVectorizer talks to a running Ollama daemon (sync/async embed / embed_many, optional host, dimension probing at init, retries). It is exported from redisvl.utils.vectorize, registered as Vectorizers.ollama, and constructible via vectorizer_from_dict with type: "ollama".

Packaging adds optional redisvl[ollama] / all extra (ollama>=0.5.4) and bumps the package to 0.18.2 in the lockfile. The vectorizers user guide gains an Ollama section with skip-on-error examples. Unit tests use a fake ollama client; integration tests run only when REDISVL_TEST_OLLAMA=1.

Reviewed by Cursor Bugbot for commit ce7b52e. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented May 20, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@nkanu17
Copy link
Copy Markdown
Collaborator

nkanu17 commented May 20, 2026

Yess!! Let's go! Ollama finally

Comment thread redisvl/utils/vectorize/text/ollama.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Ollama-backed text embedding provider to RedisVL’s vectorizer system, enabling local embedding generation via an Ollama daemon while fitting into the existing vectorizer registry/from-dict plumbing and test suite.

Changes:

  • Introduces OllamaTextVectorizer with sync/async embedding APIs and automatic dimension discovery.
  • Wires type: "ollama" into the Vectorizers enum and vectorizer_from_dict, and exports the new vectorizer from redisvl.utils.vectorize.
  • Adds an ollama optional extra (also included in all), updates uv.lock, and adds mocked unit tests plus opt-in integration tests gated by REDISVL_TEST_OLLAMA=1.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
redisvl/utils/vectorize/text/ollama.py New Ollama vectorizer implementation (sync/async) and model-dimension initialization.
redisvl/utils/vectorize/base.py Adds ollama to the Vectorizers enum.
redisvl/utils/vectorize/__init__.py Exposes OllamaTextVectorizer and adds type: "ollama" support in vectorizer_from_dict.
pyproject.toml Adds ollama optional extra and includes it in all.
uv.lock Locks the new ollama dependency and updates extras metadata.
tests/unit/test_ollama_vectorizer.py Mocked unit tests for init, sync/async embedding, and registry/from-dict integration.
tests/integration/test_ollama_vectorizer_integration.py Opt-in real Ollama integration tests gated by env var.
Comments suppressed due to low confidence (1)

redisvl/utils/vectorize/text/ollama.py:298

  • Same validation issue as _embed_many: the error message iterates contents to compute element types even when contents is not a list. Passing a non-iterable will raise during message formatting and obscure the actual input-type error; guard before iterating or simplify the message for non-list inputs.
        if not isinstance(contents, list) or not all(
            isinstance(c, str) for c in contents
        ):
            raise TypeError(
                f"Input contents must be a list of strings to embed, got {type(contents)} with elements of types {[type(c) for c in contents]}"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
Comment thread redisvl/utils/vectorize/text/ollama.py
Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
Copy link
Copy Markdown
Collaborator

@nkanu17 nkanu17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@s-agbede This looks great!
Can you add an example under /docs/user_guide/04_vectorizers.ipynb

@s-agbede
Copy link
Copy Markdown
Contributor Author

This looks great!
Can you add an example under /docs/user_guide/04_vectorizers.ipynb

@s-agbede This looks great! Can you add an example under /docs/user_guide/04_vectorizers.ipynb

Thanks @nkanu17. pushed the example changes now

Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6d6873f. Configure here.

Comment thread redisvl/utils/vectorize/text/ollama.py Outdated
Copy link
Copy Markdown
Collaborator

@nkanu17 nkanu17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Let's go! @s-agbede

@nkanu17 nkanu17 merged commit 9947b18 into redis:main May 27, 2026
2 checks passed
@applied-ai-release-bot
Copy link
Copy Markdown

🚀 PR was released in v0.19.0 🚀

@applied-ai-release-bot applied-ai-release-bot Bot added the released This issue/pull request has been released. label May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released This issue/pull request has been released.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants