Spaces:
Runtime error
Runtime error
nitinbhayana
commited on
Commit
•
ee27115
1
Parent(s):
4f4cade
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
gr.Interface.load("models/nitinbhayana/Llama-2-7b-chat-hf-review-phrases-sentiments-v2").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
#gr.Interface.load("models/nitinbhayana/Llama-2-7b-chat-hf-review-phrases-sentiments-v2").launch()
|
4 |
+
|
5 |
+
|
6 |
+
from transformers import pipeline
|
7 |
+
|
8 |
+
pipeline = pipeline("text-generation", model="nitinbhayana/Llama-2-7b-chat-hf-keyword-category-brand-v1")
|
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)
|
24 |
+
|
25 |
+
gr.Interface(
|
26 |
+
predict,
|
27 |
+
inputs='text',
|
28 |
+
outputs='text',
|
29 |
+
title="Printer review categorization with sentiments",
|
30 |
+
).launch()
|