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 hashes)
Built Distribution
ReWord-0.1.0-py3-none-any.whl
(6.1 kB
view hashes)