Rogendo commited on
Commit
459ef90
·
verified ·
1 Parent(s): e7cf006

Upload Multi-task classification model

Browse files
README.md ADDED
@@ -0,0 +1,618 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: text-classification
5
+ tags:
6
+ - distilbert
7
+ - multi-task-learning
8
+ - call-center-analytics
9
+ - child-helplines
10
+ - case-classification
11
+ - crisis-support
12
+ - social-impact
13
+ - east-africa
14
+ language:
15
+ - en
16
+ - sw
17
+ datasets:
18
+ - custom
19
+ metrics:
20
+ - accuracy
21
+ - f1
22
+ - precision
23
+ - recall
24
+ model-index:
25
+ - name: CHS_tz_classifier_distilbert
26
+ results:
27
+ - task:
28
+ type: text-classification
29
+ name: Multi-Task Case Classification
30
+ metrics:
31
+ - type: accuracy
32
+ value: 0.75
33
+ name: Overall Average Accuracy
34
+ - type: accuracy
35
+ value: 0.833
36
+ name: Main Category Accuracy
37
+ widget:
38
+ - text: "Hello, I've been trying to find help for my son Ken. He's only ten years old and he's been going through a terrible time at school. There's this boy who keeps harassing him. It started with name-calling and teasing, but it's escalated to physical violence. I don't know what to do. I can't bear to see my child suffer like this."
39
+ example_title: "School Bullying Case"
40
+ - text: "On November 15th, the helpline received a call from a 17-year-old who wanted to understand why drug use among youth is harmful. The counselor explained the physical, social, and legal risks involved with drug abuse."
41
+ example_title: "Youth Drug Education"
42
+ ---
43
+
44
+ # DistilBERT Multi-Task Classifier for Child Helpline Case Management
45
+
46
+ ## Model Description
47
+
48
+ This is a fine-tuned **DistilBERT-base-uncased** model designed for **multi-task classification of child helpline and call center transcripts**. Developed by **BITZ IT Consulting** as part of the **OpenCHS AI pipeline** for child helplines and crisis support services in East Africa.
49
+ Speed and accuracy at resolving and reporting the cases matters, this finetuned model offers both.
50
+
51
+ ## Model Architecture
52
+
53
+ - **Base Model**: DistilBERT (distilbert-base-uncased)
54
+ - **Architecture**: Multi-task classifier with 4 specialized output heads
55
+ - **Input**: Call center/helpline transcripts (max 256 tokens)
56
+ - **Output**: Classifications across 4 distinct tasks
57
+ - **Training**: Multi-task learning with shared DistilBERT encoder
58
+
59
+ ## Classification Tasks
60
+
61
+ The model performs simultaneous classification across four critical dimensions:
62
+
63
+ | Task | Classes | Count | Purpose |
64
+ |------|---------|--------|---------|
65
+ | **Main Category** | Advice & Counselling, Child Custody, Disability, GBV, VANE, Nutrition, Information | 6 | High-level case categorization |
66
+ | **Sub Category** | Adoption, Albinism, Balanced Diet, Birth Registration, Child Abuse, etc. | 43 | Detailed topic identification |
67
+ | **Intervention** | Referred, Counselling, Signposting, Awareness/Information | 4 | Recommended action type |
68
+ | **Priority** | Low (1), Medium (2), High (3) | 3 | Urgency level for escalation |
69
+
70
+ ## Performance Metrics
71
+
72
+ ### Overall Performance
73
+ - **Average Accuracy**: 75.0%
74
+ - **Best Performing Task**: Main Category (83.33%)
75
+ - **Most Challenging Task**: Sub Category (41.67%)
76
+
77
+ ### Detailed Task Performance
78
+
79
+ | Task | Accuracy | Precision | Recall | F1-Score | Performance Level |
80
+ |------|----------|-----------|---------|----------|------------------|
81
+ | **Main Category** | 83.33% | High | High | 0.762 | Excellent |
82
+ | **Priority** | 75.00% | 0.505 | Variable | 0.711 | Good |
83
+ | **Intervention** | 75.00% | Variable | Variable | 0.695 | Good |
84
+ | **Sub Category** | 41.67% | Low | Variable | 0.382 | Needs Improvement |
85
+
86
+ ### Task-Specific Analysis
87
+
88
+ **Main Category Performance:**
89
+ - **Excellent Classes**: Information (F1: 0.909), Child Maintenance & Custody (F1: 1.000), Nutrition (F1: 1.000)
90
+ - **Challenging Classes**: VANE (F1: 0.000) - requires more training data
91
+ - **Overall**: Strong performance with 5/6 categories well-represented
92
+
93
+ **Sub Category Performance:**
94
+ - **Perfect Classes**: Balanced Diet, Maintenance, Relationships (Parent/Child)
95
+ - **Challenging Areas**: Sexual & Reproductive Health, Child Labor, Drug/Alcohol Abuse
96
+ - **Note**: Performance varies significantly due to class imbalance (10/43 classes in test data)
97
+
98
+ **Priority Classification:**
99
+ - **High Accuracy on Low/Medium Priority**: Priority 1 (F1: 0.833), Priority 2 (F1: 0.727)
100
+ - **Challenge with High Priority**: Priority 3 cases need more representation
101
+ - **Critical for Routing**: Essential for proper case escalation
102
+
103
+ **Intervention Recommendations:**
104
+ - **Strong Performance**: Professional counseling (F1: 0.842)
105
+ - **Room for Improvement**: "No intervention needed" category (F1: 0.400)
106
+ - **Operational Impact**: Directly guides case worker actions
107
+
108
+ ## Model Usage
109
+
110
+ ### Installation
111
+
112
+ ```bash
113
+ pip install transformers torch numpy
114
+ ```
115
+
116
+ ### Model Classes
117
+
118
+ ```python
119
+ import torch
120
+ import torch.nn as nn
121
+ from transformers import DistilBertModel, DistilBertPreTrainedModel, AutoTokenizer
122
+ import json
123
+ import re
124
+ import numpy as np
125
+
126
+ class MultiTaskDistilBert(DistilBertPreTrainedModel):
127
+ """
128
+ Multi-task DistilBERT classifier for child helpline case management.
129
+
130
+ Performs simultaneous classification across 4 tasks:
131
+ - Main category classification
132
+ - Sub-category classification
133
+ - Intervention recommendation
134
+ - Priority assignment
135
+ """
136
+
137
+ def __init__(self, config, num_main, num_sub, num_interv, num_priority):
138
+ super().__init__(config)
139
+ self.distilbert = DistilBertModel(config)
140
+ self.pre_classifier = nn.Linear(config.dim, config.dim)
141
+
142
+ # Task-specific classification heads
143
+ self.classifier_main = nn.Linear(config.dim, num_main)
144
+ self.classifier_sub = nn.Linear(config.dim, num_sub)
145
+ self.classifier_interv = nn.Linear(config.dim, num_interv)
146
+ self.classifier_priority = nn.Linear(config.dim, num_priority)
147
+
148
+ self.dropout = nn.Dropout(config.dropout)
149
+ self.init_weights()
150
+
151
+ def forward(self, input_ids=None, attention_mask=None,
152
+ main_category_id=None, sub_category_id=None,
153
+ intervention_id=None, priority_id=None):
154
+
155
+ # Shared DistilBERT encoder
156
+ distilbert_output = self.distilbert(
157
+ input_ids=input_ids,
158
+ attention_mask=attention_mask,
159
+ return_dict=True
160
+ )
161
+
162
+ # Feature extraction and processing
163
+ hidden_state = distilbert_output.last_hidden_state
164
+ pooled_output = hidden_state[:, 0] # [CLS] token
165
+ pooled_output = self.pre_classifier(pooled_output)
166
+ pooled_output = nn.ReLU()(pooled_output)
167
+ pooled_output = self.dropout(pooled_output)
168
+
169
+ # Multi-task predictions
170
+ logits_main = self.classifier_main(pooled_output)
171
+ logits_sub = self.classifier_sub(pooled_output)
172
+ logits_interv = self.classifier_interv(pooled_output)
173
+ logits_priority = self.classifier_priority(pooled_output)
174
+
175
+ # Multi-task loss calculation (training only)
176
+ loss = None
177
+ if main_category_id is not None:
178
+ loss_fct = nn.CrossEntropyLoss()
179
+ loss_main = loss_fct(logits_main, main_category_id)
180
+ loss_sub = loss_fct(logits_sub, sub_category_id)
181
+ loss_interv = loss_fct(logits_interv, intervention_id)
182
+ loss_priority = loss_fct(logits_priority, priority_id)
183
+ loss = loss_main + loss_sub + loss_interv + loss_priority
184
+
185
+ # Return format compatible with Trainer
186
+ if loss is not None:
187
+ return (loss, logits_main, logits_sub, logits_interv, logits_priority)
188
+ else:
189
+ return (logits_main, logits_sub, logits_interv, logits_priority)
190
+ ```
191
+
192
+ ### Complete Usage Example
193
+
194
+ ```python
195
+ from transformers import AutoTokenizer
196
+ from huggingface_hub import hf_hub_download
197
+ import torch
198
+ import json
199
+ import re
200
+ import numpy as np
201
+
202
+ # Model setup
203
+ MODEL_NAME = "openchs/cls-gbv-distilbert-v1"
204
+
205
+ # Load tokenizer
206
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
207
+
208
+ # Load label mappings
209
+ main_categories = json.load(open(hf_hub_download(MODEL_NAME, "main_categories.json")))
210
+ sub_categories = json.load(open(hf_hub_download(MODEL_NAME, "sub_categories.json")))
211
+ interventions = json.load(open(hf_hub_download(MODEL_NAME, "interventions.json")))
212
+ priorities = json.load(open(hf_hub_download(MODEL_NAME, "priorities.json")))
213
+
214
+ # Initialize model
215
+ model = MultiTaskDistilBert.from_pretrained(
216
+ MODEL_NAME,
217
+ num_main=len(main_categories),
218
+ num_sub=len(sub_categories),
219
+ num_interv=len(interventions),
220
+ num_priority=len(priorities)
221
+ )
222
+
223
+ # Set device
224
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
225
+ model = model.to(device)
226
+ model.eval()
227
+
228
+ def classify_multitask_case(narrative: str):
229
+ """
230
+ Classify a helpline case narrative across all task dimensions.
231
+
232
+ Args:
233
+ narrative (str): The case narrative/transcript text
234
+
235
+ Returns:
236
+ dict: Classifications for all four tasks with confidence scores
237
+ """
238
+
239
+ # Text preprocessing
240
+ text = narrative.lower().strip()
241
+ text = re.sub(r'[^a-z0-9\s]', '', text) # Remove special characters
242
+
243
+ # Tokenization
244
+ inputs = tokenizer(
245
+ text,
246
+ truncation=True,
247
+ padding="max_length",
248
+ max_length=256,
249
+ return_tensors="pt"
250
+ ).to(device)
251
+
252
+ # Inference
253
+ with torch.no_grad():
254
+ logits_main, logits_sub, logits_interv, logits_priority = model(**inputs)
255
+
256
+ # Convert logits to probabilities
257
+ probs_main = torch.softmax(logits_main, dim=1).cpu().numpy()[0]
258
+ probs_sub = torch.softmax(logits_sub, dim=1).cpu().numpy()[0]
259
+ probs_interv = torch.softmax(logits_interv, dim=1).cpu().numpy()[0]
260
+ probs_priority = torch.softmax(logits_priority, dim=1).cpu().numpy()[0]
261
+
262
+ # Get predictions (argmax)
263
+ pred_main = int(np.argmax(probs_main))
264
+ pred_sub = int(np.argmax(probs_sub))
265
+ pred_interv = int(np.argmax(probs_interv))
266
+ pred_priority = int(np.argmax(probs_priority))
267
+
268
+ return {
269
+ "main_category": {
270
+ "label": main_categories[pred_main],
271
+ "confidence": float(probs_main[pred_main])
272
+ },
273
+ "sub_category": {
274
+ "label": sub_categories[pred_sub],
275
+ "confidence": float(probs_sub[pred_sub])
276
+ },
277
+ "intervention": {
278
+ "label": interventions[pred_interv],
279
+ "confidence": float(probs_interv[pred_interv])
280
+ },
281
+ "priority": {
282
+ "label": priorities[pred_priority],
283
+ "confidence": float(probs_priority[pred_priority])
284
+ }
285
+ }
286
+
287
+ # Example usage
288
+ narrative = """
289
+ Hello, I've been trying to find help for my son Ken. He's only ten years old and
290
+ he's been going through a terrible time at school. There's this boy, James, who
291
+ keeps harassing him. It started with name-calling and teasing, but it's escalated
292
+ to physical violence. I don't know what to do. I can't bear to see my child suffer like this.
293
+ """
294
+
295
+ result = classify_multitask_case(narrative)
296
+ print(json.dumps(result, indent=2))
297
+ ```
298
+
299
+ **Expected Output:**
300
+ ```json
301
+ {
302
+ "main_category": {
303
+ "label": "Advice and Counselling",
304
+ "confidence": 0.85
305
+ },
306
+ "sub_category": {
307
+ "label": "School Related Issues",
308
+ "confidence": 0.72
309
+ },
310
+ "intervention": {
311
+ "label": "Counselling",
312
+ "confidence": 0.68
313
+ },
314
+ "priority": {
315
+ "label": 2,
316
+ "confidence": 0.91
317
+ }
318
+ }
319
+ ```
320
+
321
+ ### FastAPI Integration
322
+
323
+ ```python
324
+ from fastapi import FastAPI, HTTPException
325
+ from pydantic import BaseModel
326
+ from typing import Optional
327
+ import time
328
+
329
+ app = FastAPI(title="Child Helpline Case Classification API")
330
+
331
+ class CaseInput(BaseModel):
332
+ narrative: str
333
+ include_confidence: Optional[bool] = True
334
+
335
+ @app.post("/classify")
336
+ async def classify_case(input_data: CaseInput):
337
+ try:
338
+ start_time = time.time()
339
+ result = classify_multitask_case(input_data.narrative)
340
+ processing_time = time.time() - start_time
341
+
342
+ response = {
343
+ "success": True,
344
+ "classification": result,
345
+ "processing_time_seconds": round(processing_time, 4)
346
+ }
347
+
348
+ if not input_data.include_confidence:
349
+ # Remove confidence scores if not requested
350
+ for task in result:
351
+ if isinstance(result[task], dict):
352
+ result[task] = result[task]["label"]
353
+
354
+ return response
355
+
356
+ except Exception as e:
357
+ raise HTTPException(status_code=500, detail=str(e))
358
+
359
+ @app.get("/health")
360
+ async def health_check():
361
+ return {"status": "healthy", "model": MODEL_NAME}
362
+ ```
363
+
364
+ ## Training Details
365
+
366
+ ### Training Data
367
+ - **Total Dataset**: 12,909 augmented helpline call transcripts
368
+ - **Real Data**: 993 anonymized helpline calls
369
+ - **Synthetic Data**: N/A
370
+ - **Languages**: Primarily English
371
+ - **Domain**: Child protection, family services, crisis support
372
+
373
+ ### Data Distribution
374
+ - **Main Categories**: Balanced across 6 primary case types
375
+ - **Sub Categories**: Long-tail distribution with 43 specific topics
376
+ - **Interventions**: 4 different action types based on case severity
377
+ - **Priority Levels**: 3 levels (Low, Medium, High) for case escalation
378
+
379
+ ### Training Configuration
380
+ - **Base Model**: distilbert-base-uncased
381
+ - **Optimizer**: AdamW (lr=2e-5)
382
+ - **Loss Function**: Combined CrossEntropyLoss across all tasks
383
+ - **Batch Size**: 16
384
+ - **Max Length**: 512 tokens
385
+ - **Epochs**: 12
386
+ - **Weight Decay**: 0.01
387
+ - **Hardware**: NVIDIA GeForce RTX 4060
388
+
389
+ ### Multi-Task Learning Approach
390
+ - **Shared Encoder**: Single DistilBERT backbone for all tasks
391
+ - **Task-Specific Heads**: Dedicated classification layers per task
392
+ - **Joint Training**: Simultaneous optimization across all objectives
393
+ - **Loss Weighting**: Equal weighting across all four tasks
394
+
395
+ ## Social Impact and Applications
396
+
397
+ ### Primary Use Cases
398
+ - **Automated Case Routing**: Instant classification and priority assignment
399
+ - **Supervisor Support**: Reduces manual case categorization workload
400
+ - **Quality Assurance**: Consistent classification standards across all calls
401
+ - **Resource Allocation**: Priority-based staffing and intervention planning
402
+
403
+ ### Operational Benefits
404
+ - **Scalability**: Handle thousands of cases without manual intervention
405
+ - **Consistency**: Eliminate human bias in case classification
406
+ - **Speed**: Real-time classification for immediate case routing
407
+ - **Insights**: Data-driven understanding of case patterns and trends
408
+
409
+ ### Target Organizations
410
+ - **Child Helplines**: 116 services across East Africa
411
+ - **Crisis Support Services**: Mental health and emergency hotlines
412
+ - **Family Support Centers**: Case management and intervention planning
413
+ - **NGOs and Government Agencies**: Child protection and welfare services
414
+
415
+ ## Limitations and Considerations
416
+
417
+ ### Performance Limitations
418
+ - **Sub-Category Challenge**: 41.67% accuracy indicates need for more balanced training data
419
+ - **Class Imbalance**: Some categories have limited representation in training data
420
+ - **Context Length**: Limited to 512 tokens may truncate longer narratives
421
+ - **Language Bias**: Primarily trained on English
422
+
423
+ ### Operational Considerations
424
+ - **Human Oversight**: Critical cases should always involve human review
425
+ - **Confidence Thresholds**: Low-confidence predictions should trigger manual review
426
+ - **Regular Retraining**: Model performance may degrade without periodic updates
427
+ - **Cultural Context**: Model may not capture all cultural nuances in case presentation
428
+
429
+ ### Ethical Considerations
430
+ - **Privacy**: All training data anonymized with strict PII removal
431
+ - **Bias Monitoring**: Regular evaluation for demographic and linguistic bias
432
+ - **Transparency**: Clear documentation of model limitations and appropriate use
433
+ - **Child Safety**: Special protocols for high-priority cases involving immediate danger
434
+
435
+ ## Integration Pipeline
436
+
437
+ The model is designed to integrate seamlessly into larger AI pipelines:
438
+
439
+ 1. **ASR (Whisper)** → Transcribes call audio to text
440
+ 2. **Text Preprocessing** → Cleans and normalizes transcript
441
+ 3. **MultiTask Classification** → Categorizes and prioritizes case
442
+ 4. **NER** → Extracts Entities
443
+
444
+ 5. **Case Management System** → Routes to appropriate classes
445
+ 6. **Quality Assurance** → Tracks outcomes and model performance
446
+
447
+ ## Model Maintenance
448
+
449
+ ### Performance Monitoring
450
+ - **Accuracy Tracking**: Monitor per-task performance over time
451
+ - **Confidence Analysis**: Track prediction confidence distributions
452
+ - **Edge Case Detection**: Identify cases requiring manual review
453
+ - **Feedback Loop**: Incorporate corrected predictions into retraining data
454
+
455
+ ### Update Schedule
456
+ - **Monthly Reviews**: Performance metrics and edge case analysis
457
+ - **Quarterly Retraining**: Incorporate new data and correct classification errors
458
+ - **Annual Model Refresh**: Major architecture updates and comprehensive evaluation
459
+
460
+ ## Citation
461
+
462
+ ```bibtex
463
+ @software{chs_distilbert_multitask_2025,
464
+ title={DistilBERT Multi-Task Classifier for Child Helpline Case Management},
465
+ author={BITZ IT Consulting Team},
466
+ year={2025},
467
+ publisher={Hugging Face},
468
+ journal={Hugging Face Model Hub},
469
+ howpublished={\url{https://huggingface.co/openchs/cls-gbv-distilbert-v1}},
470
+ note={AI for Social Impact: Automated Case Classification for Child Protection Services}
471
+ }
472
+ ```
473
+
474
+ ## Model Examination
475
+
476
+ ### Interpretability Analysis
477
+
478
+ The model's multi-task architecture allows for analysis of shared vs. task-specific representations:
479
+
480
+ - **Shared Features**: The DistilBERT encoder captures general linguistic patterns useful across all classification tasks
481
+ - **Task-Specific Heads**: Each classification head specializes in different aspects of case analysis
482
+ - **Attention Patterns**: The model shows higher attention to key phrases indicating urgency, relationship dynamics, and specific issues
483
+ - **Feature Importance**: Critical terms include age indicators, relationship descriptors, emotion words, and action verbs
484
+
485
+ ### Error Analysis
486
+
487
+ Common misclassification patterns:
488
+ - **Sub-Category Confusion**: Model sometimes confuses related sub-categories (e.g., different types of abuse)
489
+ - **Priority Assignment**: Conservative bias toward lower priority ratings for borderline cases
490
+ - **Intervention Selection**: Tendency to recommend counselling over more specific interventions
491
+
492
+ ## Environmental Impact
493
+
494
+ Carbon emissions estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute):
495
+
496
+ - **Hardware Type**: NVIDIA GeForce RTX 4060 Ti
497
+ - **Hours used**: ~1 hrs total training time
498
+ - **Cloud Provider**: N/A (Local training)
499
+ - **Compute Region**: East Africa (Kenya)
500
+ - **Carbon Emitted**: Approximately 150-200 g CO2eq
501
+
502
+ *Training was conducted locally to minimize environmental impact and ensure data privacy for sensitive helpline transcripts.*
503
+
504
+ ## Technical Specifications
505
+
506
+ ### Model Architecture and Objective
507
+
508
+ - **Architecture**: Multi-head DistilBERT with shared encoder and task-specific classification heads
509
+ - **Parameters**: ~67M total parameters
510
+ - **Objective**: Multi-task classification with joint Cross-Entropy loss optimization
511
+ - **Input Processing**: Text normalization, tokenization with 512-token limit
512
+ - **Output**: Simultaneous predictions across 4 classification tasks
513
+
514
+ ### Compute Infrastructure
515
+
516
+ #### Hardware
517
+ - **GPU**: NVIDIA GeForce RTX 4060 (16GB VRAM)
518
+ - **CPU**: Intel/AMD multi-core processor
519
+ - **RAM**: 32GB+ system memory
520
+ - **Storage**: SSD for fast data loading
521
+
522
+ #### Software
523
+ - **Framework**: PyTorch 2.0+
524
+ - **Library**: Transformers 4.30+
525
+ - **Training**: Hugging Face Trainer API
526
+ - **Tracking**: MLflow for experiment management
527
+ - **Development**: Python 3.12+, CUDA 11.8
528
+
529
+ ### Performance Benchmarks
530
+
531
+ #### Inference Speed
532
+ - **Single prediction**: ~0.05 seconds on GPU
533
+ - **Batch processing**: ~200 cases/minute on GPU
534
+ - **Model size**: ~270MB on disk
535
+ - **Memory usage**: ~1GB GPU memory during inference
536
+
537
+ #### Throughput Specifications
538
+ - **Training throughput**: ~40 samples/second
539
+ - **Inference latency**: 50ms average per case
540
+ - **Scalability**: Can handle 10,000+ cases/hour on single GPU
541
+
542
+ ## Testing Data, Factors & Metrics
543
+
544
+ ### Testing Data
545
+ - **Size**: 12 test samples (stratified split)
546
+ - **Distribution**: Representative of real helpline case types
547
+ - **Languages**: Primarily English with some Swahili terms
548
+ - **Anonymization**: All PII removed, location/name placeholders used
549
+
550
+ ### Factors
551
+ Evaluation disaggregated by:
552
+ - **Case complexity**: Simple vs. complex multi-issue cases
553
+ - **Urgency level**: Low, medium, high priority cases
554
+ - **Category type**: Different main category distributions
555
+ - **Text length**: Short vs. long narrative descriptions
556
+
557
+ ### Metrics
558
+ - **Primary**: Accuracy per task (exact match)
559
+ - **Secondary**: Precision, Recall, F1-score per class
560
+ - **Aggregate**: Weighted average across all tasks
561
+ - **Operational**: Classification confidence scores
562
+
563
+ ## Glossary
564
+
565
+ **Main Category**: High-level case classification (6 classes) used for initial routing and reporting
566
+
567
+ **Sub Category**: Detailed topic identification (43 classes) for specific issue targeting and resource allocation
568
+
569
+ **Intervention**: Recommended action type (22 classes) guiding case worker response and follow-up procedures
570
+
571
+ **Priority**: Urgency level (3 levels) determining response timeframe and resource allocation
572
+
573
+ **Multi-task Learning**: Training approach where model learns multiple related tasks simultaneously using shared representations
574
+
575
+ **PII**: Personally Identifiable Information - any data that could identify specific individuals, systematically removed from training data
576
+
577
+ **Case Routing**: Automated process of directing cases to appropriate teams based on classification results
578
+
579
+ ## More Information
580
+
581
+ ### Related Models
582
+ This model is part of a larger AI pipeline including:
583
+ - **ASR Model**: Whisper-based speech recognition for call transcription
584
+ - **QA Scoring Model**: Multi-head quality assurance evaluation (Rogendo/qa-helpline-distilbert-v1)
585
+ - **Translation Model**: Helsinki/opus-mt models for multilingual support
586
+ - **Summarization Model**: FLAN-based transcript summarization
587
+
588
+ ### Research Applications
589
+ - Child protection service optimization
590
+ - Crisis intervention system design
591
+ - Multilingual helpline support research
592
+ - AI ethics in sensitive domain applications
593
+
594
+ ### Future Development
595
+ - **Language Expansion**: Additional East African languages
596
+ - **Performance Improvement**: Address sub-category classification challenges
597
+ - **Real-time Integration**: Stream processing capabilities
598
+ - **Federated Learning**: Privacy-preserving multi-organization training
599
+
600
+ ## Model Card Authors
601
+
602
+ - **Rogendo** (Lead Developer) - Data Engineering, Model Architecture, Training Implementation
603
+ - **Shemmiriam** (Data Analyst) - Dataset Analysis, Performance Evaluation, Metrics Design
604
+ - **Nelsonadagi** (Quality Assurance) - Model Testing, Validation, Edge Case Analysis
605
+ - **BITZ IT Consulting Team** (Collaborative Development) - Social Impact Design, Ethical Guidelines
606
+
607
+ ## Model Card Contact
608
+
609
+ **Primary Contact**: peter.rogendo@bitz-itc.com
610
+ **Organization**: BITZ IT Consulting
611
+ **Support**: Technical questions and collaboratifzon inquiries welcome
612
+ **Repository Issues**: https://huggingface.co/openchs/cls-gbv-distilbert-v1/discussions
613
+
614
+ ---
615
+
616
+ **Technology for Child Protection and Crisis Support**
617
+
618
+ *This model is part of a comprehensive AI pipeline designed to improve response times and service quality for vulnerable children and families across East Africa. Every classification helps ensure that children in need receive appropriate and timely support.*
config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "distilbert-base-uncased",
3
+ "architectures": [
4
+ "MultiTaskDistilBert"
5
+ ],
6
+ "model_type": "distilbert",
7
+ "custom_model": true,
8
+ "num_main_labels": 6,
9
+ "num_sub_labels": 43,
10
+ "num_intervention_labels": 22,
11
+ "num_priority_labels": 3,
12
+ "dropout": 0.2,
13
+ "max_position_embeddings": 512,
14
+ "vocab_size": 30522
15
+ }
interventions.json ADDED
@@ -0,0 +1 @@
 
 
1
+ ["Adoption", "Application for judicial orders", "Child maintenance", "Committed to statutory institution", "Family support", "Foster care", "Joint parental agreement (Parental Responsibility Agreement - PRA)", "Kinship Care", "Legal aid", "No intervention needed", "Placement in school/(Enrolment)", "Professional counseling", "Reconciliation", "Referred to Court/Kadhi", "Referred to other Government agencies", "Referred to other non-state agencies", "Reintegration", "Release to parent(s)/Caregiver(s)", "Rescue and placement", "Reunification", "Revocation of children\u2019s committal order", "Supervision without court order (Diversion)"]
main_categories.json ADDED
@@ -0,0 +1 @@
 
 
1
+ ["Advice and Counselling", "Child Maintenance & Custody", "Disability", "Information", "Nutrition", "VANE"]
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6cc1ecc410c8bb1083525ccf0e7add1c155422c5378c11fc0be5990c125ae19
3
+ size 268054568
modeling.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import torch
3
+ import torch.nn as nn
4
+ from transformers import DistilBertModel, DistilBertPreTrainedModel
5
+
6
+ class MultiTaskDistilBert(DistilBertPreTrainedModel):
7
+ """
8
+ Multi-task DistilBERT classifier for child helpline case management.
9
+
10
+ Performs simultaneous classification across 4 tasks:
11
+ - Main category classification
12
+ - Sub-category classification
13
+ - Intervention recommendation
14
+ - Priority assignment
15
+ """
16
+
17
+ def __init__(self, config):
18
+ super().__init__(config)
19
+ self.distilbert = DistilBertModel(config)
20
+ self.pre_classifier = nn.Linear(config.dim, config.dim)
21
+
22
+ # Task-specific classification heads
23
+ self.classifier_main = nn.Linear(config.dim, config.num_main_labels)
24
+ self.classifier_sub = nn.Linear(config.dim, config.num_sub_labels)
25
+ self.classifier_interv = nn.Linear(config.dim, config.num_intervention_labels)
26
+ self.classifier_priority = nn.Linear(config.dim, config.num_priority_labels)
27
+
28
+ self.dropout = nn.Dropout(config.dropout)
29
+ self.init_weights()
30
+
31
+ def forward(self, input_ids=None, attention_mask=None,
32
+ main_category_id=None, sub_category_id=None,
33
+ intervention_id=None, priority_id=None):
34
+
35
+ # Shared DistilBERT encoder
36
+ distilbert_output = self.distilbert(
37
+ input_ids=input_ids,
38
+ attention_mask=attention_mask,
39
+ return_dict=True
40
+ )
41
+
42
+ # Feature extraction and processing
43
+ hidden_state = distilbert_output.last_hidden_state
44
+ pooled_output = hidden_state[:, 0] # [CLS] token
45
+ pooled_output = self.pre_classifier(pooled_output)
46
+ pooled_output = nn.ReLU()(pooled_output)
47
+ pooled_output = self.dropout(pooled_output)
48
+
49
+ # Multi-task predictions
50
+ logits_main = self.classifier_main(pooled_output)
51
+ logits_sub = self.classifier_sub(pooled_output)
52
+ logits_interv = self.classifier_interv(pooled_output)
53
+ logits_priority = self.classifier_priority(pooled_output)
54
+
55
+ # Multi-task loss calculation (training only)
56
+ loss = None
57
+ if main_category_id is not None:
58
+ loss_fct = nn.CrossEntropyLoss()
59
+ loss_main = loss_fct(logits_main, main_category_id)
60
+ loss_sub = loss_fct(logits_sub, sub_category_id)
61
+ loss_interv = loss_fct(logits_interv, intervention_id)
62
+ loss_priority = loss_fct(logits_priority, priority_id)
63
+ loss = loss_main + loss_sub + loss_interv + loss_priority
64
+
65
+ if loss is not None:
66
+ return (loss, logits_main, logits_sub, logits_interv, logits_priority)
67
+ else:
68
+ return (logits_main, logits_sub, logits_interv, logits_priority)
priorities.json ADDED
@@ -0,0 +1 @@
 
 
1
+ [1, 2, 3]
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
sub_categories.json ADDED
@@ -0,0 +1 @@
 
 
1
+ ["Balanced Diet", "Breastfeeding", "Child Abandonment", "Child Abduction", "Child Abuse", "Child Labor", "Child Marriage", "Child Neglect", "Child Rights", "Child in Conflict with the Law", "Custody", "Drug/Alcohol Abuse", "Emotional Abuse", "Family Relationship", "Feeding & Food preparation", "Female Genital Mutilation", "HIV/AIDS", "Info on Helpline", "Legal Issues", "Maintenance", "Malnutrition", "Mental impairment", "Missing Child", "Other", "Outside Mandate", "Peer Relationships", "Physical Abuse", "Physical Health", "Physical impairment", "Psychosocial/Mental Health", "Relationships (Boy/Girl)", "Relationships (Parent/Child)", "School Related Issues", "School related issues", "Self Esteem", "Sexual & Reproductive Health", "Sexual Abuse", "Speech impairment", "Stagnation", "Student/ Teacher Relationship", "Teen Pregnancy", "Underweight", "Unlawful Confinement"]
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "DistilBertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9997d8b51d9a6e2606dafda4b46a052cb5bf8492dcca07977df4a0a4d1c80d2a
3
+ size 5649
vocab.txt ADDED
The diff for this file is too large to render. See raw diff