Skip to main content

AlignUnformEval

This is a python tool to evaluate alignment and uniformity of sentence embedding like SimCSE paper.

SimCSE paper explains alignment and uniformity as below:

Given a distribution of positive pairs p_pos, alignment calculates expected distance between embeddings of the paired instances (assuming representations are already normalized):

On the other hand, uniformity measures how well the embeddings are uniformly distributed:

> where p_data denotes the data distribution.

Install

by pip

pip install alignuniformeval

by source

pip install https://github.com/akiFQC/AlignUnformEval

Usage

You can easily evaluate alignment and uniformity with this library.
This is a minimal example that evaluate alignment and uniformity of STS Benchmark.

from alignunformeval import STSBEval

evaluator = STSBEval(sentence_encoder)
# sentence_encoder is a callable from List[str] to numpy.array. The output numpy.array must be [dimention_of_sentence_vector].
result = evaluator.eval_summary()
# result =  {"alignment": value_of_aligenment, "uniformity": value_of_uniformity}

STSBEval get callable whose input is list of str and output is n dimentional numpy.array.

Dataset

STS Benchmark

This dataset (especially, sts-dev.csv) was used in SimCSE paper. In the paper, the threshold of similarity score was st at 4.0; pairs of sentences whose similarity score is higher than 4.0 are used for evaluation of alignment. You can set other threshold as the following example.

from alignunformeval import STSBEval
# sentence_encoder : some function List[str] to np.array[dimention_of_sentence_vector]
evaluator = STSBEval(sentence_encoder, threshold=3.0) # set threshold at 3.0
result = evaluator.eval_summary()

Please see test/test_stsb.py if you want more details.

Tokyo Metropolitan University Paraphrase Corpus (TMUP)

Tokyo Metropolitan University Paraphrase Corpus (TMUP) is a Japanese paraphrase dataset.

from alignunformeval import TMUPEval
# sentence_encoder : some function List[str] to np.array[dimention_of_sentence_vector]
evaluator = TMUPEval(sentence_encoder)
result = evaluator.eval_summary()

License

The license of this tool follows each dataset. Please read the documents of datasets you use.

Reference

  1. https://arxiv.org/pdf/2104.08821.pdf
  2. https://ixa2.si.ehu.eus/stswiki/index.php/STSbenchmark
  3. https://github.com/tmu-nlp/paraphrase-corpus

Metadata

Release files for alignunformeval 0.0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alignunformeval 0.0.1.1
File Size Uploaded Provenance Actions
alignunformeval-0.0.1.1.tar.gz 4.3 kB Without provenance Details for alignunformeval-0.0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for alignunformeval 0.0.1.1
File Interpreter ABI Platform Actions
alignunformeval-0.0.1.1-py3-none-any.whl Python 3 none any Details for alignunformeval-0.0.1.1-py3-none-any.whl

Total release size: 9.3 kB

Release files / alignunformeval-0.0.1.1.tar.gz

Download URL alignunformeval-0.0.1.1.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2b3cbd4f022a0902054fc607f04a330c871f629b381d97708bca0683665299d3
BLAKE2b-256 checksum
How to use checksums
c900c5cf9499f9405f11cebe0c08a8a733c9a6455c5638778dfe08afbec8545e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-43-generic

Release files / alignunformeval-0.0.1.1-py3-none-any.whl

Download URL alignunformeval-0.0.1.1-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28cd162622fd6c24fb0dbfb5bef6d0c1eb87745fcd51a04332501a5e2c1e4e09
BLAKE2b-256 checksum
How to use checksums
2f92f94a4101bf9c1a66b3a2d0173190ac00228ef99d895827189d0e654fc347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.7 Linux/5.11.0-43-generic

Security for alignunformeval 0.0.1.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.

Release history Release notifications | RSS feed

This release

0.0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page