Downloads · 30 days
16
1% of all-time downloads
mrutyunjay-patil/keywordGen-v2
keywordGen-v2 is a text generation model from mrutyunjay-patil. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
KeywordGen-v1 is a T5-based model fine-tuned for keyword generation from a piece of text. Given an input text, the model will return relevant keywords.
Downloads · 30 days
16
1% of all-time downloads
All-time downloads
1.5K
Public
Repo size
1.8 GB
Likes
3
Public
Click a slice to open those files.
.bin892 MB · 100%
From the Hugging Face model README
KeywordGen-v1 is a T5-based model fine-tuned for keyword generation from a piece of text. Given an input text, the model will return relevant keywords.
This model, "KeywordGen-v2", is the second version of the "KeywordGen" series. It is fine-tuned based on the T5 base model, specifically for the generation of keywords from text inputs, with a special focus on product reviews.
This model can provide useful insights by extracting key points or themes from product reviews. The output is expected to contain keywords ranging from 2 to 8 words. The model performs better when the input is at least 2-3 sentences long.
You can use this model directly with a pipeline for text generation. When using the model, please prefix your input with "Keyword: " for the best results.
Here's how to use this model in Python with the Hugging Face Transformers library:
from transformers import T5Tokenizer, T5ForConditionalGeneration
# Initialize the tokenizer and model
tokenizer = T5Tokenizer.from_pretrained("mrutyunjay-patil/keywordGen-v2")
model = T5ForConditionalGeneration.from_pretrained("mrutyunjay-patil/keywordGen-v2")
# Define your input sequence, prefixing with "Keyword: "
input_sequence = "Keyword: I purchased the new Android smartphone last week and I've been thoroughly impressed. The display is incredibly vibrant and sharp, and the battery life is surprisingly good, easily lasting a full day with heavy usage."
# Encode the input sequence
input_ids = tokenizer.encode(input_sequence, return_tensors="pt")
# Generate output
outputs = model.generate(input_ids)
output_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(output_sequence)
from transformers import T5Tokenizer, T5ForConditionalGeneration
# Initialize the tokenizer and model
tokenizer = T5Tokenizer.from_pretrained("mrutyunjay-patil/keywordGen-v2")
model = T5ForConditionalGeneration.from_pretrained("mrutyunjay-patil/keywordGen-v2")
# Define the prefix
task_prefix = "Keyword: "
# Define your list of input sequences
inputs = [
"Absolutely love this tablet. It has a clear, sharp screen and runs apps smoothly without any hiccups.",
"The headphones are fantastic with great sound quality, but the build quality could be better.",
"Bought this smartwatch last week, and I'm thrilled with its performance. Battery life is impressive.",
"This laptop exceeded my expectations. Excellent speed, plenty of storage, and light weight. Perfect for my needs.",
"The camera quality on this phone is exceptional. It captures detailed and vibrant photos. However, battery life is not the best."
]
# Loop through each input and generate keywords
for sample in inputs:
input_sequence = task_prefix + sample
input_ids = tokenizer.encode(input_sequence, return_tensors="pt")
outputs = model.generate(input_ids)
output_sequence = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(sample, "\n --->", output_sequence)
This model was trained on a custom dataset. The base model used was the T5 base model.
As with any machine learning model, the outputs of this keyword generator depend on the data it was trained on. It is possible that the model might generate inappropriate or biased keywords if the input text contains such content. Future iterations of the model will aim to improve its robustness and fairness, and to minimize potential bias.