genderfluid-tiny
Tiny offline Python name-gender classifier. Predicts gender associations from names using ML. 14 MB model, CPU only, no API needed.
pip install genderfluid-tiny
Documentation | PyPI | GitHub
What is genderfluid-tiny?
genderfluid-tiny is a lightweight Python library that predicts whether a name is statistically associated with feminine or masculine naming conventions. It uses a character n-gram classifier trained on 204,234 real names from U.S. Social Security Administration data (1880-2020), U.S. Census 2020, French INSEE first-name statistics (1900-2024), Spanish INE name statistics, Swedish official name lists, the Polish PESEL register, Japanese newborn surveys, and Chinese government name reports - over 1 billion recorded births in total.
Unlike API-based gender detection services, genderfluid-tiny runs entirely offline. No data leaves your machine. No API key required. The entire model is 14 MB (6 MB of weights plus an 8 MB vocabulary filter used to flag out-of-vocabulary names as uncertain).
| Property | Value |
|---|---|
| Architecture | Character n-gram + logistic regression |
| Model size | 14 MB |
| Training data | 204,234 names (SSA + Census + INSEE + Spain + Sweden + Poland + Japan + China) |
| Inference | CPU only, numpy only (no sklearn/scipy) |
| Internet | Not required |
| License | Polyform Noncommercial |
| Python | 3.10+ |
Install
pip install genderfluid-tiny
That's it. The genderfluid command and Python API are available immediately.
Quick start
genderfluid predict "Emma"
Name: Emma
girl-associated 100.0%
boy-associated 0.0%
uncertain 0.0%
Classification: girl-associated
Confidence: high
Python API
Simple one-liners
from genderfluid import classify_name, is_girl_name, is_boy_name, name_probability
classify_name("Emma") # "girl-associated"
classify_name("James") # "boy-associated"
classify_name("Robin") # "uncertain"
is_girl_name("Emma") # True
is_boy_name("James") # True
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"}
results = predict_names(["Emma", "James", "Robin"])
for r in results:
print(f"{r['name']}: {r['classification']}")
Model instance (for repeated use)
from genderfluid import GenderfluidModel
model = GenderfluidModel() # loads once, cached
model.predict("Olivia")
model.predict_batch(["Emma", "James", "Robin", "Max", "Taylor"])
CLI
genderfluid predict "Olivia" # human-readable
genderfluid predict --json "Alex" # JSON output
genderfluid predict --compare "Emma" "James" "Alex" # comparison table
genderfluid predict --file names.txt # batch from file
genderfluid interactive # interactive mode
genderfluid stats # model info
genderfluid benchmark # performance test
How it works
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 from names. 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 real data rather than hard-coding rules.
Accuracy
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 |
On the previous release's test set (14,587 names) the v2.0.0 model scores 85.7%, so adding Poland did not regress existing coverage. Accuracy varies by cultural context.
Benchmark
Measured on a 2-core x86_64 Linux machine. Results vary by hardware.
Model size: 14.00 MB
Single name: 3.47 ms
Batch (10): 2.9 ms (3,460 names/sec)
Batch (100): 19.6 ms (5,093 names/sec)
Batch (1000): 182.0 ms (5,495 names/sec)
Peak RSS: 73 MB
Cold start: ~0.4 s (CLI to first prediction)
Run genderfluid benchmark on your own hardware.
Use cases
- Data pipelines: Classify gender associations in CSV/spreadsheet data
- Name validation: Check if a name follows typical gender patterns
- Research: Analyze naming trends across datasets
- Privacy-sensitive applications: Process names without sending data to external APIs
- Offline applications: Works without internet connectivity
- Embedded systems: 14 MB model runs on low-resource devices
Training data
Built from real public data:
- 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
- Poland PESEL register (living people's first names): 58,106 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 (over 1 billion recorded births). Names with 85%+ statistical association are labeled girl-associated or boy-associated. Below that threshold: uncertain.
Training from source
python fetch_multinational_data.py # build dataset from official sources, write splits
python train_aggressive.py # sweep configurations, save the best model
Sweep training on GitHub Actions (recommended for retraining): the
Train Model workflow runs all 18 configurations in parallel on GitHub
runners (one job per config, ~4 minutes total) and a finalize job picks
the best config by validation F1, evaluates it on the test split, and
commits the model. Trigger it under Actions > Train Model > Run workflow,
or run the two steps locally:
python train_config.py 524288 2-6 160.0 lbfgs # one configuration
python train_finalize.py # pick best, evaluate, save
Dataset format
JSONL, one entry per line:
{"name": "Emma", "label": "girl-associated"}
{"name": "James", "label": "boy-associated"}
{"name": "Alex", "label": "uncertain"}
Optional fields: weight, country, language, year.
Comparison with alternatives
| Feature | genderfluid-tiny | gender-guesser | chicksexer |
|---|---|---|---|
| Model size | 14 MB | 600 KB+ | 10 MB+ |
| License | Polyform NC | GPLv3 | -- |
| Last updated | 2026 | 2016 | -- |
| Approach | ML (n-gram + LR) | Lookup table | ML |
| Uncertain category | Yes | Partial | No |
| pip install | Yes | Yes | Yes |
| Offline | Yes | Yes | Yes |
Limitations
- Works with full names: first, middle, and last
- Primarily U.S./European training data; accuracy varies by cultural context
- Chinese/Japanese coverage is limited (roughly 2,400 names) and still growing
- Name associations vary by culture, language, and generation
- The
uncertaincategory exists for genuinely ambiguous names - Not suitable for high-stakes decisions
Unknown inputs are handled conservatively: names in scripts never seen in
training (Cyrillic, Arabic, Greek, ...), strings without letters, and
out-of-vocabulary patterns (novel hanzi, keyboard-mash gibberish) return
uncertain instead of a confident guess. Two-word full names are classified
as a whole because the training data's two-word names are compound given
names ("si mohamed"); a surname can therefore influence the result - pass
just the given name (predict_name("Emma")) for the strongest signal.
Privacy
All inference runs locally. Names are not transmitted to any external service. Logging of names is disabled by default.
FAQ
What data is it trained on?
204,234 unique names from U.S. SSA baby names (1880-2020), U.S. Census 2020, French INSEE first names (1900-2024), Spanish INE name statistics, Swedish official name lists, the Polish PESEL register, Japanese newborn surveys, and Chinese government name reports - over 1 billion recorded births.
How accurate is it?
85.4% accuracy on held-out test data (macro F1 0.703). Girl-associated names: 92% F1. Boy-associated names: 88% F1. Uncertain/ambiguous names: 32% F1.
Does it work offline?
Yes. After pip install genderfluid-tiny, no internet connection is needed.
What Python versions are supported?
Python 3.10, 3.11, 3.12, 3.13.
Can I retrain the model?
Yes. See the Training from source section above. The training pipeline is included.
Does it work with non-English names?
The model is trained mostly on U.S./European data with growing Asian coverage. The preprocessing preserves Unicode characters, so names with accents, hanzi, and other scripts are handled - but accuracy outside the trained cultures is lower and often returns uncertain.
Repository structure
genderfluid-tiny/
├── genderfluid/ # Python package
│ ├── __init__.py # Public API
│ ├── cli.py # Command-line interface
│ ├── inference.py # GenderfluidModel class
│ ├── classifier.py # Logistic regression + calibration
│ ├── features.py # Character n-gram extraction
│ ├── preprocessing.py # Name normalization
│ └── model_io.py # Binary save/load
├── data/ # Training dataset
├── models/ # Trained model
├── native/ # C++ inference (optional)
├── tests/ # 39 tests
├── pyproject.toml # Package config
└── README.md
License
Polyform Noncommercial License 1.0.0. Free for personal, educational, and noncommercial use. Commercial use requires a license. See COMMERCIAL_LICENSE.md. Contributing: see CONTRIBUTING.md. Security: see SECURITY.md.
Metadata
Release files for genderfluid-tiny 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genderfluid_tiny-2.0.0.tar.gz | 8.4 MB | With provenance | Details for genderfluid_tiny-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genderfluid_tiny-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for genderfluid_tiny-2.0.0-py3-none-any.whl |
Total release size: 17.0 MB
Release files / genderfluid_tiny-2.0.0.tar.gz
| Download URL | genderfluid_tiny-2.0.0.tar.gz |
|---|---|
| Size | 8.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
463074d8ef387a05078b8eead3122c4dfcefa3b9f28baaf431f1ae940b64030f
|
|
BLAKE2b-256 checksum How to use checksums |
0d72c50b46d4de31267736dc0b449882e0766c30050c55c45bf724692ccb2c8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logRelease files / genderfluid_tiny-2.0.0-py3-none-any.whl
| Download URL | genderfluid_tiny-2.0.0-py3-none-any.whl |
|---|---|
| Size | 8.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55c645fa2c5bb1e9a7d154a851cd3a85ec0f4a42bedabdd5608657432f7eef18
|
|
BLAKE2b-256 checksum How to use checksums |
669704531bb63c0e3c56360b83ad10a8a31574e693245946d1ff19bd84085c93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logSecurity for genderfluid-tiny 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for genderfluid_tiny-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.