bharathh4 commited on
Commit
607469a
1 Parent(s): b185968

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +35 -36
app.py CHANGED
@@ -9,46 +9,45 @@ model = SentenceTransformer("avsolatorio/GIST-small-Embedding-v0", revision=revi
9
 
10
  # Precompute reference embeddings
11
  ref_texts = [
12
- "Theatro App: Hello John. Hey John. Hi John. Call John",
13
- "Theatro App: Message John. Message for John. Leave a message for John",
14
- "Theatro App: Play messages. Listen to messages",
15
- "Theatro App: What time is it?",
16
- "Theatro App: What time is it?",
17
- "Theatro App: Cashier Backup. Backup Cashier. Register backup. Register assistance.",
18
- "Theatro App: repeat",
19
- "Theatro App: Check inventory",
20
- "Theatro App: Check Sales",
21
- "Theatro App: Curbside Pickup",
22
- "Theatro App: Replay last message.",
23
- "Theatro App: Post it. Post it for group"
24
- "Theatro App: Announcement. Announcement for the group",
25
- "Open question: This is about products sold in TractorSupply.",
26
- "Open question: This is about pet care.",
27
- "Open question: What is the weather like?",
28
- "Open question: What's 15% off from $79.99?",
29
- "Open question: Can you look up the skew for 1091784?",
30
- ]
31
 
32
  ref_embeddings = model.encode(ref_texts, convert_to_tensor=True)
33
 
34
  def find_query_type(query):
35
- query_embeddings = model.encode([query], convert_to_tensor=True)
36
- scores = F.cosine_similarity(query_embeddings, ref_embeddings, dim=-1)
37
- max_index = torch.argmax(scores).item()
38
- ref_text = ref_texts[max_index]
39
- query_type = ref_text.split(": ")[0]
40
- return query_type
41
 
42
- import gradio as gr
43
- def predict(query):
44
- query_type = find_query_type(query)
45
- return query_type
46
-
47
- iface = gr.Interface(fn=predict,
48
- inputs=gr.Textbox(lines=2, placeholder="Enter your query here..."),
49
- outputs="text",
50
- title="Query Type Classifier",
51
- description="This model classifies the type of your query. Just input your query and get the predicted category.")
52
 
53
- iface.launch()
 
 
 
 
54
 
 
 
9
 
10
  # Precompute reference embeddings
11
  ref_texts = [
12
+ "Theatro App: Hello John. Hey John. Hi John. Call John",
13
+ "Theatro App: Message John. Message for John. Leave a message for John",
14
+ "Theatro App: Play messages. Listen to messages",
15
+ "Theatro App: What time is it?",
16
+ "Theatro App: What time is it?",
17
+ "Theatro App: Cashier Backup. Backup Cashier. Register backup. Register assistance.",
18
+ "Theatro App: repeat",
19
+ "Theatro App: Check inventory",
20
+ "Theatro App: Check Sales",
21
+ "Theatro App: Curbside Pickup",
22
+ "Theatro App: Replay last message.",
23
+ "Theatro App: Post it. Post it for group"
24
+ "Theatro App: Announcement. Announcement for the group",
25
+ "Open question: This is about products sold in TractorSupply.",
26
+ "Open question: This is about pet care.",
27
+ "Open question: What is the weather like?",
28
+ "Open question: What's 15% off from $79.99?",
29
+ "Open question: Can you look up the skew for 1091784?",
30
+ ]
31
 
32
  ref_embeddings = model.encode(ref_texts, convert_to_tensor=True)
33
 
34
  def find_query_type(query):
35
+ query_embeddings = model.encode([query], convert_to_tensor=True)
36
+ scores = F.cosine_similarity(query_embeddings, ref_embeddings, dim=-1)
37
+ max_index = torch.argmax(scores).item()
38
+ ref_text = ref_texts[max_index]
39
+ query_type = ref_text.split(": ")[0]
40
+ return query_type
41
 
42
+ import gradio as gr
43
+ def predict(query):
44
+ query_type = find_query_type(query)
45
+ return query_type
 
 
 
 
 
 
46
 
47
+ iface = gr.Interface(fn=predict,
48
+ inputs=gr.Textbox(lines=2, placeholder="Enter your query here..."),
49
+ outputs="text",
50
+ title="Query Type Classifier",
51
+ description="This model classifies the type of your query. Just input your query and get the predicted category.")
52
 
53
+ iface.launch()