WEFE API

This reference details all the utilities as well as the metrics and mitigation methods implemented so far in WEFE.

WordEmbeddingModel

wefe.word_embedding_model.WordEmbeddingModel(wv)

A wrapper for Word Embedding pre-trained models.

Query

wefe.query.Query(target_sets, attribute_sets)

A container for attribute and target word sets.

Metrics

This list contains the metrics implemented in WEFE.

wefe.metrics.WEAT()

Word Embedding Association Test (WEAT).

wefe.metrics.RND()

Relative Norm Distance (RND).

wefe.metrics.RNSB()

Relative Relative Negative Sentiment Bias (RNSB).

wefe.metrics.MAC()

Mean Average Cosine Similarity (MAC).

wefe.metrics.ECT()

Embedding Coherence Test (ECT).

wefe.metrics.RIPA()

Relational Inner Product Association Test (RIPA).

Debias

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

wefe.debias.hard_debias.HardDebias([...])

Hard Debias debiasing method.

wefe.debias.multiclass_hard_debias.MulticlassHardDebias([...])

Generalized version of Hard Debias that enables multiclass debiasing.

wefe.debias.repulsion_attraction_neutralization.RepulsionAttractionNeutralization([...])

Repulsion Attraction Neutralization method.

wefe.debias.double_hard_debias.DoubleHardDebias([...])

Double Hard Debias Method.

wefe.debias.half_sibling_regression.HalfSiblingRegression([...])

Half Sibling Debias method.

Datasets

The following functions allow you to load sets of words used in previous studies.

wefe.datasets.load_bingliu()

Load the Bing-Liu sentiment lexicon.

wefe.datasets.fetch_debias_multiclass()

Fetch the word sets used in the paper Black Is To Criminals as Caucasian

wefe.datasets.fetch_debiaswe()

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

wefe.datasets.fetch_eds([occupations_year, ...])

Fetch the sets of words used in the experiments of the _Word Embeddings

wefe.datasets.load_weat()

Load the word sets used in the experiments of the

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.

wefe.preprocessing.preprocess_word(word[, ...])

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

wefe.preprocessing.get_embeddings_from_set(...)

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

wefe.preprocessing.get_embeddings_from_tuples(...)

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

wefe.preprocessing.get_embeddings_from_query(...)

Obtain the word vectors associated with the provided Query.

Utils

Collection of assorted utils.

wefe.utils.load_test_model()

Load a Word2vec subset to test metrics and debias methods.

wefe.utils.generate_subqueries_from_queries_list(...)

Generate a list of subqueries from queries.

wefe.utils.run_queries(metric, queries, models)

Run several queries over a several word embedding models using a specific metic.

wefe.utils.plot_queries_results(results[, by])

Plot the results obtained by a run_queries execution.

wefe.utils.create_ranking(results_dataframes)

Create a ranking form the aggregated scores of the provided dataframes.

wefe.utils.plot_ranking(ranking[, ...])

wefe.utils.calculate_ranking_correlations(...)

Calculate the correlation between the calculated rankings.

wefe.utils.plot_ranking_correlations(...[, ...])

wefe.utils.flair_to_gensim(flair_embedding)