https://github.com/casperdcl/ellama
Embeddings interface for Ollama
https://github.com/casperdcl/ellama
embeddings faiss langchain ollama pca semantic-search t-sne umap vector vector-database vector-search
Last synced: 22 days ago
JSON representation
Embeddings interface for Ollama
- Host: GitHub
- URL: https://github.com/casperdcl/ellama
- Owner: casperdcl
- Created: 2026-04-24T18:00:38.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-09T19:56:47.000Z (about 1 month ago)
- Last Synced: 2026-05-09T20:39:13.008Z (about 1 month ago)
- Topics: embeddings, faiss, langchain, ollama, pca, semantic-search, t-sne, umap, vector, vector-database, vector-search
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ellama
*Embeddings library*
[](https://ollama.com/search?c=embedding)
[](https://unsloth.ai/docs/basics/embedding-finetuning)
[](https://github.com/facebookresearch/faiss)
[](https://github.com/langchain-ai/langchain)
[](https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html)
[](https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html)
[](https://umap-learn.readthedocs.io)
[](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.scatter.html)
[](https://github.com/casperdcl/ellama/actions/workflows/test.yml)
Unlike the overwhelming majority of alternatives:
- handles long inputs without truncation even if the underlying model has a small context window
- minimal config
- 100% human-written (thus sane & clean) codebase
> [!TIP]
> Please open an issue if you know of any better alternatives. I would love to archive this repo.
## search
Database semantic search:
```py
from ellama import EllamaDB, Document
db = EllamaDB("test")
db.add_documents([
Document("hello world", id="salutation"),
Document("goodbye and goodnight", id="farewell")])
docs = db.similarity_search("Greetings, Earth!", k=1)
assert len(docs) == 1
assert docs[0].id == "salutation"
```
## plot
Embeddings visualisation:
```py
import matplotlib.pyplot as plt
from ellama import EllamaDB, Document
from sklearn.datasets import fetch_20newsgroups
raw = fetch_20newsgroups(data_home='.cache')
db = EllamaDB("20newsgroups")
db.add_documents([
Document(raw.data[i], id=str(i), metadata={'name': raw.target_names[raw.target[i]]})
for i in range(200)])
for group in ['alt.atheism', 'comp', 'misc.forsale', 'rec', 'rec.sport', 'sci',
'soc.religion', 'talk.politics', 'talk.religion']:
db.plot('t-SNE', label=group,
filter=lambda metadata: metadata['name'].startswith(f'{group}.'))
plt.title(f"Newsgroup {db.embeddings.model} embeddings t-SNE")
plt.legend()
plt.show()
```

## fine-tune
Low-rank adaptation (LoRA) re-using the newsgroups database created above:
```py
from ellama import EllamaDB
db = EllamaDB("20newsgroups")
db.lora(['name'], "ellama/lora:news", epochs=600)
# create new database using the new model
db_lora = EllamaDB("20newsgroups_lora", "ellama/lora:news")
db_lora.add_documents(db.get_docs({}))
```

## install
### `pip` (CPU)
```sh
pip install "ellama[cpu]" # basic
pip install "ellama[cpu,plot]" # plot('PCA' or 't-SNE')
pip install "ellama[cpu,plot,umap]" # plot('UMAP')
pip install "ellama[lora]" # fine-tuning
```
### `conda` (GPU)
```yml
name: ellama
channels: [pytorch, nvidia, conda-forge]
dependencies:
- langchain 1.*
- langchain-community
- faiss-gpu
- requests
- tqdm
#- matplotlib # ellama plot()
#- scikit-learn # ellama plot()
#- umap-learn # ellama plot('UMAP')
#- unsloth # ellama lora()
- pip
- pip:
- ellama
```