Downloads · 30 days
6
1% of all-time downloads
njvdnbus/Interest_extraction
Interest_extraction is a machine learning model from njvdnbus. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Extracts the interests from a question-answer pair. [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.
Downloads · 30 days
6
1% of all-time downloads
All-time downloads
566
Public
Repo size
8.9 GB
Likes
1
Public
Click a slice to open those files.
.bin3 GB · 100%
From the Hugging Face model README
Extracts the interests from a question-answer pair.
[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
import nltk
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("njvdnbus/Interest_extraction")
model = AutoModelForSeq2SeqLM.from_pretrained("njvdnbus/Interest_extraction")
def use_model(text):
inputs = ["" + text]
inputs = tokenizer(inputs, truncation=True, return_tensors="pt")
output = model.generate(**inputs, num_beams=1, do_sample=True, min_length=1, max_length=64)
decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
predicted_interests = nltk.sent_tokenize(decoded_output.strip())[0]
return predicted_interests
text= '''What other hobbies do you have?
When I have time I like to cook for my family. Most often this only happens in the weekends.'''
print(use_model(text))
cooking