llm-embedding-eval
LLM plugin that will compare two embeddings and determine their similarity/relevance based on various metrics.
It also supports SemScore as proposed in a publication(https://arxiv.org/abs/2401.17072).
Installation
Install this plugin in the same environment as LLM.
llm install llm-embedding-eval
Usage
The plugin adds a new command, llm eval.
Usage: llm eval [OPTIONS] EMBEDDING1 EMBEDDING2
Evaluate similarity between two embeddings
This command compares two embeddings using various similarity metrics. For semantic scoring (semscore), original texts must be provided or available in the database for DB files.
Supports both binary embedding files and SQLite DB files (.db extension).
Example usage:
# Basic usage with auto-detection of text column with semscore
llm eval --query "DB semantics" --metric semscore docs.db docs1.db
# Basic usage with cosine similarity
llm eval --query "How similar are these?" --metric cosine docs.db docs1.db
# Basic usage custom prompt with metric llm
llm eval --metric llm -m llama3.2 --query "Are the contents similar?" --prompt "Query: {query}\n\nMetrics for first text: {metricsA}\nMetrics for second text: {metricsB}\n\nBased on the semscore of {semscore}, are these texts similar? Give a detailed explanation." docs.db docs1.db
Note: The prompt template variables are {query}, {metricsA}, {metricsB} and {semscore}.
The default prompt used is:
Given the query: {query}
Compare these two embedding results:
Embedding A metrics: {metricsA}
Embedding B metrics: {metricsB}
SemScore: {semscore:.4f}
Which embedding is more relevant to the query? Answer with "Embedding A" or "Embedding B".
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd llm-embedding-eval
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
python -m pytest
Metadata
Release files for llm-embedding-eval 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_embedding_eval-0.1.tar.gz | 11.3 kB | Without provenance | Details for llm_embedding_eval-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_embedding_eval-0.1-py3-none-any.whl | Python 3 | none | any | Details for llm_embedding_eval-0.1-py3-none-any.whl |
Total release size: 22.7 kB
Release files / llm_embedding_eval-0.1.tar.gz
| Download URL | llm_embedding_eval-0.1.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6cd32f2638c23af04e76566eea74c3922efe349bc279abbfcbf2a7c73d11b775
|
|
BLAKE2b-256 checksum How to use checksums |
7e789e458bb328ff3b396d714a54eeaa58a42acd6910c68f43c6b0040e17fbe4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Release files / llm_embedding_eval-0.1-py3-none-any.whl
| Download URL | llm_embedding_eval-0.1-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbcec621f20032e3b913f1958d2f56bf0779919a7d5a69686484a89d275541c6
|
|
BLAKE2b-256 checksum How to use checksums |
2ff7248fdc47512d313bc01edbb6e8a38de2cb9a2d3d039e1d348a727c575902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.0
|
Security for llm-embedding-eval 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.