Views
No views yet
[QUESTION]
[ANSWER]
What do you like to do in the weekend?
I like to spend my free time reading, playing video games, and going on walks.
reading, video games, walking
1import nltk
2from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3tokenizer = AutoTokenizer.from_pretrained("njvdnbus/Interest_extraction")
4model = AutoModelForSeq2SeqLM.from_pretrained("njvdnbus/Interest_extraction")
5
6def use_model(text):
7 inputs = ["" + text]
8 inputs = tokenizer(inputs, truncation=True, return_tensors="pt")
9 output = model.generate(**inputs, num_beams=1, do_sample=True, min_length=1, max_length=64)
10 decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
11 predicted_interests = nltk.sent_tokenize(decoded_output.strip())[0]
12 return predicted_interests
13
14text= '''What other hobbies do you have?
15When I have time I like to cook for my family. Most often this only happens in the weekends.'''
16print(use_model(text))cooking