PyTorch edit-distance functions
Useful functions for E2E Speech Recognition training with PyTorch and CUDA.
Here is a simple use case with Reinforcement Learning and RNN-T loss:
blank = torch.tensor([0], dtype=torch.int).cuda()
space = torch.tensor([1], dtype=torch.int).cuda()
xs = model.greedy_decode(xs, sampled=True)
torch_edit_distance.remove_blank(xs, xn, blank)
rewards = 1 - torch_edit_distance.compute_wer(xs, ys, xn, yn, blank, space)
nll = rnnt_loss(zs, ys, xn, yn)
loss = nll * rewards
levenshtein_distance
Levenshtein edit-distance with detailed statistics for ins/del/sub operations.
collapse_repeated
Merge repeated tokens, useful for CTC-based model.
remove_blank
Remove unnecessary blank tokens, useful for CTC, RNN-T, RNA models.
strip_separator
Remove leading, trailing and repeated middle separators.
Requirements
- C++11 compiler (tested with GCC 9.4.0).
- Python: 3.5, 3.6, 3.7, 3.8, 3.9 (tested with version 3.8).
- PyTorch >= 1.5.0 (tested with version 1.13.1+cu116).
- CUDA Toolkit (tested with version 11.2).
Install
There is no compiled version of the package. The following setup instructions compile the package from the source code locally.
From Pypi
pip install torch_edit_distance
From GitHub
git clone https://github.com/1ytic/pytorch-edit-distance
cd pytorch-edit-distance
python setup.py install
Test
python -m torch_edit_distance.test
Metadata
Release files for torch-edit-distance 0.4.0
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 |
|---|---|---|---|---|
| torch_edit_distance-0.4.0.tar.gz | 8.5 kB | Without provenance | Details for torch_edit_distance-0.4.0.tar.gz |
Release files / torch_edit_distance-0.4.0.tar.gz
| Download URL | torch_edit_distance-0.4.0.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce402efa87680f9215858d5d36e70115b2212cc09feb248a8d6e29508b98fe9c
|
|
BLAKE2b-256 checksum How to use checksums |
42e162aaebb2c9bd17e3e7bc2a002d6fc31a87823b031c501f6acb4dd8f677ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Security for torch-edit-distance 0.4.0
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.