akshaybabu06 commited on
Commit
5eb4f58
Β·
verified Β·
1 Parent(s): fda85fe
Files changed (1) hide show
  1. README.md +213 -1
README.md CHANGED
@@ -7,4 +7,216 @@ sdk: static
7
  pinned: false
8
  ---
9
 
10
- Edit this `README.md` markdown file to author your organization card.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  pinned: false
8
  ---
9
 
10
+ # Job Description Skill Classifier [JobSelect v0.11.6 & JobAnalyze 6k v1.0] (Multi-Label)
11
+
12
+ [![Python](https://img.shields.io/badge/Python-3.8+-3776AB?style=flat&logo=python)](https://www.python.org/)
13
+ [![PyTorch](https://img.shields.io/badge/PyTorch-2.12.1-%23EE4C2C?style=flat&logo=pytorch)](https://pytorch.org/)
14
+ [![scikit-learn](https://img.shields.io/badge/scikit--learn-1.9.0-F7931E?style=flat&logo=scikit-learn)](https://scikit-learn.org/)
15
+ [![NumPy](https://img.shields.io/badge/NumPy-2.4.6-013243?style=flat&logo=numpy)](https://numpy.org/)
16
+ [![Pandas](https://img.shields.io/badge/Pandas-3.0.3-150458?style=flat&logo=pandas)](https://pandas.pydata.org/)
17
+
18
+ This project builds a lightweight text classification pipeline that predicts **multiple technical skills** from a job posting. Given a job description (optionally augmented with role and job type), the model outputs a ranked list of likely skills.
19
+
20
+ ![JobSelect CLI](./frontend/repo/title_page_jobselect.png)
21
+
22
+ Installation:
23
+
24
+ - `pip install jobselect`
25
+
26
+ It uses:
27
+
28
+ - **TF-IDF** features over the combined text (job description + role + type)
29
+ - A **PyTorch feed-forward neural network** trained as a **multi-label** classifier
30
+ - **Per-skill thresholding** for evaluation and **top-k ranked probabilities** for inference
31
+
32
+ ---
33
+
34
+ ## What it does
35
+
36
+ 1. **Data preparation** (`model/prep/data_prep.py`)
37
+ - Reads cleaned job description data.
38
+ - Normalizes/repairs common skill typos (e.g., `tesnorflow/pytorch` β†’ `tensorflow/pytorch`).
39
+ - Builds a **multi-hot** target vector of skills.
40
+ - Fits a **TF-IDF** vectorizer (with n-grams) and splits into train/test.
41
+ - Saves:
42
+ - `model/prep/prepared_data.npz` (TF-IDF arrays + labels + indexes)
43
+ - `model/prep/vectorizer.pkl` (fitted TF-IDF vectorizer)
44
+ - `model/prep/label_vocab.json` (skill label vocabulary)
45
+
46
+ 2. **Model training** (`model/model.py`)
47
+ - Loads prepared TF-IDF arrays.
48
+ - Defines a simple **MLP**:
49
+ - Linear β†’ ReLU β†’ Dropout β†’ Linear (one logit per skill)
50
+ - Trains with `BCEWithLogitsLoss` (multi-label setting).
51
+ - Saves:
52
+ - `model_out/skill_classifier.pt` (model weights)
53
+ - `model_out/training_history.json` (train/test loss curves)
54
+
55
+ 3. **Evaluation** (`model/eval.py`)
56
+ - Loads the trained model.
57
+ - Applies a fixed sigmoid + threshold (**0.3**) to obtain binary skill predictions.
58
+ - Reports:
59
+ - Per-skill precision/recall/F1
60
+ - Micro-F1 and Macro-F1
61
+ - Compares against a simple baseline (frequency-driven / always-predict-most-frequent labels).
62
+
63
+ 4. **Prediction / Inference** (`model/pred.py`)
64
+ - Loads the TF-IDF vectorizer and trained model.
65
+ - Creates TF-IDF features for the input text.
66
+ - Outputs the **top-k** skills by probability.
67
+
68
+ ---
69
+
70
+ ## Use cases
71
+
72
+ - **Resume/job-post matching** (first-pass filtering of relevant skills)
73
+ - **Job taxonomy building** (discover recurring skills from postings)
74
+ - **Recruiting analytics** (aggregate predicted skill demand by seniority/role/type)
75
+ - **Prototyping multi-label NLP classifiers** (TF-IDF + MLP baseline)
76
+
77
+ ---
78
+
79
+ ## Requirements
80
+
81
+ See `requirements.txt` for the exact dependencies.
82
+
83
+ ---
84
+
85
+ ## Getting started
86
+
87
+ ### 1) Clone and Install dependencies
88
+
89
+ ```bash
90
+ git clone https://github.com/Ak47xdd/Job-Description-Analysis.git
91
+ pip install -r requirements.txt
92
+ ```
93
+
94
+ ### 2) Run data preparation (optional)
95
+
96
+ This builds the TF-IDF features and label vocabulary from the cleaned CSV.
97
+
98
+ ```bash
99
+ python model/prep/data_prep.py
100
+ ```
101
+
102
+ Expected outputs:
103
+
104
+ - `model/prep/prepared_data.npz`
105
+ - `model/prep/vectorizer.pkl`
106
+ - `model/prep/label_vocab.json`
107
+
108
+ ### 3) Train the model (optional)
109
+
110
+ ```bash
111
+ python model/model.py
112
+ ```
113
+
114
+ Expected outputs:
115
+
116
+ - `model_out/skill_classifier.pt`
117
+ - `model_out/training_history.json`
118
+
119
+ ### 4) Evaluate performance (optional)
120
+
121
+ ```bash
122
+ python model/eval.py
123
+ ```
124
+
125
+ Outputs include:
126
+
127
+ - Per-skill metrics (precision/recall/F1)
128
+ - Micro-F1 and Macro-F1
129
+ - Baseline comparison
130
+
131
+ ### 5) Predict skills for a new job description
132
+
133
+ #### Option A: Use Python function (LOCAL model)
134
+
135
+ `from api.pred import JobAnalyze_6k`
136
+
137
+ `data/sample_data/test.txt` contains an example job description inside. Use:
138
+
139
+ ```python
140
+ JobAnalyze_6k(job_desc, role="AI Engineer", job_type="Junior", top_k=50)
141
+ ```
142
+
143
+ #### Option B: Use the interactive CLI (API-first with validation)
144
+
145
+ ```bash
146
+ python -m cli.jobselect
147
+
148
+ # or after install
149
+ pip install jobselect
150
+ jobselect
151
+ ```
152
+
153
+ The CLI:
154
+
155
+ - prompts for **Job Description**, **Role**, and **Type**
156
+ - validates them via the API schema when running in API mode
157
+ - prints the top skills ranked by probability
158
+
159
+ ---
160
+
161
+ #### Option C: Get Predictions through API (recommended)
162
+
163
+ Currently, the API service is under development, you could press `Enter` on first screen:
164
+
165
+ - The CLI will always prompt the user for an API Key, press `Enter` to skip to LOCAL Mode
166
+
167
+ ![JobSelect CLI](./frontend/repo/mode_selection_jobselect.png)
168
+
169
+ #### Option D: Call the FastAPI service (optional)
170
+
171
+ Run `api/JobAnalyze_API.py`. Requests must include:
172
+
173
+ - header `JobAnalyze_6k_Key` with a valid API key
174
+ - JSON body with `Job_Desc`, `Role`, and `Type` (validated via Pydantic)
175
+
176
+ ---
177
+
178
+ ## How predictions work
179
+
180
+ - Text is concatenated as:
181
+ `"{job_desc} {role} {job_type}"`
182
+ - TF-IDF transforms text into a fixed-size vector
183
+ - The network outputs one logit per skill
184
+ - Sigmoid converts logits β†’ probabilities
185
+ - Skills are ranked by probability and the top-k are returned
186
+
187
+ ---
188
+
189
+ ## Important implementation notes
190
+
191
+ - **Multi-label learning:** Each skill is treated independently (binary relevance via sigmoid + `BCEWithLogitsLoss`).
192
+ - **Evaluation threshold:** `model/eval.py` uses a fixed threshold of **0.3**. For production use, you may want per-label thresholds tuned on a validation set.
193
+ - **Dataset size:** The included notebooks and evaluation code suggest the dataset may be small; results can be limited by label frequency and data coverage.
194
+
195
+ ---
196
+
197
+ ## New features / capabilities
198
+
199
+ - **Rich terminal CLI** (`cli/jobselect.py`) using `rich` + `pyfiglet` for interactive top-skill display.
200
+ - **API validation + schema enforcement**
201
+ - Input validation via **Pydantic** model constraints in `api/JobAnalyze_API.py`.
202
+ - API key auth via header + secure verification, with optional Supabase-backed storage in `api/supabase_client.py`.
203
+ - CLI mode auto-detection (`cli/api_val.py` + `cli/model_select.py`): uses API when a key is available, otherwise falls back to local inference.
204
+ - **Synonym/phrase normalization hook** (`model/prep/sym_map.py`) applied during data preparation.
205
+ - **Pipeline runner** (`pipeline.py`) to execute notebooks and training steps in sequence.
206
+
207
+ ---
208
+
209
+ ## Customization ideas
210
+
211
+ - Improve text cleaning and skill normalization in `data_prep.py`
212
+ - Tune TF-IDF parameters (`max_features`, `ngram_range`, `min_df`)
213
+ - Replace the simple MLP with a stronger baseline (e.g., logistic regression on TF-IDF)
214
+ - Calibrate thresholds per label using validation data
215
+ - Add a CLI or web service endpoint for prediction
216
+
217
+ ---
218
+
219
+ ## References / Inspiration
220
+
221
+ This repository follows a common pattern for multi-label NLP baselines:
222
+ TF-IDF features + a simple neural network + sigmoid-based multi-label outputs.