implementations of models and metrics for semantic text similarity. that's it.
Project description
semantic-text-similarity
an easy-to-use interface to fine-tuned BERT models for computing semantic similarity. that's it.
This project contains an interface to fine-tuned, BERT-based semantic text similarity models. It modifies pytorch-transformers by abstracting away all the research benchmarking code for ease of real-world applicability.
Model | Dataset | Dev. Correlation |
---|---|---|
Web STS BERT | STS-B | 0.893 |
Clinical STS BERT | MED-STS | 0.854 |
Installation
Install with pip:
pip install semantic-text-similarity
or directly:
pip install git+https://github.com/AndriyMulyar/semantic-text-similarity
Use
Maps batches of sentence pairs to real-valued scores in the range [0,5]
from semantic_text_similarity.models import WebBertSimilarity
model = WebBertSimilarity(device='cpu', batch_size=10) #defaults to GPU prediction
model.predict([("She won an olympic gold medal","The women is an olympic champion")])
More examples.
Notes
- You will need a GPU to apply these models if you would like any hint of speed in your predictions.
- Model downloads are cached in
~/.cache/torch/semantic_text_similarity/
. Try clearing this folder if you have issues.
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
semantic_text_similarity-1.0.2.tar.gz
(410.2 kB
view hashes)
Built Distribution
Close
Hashes for semantic_text_similarity-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbc7e07f47b03e496213ffb8e1fb9e90790ad2e3237b5b6ba3b92de205c4bbb |
|
MD5 | ca7b80e7b64ad3e848b8c225eb712ebc |
|
BLAKE2b-256 | 81bf896a8f6c3acf0820107aaa8aab14d34d8ce4c8602a73083ea1ba6a70f0d7 |
Close
Hashes for semantic_text_similarity-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4396a1241f4d57531d606af20e92f6e728ce7c578ae150214cfe6c468e996ec |
|
MD5 | 19b45be123568e69c2873a02c0eed843 |
|
BLAKE2b-256 | cd6492396a88ffbe2f963479219a4f4157280acaf1524b4f81e2002f4b5b663c |