Ateeqq commited on
Commit
6211caa
1 Parent(s): 5822f13

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -20
README.md CHANGED
@@ -31,6 +31,63 @@ This repository contains a fine-tuned model for generating high-quality product
31
 
32
  Developed by team at https://exnrt.com
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  ## Features
35
 
36
  - **Architecture**: t5-base (223M parameters)
@@ -60,26 +117,6 @@ Developed by team at https://exnrt.com
60
  - **Batch Size**: 1
61
  - **Max Epochs**: 1
62
 
63
- ## Usage
64
-
65
- # Load model directly
66
-
67
- ```python
68
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
69
-
70
- tokenizer = AutoTokenizer.from_pretrained("Ateeqq/product-description-generator", token="your_token")
71
- model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/product-description-generator", token="your_token")
72
-
73
- input_text = "SAMSUNG Galaxy S23+ Series AI Phone, Unlocked Android Smartphone, 256GB Storage, 8GB RAM, 50MP Camera"
74
-
75
- inputs = tokenizer.encode("description: " + input_text, return_tensors="pt", max_length=50, truncation=True)
76
-
77
- outputs = model.generate(inputs, max_length=400, num_beams=2, num_beam_groups=2, num_return_sequences=2, repetition_penalty=1.0, diversity_penalty=3.0, no_repeat_ngram_size=2, temperature=0.9, early_stopping=True)
78
-
79
- description = tokenizer.decode(outputs[1], skip_special_tokens=True)
80
-
81
- print(description)
82
- ```
83
  ## Future Work
84
 
85
  - **Update Training Data**: Retrain the model using the latest 0.5 million cleaned examples.
 
31
 
32
  Developed by team at https://exnrt.com
33
 
34
+ ## Usage
35
+
36
+ T5 model expects a task related prefix: since it is a description generation task, we will add a prefix "description: "
37
+
38
+ ```python
39
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
40
+
41
+ tokenizer = AutoTokenizer.from_pretrained("Ateeqq/product-description-generator", token="your_token")
42
+ model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/product-description-generator", token="your_token")
43
+
44
+ input_text = "18-Piece Kitchen Dinnerware white Set, Plates, Dishes, Bowls"
45
+
46
+ inputs = tokenizer.encode("description: " + input_text, return_tensors="pt", max_length=128, truncation=True)
47
+
48
+ outputs = model.generate(inputs, max_length=400, num_beams=2, num_beam_groups=2, num_return_sequences=2, repetition_penalty=1.0, diversity_penalty=3.0, no_repeat_ngram_size=2, temperature=0.9, early_stopping=True)
49
+
50
+ description = tokenizer.decode(outputs[1], skip_special_tokens=True)
51
+
52
+ print(description)
53
+ ```
54
+
55
+ ## Getting Multiple Outputs
56
+
57
+ ```python
58
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
59
+
60
+ device = "cuda"
61
+ tokenizer = AutoTokenizer.from_pretrained("Ateeqq/product-description-generator", token='your_token')
62
+ model = AutoModelForSeq2SeqLM.from_pretrained("Ateeqq/product-description-generator", token='your_token').to(device)
63
+
64
+ def generate_description(title):
65
+ input_ids = tokenizer(f'description: {title}', return_tensors="pt", padding="longest", truncation=True, max_length=128).input_ids.to(device)
66
+ outputs = model.generate(
67
+ input_ids,
68
+ num_beams=5,
69
+ num_beam_groups=5,
70
+ num_return_sequences=5,
71
+ repetition_penalty=10.0,
72
+ diversity_penalty=3.0,
73
+ no_repeat_ngram_size=2,
74
+ temperature=0.7,
75
+ max_length=128
76
+ )
77
+ return tokenizer.batch_decode(outputs, skip_special_tokens=True)
78
+
79
+ title = '18-Piece Kitchen Dinnerware white Set, Plates, Dishes, Bowls'
80
+ generate_description(title)
81
+ ```
82
+ ### Outputs:
83
+ ```
84
+ ['18-Piece Kitchen Dinnerware White Set, Plates, Dishes and Bowls. This set includes a large bowl with two plates for serving dinner or dessert dishes in the kitchen. The white plate is made of durable stainless steel that will not fade over time.',
85
+ 'The 18 Piece Kitchen Dinnerware Set features a white plate, dish and bowl. This set is made of durable stainless steel with an elegant design that will add elegance to your kitchen.',
86
+ 'This 18-piece dinnerware set is made of durable stainless steel. It features a white finish and comes with an easy to clean handle for ease of cleaning. The bowls are dishwasher safe, microwave safe or can be used as tablecloths in the kitchen.',
87
+ 'Kitchen Dinnerware is a great addition to your kitchen. This 18-piece set includes four plates, two dishes and three bowls for serving food or beverages in the dining room with an elegant design that will add sophistication to any tabletop setting.',
88
+ "p>This 18-piece dinnerware set is made of high quality stainless steel. The white plate and dish are dishwasher safe, easy to clean with the included lids for ease of use. This dining table set features an elegant design that will add elegance style in your kitchen or living room. It's also perfect for serving food on any occasion like birthday parties, house warming ceremonies, Thanksgiving celebrations etc."]
89
+ ```
90
+
91
  ## Features
92
 
93
  - **Architecture**: t5-base (223M parameters)
 
117
  - **Batch Size**: 1
118
  - **Max Epochs**: 1
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  ## Future Work
121
 
122
  - **Update Training Data**: Retrain the model using the latest 0.5 million cleaned examples.