nitinbhayana commited on
Commit
716f60f
1 Parent(s): 4c89e2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -5,19 +5,26 @@ import gradio as gr
5
 
6
  from transformers import pipeline
7
 
8
- pipeline = pipeline("text-generation", model="nitinbhayana/Llama-2-7b-chat-hf-review-phrases-sentiments-v2")
9
 
10
- def predict(review):
 
 
 
11
 
12
- prompt=f"""[INST] <<SYS>>
13
- You are a helpful assistant that provides accurate and concise responses. Do not hallucinate.
14
  <</SYS>>
15
- Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
16
- ### Instruction:
17
- Analyze the following printer product review on amazon to extract any relevant phrases from the review that are related to each of the specified topics: ['connectivity', 'customer_support', 'delivery_and_packaging', 'durability', 'features', 'ink_toner_cost_efficiency', 'noise', 'print_quality', 'setup_and_installation', 'speed', 'user_interface', 'value_for_money', 'portability', 'easy_to_use', 'mobile_printing_functionality','authenticity','product_quality'], and indicate the sentiment expressed in each phrase.The sentiment evaluations should range from 0 to 5, with 5 represents extremely positive sentiment, 4 indicates very positive sentiment, 3 suggests neutral sentiment, 2 reflects somewhat negative sentiment, 1 represents highly negative sentiment, and 0 means not mentioned. Provide the output in JSON format.
18
- ### Input:
19
- {review}
20
- [/INST]
 
 
 
 
21
  """
22
  predictions = pipeline(prompt)
23
  return (predictions)
@@ -26,5 +33,5 @@ gr.Interface(
26
  predict,
27
  inputs='text',
28
  outputs='text',
29
- title="Printer review categorization with sentiments",
30
  ).launch()
 
5
 
6
  from transformers import pipeline
7
 
8
+ #pipeline = pipeline("text-generation", model="nitinbhayana/Llama-2-7b-chat-hf-review-phrases-sentiments-v2")
9
 
10
+
11
+ pipeline = pipeline("text-generation", model="nitinbhayana/TinyLlama-1.1B-Chat-v1.0-title-suggestion-v1.0")
12
+
13
+ def predict(title):
14
 
15
+ prompt=f"""<s>[INST] <<SYS>>
16
+ You are a helpful, respectful, and honest assistant for product feature mapping.
17
  <</SYS>>
18
+
19
+ [INST]
20
+ For a given e-commerce product title.
21
+ [TITLE]
22
+ Pantene Hair Science Silky Smoth Shampo with Pro-Vitamins & Vitamin E, shampoo for woman & men, shampoo for frizzy and dry hairs, 650ml
23
+ [/TITLE]
24
+ Create a new, easy-to-read, error-free title.
25
+ [/INST]
26
+
27
+ Suggested Title:
28
  """
29
  predictions = pipeline(prompt)
30
  return (predictions)
 
33
  predict,
34
  inputs='text',
35
  outputs='text',
36
+ title="Title Suggestion",
37
  ).launch()