Text classification system using a fine-tuned DistilBERT model to predict job categories from natural language descriptions. Built with a FastAPI inference backend and Streamlit frontend.
Given a free-text description of someone's skills, interests, and experience, the model classifies it into one of four job categories: Athlete, Teacher, Construction Worker, or Lawyer.
The model is a DistilBERT transformer fine-tuned for sequence classification using the Hugging Face transformers library.
┌─────────────────┐ POST /predict ┌─────────────────────┐
│ Streamlit UI │ ──────────────────────────▸│ FastAPI Backend │
│ (app.py) │◂──────────────────────────│ (main.py) │
└─────────────────┘ JSON response │ │
│ DistilBERT Model │
│ ┌───────────────┐ │
│ │ Tokenizer │ │
│ │ Classifier │ │
│ │ → argmax │ │
│ └───────────────┘ │
└─────────────────────┘
- FastAPI serves a
/predictendpoint that tokenizes input text, runs inference through the fine-tuned DistilBERT model, and returns the predicted label. - Streamlit provides a browser-based UI where users enter text and see classification results.
The fine-tuned model weights (~260 MB) are not included in this repository due to size. To run the project, you need a fine-tuned DistilBERT checkpoint placed at:
fastapi_app/model/distilbert-finetuned-four-v4/
├── config.json
├── model.safetensors
├── special_tokens_map.json
├── tokenizer_config.json
└── vocab.txt
You can produce this by fine-tuning distilbert-base-uncased for sequence classification on a labeled job-description dataset, or substitute any compatible Hugging Face checkpoint.
cd fastapi_app
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reloadThe API will be available at http://localhost:8000.
cd streamlit_app
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
streamlit run app.pyOpen http://localhost:8501 in your browser.
The classifier was built by fine-tuning DistilBERT (a distilled version of BERT that retains 97% of BERT's language understanding while being 60% faster) on a labeled dataset of job descriptions mapped to four categories. Training used the Hugging Face Trainer API with cross-entropy loss for multi-class classification.
| Component | Technology |
|---|---|
| Model | DistilBERT (fine-tuned) via Hugging Face Transformers |
| Inference | PyTorch + SafeTensors |
| Backend | FastAPI + Uvicorn |
| Frontend | Streamlit |