WEFE API

This is the documentation of the API of WEFE.

WordEmbeddingModel

WordEmbeddingModel(wv[, name, vocab_prefix])

A wrapper for Word Embedding pre-trained models.

Query

Query(target_sets, attribute_sets[, ...])

A container for attribute and target word sets.

Metrics

This list contains the metrics implemented in WEFE.

WEAT()

Word Embedding Association Test (WEAT).

RND()

Relative Norm Distance (RND).

RNSB()

Relative Relative Negative Sentiment Bias (RNSB).

MAC()

Mean Average Cosine Similarity (MAC).

ECT()

Embedding Coherence Test [1].

RIPA()

An implementation of the Relational Inner Product Association Test, proposed by [1][2].

Debias

This list contains the debiasing methods implemented so far in WEFE.

HardDebias([pca_args, verbose, criterion_name])

Hard Debias debiasing method.

MulticlassHardDebias([pca_args, verbose, ...])

Generalized version of Hard Debias that enables multiclass debiasing.

Dataloaders

The following functions allow one to load word sets used in previous works.

load_bingliu()

Load the Bing-Liu sentiment lexicon.

fetch_debias_multiclass()

Fetch the word sets used in the paper Black Is To Criminals as Caucasian Is To Police: Detecting And Removing Multiclass Bias In Word Embeddings.

fetch_debiaswe()

Fetch the word sets used in the paper Man is to Computer Programmer as Woman is to Homemaker? from the source.

fetch_eds([occupations_year, ...])

Fetch the word sets used in the experiments of the work Word Embeddings *Quantify 100 Years Of Gender And Ethnic Stereotypes.

load_weat()

Load the word sets used in the paper Semantics Derived Automatically From Language Corpora Contain Human-Like Biases.

Preprocessing

The following functions allow transforming sets of words and queries to embeddings. The documentation of the functions in this section are intended as a guide for WEFE developers.

preprocess_word(word[, options, vocab_prefix])

pre-processes a word before it is searched in the model's vocabulary.

get_embeddings_from_set(model, word_set[, ...])

Transform a sequence of words into dictionary that maps word - word embedding.

get_embeddings_from_sets(model, sets[, ...])

Given a sequence of word sets, obtain their corresponding embeddings.

get_embeddings_from_query(model, query[, ...])

Obtain the word vectors associated with the provided Query.