Reorder word in English sentence to follow correct grammar
Project description
Word ordering
Sequence tagging to predict the correct order of input sequence trained on dedicated dataset
How to use
pip install ReWord
from ReWord import ReWordModel
from transformers import RobertaTokenizer
import torch
pretrained_ck = 'transZ/reword'
tokenizer = RobertaTokenizer.from_pretrained(pretrained_ck, add_prefix_space=True)
model = ReWordModel.from_pretrained(pretrained_ck)
model.eval()
sent = "I education company . <ma> <mp> <mv>"
inputs = sent.split(" ")
tokenized_inputs = tokenizer(
inputs,
padding="max_length",
truncation=True,
max_length=25,
is_split_into_words=True,
return_tensors="pt"
)
with torch.no_grad():
logits = model(**tokenized_inputs)
preds = logits.argmax(dim=-1)
decoded_preds = tokenizer.decode(preds, skip_special_tokens=True)
print(decoded_preds) # "I <mv> <mp> <ma> education company ."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ReWord-0.1.0.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ReWord-0.1.0.tar.gz.
File metadata
- Download URL: ReWord-0.1.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79b457cad042a6484c6ac7c80b7ddcb9d143e4f04a77ad63dd56f8f869039b26
|
|
| MD5 |
76fedbf7bbac38eaf1ce745b56393a39
|
|
| BLAKE2b-256 |
ea8734ba23a1b1cad7f2a45022c02c8850cc8bdaae7d32f064c59720a1767793
|
File details
Details for the file ReWord-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ReWord-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b204927889c4929d666c6c290b6dfaca64c3622004d023863de2240502e9c4
|
|
| MD5 |
d9bc5b5e25df9329c4145b0c00164891
|
|
| BLAKE2b-256 |
bc36273337e6733a0765924e6ae4d967d2e4b9da99f8714c29d6a7aa287f0533
|