Skip to main content

Embeddings interface for Ollama

Project description

Ellama

Embeddings library

ollama faiss langchain

pca t-sne umap plot

test

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.

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

Embedding database visualisation:

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()

install

pip (CPU)

pip install "ellama[cpu]"           # basic
pip install "ellama[cpu,plot]"      # plot('PCA' or 't-SNE')
pip install "ellama[cpu,plot,umap]" # plot('UMAP')

conda (GPU)

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')
- pip
- pip:
  - ellama

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ellama-0.3.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ellama-0.3.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file ellama-0.3.2.tar.gz.

File metadata

  • Download URL: ellama-0.3.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for ellama-0.3.2.tar.gz
Algorithm Hash digest
SHA256 d2082cbca34d35f2eeacf0f369679f2506a5cd079a102248b16d5914a911d55d
MD5 003a668a6ce22dfa8242356a5f68566d
BLAKE2b-256 d73bf068aceedc86ee4de1394143b57b1a7953b069e0a7b7bc9aa26b642d908f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellama-0.3.2.tar.gz:

Publisher: test.yml on casperdcl/ellama

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ellama-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: ellama-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for ellama-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 17453e526862a1b65e680172256927146e910077eff5e2a49443dcd15986cc36
MD5 2f6e0d51753a6429729fb3a4dd7b8c96
BLAKE2b-256 966e67ffdd66354160a4f0cb6511500fc1df85a290e630daf30ed1861b11d6f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ellama-0.3.2-py3-none-any.whl:

Publisher: test.yml on casperdcl/ellama

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page