https://github.com/t-abishek/embedded-intent-classifier
A production-grade FastAPI application that uses sentence embeddings to classify user prompts into 4 categories: Built using Python, BGE SentenceTransformer, Scikit-learn, and FastAPI.
https://github.com/t-abishek/embedded-intent-classifier
classifier embedded huggingface pandas scikit-learn transformer
Last synced: about 1 month ago
JSON representation
A production-grade FastAPI application that uses sentence embeddings to classify user prompts into 4 categories: Built using Python, BGE SentenceTransformer, Scikit-learn, and FastAPI.
- Host: GitHub
- URL: https://github.com/t-abishek/embedded-intent-classifier
- Owner: T-ABISHEK
- Created: 2025-04-01T12:34:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-01T12:40:54.000Z (about 1 year ago)
- Last Synced: 2025-04-01T13:34:58.940Z (about 1 year ago)
- Topics: classifier, embedded, huggingface, pandas, scikit-learn, transformer
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
๐ค Embedded Intent Classifier
A FastAPI application that uses **sentence embeddings** to classify user prompts into 4 categories:
1. Search-based (e.g. weather, time, news)
2. Math-based queries
3. Casual conversation
4. Image generation prompts
Built using **Python**, **BGE SentenceTransformer**, **Scikit-learn**, and **FastAPI**.
---
๐ Features
- BGE Embeddings via `sentence-transformers`
- Random Forest Classifier
- REST API using FastAPI
- JSON response with label predictions
---
---
๐ฆ Installation
```bash
git clone https://github.com/T-ABISHEK/Embedded-Intent-Classifier.git
cd Embedded-Intent-Classifier
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate (Windows)
pip install -r requirements.txt
```
---
๐ Prepare Dataset
Create a `data/labeled_prompts.csv` like:
```csv
prompt,label
"What's the weather like today?",1
"What is 7 multiplied by 8?",2
"Tell me a joke.",3
"Generate an image of a cyberpunk city",4
```
---
๐งช Train the Model
```bash
python main.py
```
This saves the model to `model/classifier.pkl`
---
๐ Run the API
```bash
uvicorn api:app --reload
```
Then open: [http://localhost:8000/docs](http://localhost:8000/docs) for Swagger UI
---
๐ฌ Sample Prediction
```json
POST /predict
{
"text": "What is the current time in London?"
}
Response:
{
"label": 1
}
```