GitHub

genderfluid-tiny

Offline Python classifier that predicts gender associations from names. 14 MB model, CPU only, no API needed.

$ pip install genderfluid-tiny
0 MBModel
0 msPrediction
0KNames trained
0API calls

Installation

$ pip install genderfluid-tiny

From 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.

204,234 names trained from U.S. Social Security Administration (1880-2020), Census 2020, French INSEE, Spanish INE, Swedish official name lists, the Polish PESEL register, Japanese newborn surveys and Chinese government reports (1B+ births).

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.9998

Or from the command line:

$ genderfluid predict Emma

Name: Emma

  girl-associated  100.0%
  boy-associated     0.0%
  uncertain          0.0%

  Classification: girl-associated
  Confidence:     high

Python 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.9998

Full 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:     high

Multi-word names work without quotes:

$ genderfluid predict Isabella

Compare 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 ms

Batch processing

Create a text file with one name per line:

# names.txt
Emma
James
Alex
Isabella

Then run:

$ genderfluid predict --file names.txt

Output 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 / uncertain

The 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

Fully offlineNo internet. No API. No data leaves your machine.
14 MB modelStill smaller than a low-res image.
Millisecond-fast3.5 ms per name on a 2-core CPU.
CPU onlyNo GPU. No CUDA. Works on old hardware.
Uncertain categoryDoes not force binary. Ambiguous names get flagged.
Real data204,234 names from SSA, Census, INSEE, Spain, Sweden, Poland, Japan and China.
Unicode supportHandles accented characters, hanzi, hyphens, apostrophes.
Simple APIOne function call. No complex setup.

Benchmark

Measured on a 2-core x86_64 Linux machine. Results vary by hardware.

MetricValue
Model size14.00 MB
Single prediction3.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 RSS73 MB
Cold start~0.4 s (CLI to first prediction)
$ genderfluid benchmark

Accuracy

Tested on held-out test data (15,977 names, none seen in training):

MetricValue
Accuracy85.4%
Macro F10.703
Girl-associated F10.915
Boy-associated F10.875
Uncertain F10.318
Calibration error0.075

Primarily U.S./European training data with growing Asian coverage. Accuracy varies by cultural context.

CLI reference

CommandDescription
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 interactiveInteractive prediction mode
genderfluid statsShow model metadata
genderfluid benchmarkRun inference benchmark
genderfluid --versionShow version
genderfluid --helpShow help

Training from source

$ python fetch_multinational_data.py  # build dataset from official sources, write splits
$ python train_aggressive.py    # sweep configurations, save best model

The training script:

  1. Loads and validates the dataset
  2. Trains logistic regression with 3 classes
  3. Calibrates probabilities with sigmoid scaling
  4. Evaluates on the test set
  5. 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 uncertain category 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.

Commercial licensing · GitHub · PyPI