Views
No views yet
1import torch
2from levt import LevTConfig, LevTModel, GreedyDecoder
3
4# Load config and model
5config = LevTConfig.from_json('config.json')
6model = LevTModel(config)
7state_dict = torch.load('pytorch_model.bin', map_location='cpu')
8model.load_state_dict(state_dict)
9model.eval()
10
11# Run inference
12decoder = GreedyDecoder(model, config)
13output, iterations = decoder.decode(torch.tensor([4, 5, 6]))
14print(output)1from huggingface_hub import hf_hub_download
2import torch
3from levt import LevTConfig, LevTModel
4
5config = LevTConfig.from_json(
6 hf_hub_download('KrisTHL181/LevT-Nekoizer', 'config.json')
7)
8model = LevTModel(config)
9state_dict = torch.load(
10 hf_hub_download('KrisTHL181/LevT-Nekoizer', 'pytorch_model.bin'),
11 map_location='cpu'
12)
13model.load_state_dict(state_dict)1@inproceedings{gu2019levenshtein,
2 title={Levenshtein Transformer},
3 author={Gu, Jiatao and Wang, Changhan and Zhao, Junbo},
4 booktitle={Advances in Neural Information Processing Systems},
5 year={2019}
6}