Arul-Krish
commited on
Commit
·
6f5969f
1
Parent(s):
ce5bba8
first commit
Browse files- README.md +14 -0
- app.py +36 -0
- intent_model.pkl +3 -0
- requirements.txt +3 -0
README.md
CHANGED
|
@@ -10,4 +10,18 @@ pinned: false
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
| 10 |
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Jarvis Intent Classifier (Gradio Space)
|
| 14 |
+
|
| 15 |
+
This Space runs a lightweight CPU-friendly intent detection assistant.
|
| 16 |
+
|
| 17 |
+
Input examples:
|
| 18 |
+
- "increase volume"
|
| 19 |
+
- "open gmail"
|
| 20 |
+
- "restart pc"
|
| 21 |
+
|
| 22 |
+
Output includes predicted intent, response text, and system action.
|
| 23 |
+
|
| 24 |
+
|
| 25 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
| 26 |
+
|
| 27 |
+
|
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pickle, random
|
| 3 |
+
from sentence_transformers import SentenceTransformer
|
| 4 |
+
|
| 5 |
+
# Load model (must be in the same folder)
|
| 6 |
+
with open("intent_model.pkl", "rb") as f:
|
| 7 |
+
data = pickle.load(f)
|
| 8 |
+
|
| 9 |
+
clf = data["classifier"]
|
| 10 |
+
id2label = data["id2label"]
|
| 11 |
+
embedder = SentenceTransformer(data["embed_model"])
|
| 12 |
+
intents_meta = data["intents_meta"]
|
| 13 |
+
|
| 14 |
+
def predict_intent(user_input):
|
| 15 |
+
"""Predict intent and return formatted response."""
|
| 16 |
+
if not user_input.strip():
|
| 17 |
+
return "Please enter a command."
|
| 18 |
+
emb = embedder.encode([user_input])
|
| 19 |
+
pred = clf.predict(emb)[0]
|
| 20 |
+
intent = id2label[pred]
|
| 21 |
+
meta = intents_meta[intent]
|
| 22 |
+
response = random.choice(meta["responses"])
|
| 23 |
+
action = meta["action"]
|
| 24 |
+
return f"🧠 Intent: {intent}\n💬 Response: {response}\n⚙️ Action: {action}"
|
| 25 |
+
|
| 26 |
+
# Gradio interface
|
| 27 |
+
demo = gr.Interface(
|
| 28 |
+
fn=predict_intent,
|
| 29 |
+
inputs=gr.Textbox(label="Enter your command", placeholder="e.g. restart pc, open gmail"),
|
| 30 |
+
outputs=gr.Textbox(label="Jarvis Response"),
|
| 31 |
+
title="🧠 Jarvis Intent Classifier",
|
| 32 |
+
description="Lightweight intent classification model that detects system commands and returns appropriate responses & actions."
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
demo.launch()
|
intent_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3f89de5e99c9fb8e4a476d2827b1f577fe494d305759c139bdd66fa4e7ce1377
|
| 3 |
+
size 356963
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
sentence-transformers
|
| 3 |
+
scikit-learn
|