Skip to content

JuliusScheuerer/nlp-job-classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NLP Job Classifier

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.

Python FastAPI Streamlit HuggingFace PyTorch

Overview

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.

Architecture

┌─────────────────┐       POST /predict       ┌─────────────────────┐
│   Streamlit UI  │ ──────────────────────────▸│   FastAPI Backend   │
│   (app.py)      │◂──────────────────────────│   (main.py)         │
└─────────────────┘       JSON response        │                     │
                                               │  DistilBERT Model   │
                                               │  ┌───────────────┐  │
                                               │  │ Tokenizer     │  │
                                               │  │ Classifier    │  │
                                               │  │ → argmax      │  │
                                               │  └───────────────┘  │
                                               └─────────────────────┘
  • FastAPI serves a /predict endpoint 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.

Setup

1. Model

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.

2. Backend

cd fastapi_app
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
uvicorn main:app --reload

The API will be available at http://localhost:8000.

3. Frontend

cd streamlit_app
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
streamlit run app.py

Open http://localhost:8501 in your browser.

Fine-Tuning Approach

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.

Tech Stack

Component Technology
Model DistilBERT (fine-tuned) via Hugging Face Transformers
Inference PyTorch + SafeTensors
Backend FastAPI + Uvicorn
Frontend Streamlit

About

Text classification with fine-tuned DistilBERT — FastAPI + Streamlit

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages