1
$\begingroup$

I am looking for a python NLP library that can generate a proper product description based on product features provided to it.

Till now, i have tried transformers library and this is the code:

from transformers import pipeline
def generate_description(specs):
 # Construct input text from specifications
 input_text = "This is a"
 
 if 'category' in specs:
 input_text += f" {specs['category']}"
 else:
 input_text += "n item"
 
 if 'condition' in specs:
 input_text += f" in {specs['condition']} condition"
 
 if 'battery_health' in specs:
 input_text += f" with battery health: {specs['battery_health']}"
 
 if 'cosmetic_damage' in specs:
 input_text += f" and {specs['cosmetic_damage']} cosmetic damage"
 
 input_text += "."
 
 # Generate description using GPT-2 model
 generator = pipeline("text-generation", model="gpt2")
 description = generator(input_text, max_length=100, num_return_sequences=1)[0]['generated_text']
 
 return description
# Example specifications
specs = {
 'category': 'laptop',
 'condition': 'like new',
 'battery_health': 'good',
 'cosmetic_damage': 'minor scratches'
}
# Generate description
description = generate_description(specs)
print('DESCRIPTION : ' , description)

but the generated description is not even slightly accurate.

I am looking for some library that works somewhat similar to: https://ahrefs.com/writing-tools/product-description-generator

I would be using this along with a web application where dynamic fields for different products would be filled and I would require a description for the product.

I have also tried storing different combinations of features and their resultant description in a DB and tried fetching them, but there seem to be just too many combinations for this method to be feasible.

Any ideas regarding which library to use or how to solve this issue would be appreciated.

asked Apr 12, 2024 at 10:47
$\endgroup$

1 Answer 1

0
$\begingroup$

Shopping questions (requests for us to recommend a library or software package) are off-topic on Stack Exchange.

One possible way to achieve your goals is to use a large language model, like GPT4, to generate a description. GPT2 is likely to be terrible at this. Try GPT4.

answered Apr 12, 2024 at 18:03
$\endgroup$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.