Views
No views yet
XiaoZhang98/byT5-DRS model with the Hugging Face Transformers library to process an example sentence.1from transformers import AutoTokenizer, T5ForConditionalGeneration
2
3# Initialize the tokenizer and model
4tokenizer = AutoTokenizer.from_pretrained('XiaoZhang98/byT5-DRS', max_length=512)
5model = T5ForConditionalGeneration.from_pretrained("XiaoZhang98/byT5-DRS")
6
7# Example sentence
8example = "I am a student."
9
10# Tokenize and prepare the input
11x = tokenizer(example, return_tensors='pt', padding=True, truncation=True, max_length=512)['input_ids']
12
13# Generate output
14output = model.generate(x)
15
16# Decode and print the output text
17pred_text = tokenizer.decode(output[0], skip_special_tokens=True, clean_up_tokenization_spaces=False)
18print(pred_text)