Spaces:
Runtime error
Runtime error
nitinbhayana
commited on
Commit
•
f262781
1
Parent(s):
95d1934
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
gr.Interface.load("models/nitinbhayana/Llama-2-7b-chat-hf-keyword-category-brand-v1").launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
#gr.Interface.load("models/nitinbhayana/Llama-2-7b-chat-hf-keyword-category-brand-v1").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(search_term):
|
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 keyword searched on amazon with intent of shopping. Identify the product category from the list ['Baby Products', 'Bags, Wallets and Luggage', 'Beauty', 'Books', 'Car & Motorbike', 'Clothing & Accessories', 'Computers & Accessories', 'Electronics', 'Garden & Outdoors', 'Gift Cards', 'Grocery & Gourmet Foods', 'Health & Personal Care', 'Home & Kitchen', 'Home Improvement', 'Industrial & Scientific', 'Jewellery', 'Kindle Store', 'Movies & TV Shows', 'Music', 'Musical Instruments', 'Office Products', 'Pet Supplies', 'Shoes & Handbags', 'Software', 'Sports, Fitness & Outdoors', 'Toys & Games', 'Video Games', 'Watches']. Extract the brand from keyword related to brand loyalty intent.\nOutput in JSON with keyword, product category, brand as keys.
|
18 |
+
### Input:
|
19 |
+
{search_term}
|
20 |
+
[/INST]"""
|
21 |
+
predictions = pipeline(prompt)
|
22 |
+
return (predictions)
|
23 |
+
|
24 |
+
gr.Interface(
|
25 |
+
predict,
|
26 |
+
inputs='text',
|
27 |
+
outputs='text',
|
28 |
+
title="Keyword-Category-Brand-Mapping",
|
29 |
+
).launch()
|
30 |
+
|
31 |
+
|
32 |
+
|