genderfluid-tiny
Offline Python classifier that predicts gender associations from names. 14 MB model, CPU only, no API needed.
Installation
$ pip install genderfluid-tinyFrom source:
$ git clone https://github.com/MaxEdgar/genderfluid-tiny.git
$ cd genderfluid-tiny
$ pip install -e .Requirements: Python 3.10+, scikit-learn, numpy. No GPU or internet required.
What it does
Given a name, genderfluid-tiny estimates whether it is statistically
associated with feminine or masculine naming conventions. It outputs
girl-associated, boy-associated, or uncertain.
Quick start
from genderfluid import classify_name, is_girl_name, name_probability
classify_name("Emma") # "girl-associated"
classify_name("James") # "boy-associated"
classify_name("Robin") # "uncertain"
is_girl_name("Emma") # True
name_probability("Emma") # 0.9998Or from the command line:
$ genderfluid predict Emma
Name: Emma
girl-associated 100.0%
boy-associated 0.0%
uncertain 0.0%
Classification: girl-associated
Confidence: highPython API
Simple functions
from genderfluid import classify_name, is_girl_name, is_boy_name, name_probability
classify_name("Emma") # "girl-associated"
is_girl_name("Emma") # True
is_boy_name("James") # True
classify_name("Robin") # "uncertain"
name_probability("Emma") # 0.9998Full result dict
from genderfluid import predict_name, predict_names
result = predict_name("Isabella")
# {
# "name": "Isabella",
# "girl_associated_probability": 1.0,
# "boy_associated_probability": 0.0,
# "uncertain_probability": 0.0,
# "classification": "girl-associated",
# "confidence": "high"
# }Model instance (for repeated use)
from genderfluid import GenderfluidModel
model = GenderfluidModel() # loads once, cached
model.predict("Olivia")
model.predict_batch(["Emma", "James", "Robin"])Batch prediction
from genderfluid import predict_names
results = predict_names(["Emma", "James", "Robin", "Max"])
for r in results:
print(f"{r['name']}: {r['classification']}")Command line
$ genderfluid predict Olivia
Name: Olivia
girl-associated 100.0%
boy-associated 0.0%
uncertain 0.0%
Classification: girl-associated
Confidence: highMulti-word names work without quotes:
$ genderfluid predict IsabellaCompare names
$ genderfluid predict --compare Emma James Robin Max Taylor
Name Classification Girl Boy Unc Confidence
----------------------------------------------------------------------------
Emma girl-associated 100% 0% 0% high
James boy-associated 0% 100% 0% high
Robin uncertain 0% 0% 100% high
Max boy-associated 0% 100% 0% high
Taylor uncertain 1% 0% 99% high
5 names in 44.0 msBatch processing
Create a text file with one name per line:
# names.txt
Emma
James
Alex
IsabellaThen run:
$ genderfluid predict --file names.txtOutput is JSONL (one JSON object per line), with timing info at the end.
JSON output
$ genderfluid predict --json Robin
{
"name": "Robin",
"girl_associated_probability": 0.0003,
"boy_associated_probability": 0.0018,
"uncertain_probability": 0.9979,
"classification": "uncertain",
"confidence": "high"
}Architecture
Input name
|
Unicode normalization + lowercase
|
Character n-gram extraction (2-6 grams)
|
Hashing trick (524,288-dim feature vector)
|
Logistic regression (3 classes)
|
Sigmoid calibration
|
Output: girl-associated / boy-associated / uncertainThe classifier extracts character-level patterns. Names ending in
-a, -ia, -ine tend to be feminine.
Names ending in -o, -us, -er tend
to be masculine. The model learns these patterns from data rather than
hard-coding rules.
Features
Benchmark
Measured on a 2-core x86_64 Linux machine. Results vary by hardware.
| Metric | Value |
|---|---|
| Model size | 14.00 MB |
| Single prediction | 3.47 ms |
| Batch (10 names) | 2.9 ms (3,460 names/s) |
| Batch (100 names) | 19.6 ms (5,093 names/s) |
| Batch (1000 names) | 182.0 ms (5,495 names/s) |
| Peak RSS | 73 MB |
| Cold start | ~0.4 s (CLI to first prediction) |
$ genderfluid benchmarkAccuracy
Tested on held-out test data (15,977 names, none seen in training):
| Metric | Value |
|---|---|
| Accuracy | 85.4% |
| Macro F1 | 0.703 |
| Girl-associated F1 | 0.915 |
| Boy-associated F1 | 0.875 |
| Uncertain F1 | 0.318 |
| Calibration error | 0.075 |
Primarily U.S./European training data with growing Asian coverage. Accuracy varies by cultural context.
CLI reference
| Command | Description |
|---|---|
genderfluid predict <name> | Predict gender association |
genderfluid predict --json <name> | JSON output |
genderfluid predict --compare <names> | Compare multiple names |
genderfluid predict --file <file> | Batch from file (JSONL output) |
genderfluid predict --model <path> | Use a custom model file |
genderfluid interactive | Interactive prediction mode |
genderfluid stats | Show model metadata |
genderfluid benchmark | Run inference benchmark |
genderfluid --version | Show version |
genderfluid --help | Show help |
Training from source
$ python fetch_multinational_data.py # build dataset from official sources, write splits
$ python train_aggressive.py # sweep configurations, save best modelThe training script:
- Loads and validates the dataset
- Trains logistic regression with 3 classes
- Calibrates probabilities with sigmoid scaling
- Evaluates on the test set
- Saves the model to
models/genderfluid-tiny.bin
Dataset
JSONL format, one entry per line:
{"name": "Emma", "label": "girl-associated"}
{"name": "James", "label": "boy-associated"}
{"name": "Alex", "label": "uncertain"}Optional fields: weight, country, language, year.
Training data sources:
- U.S. Social Security Administration baby names (1880-2020): 100,364 unique names
- U.S. Census Bureau 2020 Census first names: 53,616 unique names
- France INSEE first names (1900-2024): 48,506 unique names
- Spain INE first names by birth decade: 62,444 unique names
- Japan Meiji Yasuda newborn-name surveys: 2,387 unique kanji names
- China Ministry of Public Security name reports: 60 official given names
- Sweden official name statistics (isoF): 224 unique names
Combined: 204,234 unique names across all sources.
Names with 85%+ statistical association are labeled
girl-associated or boy-associated.
Below that threshold: uncertain.
Limitations
- Works with full names: first, middle, and last
- Primarily U.S./European data; Chinese/Japanese coverage limited (~2,400 names) and growing
- Name associations vary by culture, language, and generation
- The
uncertaincategory exists for genuinely ambiguous names - Unknown inputs return
uncertain: scripts never seen in training (Cyrillic, Arabic, Greek), strings without letters, and out-of-vocabulary patterns (novel hanzi, gibberish) - Two-word full names are classified as a whole (the data's two-word names are compound given names); a surname can influence the result, so pass just the given name for the strongest signal
- Not suitable for high-stakes decisions
- The classifier can be wrong
License
Polyform Noncommercial License 1.0.0. Free for personal, educational, and noncommercial use. Commercial use requires a license.