bleurt-pytorch
Use BLEURT models in native PyTorch with Transformers.
Getting started
Install with:
pip install git+https://github.com/lucadiliello/bleurt-pytorch.git
Now load your favourite model with:
import torch
from bleurt_pytorch import BleurtConfig, BleurtForSequenceClassification, BleurtTokenizer
config = BleurtConfig.from_pretrained('lucadiliello/BLEURT-20-D12')
model = BleurtForSequenceClassification.from_pretrained('lucadiliello/BLEURT-20-D12')
tokenizer = BleurtTokenizer.from_pretrained('lucadiliello/BLEURT-20-D12')
references = ["a bird chirps by the window", "this is a random sentence"]
candidates = ["a bird chirps by the window", "this looks like a random sentence"]
model.eval()
with torch.no_grad():
inputs = tokenizer(references, candidates, padding='longest', return_tensors='pt')
res = model(**inputs).logits.flatten().tolist()
print(res)
# [0.9604414105415344, 0.8080050349235535]
You can find all BLUERT models adapted for PyTorch here. The recommended model is lucadiliello/BLEURT-20, however this model is very large and may require too much resources. BLEURT-20-D12 is smaller but works well enough for most comparisons.
Credits
- Google original BLEURT implementation
- Transformers project
- Users of this issue, from which I took inspiration.
Metadata
Release files for bleurt-pytorch 0.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 |
|---|---|---|---|---|
| bleurt-pytorch-0.0.1.tar.gz | 19.8 kB | Without provenance | Details for bleurt-pytorch-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bleurt_pytorch-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for bleurt_pytorch-0.0.1-py3-none-any.whl |
Total release size: 42.1 kB
Release files / bleurt-pytorch-0.0.1.tar.gz
| Download URL | bleurt-pytorch-0.0.1.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
55c2756517682c43c648c7eb20e6a117d1ec1146d1d1713c1847afbf345d152d
|
|
BLAKE2b-256 checksum How to use checksums |
254cb5c8f2f122ec25fdbeb71aa71bf13c48d43793b49a55a4c1ade22393bad6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Release files / bleurt_pytorch-0.0.1-py3-none-any.whl
| Download URL | bleurt_pytorch-0.0.1-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3023bb6a3670cb571994a838f147fe766da53786349ac9a25475fd9cbf3e755b
|
|
BLAKE2b-256 checksum How to use checksums |
bce06059b6c9e7efdc8ad058320867a31f4f5aff2c312a4827ca70ebbe19b143
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.11
|
Security for bleurt-pytorch 0.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.