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 | Training Dataset | Dev. Correlation |
---|---|---|
Web STS BERT | STS-B | 0.893 |
Clinical STS BERT | MED-STS |
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size semantic_text_similarity-1.0.1-py3-none-any.whl (414.7 kB) | File type Wheel | Python version py3 | Upload date | Hashes View |
Filename, size semantic_text_similarity-1.0.1.tar.gz (409.5 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for semantic_text_similarity-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ba80570345461ca03639b197a1fe85cd7e0f213c1a803787fb04b887d62ece6 |
|
MD5 | 53983afab6da547d8ca2f01233899c6c |
|
BLAKE2-256 | 2a0aa1fe5e96fd6acf24dcd96f64376c2bed341ee64974683431519aa19b9dc8 |
Close
Hashes for semantic_text_similarity-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b85c89733b129f8f8e215a23f90b060f0fed32f23556d7ee757508f5942e4b6 |
|
MD5 | 344ef61fb2fcf31da0e0e7d2b24ad000 |
|
BLAKE2-256 | bbd60cd6c5081107bcbe6d246c798d1e8c8f5bbcd4fc094cb28b0cffef7e613c |