Downloads · 30 days
13
8% of all-time downloads
ivan-kleshnin/en_textcat_gender
en_textcat_gender is a text classification model from ivan-kleshnin. Use it when you need a label for a piece of text. It is set up for spacy.
Profile text data classification using SpaCy textcat components. A super tiny model with no vectors. Internally uses an ensemle of BOW and single-headed attention. I've got better performance scores with transformer-b…
Downloads · 30 days
13
8% of all-time downloads
All-time downloads
154
Public
Repo size
39.9 MB
Likes
0
Public
Click a slice to open those files.
.whl15.3 MB · 64%
From the Hugging Face model README
Profile text data classification using SpaCy textcat components. A super tiny model with no vectors.
Internally uses an ensemle of BOW and single-headed attention. I've got better performance scores with transformer-based models
but they are much slower to train/run on CPU and much larger. Sticking to the basics so far.
The model is trained on specifically formatted profile fields [name] ([login], [email]) in [location] so it's critical
to format the data with the provided format_input helper before applying a model to the text.
from en_textcat_gender import load as load_gender_model
from en_textcat_gender.utils import format_input
gender_model = load_gender_model()
class PredictGenderByProfileInput(BaseModel):
login: str
name: str
location: str | None = None
email: str | None = None
type Gender = Literal["Male", "Female", "Neutral"]
# Example of model use in the context of FastAPI route
@router.post("/predictGenderByProfile")
async def predictGenderByProfile(body: list[PredictGenderByProfileInput]) -> list[Gender]:
texts = [format_input({
"login": input.login,
"name": input.name,
"location": input.location,
"email": input.email,
}) for input in body]
docs = gender_model.pipe(texts)
genders: list[GenderAlt] = []
for doc in docs:
match max(doc.cats, key=doc.cats.get):
case "FEMALE": genders.append("Female")
case "MALE": genders.append("Male")
case "NEUTRAL": genders.append("Neutral")
case _: raise HTTPException(500, "Invalid enum value")
return genders
| Feature | Description |
|---|---|
| Name | en_textcat_gender |
| Version | 0.0.3 |
| spaCy | >=3.8.7,<3.9.0 |
| Default Pipeline | textcat |
| Components | textcat |
| Vectors | 0 keys, 0 unique vectors (0 dimensions) |
| Sources | n/a |
| License | n/a |
| Author | n/a |
| Component | Labels |
|---|---|
textcat | MALE, FEMALE, NEUTRAL |
| Type | Score |
|---|---|
CATS_SCORE | 93.37 |
CATS_MICRO_P | 93.19 |
CATS_MICRO_R | 93.19 |
CATS_MICRO_F | 93.19 |
CATS_MACRO_P | 93.75 |
CATS_MACRO_R | 93.04 |
CATS_MACRO_F | 93.37 |
CATS_MACRO_AUC | 98.76 |
CATS_MACRO_AUC_PER_TYPE | 0.00 |
TEXTCAT_LOSS | 105.21 |