Embeddings interface for Ollama
Project description
Ellama
Embeddings library
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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2082cbca34d35f2eeacf0f369679f2506a5cd079a102248b16d5914a911d55d
|
|
| MD5 |
003a668a6ce22dfa8242356a5f68566d
|
|
| BLAKE2b-256 |
d73bf068aceedc86ee4de1394143b57b1a7953b069e0a7b7bc9aa26b642d908f
|
Provenance
The following attestation bundles were made for ellama-0.3.2.tar.gz:
Publisher:
test.yml on casperdcl/ellama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ellama-0.3.2.tar.gz -
Subject digest:
d2082cbca34d35f2eeacf0f369679f2506a5cd079a102248b16d5914a911d55d - Sigstore transparency entry: 1413396265
- Sigstore integration time:
-
Permalink:
casperdcl/ellama@572cd663b9ce40296fbf45f57c70489f6e1322d5 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/casperdcl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@572cd663b9ce40296fbf45f57c70489f6e1322d5 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17453e526862a1b65e680172256927146e910077eff5e2a49443dcd15986cc36
|
|
| MD5 |
2f6e0d51753a6429729fb3a4dd7b8c96
|
|
| BLAKE2b-256 |
966e67ffdd66354160a4f0cb6511500fc1df85a290e630daf30ed1861b11d6f2
|
Provenance
The following attestation bundles were made for ellama-0.3.2-py3-none-any.whl:
Publisher:
test.yml on casperdcl/ellama
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ellama-0.3.2-py3-none-any.whl -
Subject digest:
17453e526862a1b65e680172256927146e910077eff5e2a49443dcd15986cc36 - Sigstore transparency entry: 1413396198
- Sigstore integration time:
-
Permalink:
casperdcl/ellama@572cd663b9ce40296fbf45f57c70489f6e1322d5 -
Branch / Tag:
refs/tags/v0.3.2 - Owner: https://github.com/casperdcl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@572cd663b9ce40296fbf45f57c70489f6e1322d5 -
Trigger Event:
push
-
Statement type: