Downloads · 30 days
18
35% of all-time downloads
sajalmadan09/indian-name-gender-classifier
indian-name-gender-classifier is a text classification model from sajalmadan09. Use it when you need a label for a piece of text. The card lists the license as mit.
A small Linear - ReLU - Linear - Softmax classifier over character-bigram features, predicting conventional gender (M/F) from an Indian first name. Built as the real-model case study for Sajal Labs — a research projec…
Downloads · 30 days
18
35% of all-time downloads
All-time downloads
52
Public
Parameters
22.1K
267 KB on disk
Likes
2
Public
Click a slice to open those files.
.onnx89.1 KB · 32%
From the Hugging Face model README
A small Linear -> ReLU -> Linear -> Softmax classifier over character-bigram
features, predicting conventional gender (M/F) from an Indian first name.
Built as the real-model case study for Sajal Labs —
a research project on compiling trained models into minimal, dependency-free
native C/C++ inference artifacts. See
exp9-gender-classifier
and exp10-e2e-native-pipeline
for the full methodology.
Linear(343->64) -> ReLU -> Linear(64->2) -> Softmax^/$ boundary markers, counted per bigram)Trained on 688 names, validated on 121 held-out names (85/15 split, vocabulary built from training names only, no leakage).
| Accuracy | |
|---|---|
| Train | 99.4% |
| Validation | 81.8% |
The train/validation gap reflects real overfitting on a small (~800-name) dataset — reported as measured, not smoothed over. This is a teaching/research case study, not a claim of state-of-the-art name-gender classification.
Full raw data in benchmark_results.json. True end-to-end cold invocation
(process spawn -> raw name string in -> prediction out -> process exit,
external wall-clock, 30 trials, interleaved):
| Implementation | Cold invocation p50 |
|---|---|
| Native C++ (Sajal runtime) | 3.80ms |
| ONNX Runtime (CPU) | 75.52ms (19.9x slower) |
| PyTorch eager | 584.54ms (153.8x slower) |
This native artifact has no Python dependency at inference time. Per Sajal Labs' broader findings (research/gap-analysis.md), the advantage shown here is specifically in avoiding Python/framework process-startup cost for single-shot invocation (serverless, CLI, intermittent edge use) — not a general claim that native code out-computes these frameworks at sustained throughput; see the linked experiments for the full, honest picture including where the advantage does and doesn't hold.
sajal run <this_directory> "priya"
# {"input": "priya", "output": [0.0043, 0.9957]} -- [P(male), P(female)]
import json
from safetensors.numpy import load_file
weights = load_file("model.safetensors") # fc1.weight, fc1.bias, fc2.weight, fc2.bias
config = json.load(open("config.json"))
vocab = open("vocab.txt").read().splitlines()
# See https://github.com/Sajalmadan09/sajal-labs/blob/main/python/gender_features.py
# for the exact bigram feature extraction (must match, or predictions will
# be wrong) and python/tiny_mlp.py for the exact forward pass these weights
# implement.
import onnxruntime as ort
session = ort.InferenceSession("model.onnx", providers=["CPUExecutionProvider"])
# feed a [1, 343] float32 bigram-feature vector (see gender_features.py)
model.safetensors — weights, HF/PyTorch-ecosystem formatmodel.onnx — ONNX Runtime-compatible exportfc1_weight.bin, fc1_bias.bin, fc2_weight.bin, fc2_bias.bin, shapes.txt — raw native Sajal runtime formatvocab.txt — the 343-entry character-bigram vocabulary (needed by all three formats)config.json — architecture metadatabenchmark_results.json — full machine-readable benchmark data behind the numbers above