Skip to main content

Calculate SC-WEAT bias from GloVe 200d Gigaword embeddings.

Project description

Gender Bias in Word Embeddings

A command-line tool for measuring gender bias in GloVe word embeddings using the Single-Category Word Embedding Association Test (SC-WEAT).

Student: Katharina Nemtsev

ID Number: 19-922-137

Repo: gitlab

Background

Word embeddings are reflective of the texts they were trained on. Much research has shown that there is a gender bias reflected in word embeddings. With this module, I want to make it possible to quickly find the gender bias of words based on the newest GloVe word embeddings.

The GloVe corpus used is the 2024 Wikipedia + Gigaword 5 (11.9B tokens, 1.2M vocab, uncased, 200d vectors, 1.1 GB download), downloadable also at: GloVe. The program already includes the necessary file, so no need to download anything for you.

The SC-WEAT methodology is based on Caliskan et al. (2022), Gender Bias in Word Embeddings: A Comprehensive Analysis of Frequency, Syntax, and Semantics arXiv, which used the SC-WEAT score to demonstrate the widespread prevalence of gender bias across GloVe and fastText embeddings. I also used their anchor words, which came from a previous paper of Caliskan et al. (2017): arXiv. I am not very familiar with the SC-WEAT measurement and only learned about it for this project, so please excuse any comprehension errors you may find.

SC-WEAT Formula

For a given input word w, the module computes a Cohen's d effect size by comparing how close w is to a set of male anchor words versus a set of female anchor words in vector space:

ES(w) = ( mean_cos(w, male_anchors) - mean_cos(w, female_anchors) )
        ─────────────────────────────────────────────────────────────
                    std_dev( all cosine similarities )

A negative effect size indicates male association; a positive effect size indicates female association. The magnitude follows Cohen's d conventions, as also described by Caliskan et al.:

| |d| | Interpretation | |-----------|----------------| | < 0.20 | Negligible | | 0.20–0.49 | Small | | 0.50–0.79 | Medium | | ≥ 0.80 | Large |

Each side requires at least 8 anchor words, as specified by the SC-WEAT methodology. The default anchors can be changed by editing anchors.json directly.

Setup

Requirements

  • Python 3.13
  • numpy

Usage

Installation:

pip install scweatwords

Score a single word

scweatwords --word nurse
scweatwords --word engineer

Score a list of words from a file

scweatwords --list words.txt

One word per line. Words not found in the GloVe vocabulary are skipped with an error.

Find nearest neighbours

Add --neighbours N to either the word or file to retrieve the N most similar words in the embedding space, alongside their similarity to the input word:

scweatwords --word doctor --neighbours 10
scweatwords --list jobs.txt --neighbours 5

Be aware: In the list option, this iterates over the entire GloVe file once for each word. The size of N will not have a noticeable impact on your runtime, but the amount of words in your list will.

Anchor words

The gender anchor words are stored in anchors.json. The defaults are:

{
  "male":   ["male", "he", "him", "his", "man", "boy", "son", "brother"],
  "female": ["female", "she", "her", "hers", "woman", "girl", "daughter", "sister"]
}

These are taken from the two Caliskan et al. papers mentioned earlier.

Reference

Caliskan, A. et al. (2022) Gender bias in word embeddings: A comprehensive analysis of frequency, syntax, and semantics, arXiv.org. Available at: https://doi.org/10.48550/arXiv.2206.03390 (Accessed: 07 June 2026).

Jeffrey Pennington, Richard Socher, and Christopher D. Manning. 2014. GloVe: Global Vectors for Word Representation. [pdf] [bib]

Riley Carlson, John Bauer, and Christopher D. Manning. 2025. A New Pair of GloVes. [pdf]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scweatwords-1.0.3.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scweatwords-1.0.3-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file scweatwords-1.0.3.tar.gz.

File metadata

  • Download URL: scweatwords-1.0.3.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scweatwords-1.0.3.tar.gz
Algorithm Hash digest
SHA256 00ce97508c96c882e747b62d3cf9f15edb247c9e7d2693c5ff6017f1911bf8b4
MD5 63a68836c40160bc0d389c163eabc7f9
BLAKE2b-256 1c62b1f12ba3791634834090c1c251164bc2f7bfe6679eaf552b7b0867642b6e

See more details on using hashes here.

File details

Details for the file scweatwords-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: scweatwords-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for scweatwords-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 18476c8d61540ddcd11328007e9566784ece2cb975293e212b73b31157f477d6
MD5 b12194ad1b4cfbed493f39003ba4c981
BLAKE2b-256 6c23042523f58d605ea981ac557c35b51152b850e2603c0f39459a0896efd1bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page