Skip to content

Production-style intent recognition system: transformer embeddings, multi-model inference (LR/SVC), offline STT, dynamic skill modules, and a full Streamlit demo UI. Fast, modular, and extensible. IN SHORT : Modular intent recognition engine with transformers, ML models, and real-time inference.

Notifications You must be signed in to change notification settings

sagar31joon/Intent_IQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

IntentIQ β€” A Modular Intent Recognition System

IntentIQ is a fully modular, extensible intent recognition engine built for voice and text inputs.
It combines classical ML classifiers, sentence-transformer embeddings, dynamic skill routing, and optional offline speech-to-text using Vosk.

This repository includes:

  • A CLI engine for real-time intent recognition
  • A Streamlit web UI for demo and deployment
  • Trainable, versioned ML models
  • Auto-discovery and auto-generation of skill modules
  • Transformer model caching for offline inference

πŸš€ Features Overview

πŸ”Ή 1. Text & Voice Input Support

  • Text mode: Fully functional in CLI + Streamlit UI
  • Voice mode: Powered by Vosk (offline STT), available only in CLI
  • Online demos disable voice mode due to 2GB Vosk model size

πŸ”Ή 2. Multi-Model Architecture

Supports multiple ML families with versioning:

  • LR (Logistic Regression)
  • SVC (Support Vector Classifier)
  • NeuralNet (Reserved for future expansion)

πŸ”Ή 3. Versioned Models

Every trained model is saved in:

models/intent_models/<MODEL_TYPE>/classifier_vX.pkl
models/intent_models/<MODEL_TYPE>/label_encoder_vX.pkl
models/intent_models/<MODEL_TYPE>/metadata_vX.json

The engine supports:

  • Loading any model type
  • Loading any version
  • Always backward compatible

πŸ”Ή 4. Dynamic Skill Routing

Each predicted intent maps to a Python skill file:

skills/<intent>.py

If a skill does not exist, the router auto-creates a placeholder module:

def run(text):
    print('Placeholder skill executed for intent: <intent>')

πŸ”Ή 5. Offline Transformer Caching

The embedding model all-MiniLM-L6-v2 is downloaded once, saved inside:

models/transformer_model/

Subsequent runs load it instantly without re-downloading.

πŸ”Ή 6. Streamlit Web UI

The UI provides:

  • Model selection (family(model_type) + version)
  • Load Model button
  • Text prediction
  • Probability visualization
  • Fully client-friendly layout for deployment on Render

πŸ“ Project Structure

IntentIQ_Lappy/
β”‚
β”œβ”€β”€ core/
β”‚   β”œβ”€β”€ config.py        # Paths, constants, model directories
β”‚   β”œβ”€β”€ engine.py        # Main CLI engine
β”‚   β”œβ”€β”€ router.py        # Dynamic skill routing
β”‚   └── logger.py        # Logging utilities
β”‚
β”œβ”€β”€ intent_system/
β”‚   β”œβ”€β”€ preprocess.py            # Text cleanup, wake word, fillers, lemmatization
β”‚   β”œβ”€β”€ intent_recognizer.py     # Loads embeddings + classifier
β”‚   β”œβ”€β”€ trainer.py               # Dataset preprocessing, embedding, training
β”‚   β”œβ”€β”€ evaluation.py            # Full evaluation pipeline
β”‚   β”œβ”€β”€ model_handlers.py        # LR, SVC handlers
β”‚   └── ...
β”‚
β”œβ”€β”€ io_layer/
β”‚   β”œβ”€β”€ stt_vosk.py      # Offline speech recognition
β”‚   └── audio_utils.py
β”‚   
β”‚
β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ intent_models/
β”‚   β”‚   β”œβ”€β”€ LR/
β”‚   β”‚   β”œβ”€β”€ SVC/
β”‚   β”‚   └── NeuralNet/   # Coming in Future
β”‚   β”œβ”€β”€ transformer_model/  # Cached transformer
β”‚   └── voice_models/
β”‚
β”œβ”€β”€ ui/
β”‚   β”œβ”€β”€ local_app.py         # streamlit user interface for local machine (includes STT) # Coming in future
β”‚   └── app.py           # Streamlit user interface for deployment
β”‚
β”œβ”€β”€ skills/
β”‚   β”œβ”€β”€ greeting.py
β”‚   β”œβ”€β”€ get_time.py
β”‚   β”œβ”€β”€ weather_query.py
β”‚   β”œβ”€β”€ open_app.py
β”‚   β”œβ”€β”€ general_conversation.py
β”‚   └── exit.py
β”‚
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ ensure_transformer.py
β”‚   └── file_utils.py
β”‚
β”œβ”€β”€ logs/
β”‚   └── intent_iq.log
β”‚
β”œβ”€β”€ dataset/
β”‚   β”œβ”€β”€ dataset_downloader.py       # Can download dataset from hugging face and save as csv file
β”‚   β”œβ”€β”€ EDA.py                      # For Exploratory Data Analysis
β”‚   β”œβ”€β”€ intents2.csv
β”‚   └── intents.csv
β”‚
β”œβ”€β”€ main.py              # CLI entrypoint
└── README.md

🧠 System Architecture (Deep Explanation)

1. Input Layer

βœ” Text Input

Direct string input (CLI or UI)

βœ” Voice Input

Pipeline:

Microphone β†’ RawAudio β†’ VoskSTT β†’ Recognized text β†’ Preprocess β†’ IntentRecognizer

2. Preprocessing Layer

Functions performed:

  • Lowercasing
  • Punctuation cleanup
  • Wake-word detection (β€œlappy”)
  • Filler-word removal (uh, umm, please…)
  • Lemmatization (spaCy optional)

Returns:

(has_wake_word, cleaned_text)

3. Embeddings Layer (Transformer)

Embedding model:
all-MiniLM-L6-v2

Workflow:

Raw text β†’ preprocess β†’ transformer.encode() β†’ 384-dim embedding vector

Caching ensures fast inference offline.


4. Intent Recognition Layer

  • Loads classifier + label encoder for chosen model + version
  • Produces:
intent_label, probability_distribution

5. Router Layer

Maps recognized intent to:

skills/<intent>.py

If missing β†’ auto-created placeholder.

Executes:

run(text)

6. Skills Layer

Simple Python scripts performing actions:

  • greet
  • tell time
  • fetch weather
  • exit system
  • general conversation
  • open apps

Fully extensible.


7. Streamlit UI (Demo Layer)

3 sections:

βœ” 1. Project Information

Explains system functionality.

βœ” 2. Model Selection

User picks:

  • model family (LR/SVC)
  • version (v1/vX)
  • clicks Load Model

βœ” 3. Prediction Panel

User enters text β†’ system outputs:

  • intent
  • probability table
  • real-time data visualition as the model predicts the intents # Coming in Future.

πŸ“Š Training Pipeline

1. Load dataset

dataset/intents.csv

2. Preprocess text

Uses same cleaning pipeline as inference.

3. Encode using transformer

Creates an embedding for each sample.

4. Train using chosen ML handler

  • LR β†’ logistic regression
  • SVC β†’ radial-basis SVM

5. Save artifacts

Classifier, label encoder, metadata.


πŸ§ͺ Evaluation Pipeline

evaluation.py provides:

  • Accuracy
  • Classification report
  • Confusion matrix

πŸ’» Running the CLI Engine

Command:

python3 main.py

Workflow:

  1. Select input mode (voice/text)
  2. Select model family
  3. Select version
  4. System enters real-time inference loop

🌐 Running Streamlit UI

Command:

streamlit run ui/app.py

Available online demo features:

  • Text-only predictions
  • Model selection
  • Intent + probability display + Real-Time Data visualition (coming in future)

Voice mode is disabled for deployment.


πŸš€ Deployment Guide (Render)

1. Create requirements.txt

Include:

streamlit
sentence-transformers
scikit-learn
pandas
joblib
numpy

2. Deploy Streamlit app

Render will:

  • Start the app using streamlit run ui/app.py
  • Provide a public URL
  • You can link this URL in your portfolio

🏁 Future Enhancements

  • NeuralNet classifier support
  • Real skill implementations
  • Live probability charts in UI
  • Task automation integrations
  • Full web-based STT through WebRTC (future)

πŸ™Œ Credits

Built by Sagar Joon.
IntentIQ is designed as a modular showcase of ML engineering, inference systems, and UI integration.

About

Production-style intent recognition system: transformer embeddings, multi-model inference (LR/SVC), offline STT, dynamic skill modules, and a full Streamlit demo UI. Fast, modular, and extensible. IN SHORT : Modular intent recognition engine with transformers, ML models, and real-time inference.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages