Embedding models using Ollama pulled models
Project description
llm-embed-ollama
LLM plugin providing access to embedding models running on local Ollama server.
Installation
Install this plugin in the same environment as LLM.
llm install llm-embed-ollama
Background
Ollama provides Few embedding models. This plugin enables the usage of those models using llm and ollama embeddings..
To utilize these models, you need to have an instance of the Ollama server running.
See also Embeddings: What they are and why they matter for background on embeddings and an explanation of the LLM embeddings tool.
See also Ollama Embeddings Models Blog
Usage
This plugin adds support for the following embedding models available in ollama:
- all-minilm
- nomic-embed-text
- mxbai-embed-large
- bge-large: Embedding model from BAAI mapping texts to vectors.
- bge-m3: BGE-M3 is a new model from BAAI distinguished for its versatility in Multi-Functionality, Multi-Linguality, and Multi-Granularity.
The models needs to be downloaded. Using `ollama pull the first time you try to use them.
See the LLM documentation for everything you can do.
To get started embedding a single string, run the following:
Make sure you have the appropriate ollama model.
ollama pull all-minilm
llm embed -m all-minilm -c 'Hello world'
This will output a JSON array of 384 floating point numbers to your terminal.
To calculate and store embeddings for every README in the current directory (try this somewhere with a node_modules directory to get lots of READMEs) run this:
llm embed-multi ollama-readmes \
-m all-minilm \
--files . '**/README.md' --store
Then you can run searches against them like this:
llm similar ollama-readmes -c 'utility functions'
Add | jq to pipe it through jq for pretty-printed output, or | jq .id to just see the matching filenames.
Prefix and suffix support
Some embedding models expect prefixed or suffixed input (for example, instruction-style or query embeddings).
This plugin supports optional embedding prefixes and suffixes provided by llm. When a prefix or suffix is set on the embedding model, it is automatically applied before generating embeddings.
Example (Python):
import llm
model = llm.get_embedding_model("all-minilm")
model.prefix = "query: "
embedding = model.embed("hello world")
This is useful for models that distinguish between query and document embeddings.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd llm-embed-ollama
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
llm install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_embed_ollama-0.1.3.tar.gz.
File metadata
- Download URL: llm_embed_ollama-0.1.3.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddeb62719ea69aa1e7b73fe218022c4b5d89e132aba3862692ee933f80ce3d42
|
|
| MD5 |
8d849b05c5508c80d4a49bfa28a22fcd
|
|
| BLAKE2b-256 |
db12ddb0b7a537ad264f92cf9013685a38c883db874616a1c23121c8a7b73ecd
|
Provenance
The following attestation bundles were made for llm_embed_ollama-0.1.3.tar.gz:
Publisher:
publish.yml on sukhbinder/llm-embed-ollama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_embed_ollama-0.1.3.tar.gz -
Subject digest:
ddeb62719ea69aa1e7b73fe218022c4b5d89e132aba3862692ee933f80ce3d42 - Sigstore transparency entry: 836151971
- Sigstore integration time:
-
Permalink:
sukhbinder/llm-embed-ollama@585e8876ea2f795a13a77fcb0274b81af565d245 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/sukhbinder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@585e8876ea2f795a13a77fcb0274b81af565d245 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_embed_ollama-0.1.3-py3-none-any.whl.
File metadata
- Download URL: llm_embed_ollama-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
194e7d388dc5f3db88c089436a9c85d6c7da6ff8ac2a22f5de8bee7cd68f9978
|
|
| MD5 |
e6aa90c02bc90ba462232f8535c14da5
|
|
| BLAKE2b-256 |
c674ce8220c4161d779394a4a76d442da159cb7808c62487bd3d249ceb5af9f3
|
Provenance
The following attestation bundles were made for llm_embed_ollama-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on sukhbinder/llm-embed-ollama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_embed_ollama-0.1.3-py3-none-any.whl -
Subject digest:
194e7d388dc5f3db88c089436a9c85d6c7da6ff8ac2a22f5de8bee7cd68f9978 - Sigstore transparency entry: 836151974
- Sigstore integration time:
-
Permalink:
sukhbinder/llm-embed-ollama@585e8876ea2f795a13a77fcb0274b81af565d245 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/sukhbinder
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@585e8876ea2f795a13a77fcb0274b81af565d245 -
Trigger Event:
release
-
Statement type: