Views
No views yet
pip install simctg --upgrade1import torch
2# load SimCTG language model
3from simctg.simctggpt import SimCTGGPT
4model_name = r'cambridgeltl/simctg_wikitext103'
5model = SimCTGGPT(model_name)
6model.eval()
7tokenizer = model.tokenizer1prefix_text = r"Butt criticized Donald 's controls in certain situations in the game , as well as the difficulty of some levels and puzzles .
2Buchanan also criticized the controls , calling"
3print ('Prefix is: {}'.format(prefix_text))
4tokens = tokenizer.tokenize(prefix_text)
5input_ids = tokenizer.convert_tokens_to_ids(tokens)
6input_ids = torch.LongTensor(input_ids).view(1,-1)1beam_width, alpha, decoding_len = 8, 0.6, 128
2output = model.fast_contrastive_search(input_ids=input_ids, beam_width=beam_width,
3 alpha=alpha, decoding_len=decoding_len)
4
5print("Output:\n" + 100 * '-')
6print(tokenizer.decode(output))
7'''
8 Prefix is: Butt criticized Donald 's controls in certain situations in the game , as well as the difficulty of some levels and puzzles .
9 Buchanan also criticized the controls , calling
10 Output:
11 ----------------------------------------------------------------------------------------------------
12 Butt criticized Donald's controls in certain situations in the game, as well as the difficulty of some levels and puzzles. Buchanan also
13 criticized the controls, calling them " unimpressive " and a " nightmare " of an experience to play with players unfamiliar with Tetris.
14 On the other hand, his opinion was shared by other reviewers, and some were critical of the game's technical design for the Wii version
15 of Tetris. In addition, Tintin's review included a quote from Roger Ebert, who said that Tetris was better than the original game due to
16 its simplicity and ease of play. Ebert's comments were included in the game's DVD commentary, released on March 22, 2010. It is unclear
17 if any of the video commentary was taken from the DVD
18'''1@article{su2022contrastive,
2 title={A Contrastive Framework for Neural Text Generation},
3 author={Su, Yixuan and Lan, Tian and Wang, Yan and Yogatama, Dani and Kong, Lingpeng and Collier, Nigel},
4 journal={arXiv preprint arXiv:2202.06417},
5 year={2022}
6}