<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Fixing Sexist AI - Medium]]></title>
        <description><![CDATA[A computer science student’s account of writing their senior thesis, trying to make AI a little less shitty. - Medium]]></description>
        <link>https://medium.com/fixing-sexist-ai?source=rss----ded0cd79f0c4---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Fixing Sexist AI - Medium</title>
            <link>https://medium.com/fixing-sexist-ai?source=rss----ded0cd79f0c4---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 16:00:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/fixing-sexist-ai" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Step 7: Semester recap]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-7-semester-recap-617025ec29f8?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/617025ec29f8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Sat, 15 Dec 2018 04:25:05 GMT</pubDate>
            <atom:updated>2018-12-15T04:25:05.832Z</atom:updated>
            <content:encoded><![CDATA[<p>This post will be somewhat unlike the others because it’s a more formal write-up of what I’ve been up to over the course of the semester. If you’ve been reading my posts along the way, first, thank you! This write-up may seem a bit redundant to you, but it’s (hopefully) a nice summary of what I was able to accomplish this semester.</p><p>Stay tuned because this project isn’t over yet! More updates to come in January.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z7co3H5skgIhlkUoIxnHzg.jpeg" /><figcaption>Final research poster</figcaption></figure><p><strong>I. Introduction and Project Purpose</strong></p><p>Throughout the last four months, I have been focused on exploring how to minimize the amount of measured gender bias in word embeddings by altering the input data for my senior comps in computer science. Word embeddings are a relatively new method in computational linguistics, and they are used to create vectors that represent the meanings of words. Usually, a large corpus of text (e.g., Google News articles, Wikipedia articles, or the Common Crawl) is used as the input to the embedding. Then, the embedding outputs a dictionary that maps from each unique word in the input corpus, to a corresponding high-dimensional vector. There are multiple approaches and libraries that can be used to create these vectors, including word2vec and FastText — which are predictive models that use n-gram or skip-gram approaches (explained in Section 3.3) — or Global Vectors for Word Representation (GloVe) which uses word co-occurrence. A more detailed description of these two approaches, as well as the differences between them, is discussed in section 2.</p><p>The vectors produced by the word embedding model encode semantic information about the respective words, in terms of their relationships to other words. For example, the angle between the vectors for <em>male and female</em>, <em>man</em> and <em>woman</em>, and <em>king</em> and <em>queen</em> are all relatively equal (at least when compared to the angle between <em>king</em> and <em>toothbrush</em>, for example) because they all stand in the same kind of gender-opposed relationships with each other.</p><p>Throughout the last five years, however, researchers have studied how these vectors can also encode unwanted biases. For example, the word <em>doctor</em> is typically closer (in terms of cosine distance) to the word vector for <em>man</em> rather than <em>woman</em>. This is likely because there are more male doctors than female doctors in general, and thus the word <em>doctor</em> appears in the same sentence more often with <em>man</em> than <em>woman</em>. While this word meaning in of itself does not represent bias per se, it does have the potential to alter user experience if it is implemented in a larger application. For example, if Google implements a word embedding to refine search results, then it is possible that a female user may receive fewer results for the query “pediatric doctor nearby” than a male user, because of the word similarity. In 2015, Datta et al. showed that female subjects saw an executive level job advertisement less frequently than male subject. Although this study never explicitly mentions that word embeddings are the cause of this phenomena, it is plausible that this kind of effect could occur if word embeddings are not neutralized before they are implemented into systems like Google search.</p><p>For my senior comprehensive project, I wanted to review the existing literature on how this kind of inherited bias is being reduced in word embeddings. Then, I wanted to see if neutralizing the gender pronouns in the input data would have an effect on how much gender bias was measured. To measure bias, I used the direct bias measure published by Bolukbasi et al. (2016) (this algorithm is described in detail in section <strong>3.4</strong>). I controlled for the amount of data that I used to train my model (the type of data used is described in <strong>3.1</strong>), three different kinds of way to define gender to evaluate the model (the differences between these definitions are explained in section <strong>3.5</strong>), and two different sets of gender-neutral terms to evaluate the amount of gender bias (see section <strong>3.4</strong>).</p><p><strong>II. Background and Literature Review</strong></p><p>The term “word embeddings” refers to a technique in computational linguistics for creating a lexicon of word meanings, usually through the use of neural networks. In general, word embeddings take a corpus of text and return a dictionary that maps from each unique word in the corpus to a vector that represents that word’s meaning (in terms of its relationship to other words in the corpus). The approach was popularized by large-scale pre-trained models like word2vec and GloVe, but through further research, there are now numerous alternatives, like FastText and Gensim (among others). There are generally two classes of word embedding models: <em>predictive models</em> and <em>count-based models</em>. Predictive models — like word2vec and FastText — create a word’s vector according to how likely it is to occur in conjunction with all other words in the model. The more likely two words are to appear in the same sentence, the more associated they are (and therefore, the smaller the cosine angle between the vectors is). Count-based models (also referred to as Continuous-Bag-Of-Words — or CBOW- models) — like GloVe — use word co-occurrence to create a vector for a given word. Essentially, the model creates a matrix that represents the co-occurrence of each word with every other word in the corpus, and then, using dimensionality reduction, creates one vector for each word. For this project, I elected to use FastText, which, as mentioned, is a predictive model. The structure of FastText will be further discussed in section <strong>3.3</strong>.</p><p>Although the strength and diversity of word embedding techniques has grown throughout the last ten years, it is still a new field, subject to many open questions. In particular, there are a number of cardinal issues with all word embeddings, and there is no agreed-upon standard with regards to evaluating the strength of a particular embedding. In 2018, Bakarov published <em>A Survey of Word Embeddings Evaluation Methods</em> where he discusses some of the open issues with word embeddings and the available evaluation methods. He identifies five important problems in the field:</p><ol><li>General occurrence of the notion of semantics. In other words, general discourse and disagreement over the meaning of words to begin with. It is not clear what it means to know the meaning of a word, nor whether or not we ever really know the true meaning of a word.</li><li>Training data is not typically separated from test data to train an embedding. Usually, no test data is saved, all of the data is used to train the model. This is inconsistent with a typical machine learning training process and makes evaluation more difficult.</li><li>There is an absence of correlation between the two categories of evaluation methods: <em>intrinsic</em> and <em>extrinsic</em> methods. Thus, we are still not sure what kinds of evaluations we should rely on.</li><li>There is a lack of statistical significance tests to apply to word embeddings, therefore there is no empirical analysis to show that they hold statistical power.</li><li>Finally: <em>the hubness problem</em>, (which was originally defined in 2014 and 2015, from the research of Dinu et al, and Schnabel et al.) refers to a phenomena that occurs with words in the embedding that are used very often (called “hub words”, e.g., <em>is</em>, <em>the</em>, <em>and</em>, etc.), and thus lack real intrinsic meaning. They also create noise in the other vectors for more unique and rare words. The degree to which this is an issue is also still unclear.</li></ol><p>Then, Bakarov explains the difference between extrinsic and intrinsic tasks. Extrinsic tasks evaluate the strength of a word embedding based on its ability to perform a particular task (e.g., completing an analogy). Overall, Bakarov does not endorse this method because it is selective, meaning that success in performing the task is a very limited scope of the model’s strength in general. Intrinsic tasks, on the other hand, compare a word embedding to human judgments or word relations, which reflect more generally-held understandings of a given word’s meaning. Intrinsic methods evaluate the model more rigorously. In general, it is important to acknowledge that all research on word embeddings is somewhat limited until these open questions are answered, and a more robust evaluation method is chosen.</p><p>In 2016, word embedding research began to branch into studying how word embeddings were inheriting bias from the text corpora they were trained with. The bedrock of this research is <em>Man is to Computer Programmer as Woman is to Homemaker? Debiasing Word Embeddings</em> by Bolukbasi et al. (2016). Researchers showed that word2vec has severe stereotypes on the basis of gender and race. In the paper, they present a novel algorithm for measuring “direct bias”. Essentially, Bolukbasi et al. create a vector subspace that represents a neutral amount of bias (for example, a <em>gender</em> subspace). Then, direct bias for a group of words is the sum of their distances from this neutral subspace (measured using the cosine angle). This algorithm will be discussed in detail in section 3.4 as it was used as the primary evaluation tool for this project. Bolukbasi et al. also focused on reducing gender bias, which they accomplished by isolating a subset of words that they deemed necessary to neutralize, and then neutralizing them with respect to the subspace. Chakraborty et al. (2016) completed a replication of Bolukbasi et al.’s work but applied to the GloVe word embedding instead. The embedding showed similar biases to the ones found in word2vec, showing that the training method used does not have a significant effect on how much bias is inherited.. Chakraborty et al., like Bolukbasi et al., debias their word embedding model by taking a subset of words and neutralizing them according to a vector subspace. Together, these two articles began the larger discussion about the permeation of bias in word embeddings, and present one particular method of reducing bias through neutralizing specific words (e.g., gender-neutral words that were particularly male or female, like <em>plumber</em> or <em>nurse</em>).</p><p>Subsequent research has continued to explore this inheritance of bias, but the method for <em>minimizing</em> it has remained largely the same., Research has been somewhat stagnantly focused on altering the model after it has already been created, but I have yet to find evidence where the input data itself is being manipulated to reduce gender bias. Thus, it is important to see if altering the input data can minimize bias, because it has the potential to be a more generalizable solution than choosing words that “should” be gender-neutral, and minimizing their bias.</p><p><strong>III. Algorithmic Overview/Project Design<br></strong><em>3.1 Input Data and Preprocessing</em><br> First I will discuss the kind of text data that I used to train all of my word embedding models. All of my data was composed of Wikipedia articles that were downloaded from a publicly available online article dump. I completed two separate versions of the project, one using a smaller dataset of around 2GB of Wikipedia articles (composed of the latest articles added to Wikipedia), and the other using a much larger, 15.5GB group of articles (a larger group of the latest articles). The smaller dataset was used when I was initializing and testing the project so that my runtimes would be relatively low for testing purposes. Then, the larger dataset was used so that I could 1) train a presumably more robust word embedding, and 2) so that I could see if the size of the dataset would affect my bias reduction results. I wanted to see if there were significant differences in the number of instances in which gender bias was reduced between the different sized models, as well as to what degree it was reduced (if it was).</p><p>All data was downloaded as a compressed .xml file of HTML for each article. Then, I used a script written in Python adapted from KDNuggets to pre-process the data. The script unzips the compressed file, scrapes it for all purely text data (excluding all non-necessary HTML tagging), and writes the text to a file that was used as the input for the <em>original</em> model.</p><p><em>3.2 Data Treatment</em></p><p>The input for the <em>retrained</em> model was an altered version of the data described in the previous subsection. As mentioned earlier, my primary method for minimizing bias was through altering the input data, and the original dataset was simply the raw text data that was extracted from the compressed Wikipedia articles. The second copy involved concatenating <em>two</em> copies of the original input data, where the gender pronouns in the second copy were inverted according to this map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/0*bJ9_n_texQ_1MSOg" /></figure><p>Any instance of a word in the set of keys was replaced by its corresponding value. Essentially, all gender pronouns were reversed in one copy of the original data. I elected to use this approach because I wanted to create a dataset where there was equal representation of the male and female versions of one particular pronoun, therefore neutralizing it.</p><p><em>3.3 Training the Word Embedding</em></p><p>In order to train the word embedding, I decided to use FastText, which is a library from Facebook research for text classification and representation learning. FastText, as mentioned earlier, is a predictive-based method for training an embedding. That is to say, it uses the probability that the given word will appear in the same sentence as another word to value their semantic similarity. FastText also uses an n-gram approach to construct vectors. N-gram methods construct a word’s vector based on the vectors of substrings within that word. For example, the vector for <em>ate</em> is built up of the vectors for <em>at</em> and <em>a</em>. This is an important quality of FastText because it allows users to extract vectors out of the model for non-existent words, or words that do not exist in the input corpus. That said, if, for example, the word <em>attached</em> was not in the model, but the word <em>attach</em> was, then FastText would return a vector for <em>attached</em> that was very similar to the one for <em>attach</em>, which preserves important semantic information.</p><p>FastText is run entirely from the command line, and it takes a single text file as an input and outputs a .bin file of all words with their associated vectors. In order to use this .bin file, I utilized a portion of the Gensim model library that is designed to load FastText models so they can be accessed with regular Python dictionary syntax.</p><p><em>3.4 Measuring Direct Bias</em></p><p>As mentioned in the Introduction, I utilized the direct bias measure first defined by Bolukbasi et al. in order to quantify gender bias in each of my models. First, I will explain the components of the algorithm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/0*vSVOEypMLAYIoEbR" /></figure><p>Where:</p><ul><li><strong>N</strong> is a set of gender-neutral words. I chose to use a set of gender-neutral occupational words, and a set of adjectives (explained below in <strong>3.4.1</strong>)</li><li><strong>w </strong>is the vector for one of the words in that set of gender-neutral words</li><li><strong>g</strong> is the gender subspace (explained below in <strong>3.4.2</strong>)</li><li><strong>c</strong> is the strictness parameter. Bolukbasi et al. mention that c can be between 0 and 1. The smaller it is, the more “strict” the algorithm is. For example, if c=0.5, then only the square root of the distance is preserved. I kept c=1 because I saw no reason to discount part of the distance between a word and the subspace.</li></ul><p><em>3.4.1 Sets of Gender-Neutral Words</em></p><p>First, I choose two sets of words for N, occupations, and adjectives. I chose occupations because many occupations, though framed as gender-neutral words, have strong male or female stereotypes, or actual representation (more male or more female employees). The adjectives I used were based on sets of adjectives that tend to be used in male or female recommendation letters. All occupations and adjectives were taken from <em>Word Embeddings Quantify 100 Years of Gender and Ethnic Stereotypes</em> by Garg et al. (2017). I chose to use two separate kinds of gender-neutral words because I wanted to see if the amount of bias reduction would remain constant between the original and retrained model.</p><p><em>3.4.2 Defining a Gender Subspace</em></p><p>The gender subspace is a vector subspace that represents a “gender neutral” meaning. In order to create this subspace, I create a list of gender-opposed word pairs. For example, <em>male/female</em>, <em>man/woman</em>, <em>king/queen</em>, etc. Then, for each pair, I subtract the male vector from the female vector. Then, I apply Principal Component Analysis and take the first eigenvalue as the gender subspace. Essentially, PCA combines a set of high dimensional vectors into one, singular high-dimensional vector that generalizes the set. In the next section, I explain the three different versions of g that I created, all differing based on the kinds of gender word pairs used to create the subspace.</p><p>Both the gender subspace (g) and the gender-neutral word (w) are normalized so that their magnitude is length 1. Thus, the cosine similarity between the subspace and the word is simply the dot product. This mathematical simplification can be seen in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/0*L7MQD823K5Yfb21s" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/0*ZPqqC0RavMwUdKur" /></figure><p><em>3.5 Defining Gender as a Linear Subspace</em></p><p>At the beginning of the project, I began by establishing one gender subspace (g) that was defined using all different kinds of words that refer to gender. Upon further reflection, however, I realized that there are (roughly) three kinds of gender-related words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/0*PXHzNUCKZXABe1ef" /></figure><p>Thus, I decided to make three different gender subspaces, each created using the words corresponding to one of these three categories. This was to test if the way gender is defined as a linear subspace (and therefore as my method of evaluating bias) has an effect on how much the bias is reduced (or whether it is reduced at all). I hypothesized that the gender subspace defined using pronouns was most likely to have cases where the gender bias was reduced, simply because this is exactly how I was treating the input between my two models.</p><p><strong>IV. Results</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/0*_uDcvnIsDMLRfA0F" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/0*Y15YeRxWNMZO1-K-" /></figure><p><em>4.1 Differences in Large and Small Models</em></p><p>In general, there were more cases where gender bias was reduced in the models trained with less Wikipedia data (three for the small model, two for the large model). This is likely because with more data, there is more representation of bias, and thus, a higher chance that the amount of gender bias will increase. In other words, if the original model displays significant gender bias, then adding twice as much data to the training dataset will amplify that bias. Conversely, smaller changes are likely to have relatively larger effects within the small model. Changing the pronouns within a smaller dataset presumably changes a larger portion of the data than in the larger dataset.</p><p><em>4.2 Differences in Gender-Neutral Terms</em></p><p>Bias was reduced in a similar number of instances for each group of gender-neutral terms. In addition, in the cases where bias was reduced, the degree to which it was reduced was relatively similar between the two kinds of words as well. It is important to note that I made a mistake in not controlling for the relative number of words used in each group of gender-neutral words. The group of adjectives featured far more words than the group of occupations, and in future research, this will be controlled for, especially in the interest of comparing initial bias measurements.</p><p><em>4.2 Differences in definitions of gender</em></p><p>The only cases where gender bias was reduced in the large model was when the pronoun gender subspace was used to measure gender bias. This is in accordance with my hypothesis. Because I altered the input data by essentially neutralizing the meaning of gender pronouns, it makes sense that this case, if any, would show bias reduction. There is a small, unexpected anomaly in the small model, in the case of occupations for the pronoun subspace. I would have expected this number to reduce between training, but the small size of the dataset introduces a higher chance of variability.</p><p><strong>V. Future Work</strong></p><p>There are a number of potential avenues for future work, many of which I plan to pursue in the spring semester (2019). First, and most simply, I will control for the relative number of adjectives and occupations used to evaluate direct bias. Doing this will allow me to look at which set of gender-neutral terms naturally carries more bias. Second, I want to apply this method for gender bias reduction across different kinds of word embedding techniques (while keeping the original corpus constant). I would like to compare across word2vec (especially because it has a skip-gram design quite similar to FastText’s), GloVe (because it has an entirely different design to that of FastText), and Gensim, among possible other methods. I also want to establish a more robust means of evaluating the overall “goodness” or strength of a model by utilizing some of the intrinsic evaluation techniques discussed in Bakarov’s paper (2018). I want to apply the technique across different kinds of text corpora, including fictional corpora, especially ones told in the third person (they may contain more instances of pronouns, especially because they are descriptive and narrative). Finally, I want to validate the three means of creating a gender subspace. To do this, I want to train multiple different kinds of models with the same input corpus, and see if the direct bias measure for one particular word is correlated across the models, and across the gender subspace definitions.</p><p><strong>VI. Conclusion</strong></p><p>In order to study whether or not input data can be altered to reduce the amount on inherited gender bias in word embeddings, I trained two before-and-after models to compare direct bias measurements and test for reduction. I treated the input data by creating two copies of the original data, the second of which all gender pronouns were swapped. I also controlled for varying methods of describing gender in language (i.e., gender <em>pronouns</em>, <em>explicit</em> gender words, and <em>implicit</em> gender words), as well as the kinds of words that the model would be evaluated by (i.e. occupations and adjectives). I found that in general, as the size of the embedding increases, bias is more difficult to reduce, likely because the input alterations are relatively smaller changes to the data overall. In addition, the way in which gender is defined as a subspace affects the evaluation of direct bias. Therefore, in cases where the gender subspace matched the way in which the input changed (i.e., using the <em>pronoun</em> subspace), bias was successfully reduced.</p><p><strong>VII. Appendix</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*clK-UyIsHh_Vxluv" /><figcaption>Final research poster</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=617025ec29f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-7-semester-recap-617025ec29f8">Step 7: Semester recap</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step 6: Make it pretty]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-6-make-it-pretty-21a67d3cd672?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/21a67d3cd672</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Tue, 27 Nov 2018 06:09:11 GMT</pubDate>
            <atom:updated>2018-11-27T06:09:10.785Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UfQaRe28BCq7my66NaVf8g.png" /><figcaption>One of my favorite charts at the moment. I actually collect these when I find particularly good ones, I think they’re a great source of inspiration. Thanks, <a href="https://www.evogeneao.com/learn/tree-of-life">evogeneao</a>.</figcaption></figure><p>First, I want to talk a little bit about data visualization in general. One of the many tasks of scientists is to make data visualizations, and I think a <em>good </em>visualization should do two things:</p><ul><li><strong>Maximize</strong> the amount of information you are communicating</li><li><strong>Minimize</strong> the amount of work the reader must do to get this information</li></ul><p>The chart up above displays all the living branches of life (extinct species excluded), and I think it’s really wonderful. First, it uses both space and color to represent information. Unfortunately, not all information is conducive to such beautiful representation. But, even if data isn’t represented in a rainbow arch, doesn’t mean that it’s poorly represented.</p><p>The trick, I think, is to use what dimensions you have in visualization (color, axes, space, shape, etc.) to represent information, without making the design overkill.</p><p><strong>Why is it so important to represent information in the <em>right</em> way?</strong></p><p>Well, I guess that comes down to why do we even do research, to begin with? And I think, at least for me, the answer is to learn more about how to exist. Ok, maybe that’s a bit existential, but the point is that we do research to answer questions. Once we answer those questions, regardless of how they’re being answered, it’s the duty of scientists to disseminate this information to the masses. If we don’t do this, then science becomes a closed society in which a small group of individuals is well-informed.</p><p>I don’t want to get <em>super</em> political, but this is problematic because then we can’t do things like use scientific information to make a change. If politicians don’t vote on behalf of things like climate change simply because they don’t understand it, then we’re allowing them to drive society based on a lack of information <em>that already exists</em>.</p><p>All in all, share your data and bother to package it in a way that other people can understand it.</p><p><strong>Ok cool, but how does this relate to your project?</strong></p><p>These past two weeks, I’ve been preparing a poster that encapsulates my research questions and results. This task is essentially asking us to visually represent what we’ve spent the last few months doing while minimizing words, and maximizing aesthetic.</p><p>It’s a challenge, definitely. Not only do you have to clearly communicate where you ended up, the “end state” if you will, but you have to communicate how you got there. You’re telling a story while delivering the moral in a short, punchy sentence.</p><p>Spoiler alert: I don’t have a really cool rainbow web of little lines. I have a table, that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*kFho0pDgsRBOB1vuCtqn0A.png" /><figcaption>Blue is where bias was reduced, white it remained constant, red it increased</figcaption></figure><p>But, I do think that this communicates a lot of information. It shows that my first set of models, trained on a smaller corpus of text, was more responsive to my bias reduction technique. While it didn’t always work, it did half of the time. Then, in the larger model, the bias was only reduced a third of the time, and it reduced by a much smaller margin when it did decrease. Plus, the cases where the bias was reduced were limited to the use of the pronoun gender subspace.</p><p><strong>Why?</strong></p><p>Well in the case of both model sizes, the pronouns were neutralized (if you want more explanation of what this means, look <a href="https://medium.com/fixing-sexist-ai/step-3-measurable-results-2d25829844e6">here</a> under the section <strong>I manipulated my data and retrained my model</strong>). Because there is less text in the first model, this neutralization affects a larger portion of the text.</p><p>The data ratio between the small model and the large model is around 1:7. In other words, for every <em>one</em> sentence of data in the small model, there are <em>seven </em>sentences in the larger model. So, when you neutralize the data, it probably has a larger effect on the word meanings in the small model, because their meanings are based on less text, to begin with.</p><p>The fact that we saw minimization for the large model <em>only</em> when using the pronoun subspace is also within expectations. Because the way we’re neutralizing the data is based on neutralizing the pronouns, then it makes sense that it would be reduced in the case of the pronoun subspace. To make a comparison, it’s like testing how good a recipe for cookies is. If you define “goodness” by how sweet it is, then you’d expect that when you chuck in an extra cup of sugar, the cookies are considered better than they originally were.</p><p><strong>So, where are you right now?</strong></p><p>Well, I’m in the final squabbles with my advisor over what the final poster will look like. Once it’s done, however, I’m taking the <em>best</em> Thanksgiving break I’ve ever taken, because I’ve earned it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21a67d3cd672" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-6-make-it-pretty-21a67d3cd672">Step 6: Make it pretty</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step 5: Did it work?]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-5-did-it-work-e361c59e1b29?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/e361c59e1b29</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Mon, 12 Nov 2018 06:24:36 GMT</pubDate>
            <atom:updated>2018-11-12T06:26:01.940Z</atom:updated>
            <content:encoded><![CDATA[<h3>Step 5: Entering the big leagues</h3><p>I spent a lot of time trying to find some sort of metaphor/analogy/simile to capture what I did over the last two weeks. First, I thought I’d compare myself to Dee Dee from Dexter’s Laboratory, spending a week pressing buttons, oblivious to the possible harm that might come to my CPU. Then I was thinking about this complex architecture metaphor, where the work before right now was all about drawing designs and building scaffolding, and this week was about actually erecting the building. I don’t feel like any of these really capture the entirety of what I did, but maybe they give you a bit of a general idea. I’m going to break what I did down into sections, and please refer to this crude flowchart for a breakdown of the information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nbfsPkX0I6TOtgSPOX8ROQ.png" /><figcaption>Figure 1: Breakdown of the information I’m computing.</figcaption></figure><p><strong>I got a new model trained on more data</strong></p><p>First and foremost, for a long time, I have been planning on taking all the direct bias statistics I’ve been computing, and running them on a word embedding trained with <em>much</em> more data. So far, I’ve been using a word embedding that I only trained with ~2GB of data, which is really not a lot compared to the typical word embedding. Theoretically, a larger training dataset will lend more information about the true function and meaning of a word, because there are simply more examples of its use.</p><p>This new model (referred to as the “Large Model” in <strong>Figure 1</strong>), was trained on around 16 GB of Wikipedia text. Now, I can also compare the amount of gender bias in a small and large model, and make some hypotheses about why they might be different (provided they are, actually different).</p><p><strong>I trained a second model, one that had “gender neutralized data”</strong></p><p>I’m assuming that if you’re reading this right now, you’ve read some of my past documentation. In case you’re confused, read this article, focus on the <strong>“I manipulated my data and retrained my model”</strong> section. So, I made a second version of my 16 GB Wikipedia dataset, one with both instances of pronouns (i.e., he and she, him and her, his and hers).</p><p>If you did the math (like I did), I had to download 16 GB of Wikipedia (nearly the entirety of Wikipedia, btw), then I had to unzip the file and get the raw data into a text file. Then, I had to train the first word embedding with the original data. Then I had to make a new version of the data, the “gender-neutral” version. Then, I had to train yet another word embedding (Model 2 in figure 1, for the Large Model) with said data. Over the course of about four days, my computer ran code for around 40 hours. This is when I began to feel like Dee Dee from Dexter’s Laboratory, perpetually pressing important buttons, with a somewhat lackadaisical mindset.</p><p><strong>I realized that (English) language has a lot of ways of talking about gender</strong></p><p>Well, I and my faculty advisor (can’t take all the credit here). What is the difference between words like <em>he</em>, <em>she</em>, <em>his</em>, and <em>hers</em>, and words like <em>woman</em>, <em>man</em>, <em>female</em>, and <em>male</em>, and words like <em>king</em>, <em>queen</em>, <em>waiter</em>, and <em>waitress</em>?</p><p>In my mind, they break down into three distinct categories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XM-uyCokfxBkS8DUKuMLA.png" /></figure><p>And because I am using these gender words to create a vector subspace that <em>represents </em>gender, I need to actually make <em>three separate</em> gender subspaces, where each one is represented by words falling in each of these categories. Why is this important to do? Well, it’s possible that the kind of gender word used actually alters the way in which we measure gender. In fact, it’s probably the case that this is happening. If I can differentiate meaning between these three categories, then why wouldn’t my model? This could be a confound.</p><p>This is why the third tier (left to right) of <strong>Figure 1</strong> breaks into three children for each node. For each model, there are three possible gender representations to use to calculate the direct bias statistic.</p><p><strong>I created two distinct sets of words that I can use to measure direct bias</strong></p><p>The first are words that are different gender-neutral occupations. What makes an occupation gender-neutral? Well, it can’t specify a gender. So things like <em>waiter </em>and <em>waitress</em> are excluded, but things like <em>geologist</em> and <em>doctor</em> are included. The second group is composed of adjectives (e.g., <em>sober</em>, <em>prudent</em>, <em>confused</em> etc.).</p><p>Why do I use two groups? Well, I want to make sure that in the case that I <em>do</em> observe minimization of bias, that it’s consistent across different kinds of words. Essentially, I want to make sure that — if I see minimization — that neutralizing the pronouns is a <em>reliable technique</em>.</p><p>If you’ve been looking at <strong>Figure 1</strong>, this is the rightmost column of branches.</p><p><strong>So where are you now?</strong></p><p>Well if you counted the number of branches in the rightmost column, I’m expecting 24 distinct direct bias statistics. And here they are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*O8gAFSp1LYxWWu8F4fKr5w.png" /><figcaption>Every two lines are the adjective/occupational stats for a given model. Small Model 1 (0–1), Small Model 2 (2–3), Large Model 1 (4–5), and Large Model 2 (6–7). Even rows are adjectives, odd rows are occupations.</figcaption></figure><p>Not that helpful, Chloe. That caption alone makes me want an Advil.</p><p>I know. That’s why these next two weeks are all about data visualization.</p><p>Stay tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e361c59e1b29" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-5-did-it-work-e361c59e1b29">Step 5: Did it work?</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step 4: Learning individual project management]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-4-learning-individual-project-management-328ac9352acc?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/328ac9352acc</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Wed, 31 Oct 2018 22:40:20 GMT</pubDate>
            <atom:updated>2018-10-31T22:40:19.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMfnf29zCn0P3UHEoX_K8w.jpeg" /><figcaption>This is in NO way a representation of myself. <a href="https://toggl.com/time-management-tips/">Source</a></figcaption></figure><p>Two weeks (and a few days later), it’s time for an update on the trajectory of my project.</p><p>To be frank, there isn’t such an exhaustive list of accomplishments this week, but I think the reasons why are important to discuss.</p><p>This is the first project I’ve worked on that has been <em>this independent</em>. I’ve not only worked on many group projects, but I actually teach others on my campus how to use frameworks like Agile, Git workflow, and team management in order to execute software development projects. I spend lots of time working with people on how to achieve their goals, and I really like doing it. This project, however, I don’t report to anyone (besides my advisor), and I call the shots. This, as it turns out, is a novel thing for me, and I want to recap some of the things I’m learning along with my project updates.</p><p><strong>What actually did get done…</strong></p><p>First, I realized that the Direct Bias statistic that I showed in my previous wasn’t entirely correct. Why?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*_0drjVQDoOEPu1fo6Ydm4w.png" /><figcaption>Dot product vs. cosine distance. <a href="http://www.sharetechnote.com/html/Handbook_EngMath_Matrix_InnerProduct.html">Source</a></figcaption></figure><p>I’m trying to find the distance between two vectors. In linear algebra, to do this, you have two options: 1) you can find the cosine angle between the two vectors, or 2) <strong>if the vectors are normalized (each of their magnitudes is one)</strong> then you can simply dot them together.</p><p>What I did is dot two vectors together without normalizing their length. So, I fixed that. This is easier said than done. For some reason, getting the vectors normalized was fairly difficult for me, mostly because numpy arrays have to have ≥ 2 dimension shape to be normalized using the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.normalize.html">sklearn built-in normalization function</a>. Turns out that <a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.linalg.norm.html">numpy’s normalization function</a> is a little easier to use, so I used it instead.</p><p>I also spent some time considering why some other things that might be affecting my direct bias statistic. With the changes, this is where my statistics are:</p><pre>OLD MODEL Direct Bias Statistic on the Basis of 10 gender-neutral occupations: <strong>0.00018722004668753861</strong></pre><pre>NEW MODEL DirectBias Statistic on the Basis of 10 gender-neutral occupations: <strong>-0.0009512678027801615</strong></pre><p>First, let’s recall the thing we’re actually trying to compute:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*YDhOnoC4MYbXldziKLnccw.png" /></figure><p>So, let’s assume that w and g are now magnitude 1, and c is 1. This is essentially an average, where we are getting the average distance between a word and the gender subspace, where each word is part of a group of gender-neutral occupations. Now, I didn’t actually realize what happened if I tried to get a word out of my model that didn’t actually exist. So, I tested it out. I tried to get a vector from fastText that corresponded to the word: ‘asdfgh’. It looks like this:</p><pre>THIS IS AN UNREAL WORD: [ 0.19603913  0.06956719 -0.0563748  -0.30959803  0.2993793   0.27973962  0.32902965 -0.18571393 -0.10059531 -0.1486822  -0.27100426  0.29755905  -0.52805394 -0.06898575  0.17272708 -0.3187574   0.40220237 -0.12613639<br>  0.1088889   0.00248592 -0.19842608 -0.27305803 -0.30295298  0.20620343  0.16899382 -0.10264714  0.00468672 -0.29631147 -0.5853479  -0.1308239  -0.538761    0.23253694  0.44791144  0.31552023 -0.46631265  0.12882975  -0.1644862   0.03299017 -0.13298115  0.23187307  0.37906307  0.26582178  -0.0104968   0.25408912  0.12902667  0.2595827  -0.48804706 -0.49396724  -0.36342803 -0.17822301 -0.05941273  0.10295238 -0.4003129   0.1141475  -0.6665548   0.4656372   0.37063244  0.6114147   0.00410935  0.26731855  0.3447803  -0.08309543 -0.3042573  -0.44058347 -0.0169682   0.34490362  0.39653784 -0.5079092  -0.32882825  0.03034679 -0.28801867 -0.03561336  -0.32503685 -0.02073119  0.29619738 -0.41246206 -0.2579498  -0.01661415  0.48539513  0.07459822 -0.16619873  0.16083758  0.2957467  -0.4803907  0.4292446  -0.04832766 -0.1960634  -0.25972307 -0.10428002 -0.19937873  0.00891159  0.21819258  0.4107799   0.39623818 -0.5364649   0.01254761  -0.07400648 -0.3827766  -0.00472946 -0.03603581]</pre><p>Hmm, highly suspicious. So, it’s important to filter out words that aren’t actually in the model. I need to figure out how to do this because my initial solution:</p><pre>word = &#39;asdfgh&#39;<br>if word in model:<br>     vector = model[word]<br>     print(vector)<br>else:<br>     print(&quot;This word doesn&#39;t even exist, nice try)</pre><p>doesn’t actually work. It prints out the vector again. Also, when I actually divide by the number of words, I actually only want to divide by the number of words that are actually in the model’s lexicon. That was an easy fix, simply added a count instead of using the length of the word list.</p><p><strong>Why things sometimes don’t get done…</strong></p><p>So there are two main reasons why I found it so difficult to keep working on my project these past two weeks. I want to elaborate on these two things because I think they’re actually two very different kinds of issues, and both very common.</p><ol><li>I hit some legitimate roadblocks that gave me some real headaches and exposed the gaps in my knowledge. Plus, some of it was legitimate time management delegation.</li><li>I didn’t set good actionable goals for this sprint, and I think it really got in my way, especially considering my extremely goal-oriented perspective.</li></ol><p>The first of these issues is fairly normal. Life gets in the way. I’m in the process of writing another separate senior thesis for my cognitive science major, taking two other classes, serving as an executive board member of three organizations, trying to apply to jobs, and also trying to answer my mother’s phone calls. So, managing my time is in of itself, a full-time job. There are some weeks when I just don’t have as much time as I’d like.</p><p>That said, the second issue is one that I find gets in the way of almost all projects, and affects individuals regardless of their outside workload. I find that if I don’t have discrete, achievable goals that I can accomplish over the short term, then I am incapable of making progress. And this relates to issue 1 as well: the only way I can actually get all of these things done at once is because I can only afford to set hourly, even sometimes half-hourly goals at a time. If I think about how much I have to get done in one full week, even one full day sometimes, then it gets so overwhelming that you kinda shut down. So, it’s really important to set yourself up for success. Don’t set goals like “deal with this error”, instead, rephrase: “check these three functions for proper performance, then write test cases that handle edge cases”.</p><p>This week, I have much more clean-cut goals, and I’ve already gotten SO much more done. When you’re working on your own, you aren’t accountable to anyone else, which seems freeing at first. In some ways, it is. You have much more creative freedom, and as I said earlier, you call all the shots. But, you need to learn to be accountable to yourself and set your own standards of success and progress.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=328ac9352acc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-4-learning-individual-project-management-328ac9352acc">Step 4: Learning individual project management</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step 3: Measurable results]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-3-measurable-results-2d25829844e6?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/2d25829844e6</guid>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Tue, 16 Oct 2018 03:29:53 GMT</pubDate>
            <atom:updated>2018-10-16T03:29:53.295Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello! I have arrived at the third-ish sprint of this project, which is hard to believe because it also coincides with the midpoint of the term. Meaning that I am supposed to be halfway-ish done with this project? Well, this project could go on for years, but generally, I am happy with where I am. I have learned new libraries, new techniques, and this past week, as I will discuss, was all about testing which things I <em>really</em> need to understand to move forward with this project, and which things only need a cliff-notes level of understanding. Here’s a quick run-down of what happened:</p><p><strong>I figured out how to integrate Gensim and FastText</strong></p><p>During the last post, I documented my process training my model using FastText, a library designed by Facebook to train word embeddings (which is only one of the <a href="https://fasttext.cc/docs/en/cheatsheet.html">many things it can do</a>). It’s <em>super</em> easy to use. You just run it through the command line, and all you need is your input data. It outputs two files, but the one of interest is model.bin, a zip file with all the vectors. The issue is that to use this model with FastText alone, I can only get my vectors through the command line, which is really inconvenient.</p><p>This is where Gensim comes in. I found <a href="https://radimrehurek.com/gensim/models/fasttext.html">this</a>, and <a href="https://datascience.stackexchange.com/questions/20071/how-do-i-load-fasttext-pretrained-model-with-gensim">this</a> to be helpful in my plight to connect Gensim and FastText. Essentially, Gensim makes it <em>super</em> easy to load a trained FastText model, and get vectors out of it using a dictionary. It took me 5 minutes to implement, and it made my whole week better. Thanks, Gensim!</p><p><strong>I got a direct bias statistic for my original model</strong></p><p>Once Gensim made it possible for me to easily get vectors out of my model, I could get to the interesting stuff: calculating how sexist my model was. Now, I know I have been fairly hand-wavey about this in my previous posts, but we’re going to go through how this actually works this time, and discuss each variable in the statistic.</p><p>Ok, so down there, below this paragraph, that’s how we can calculate the degree to which an embedding contains a particular bias of our choice. This is from <a href="https://arxiv.org/abs/1607.06520"><em>Man is to Computer Programmer as Woman is to Homemaker?</em></a><em> </em>by Bolukbasi et al. For this example, I’m going to stick with gender because, at least in English (and in most languages), gender is <em>incredibly</em> binary (which is unfortunate), but this trait turns out to be helpful in this one particular scenario. An aside, it would be cool to do this project in another language, maybe one that handles gender pronouns in a very different way from English. ANYWAY, back to the algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*lCtYvZhsCAccERuluzYP5w.png" /></figure><p>For this example, we’re going to take a list of 10 gender-neutral occupations, and see how much sway they have on the basis of gender.</p><ul><li>N → The set of gender-neutral occupation words (e.g. nurse, doctor, programmer, hairstylist, plumber etc.)</li><li>w → One of those members of N. This is a summation, or a loop if you’re thinking programmatically. Basically, we’re just going to look at one word at a time in the list of occupations. occupations[i]</li><li>g → The gender subspace. Ah yes, the elusive fox of the algorithm. Pick a list of opposing gender words (e.g. man and woman, he and she, waitress and waiter etc.) and subtract the male words from the female words (or vice versa). Then, from that set of subtracted vectors, find their principal components, and use the first eigenvalue. Sounds like linear algebra vomit, and it kind of is, but if you can learn the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html">PCA function in the sklearn</a> library, then you’ll be fine.</li><li>c → The strictness of the algorithm. This is a value between 0 and 1, and for the full year that I have worked on this project, and the four separate times I’ve calculated this statistic, I’ve always set it at 0.8. To be more specific, if c is 0, and there is no bias detected between the word and the gender direction g, then the word w has no overlap with g at all.</li></ul><p>I did a <em>very</em> basic version of this algorithm for the first version of my project. I made my gender subspace with the words <em>she, her, hers, he, him</em> and <em>his</em>. And I chose a list of 10 occupations to dot with it:</p><pre>occupations = [<strong>&#39;doctor&#39;</strong>, <strong>&#39;nurse&#39;</strong>, <strong>&#39;actor&#39;</strong>, <strong>&#39;housekeeper&#39;</strong>, <strong>&#39;mechanic&#39;</strong>, <strong>&#39;soldier&#39;</strong>, <strong>&#39;cashier&#39;</strong>, <strong>&#39;comedian&#39;</strong>,<br>               <strong>&#39;gynecologist&#39;</strong>, <strong>&#39;musician&#39;</strong>]</pre><p><strong>I manipulated my data and retrained my model</strong></p><p>Before I discuss what I found, I want to remind you that the objective of this project is to <em>minimize</em> this statistic by making clever alterations to the data I feed into the model. And while my first data manipulation wasn’t exactly clever, it was something.</p><p>I made a second model, to compare to the first. This time though, I fed it a new set of data. It’s actually two concatenated copies of the old text dataset, but in the second copy, I swapped all of the gender pronouns:</p><pre>REPLACEMENTS = [<br>    [<strong>&#39;she&#39;</strong>,<strong>&#39;he&#39;</strong>],<br>    [<strong>&#39;her&#39;</strong>,<strong>&#39;him&#39;</strong>],<br>    [<strong>&#39;hers&#39;</strong>,<strong>&#39;his&#39;</strong>],<br>    [<strong>&#39;he&#39;</strong>,<strong>&#39;she&#39;</strong>],<br>    [<strong>&#39;him&#39;</strong>,<strong>&#39;her&#39;</strong>],<br>    [<strong>&#39;his&#39;</strong>,<strong>&#39;hers&#39;</strong>],<br>    [<strong>&#39;herself&#39;</strong>, <strong>&#39;himself&#39;</strong>],<br>    [<strong>&#39;himself&#39;</strong>, <strong>&#39;herself&#39;</strong>],<br>    [<strong>&quot;she&#39;s&quot;</strong>, <strong>&quot;he&#39;s&quot;</strong>],<br>    [&quot;<strong>she&#39;ll&quot;, &quot;he&#39;ll&quot;],<br>    </strong>[&quot;<strong>he&#39;ll&quot;, &quot;she&#39;ll&quot;]</strong></pre><pre>]</pre><p>And so, armed with a script, and two models, it was TIME to see if the plan worked…</p><p><strong>Holy shit! It kinda worked!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xh4PGFh89ysviu1jGfKVlw.png" /><figcaption>Minor minimization between my old and new models!</figcaption></figure><p>I don’t care who you are, the second number is less than the first. Objective truth!</p><p>Obviously. There’s A LOT to be done. First of all, the original bias statistic is teeny tiny. When I calculated this statistic on word2Vec last year (a <em>much</em> larger model, v v famous as well), my baseline gender bias on occupations was 0.2. There are a number of reasons why this could be:</p><ul><li>My gender subspace is still pretty shitty, so I’ll bolster it with some more word pairs next time.</li><li>My list of occupations was much shorter when I did this most recent calculation so that inevitably lessens the effect.</li><li>I need more data to train this model with. I’ve had this suspicion for a while now. Starting to eat at me.</li></ul><p><strong>Ok, what’s next?</strong></p><p>Well, I want to find some way to evaluate my model, see if it’s actually a good representation of word meanings. I’ve been meaning to get around to this, but I think I’ll actually tackle it sometime this week.</p><p>Plus, those philosophical questions are still lingering, so I might pose them to someone who is actually a philosopher. Lucky for me, the professor overseeing my other thesis project is a philosopher! So maybe he can offer some respite, or maybe not. Either way, I’m sure it’ll be fascinating.</p><p>I also want to get some more interesting subspaces. Maybe ones that represent race or ethnicity. This involves re-reading old literature. The linear algebra is a little more elusive here, but I have yet another contact on campus who is a linear algebra wizard! Maybe he can help.</p><p>I can use all the help I can get.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d25829844e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-3-measurable-results-2d25829844e6">Step 3: Measurable results</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step 2: Digging a philosopher’s hole…]]></title>
            <link>https://medium.com/fixing-sexist-ai/step-2-digging-a-philosophers-hole-12708ee0c05a?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/12708ee0c05a</guid>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[undergraduate]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 20:14:03 GMT</pubDate>
            <atom:updated>2018-09-30T20:14:03.192Z</atom:updated>
            <content:encoded><![CDATA[<p>Here we are! Entry #2! It’s been 2 weeks since my last update, and I have done quite a bit. Also, if you’re reading this and haven’t read <a href="https://medium.com/fixing-sexist-ai/the-beginning-dacef1454f26">my first article</a> on what I’m doing, start there. Here’s a list of what I got done:</p><p><strong>I trained my model!</strong></p><p>I got all of my text data from Wikipedia and trained my model! AND THEN, it all got deleted, and I did it a second time! Pro-tip: be careful when you connect a GitKraken remote to your GitHub repo to push/pull. I accidentally added a README when I initialized my repo on GitHub, so there were conflicts when I tried to push and pull. Somewhere, perhaps via some unnecessarily forceful version control, I lost my local copy of my work. So, at about 2 am in Occidental’s library, I redid the whole damn thing. Luckily, my data scraping scripts were preserved, and it was easy to re-download FastText. And, my repository has been cleaned up, not to worry. Plus, I wrote my first .gitignore! Also, <a href="https://github.com/crzeller11/Debiasing-Word-Embeddings">here is the repo</a> if you want to look at the project.</p><p>Next, I need to figure out how to take the model I now have, and make it easier to get vectors out of it. I don’t want to use the command line when I’m querying hundreds of vectors at a time. I think I might need Gensim, so that’s what I’m exploring this week.</p><p>Once I have those vectors, I can use this ~fancy~ DirectBias statistic from this paper that I really love, <em>Man is to Computer Programmer as Woman is to Homemaker?</em> by Bolukbasi et al. It’s a little algorithm that allows me to do some linear algebra magic, and evaluate how biased my model is. More discussion of <em>how</em> you actually do that will come in my next post.</p><p><strong>I did some research on evaluating word embeddings</strong></p><p>One thing that I have noticed is that anyone who is anyone in the world of word embeddings knows of word2vec and GloVe. I mean, I’ve used both of them during a previous iteration of this project. And a lot of the reason why is because they’re trained with <em>tons</em> of data. And for some reason, that equates a “rigorous” model. If a researcher isn’t using a pre-trained model, then they are using one of their own that is also trained with a <em>ton</em> of data.</p><p>This makes only marginal sense to me. Obviously, having more data probably can’t hurt, but what’s alarming is that there appears to be <em>no standard</em> of evaluation in word embeddings. Luckily, I scrounged up a paper from Google Scholar (what a gem) called <em>A Survey of Word Embedding Evaluation Methods</em> by Amir Bakarov that seeks to provide some respite.</p><p>Five big things make evaluating these things really hard:</p><ol><li>What does “meaning” even <em>mean</em>? How do we know when a definition of a word is actually right, especially when it’s defined through it’s relation to other words?</li><li>It’s actually somewhat rare for programmers to filter out test data when they’re training word embeddings, but without it, how are we supposed to evaluate the models?</li><li>No one can find a significant correlation between the two major kinds of evaluation methods, so which one is right?</li><li>There are no defined statistical significance tests to show statistical power, and</li><li>There’s this thing called the “hubness problem,” which refers to hub words that are <em>really </em>commonly used (e.g. “is”, “and”), and it’s unclear how the distance between two arbitrary words is noised by these hub words.</li></ol><p>That said, I found two compelling ways to evaluate my model: synonym detection (given a word, pick out its synonym from a multiple choice list) and outlier word detection (given a group of synonyms, and one randomly selected word, identify the odd-one-out). My next entry will have more detail on these.</p><p><strong>I looked at how other’s have debiased word embeddings for some #inspriation</strong></p><p>So, I want to change the way the input data is organized so that when I train the model, my word vectors come out in a way that is less biased.</p><p>Others have had the goal of minimizing bias (like <a href="https://arxiv.org/abs/1607.06520">here</a>, <a href="https://researchportal.bath.ac.uk/en/publications/semantics-derived-automatically-from-language-corpora-necessarily">here</a>, <a href="http://blog.conceptnet.io/posts/2017/how-to-make-a-racist-ai-without-really-trying/">here</a>, and <a href="https://arxiv.org/abs/1809.01496">here</a>, to name a few), but generally, they take a list of words that need to be “neutralized” and essentially neutralize them by using a subspace that spans gender or race-based vectors.</p><ul><li>An aside: to make this subspace, let’s say for gender, they take words that are diametrically opposed on the basis of gender (like waiter and waitress) and subtract the female vector from the male vector. Then, they take the first vector from PCA of those vector subtractions.</li></ul><p>None of the papers I have read actually minimize bias through changing the way in which the text is prepared before it goes into the model. That said, if you know of one, shoot me an email (czeller@oxy.edu). So, my current game plan is to make two copies of my corpus, one with the original gender pronouns, and one with the gender pronouns swapped (he → she, him → her, his → hers), and then concatenate them. Then see what happens.</p><p><strong>And finally, the philosopher’s crisis I came to</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TQgsYniJt8do0aqK_ctNA.png" /><figcaption><a href="https://hackernoon.com/bias-sexist-or-this-is-the-way-it-should-be-ce1f7c8c683c">Kindly borrowed from HackerNews</a>.</figcaption></figure><p>This is where the title of this particular blog entry comes in. With my bi-weekly meeting with my faculty advisor, other than updating him on what I’d done, I talked to him about some of the actually scary things I’ve been thinking about. Sure, I can build a model, evaluate it, calculate this DirectBias statistic, do the changes to my data, remeasure the statistic, and be done with it. But I don’t feel like that answers any of my questions. And as I putter along, working on this project, the code isn’t what keeps me up at night, this is:</p><ul><li>What does it <em>mean</em> to be racist or sexist? Does that change in the context of a word embedding?</li><li>Also, my opinion of what constitutes sexism and racism is different from someone else’s. I mean I’m a white, cis-gendered, straight woman. My own privilege affects my definition of these words. Do I even have the authority to determine what it means to be “debiased”?</li><li>Even if we could assemble some sort of “public opinion”, does it not change every year, every month, every hour? Can we ever be “hands off”? I’m not sure…</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12708ee0c05a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/step-2-digging-a-philosophers-hole-12708ee0c05a">Step 2: Digging a philosopher’s hole…</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Beginning]]></title>
            <link>https://medium.com/fixing-sexist-ai/the-beginning-dacef1454f26?source=rss----ded0cd79f0c4---4</link>
            <guid isPermaLink="false">https://medium.com/p/dacef1454f26</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fasttext]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <dc:creator><![CDATA[Chloe Zeller]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 03:23:42 GMT</pubDate>
            <atom:updated>2018-09-14T03:25:57.440Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*gejeBAG1aRDFWOL8Uxz3dg.png" /><figcaption>Somehow, xkcd makes all parts of CS more human <a href="https://xkcd.com/1838/">https://xkcd.com/1838/</a></figcaption></figure><p><strong><em>Who is this?</em></strong></p><p>Hello! My name is Chloe Zeller. I’m a senior at Occidental College, a small liberal arts institution in Los Angeles. I’m studying computer science and cognitive science, and I’m minoring in math.</p><p><strong><em>Why are you here?</em></strong></p><p>Good question. For my comps (senior thesis), I’m spending time trying to understand how to make word-embeddings less biased. Mostly by following the guidance of the stick figure on your left. Well, for the most part.</p><p><strong><em>How, though? Be more specific.</em></strong></p><p>In a nutshell, word embeddings are a method of taking <em>TONS</em> of text and trying to extrapolate word meaning based on patterns and relationships in the text data. Maybe this is a gross over-simplification, but that’s how I see it. Unfortunately, we live in a society where the way we write doesn’t entirely capture who we wish we were. Let me be more specific — do you think the word <em>man</em> appears more often with the word <em>doctor</em> than <em>woman</em>? Probably. I mean, there are <a href="https://www.kff.org/other/state-indicator/physicians-by-gender/?currentTimeframe=0&amp;sortModel=%7B%22colId%22:%22Location%22,%22sort%22:%22asc%22%7D">two times more male practicing physicians than female</a>.</p><p>This means that when my neural network goes through hundreds of millions of words, it will learn that <em>doctor </em>is closer to <em>man</em> than <em>woman</em>. And this mistake propagates. This could mean that less high-paying jobs are prioritized to women using Google than men. Scratch that, <a href="https://arxiv.org/abs/1408.6491">this article</a> showed that was true.</p><p>So, <em>very</em> generally, I want to do four things:</p><ol><li>Train a word embedding using FastText (a <a href="https://fasttext.cc/">word embedding library</a>developed by Facebook) and a corpus of Wikipedia articles (they do <a href="https://dumps.wikimedia.org/enwiki/20180901/">regular dumps</a> of their content)</li><li>Evaluate the amount of gender bias the model inherits, based on the Direct Bias statistic defined in <a href="https://arxiv.org/abs/1607.06520">this paper</a>.</li><li>Change around the input corpus so that I minimize the overall amount of bias, while not losing the meaning of words.</li><li>Retest the bias statistic, and minimize it.</li></ol><p><strong><em>Where are you right now?</em></strong></p><p>Over the course of the first few weeks of the semester, I have been puttering along, trying to get the ball rolling. There are a number of things I have done, a few decisions I have made, and some roadblocks I have hit:</p><ul><li><strong>FastText:</strong> I ran it for the first time! I couldn’t really get a hold of good data yet (more on that in the bullet below), but I passed the Declaration of Independence as a corpus and it ran without a hitch! I am actually really surprised at how easy it is to use FastText. Runs right off the command line, and there’s very little I need to do to get it going, other than provide it with some text as input.</li><li><strong>Data:</strong> I had some hiccups trying to find the right place to actually download Wikipedia’s dumps. I think they could do a much better job at labeling the different kinds of downloads they provide because there is a huge variety. I have found that Gensim is a great tool for isolating Wikipedia data and that the process is <a href="https://www.kdnuggets.com/2017/11/building-wikipedia-text-corpus-nlp.html">incredibly well documented</a>. Thank you Matthew Mayo, your code is saving me at least a few days of .xml parsing. Ick.</li><li><strong>Putting them together:</strong> So now, I am in the process of getting my 2GB worth of data saved to one nice, clean text file. Once I have done this, I can run FastText for the first time, with a relatively robust dataset. From there, I have to figure out how to isolate the output vectors, so I can calculate the bias statistic. That bias is <em>gender</em> bias, btw. Later, I want to expand to other kinds of bias like race, socioeconomic status, education, etc. I also need to work on documentation this week (i.e. writing a good README, keeping better track of the questions that come up when I’m in the shower, etc.), but this blog is a fairly good start.</li></ul><p>So, here we go! Am I terrified? Absolutely! I think that’s good, though. It means that there’s something worth exploring.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dacef1454f26" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fixing-sexist-ai/the-beginning-dacef1454f26">The Beginning</a> was originally published in <a href="https://medium.com/fixing-sexist-ai">Fixing Sexist AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>