<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>christina.kim</title>
    <description></description>
    <link>https://christina.kim/</link>
    <atom:link href="https://christina.kim/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Tue, 23 Jul 2024 06:19:29 +0000</pubDate>
    <lastBuildDate>Tue, 23 Jul 2024 06:19:29 +0000</lastBuildDate>
    <generator>Jekyll v3.9.5</generator>

    
      <item>
        <title>Scaling Laws for Language Transfer Learning</title>
        <description>&lt;h5 id=&quot;building-upon-openais-recent-work-on-scaling-laws-my-project-explores-how-much-pre-training-on-english-helps-when-transferring-across-different-languages&quot;&gt;Building upon OpenAI’s recent work on scaling laws, my project explores how much pre-training on English helps when transferring across different languages.&lt;/h5&gt;

&lt;h5 id=&quot;here-i-will-discuss-scaling-laws-discovered-while-fine-tuning-across-different-languages-with-pre-trained-english-language-models-specifically-i-found-that-a-pre-trained-english-models-help-most-when-learning-german-then-spanish-and-finally-chinese-and-b-transfer-from-english-to-chinese-german-and-spanish-scales-predictably-in-terms-of-parameters-data-and-compute&quot;&gt;Here, I will discuss scaling laws discovered while fine-tuning across different languages with pre-trained English language models. Specifically, I found that a) pre-trained English models help most when learning German, then Spanish, and finally Chinese and b) transfer from English to Chinese, German, and Spanish scales predictably in terms of parameters, data, and compute.&lt;/h5&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/christinakim/scaling-laws-for-language-transfer&quot;&gt;code&lt;/a&gt; | &lt;a href=&quot;https://huggingface.co/christina&quot;&gt;models&lt;/a&gt; | &lt;a href=&quot;https://youtu.be/lpe5Gwuqa-k&quot;&gt;presentation&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p class=&quot;imgContainer1&quot;&gt;Historically, the advancement of deep learning capabilities has centered around three levers: improved algorithms, faster and cheaper compute, and larger and higher quality datasets.  Given machine learning’s promise to significantly impact society, deepening our general understanding of machine learning, and how certain levers improve models, is critical for making better predictions for which capabilities will develop next, and when. Recently, researchers have increasingly explored scaling relationships between these three levers.
&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/scaling-autoreg.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 1. Figure from Henighan et al. 2020.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My project’s framework for experiments is inspired by the work on scaling laws published by OpenAI in the past year. Scaling laws (Kaplan et al. 2020) can predict machine learning performance as a function of model size, dataset size, and the amount of compute used for training. Henighan et al. (2020) also found that this relationship holds over several orders of magnitude across different modalities, as seen in the figure above. Earlier this year, scaling relationships were found for transfer learning from pre-trained english text models to Python (Hernandez et al 2021). These results show that compute, dataset size, and model size are different limiting factors that scale with each other in surprisingly predictable trends when we setup our experiments to measure those things.&lt;/p&gt;

&lt;p class=&quot;imgContainer1&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/meme.jpg&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In my project, I continue the study of transfer between distributions and look at scaling between three other languages and English. Scaling laws for transfer are important because the scaling relationships explain how to work in limited data regimes. In an ideal world, one would have an infinite amount of data for a model to learn from. However, getting a large quantity of high quality data is a nontrivial, if not impossible, task and as a result, most problems exist in the low data regime. Before the Scholars program, I was a machine learning engineer and saw firsthand how costly it was in terms of both time and money to get good quality human labels for our tasks. Exploring the relationships between different languages can provide more insight on how to tackle low-resource languages and how to best leverage pre-trained language models. Given the real world limitations of data, the tradeoffs between budgeting for compute on larger models and budgeting for more fine-tuning data is an important practical relationship to understand.&lt;/p&gt;

&lt;h2 id=&quot;experiment-methodology&quot;&gt;Experiment Methodology&lt;/h2&gt;
&lt;p&gt;Building upon work from Scaling Laws for Transfer (Hernandez et. al. 2021), my experiments focused on exploring the relationships between fine-tuning on non-English languages. My experiments try to answer the question: &lt;strong&gt;How much does pre-training on English help when transferring across different languages as we vary the dataset size and model size?&lt;/strong&gt;&lt;/p&gt;

&lt;h3 id=&quot;pre-training&quot;&gt;Pre-training&lt;/h3&gt;
&lt;p&gt;I first trained English language models in a similar setup to Scaling Laws for Neural Language Models. I pre-trained decoder-only transformers of size 124M, 70M, 51M, 39M, 16M, 3.3M, non-embedding parameters with the same hyperparameters on &lt;a href=&quot;https://openwebtext2.readthedocs.io/en/latest/&quot;&gt;OpenWebtext2&lt;/a&gt;(65.86GB), an open-source version of WebText created by &lt;a href=&quot;https://www.eleuther.ai/&quot;&gt;Eleuther AI&lt;/a&gt;. All models used Adam, a batch size of 512, context length of 1024 tokens, and a learning rate schedule with a 500 step linear warm-up with a cosine decay to 10% of the maximum learning rate. The text was encoded with a &lt;a href=&quot;https://huggingface.co/transformers/model_doc/gpt2.html#gpt2tokenizer&quot;&gt;GPT2 tokenizer&lt;/a&gt;, a byte-level Byte-Pair Encoding tokenizer with a 50K vocab size. All models were trained for a total of 26 billion tokens with no repeats. The code to reproduce these pre-trained models is available on &lt;a href=&quot;https://github.com/christinakim/scaling-laws-for-language-transfer&quot;&gt;GitHub&lt;/a&gt;, including model weights. As seen in the figure below comparing loss and model size, the models exhibit scaling laws as model size increases. However, the relationship isn’t exactly linear, suggesting that maybe the models are under-trained or the hyperparameters are not tuned thoroughly.&lt;/p&gt;

&lt;p class=&quot;imgContainer1&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/openwebtext2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 2. Training curves for transformers on OpenWebtext2. The larger models overlap with each other early in training which suggest the hyperparameters are not tuned thoroughly.&lt;/em&gt;&lt;/p&gt;

&lt;p class=&quot;imgContainer1&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/openwebtext2_compute.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 3. Language modeling performance improves as parameters increases, but the relationship is not linear.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;fine-tuning&quot;&gt;Fine-Tuning&lt;/h3&gt;
&lt;p&gt;For the fine-tuning experiments, dataset size spanned six orders of magnitude, and model size spanned two orders of magnitude trained on three different languages: Spanish, Chinese, and German. Models trained or fine-tuned on Chinese datasets leveraged a 1.2 billion character dataset, Community QA. Community QA (webtext2019zh) is similar to the WebText corpus. Models trained or fine-tuned on Spanish texts and German texts are from &lt;a href=&quot;https://oscar-corpus.com/&quot;&gt;Oscar&lt;/a&gt;, a multilingual corpus obtained by language classification and filtering of the Common Crawl corpus.&lt;/p&gt;

&lt;p&gt;The models fine-tuned on non-English languages with the pre-trained English model weights, and the models trained on non-English languages from-scratch were all trained up to the optimal loss if the model started over-fitting or up to 15M tokens, whichever came first. Models were trained with a learning rate schedule of a 300 step warm-up with a cosine decay to 10% of the maximum learning rate. The code to replicate these experiments will also be available on GitHub.&lt;/p&gt;

&lt;h2 id=&quot;results&quot;&gt;Results&lt;/h2&gt;
&lt;h4 id=&quot;effective-data-transfer&quot;&gt;Effective Data Transfer&lt;/h4&gt;
&lt;p class=&quot;imgContainer1&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/effective-data-transfer-explanation.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 4. The performance of a 16M parameter transformer model on Chinese, both trained from scratch on Chinese and pre-trained on English then fine-tuned on Chinese.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In my experiments, I wanted to find the effective data transferred for models trained on English text to Chinese, Spanish, and German text. The effective data transferred is defined in Scaling Laws for Transfer as the amount of additional fine-tuning data that a model of the same size, trained on only that fine-tuning dataset, would have needed to achieve the same loss as a pre-trained model. In the figure above, each point is a 16M transformer trained to convergence on dataset of X tokens. The total amount of data required for the model trained from scratch can be represented as $D_e = D_f + D_t$ where $D_e$ is the total amount of effective data, $D_f$ is the amount of data needed for the fine-tuned model, and $D_t$ is the amount of additional data needed for the trained from scratch model. $D_t$ is the amount of data transferred from pre-training on English.&lt;/p&gt;

&lt;style type=&quot;text/css&quot;&gt;
  .imgContainer img {
    max-width: 175% !important;
    margin-left: 50%;
    transform: translateX(-50%);
  }

  .imgContainer1 img {
    margin-left: 50%;
    transform: translateX(-50%);
  }

  .image-caption {
    text-align: center;
    font-size: .8rem;
  }

&lt;/style&gt;

&lt;p class=&quot;imgContainer&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/effective_data_transfer_16M_transformer.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 5. Comparing performance of a 16M parameter transformers trained from scratch, and fine-tuned on Chinese, Spanish, and German. For the dataset size of 8000 tokens, $D_t$, the amount of data transferred, is largest for German. The dashed line on the graphs represent $D_t$. As the number of tokens in the dataset size increase, $D_t$ becomes smaller across all languages.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As seen in the figures above, English to Chinese had a smaller amount of data transferred compared to English to Spanish for the same model size and English to German had the greatest amount of data transferred. Pre-trained English text models help most when learning German, followed by Spanish, and finally, Chinese. I believe these results reflect the degree of linguistic similarities between English and the non-English  languages. English and German are both derived from Proto-Germanic and are linguistically most similar. Although the Spanish alphabet shares almost all the same symbols with the English alphabet, it is a Romance language, and Chinese does not share the same alphabet as English. Each language has a distinctive shape and distance between fine-tuning and training from scratch. For instance, the effective data transfer is not too much greater for Spanish, vs Chinese, at the smallest dataset size, 8000 tokens. However, as we increase the dataset size, pre-training continues to help for another order of magnitude until the 100M token dataset size  than the Chinese which converges at 10M token dataset size.&lt;/p&gt;

&lt;h4 id=&quot;comparing-the-fraction-of-effective-data-from-fine-tuning-d_f-d_e-&quot;&gt;Comparing the Fraction of Effective Data from Fine-Tuning, $D_f /D_e $&lt;/h4&gt;

&lt;p&gt;$D_f /D_e $ measures the fraction of effective data from fine-tuning. A smaller fraction means pre-training helps more. I found that as model size increases, $D_f /D_e$ decreases across all languages and pre-training becomes more effective. However, as dataset size increases, $D_f /D_e$  increases across model sizes and pre-training becomes less effective. In the figure above, German has steeper curves, seeing the effective data from fine-tuning decrease the most, which shows English helps the most while Chinese has the flattest curves, showing pre-training helps the least for Chinese.&lt;/p&gt;

&lt;p class=&quot;imgContainer&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/comparing_1-effective.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 6. Comparing the fraction of effective data from fine-tuning of a 16M parameter transformer model on Chinese, Spanish, and German.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I find many of the same trends and relationships found in the Scaling Law for Transfer between text and code, between English and different languages.&lt;/p&gt;

&lt;p class=&quot;imgContainer1&quot;&gt;&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/data-limited.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the low data regime, pre-training is helpful across model sizes, but especially in large model sizes. When using pre-trained models, model performance is &lt;em&gt;parameter limited&lt;/em&gt;. Model performance is considering parameter limited when the loss continues to decrease as we increase the model size. Model performance is data limited when increasing the number of parameters does not impact the loss. This is evident in the figure above, which shows that as model size increased with a fixed dataset size of Chinese text to fine-tune on, models trained from scratch on Chinese did not improve as much while models that were pre-trained on English improved more to achieve better performance. The flat lines indicate the performance is data limited, while the sloped lines indicates the performance is more limited by the number of parameters.&lt;/p&gt;

&lt;p class=&quot;imgContainer1&quot;&gt;Lastly, pre-trained models are more compute efficient than training from-scratch across dataset sizes. This is without accounting for the compute costs for the pre-trained model.
&lt;img src=&quot;/images/posts/scaling-laws-for-language-transfer/loss_v_compute_60M_transformer_500M_chinese.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;p class=&quot;image-caption&quot;&gt;&lt;em&gt;Fig 7. Comparing amount of compute needed for a 60M transformer trained from scratch and fine-tuned on 500M tokens of Chinese&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;limitations&quot;&gt;Limitations&lt;/h2&gt;
&lt;p&gt;There are important limitations of my work. First, I used the same BBPE GPT-2 tokenizer for all languages. This is extremely inefficient for the non-English languages since the tokenization requires more tokens to represent the language. For example, Chinese is upwards of 50K characters, while the BBPE tokenizer used a 50k vocab size. Second, my largest models could have been pre-trained for longer. For scaling law experiments, it’s important to make sure models are in the correct regime, either convergence frontier, or compute frontier. Additionally, I was only able to do a limited hyperparameter sweep and learning rate schedules due to compute and time. I suspect the results found are very learning rate schedule dependent. Finally, my fine-tuning datasets were from different sources. This is important to note since my results maybe more specific to the distribution found in the dataset than the underlying language.&lt;/p&gt;

&lt;h2 id=&quot;future-work&quot;&gt;Future Work&lt;/h2&gt;
&lt;p&gt;Some potential future directions include:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Compare the effective data transfer using pre-trained models in Chinese, German, Spanish, then fine-tuned to English&lt;/li&gt;
  &lt;li&gt;Fine-tune with low resource languages or other tasks/distributions and find the effective data transfer&lt;/li&gt;
  &lt;li&gt;Predict ideal ratio for pre-trained v.s. fine-tune for any given problem, given some budget&lt;/li&gt;
  &lt;li&gt;Study the “forgetting” problem in transfer learning in terms of effective data transfer&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h2&gt;
&lt;p&gt;Thanks to my mentor Jerry Tworek, the Scholars cohort, Danielle Ensign and Kudzo Ahegbebu for sharing compute, everyone that gave me feedback (especially Danny Hernandez and Mohammad Bavarian), Jeromy Johnson for helping me find the Community QA dataset, Scholar program coordinators, Muraya Maigua and Christina Hendrickson, and OpenAI and Azure for making this all possible.&lt;/p&gt;

&lt;h2 id=&quot;citation&quot;&gt;Citation&lt;/h2&gt;
&lt;p&gt;If you find this work useful, please cite it as:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@article{kim2021scalinglanguagetransfer,
  title   = &quot;Scaling Laws for Language Transfer Learning&quot;,
  author  = &quot;Kim, Christina&quot;,
  journal = &quot;christina.kim&quot;,
  month   = 4,
  year    = &quot;2021&quot;,
  url     = &quot;https://christina.kim/2021/04/11/scaling-laws-for-language-transfer-learning/&quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;p&gt;Jörg Bornschein et al. Sep 26, 2020. Small Data, Big Decisions:  Model Selection in the
       Small-Data Regime&lt;/p&gt;

&lt;p&gt;Frédéric Branchaud-Charron et al. May 20, 2019. Spectral Metric for Dataset Complexity Assessment&lt;/p&gt;

&lt;p&gt;Tom Henighan et al. Oct 28, 2020. Scaling Laws for Autoregressive Generative Modeling&lt;/p&gt;

&lt;p&gt;Henning Fernau. Jan 24, 2019. Algorithms for Learning Regular Expressions from Positive Data Algorithms&lt;/p&gt;

&lt;p&gt;Pierre Guillou. Jul 3, 2020. Byte-level BPE, an Universal Tokenizer but…&lt;/p&gt;

&lt;p&gt;Danny Hernandez et al. Feb 2, 2021. Scaling Laws for Transfer&lt;/p&gt;

&lt;p&gt;Joel Hestness et al. Dec 1, 2017. Deep Learning Scaling is Predictable, Empiricially.&lt;/p&gt;

&lt;p&gt;Jared Kaplan et al. Jan 23, 2020. Scaling Laws for Neural Language Models&lt;/p&gt;

&lt;p&gt;Ameet A. Rahane et al. Apr 16, 2020.  Measures of Complexity for Large Scale Image Datasets&lt;/p&gt;

&lt;p&gt;Jonathan S. Rosenfeld et al. Sep 25, 2019. A Constructive Prediction of the Generalization Error Across Scales&lt;/p&gt;

&lt;p&gt;Céline Van den Rul. Nov 9, 2019. [NLP] Basics: Measuring The Linguistic Complexity of Text&lt;/p&gt;

</description>
        <pubDate>Sun, 11 Apr 2021 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2021/04/11/scaling-laws-for-language-transfer-learning/</link>
        <guid isPermaLink="true">https://christina.kim/2021/04/11/scaling-laws-for-language-transfer-learning/</guid>
      </item>
    
      <item>
        <title>Experimenting in an Infinite Data Regime</title>
        <description>&lt;p&gt;Most machine learning tutorials gear toward defined datasets that can fit in the memory of most machines. These datasets are great for benchmarking new algorithms and for learning. However, newer SOTA models have many more parameters, and they train in an infinite data regime.&lt;/p&gt;

&lt;p&gt;I ran into quite a few bugs while setting up an experiment with OpenWebText2, a clone of WebText which contains over 40GB of data. In this blog post, I want to share some differences to consider when working in an infinite data regime and how to prevent common bugs.&lt;/p&gt;

&lt;p&gt;Working in an infinite data regime means you won’t have overfitting issues. You won’t need to be worried about having enough samples for training while saving enough for testing and evaluating. Instead of setting a max number of epochs, you’ll be setting the max number of steps in an infinite data regime since you shouldn’t need to see all of the samples (aka an entire epoch) to reach the lowest possible loss.&lt;/p&gt;

&lt;p&gt;In an infinite data regime, it makes sense to prepare, tokenize, batch on the fly. In contrast, an indexable finite dataset can transform and fit easily in a GPU’s memory. Understanding how to work in an infinite data regime will only become more critical for machine learning researchers and practitioners.&lt;/p&gt;

&lt;p&gt;Below is how I use PyTorch’s IterableDataset to stream from multiple files to create batches. You can use this dataset class with PyTorch’s DataLoader class. It’s important to remember that all shuffling and batching should be handled within your IterableDataset, (batch_size for your DataLoader should be set to None to let the DataLoader know that your dataset is batching).&lt;/p&gt;

&lt;p&gt;To handle the multiple transformations from the raw text, to a batched output, I use generators for each transformation in the process.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;random&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;itertools&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;chain&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;itertools&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cycle&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;torch.utils.data.dataset&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IterableDataset&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;transformers&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPT2Tokenizer&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;FileIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;with&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;r&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;readlines&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__iter__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;path&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;TokenizerIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_iter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FileIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tokenize_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;truncation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input_ids&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# adding end of sequence to the beginning and end of the document
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eos_token_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eos_token_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;tokenized&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;pass&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__iter__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenize_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;BatchIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;

        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;tokenizer_iter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TokenizerIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer_iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;shuffled_file_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;split&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;chain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_iterable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;process_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cycle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;get_streams&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;zip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shuffled_file_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)])&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__iter__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_streams&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;


&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StreamingIterableDataset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IterableDataset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GPT2Tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;from_pretrained&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;gpt2&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_iter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BatchIterator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;drop_last&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tokenizer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dataset_paths&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__iter__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;batch_iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collate_fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;except&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;StopIteration&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;collate_fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;data_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seq_len_list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[],&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_seq&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;batch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;data_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;label_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_label&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;seq_len_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# adding the permute to make the batch be the first dimension
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LongTensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;permute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LongTensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;label_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;permute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;torch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LongTensor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq_len_list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

</description>
        <pubDate>Fri, 12 Feb 2021 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2021/02/12/experimenting-in-an-infinite-data-regime/</link>
        <guid isPermaLink="true">https://christina.kim/2021/02/12/experimenting-in-an-infinite-data-regime/</guid>
      </item>
    
      <item>
        <title>Scaling Laws</title>
        <description>&lt;p&gt;My research direction for the OpenAI Scholar’s program is heavily influenced by the scaling laws paper by OpenAI on &lt;a href=&quot;https://arxiv.org/abs/2001.08361&quot;&gt;language models&lt;/a&gt;, and &lt;a href=&quot;https://arxiv.org/abs/2010.14701&quot;&gt;autoregressive models&lt;/a&gt; published last year. Scaling laws exist for cross-entropy loss in five domains: language modeling, generative image modeling, video modeling, multimodal image to text models, and mathematical problem solving (Henighan et al 2020). They have also been discovered for a few specific problems within those domains. Scaling laws’ applicability across a wide range of scales and surprisingly exact curves indicate they are an important piece to understanding neural networks and their performance.&lt;/p&gt;

&lt;p&gt;Scaling laws exist throughout nature and it’s particularly interesting to find them in deep learning as well.&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;https://arxiv.org/abs/2001.08361&quot;&gt;Scaling Laws for Neural Language Models&lt;/a&gt;, the authors found that the loss of LM scales as a power-law with model size, dataset size, and the amount of compute used for training up to seven order of magnitudes.&lt;/p&gt;

&lt;p&gt;Scaling laws flavored AI research can help with our understanding of model improvements and get past the benchmark optimization phase of AI research. Instead, research can be focused scaling law optimization and scaling law tradeoff understanding. Experiments designed with scaling laws in mind can be smaller, and less compute heavy experiments as long as findings can extrapolate into trends.&lt;/p&gt;
</description>
        <pubDate>Fri, 29 Jan 2021 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2021/01/29/scaling-laws/</link>
        <guid isPermaLink="true">https://christina.kim/2021/01/29/scaling-laws/</guid>
      </item>
    
      <item>
        <title>Keeping Things Regular</title>
        <description>&lt;p&gt;&lt;em&gt;In this post, I will introduce the direction of my OpenAI scholars’ project.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inspired by the Scaling Laws papers by OpenAI on &lt;a href=&quot;https://arxiv.org/abs/2001.08361&quot;&gt;language models&lt;/a&gt;, and &lt;a href=&quot;https://arxiv.org/abs/2010.14701&quot;&gt;autoregressive models&lt;/a&gt; published last year, I’m interested in learning more about exploring potential scaling laws for dataset complexity. The questions I’m most interested in studying with my project are: Are there universal scaling laws for dataset complexity, or is dataset difficulty more of a pre-factor to performance? Another way to phrase this would be, can we build a map of scaling laws with respect to dataset complexity for regular languages? Can we show that these same trends apply to other natural datasets if there are scaling relationships for dataset complexity for regular languages?&lt;/p&gt;

&lt;p&gt;Finding scaling laws for dataset complexity will contribute to a more precise understanding of transformer models and data. There exists substantial literature on the impact of algorithms and compute for machine learning, but less on the impact of data on machine learning. Previous scaling laws work has shown the relationship between dataset size and model performance. However, other potential relationships that may exist with data have not yet been explored. Understanding datasets may provide insights on how to improve performance on downstream tasks, in addition to how to transfer unsupervised approaches with transformers to other domains of ML research.&lt;/p&gt;

&lt;p&gt;Yet while neural networks have made incredible progress, it is not always clear why this progress has been made. Better understanding what factors, such as dataset complexity, are causing models to work and why they are improving will allow us to better predict which capabilities will develop and when.&lt;/p&gt;

&lt;h2 id=&quot;what-is-a-regular-language&quot;&gt;What is a Regular Language?&lt;/h2&gt;
&lt;p&gt;I will train transformers to predict the next character for strings from a regular language for my experiments. A &lt;a href=&quot;https://en.wikipedia.org/wiki/Regular_language&quot;&gt;regular language&lt;/a&gt; is a type of formal language defined by a regular expression. &lt;a href=&quot;https://en.wikipedia.org/wiki/Formal_language&quot;&gt;Formal language&lt;/a&gt; is a set of words from a given finite alphabet. &lt;a href=&quot;http://www.cs.cornell.edu/courses/cs2800/2017sp/lectures/lec27-kleene.html#:~:text=of%20Kleene's%20theorem-,Kleene's%20theorem%3A%20The%20set%20of%20regular%20languages%2C%20the%20set%20of,languages%20are%20all%20the%20same.&quot;&gt;Kleene’s theorem&lt;/a&gt; shows finite automata and regular expressions are equivalent in their expressiveness for denoting languages.&lt;/p&gt;

&lt;p&gt;For example, the regular expression &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a*b&lt;/code&gt; can convert into a non-deterministic finite automaton (NFA), which can convert into a deterministic finite automaton (DFA), which can reduce into a minimum deterministic finite automaton (MDFA). It has two states, with one of those states being an accepting or final state.
The symbols of the regular language &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a*b&lt;/code&gt; are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;, and it has two transitions. A string is a valid word in a given language if it ends in an accepting state of the finite automaton representing the language.
&lt;img src=&quot;/images/posts/a*b_mdfa.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;measuring-complexity&quot;&gt;Measuring Complexity&lt;/h2&gt;
&lt;p&gt;To measure dataset complexity, we will compare the number of states, transitions, and end states of the deterministic finite automata against the different regular languages. The number of states is the primary number of comparisons. The thesis here is that more states would result in a more complicated language. However, it is also essential to consider the secondary factors, such as how many states are accepting stages and how many transitions are between the states. For example, a finite automaton with many states, but all of the states are accepting, will be easy to solve. The advantages of using our synthetic languages will allow us to build a formal measurement of complexity. Creating a formal measure of complexity will allow us to increase the difficulty and control our data. For example, we can generate as many samples as needed and will not be data limited. There is existing research in computer science for how to measure the complexity of regular languages such as &lt;a href=&quot;https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.42.2143&amp;amp;rep=rep1&amp;amp;type=pdf&quot;&gt;state complexity&lt;/a&gt;, and &lt;a href=&quot;https://arxiv.org/pdf/1702.05024.pdf&quot;&gt;quotient complexity&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;progress-so-far&quot;&gt;Progress So Far&lt;/h2&gt;
&lt;p&gt;Currently, I have been testing &lt;a href=&quot;https://openai.com/blog/language-unsupervised/&quot;&gt;GPT&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/abs/1901.02860&quot;&gt;TransformerXL&lt;/a&gt; architectures on generated datasets of various regular languages. It appears that the number of transitions in the finite automaton impacts how easy a language is to learn. I started off generating datasets of 50&amp;gt; states with 100+ transitions but found that the models could not learn anything. I had initially been worried that creating straightforward regular languages would not be interesting to study. I’ve since been working from very simple (but still infinite) regular languages and plan on slowly increasing the number of states and transitions.&lt;/p&gt;

&lt;p&gt;Thanks to my mentor Jerry Tworek for helping me design this project!&lt;/p&gt;
</description>
        <pubDate>Fri, 15 Jan 2021 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2021/01/15/keeping-things-regular/</link>
        <guid isPermaLink="true">https://christina.kim/2021/01/15/keeping-things-regular/</guid>
      </item>
    
      <item>
        <title>How to Navigate Conferences</title>
        <description>&lt;p&gt;The state of machine learning research moves incredibly fast. There are dozens of new papers published on arxiv every day, and it’s overwhelming trying to keep up to date. Conferences are a great way to get a lot of signals in a condensed amount of time. Conference papers and sessions are pretty vetted, which saves you from judging each new publication that comes out. As someone more recent to the field of AI research, I think it’s super beneficial to try to go to conferences, even as just a participant. I was lucky to go to NeurIPs last year with my previous startup.&lt;/p&gt;

&lt;p&gt;One thing I like to do before conferences, though this might get harder and harder to do as conference size increases and the number of accepted papers increases, is skim all the abstracts of papers I find interesting. I’ll do an initial run through based on titles, keywords, and author affiliations to determine if I want to read the abstracts. I’m pretty generous at this stage. In the next step, I’ll read through the abstracts of all the papers I’ve selected. Then from there, I’ll (skim) read the papers of the abstracts I’ve found interesting. This process then gives me a shortlist of papers and authors I’ll try to seek out during poster sessions. Poster sessions are a great way to meet researchers and ask questions. Last year people were very excited to share their work and answer any small or big questions you may have.&lt;/p&gt;

&lt;p&gt;For me, the most fun and educational bits of conferences are when I get to engage in 1:1 or small discussions with researchers. I’ll try to look for events happening during the meeting that are interest-oriented or find events where researchers I admire are speaking at. For example, last year, an AI Safety Unconference was an unofficial event and had fascinating discussions. Conference workshops are also a great way to find experts in a specific subject.&lt;/p&gt;

&lt;p&gt;Conferences, whether or not they are virtual, are intimidatingly packed with events. NeurIPs this year has events 24/7 through the week. I like to spend some time figuring out which events I want to prioritize and optimize for discussion-oriented events first. Most talks are recorded, so you can always catch those later (at 2x speed) on your own time.&lt;/p&gt;

&lt;p&gt;I’ll update this post with tips for how to navigate online conferences after next week’s virtual NeurIPs.&lt;/p&gt;
</description>
        <pubDate>Fri, 04 Dec 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/12/04/how-to-navigate-conferences/</link>
        <guid isPermaLink="true">https://christina.kim/2020/12/04/how-to-navigate-conferences/</guid>
      </item>
    
      <item>
        <title>Research Tools</title>
        <description>&lt;p&gt;One of the hardest things from switching from software engineering to research has been the open-ended nature of research and measuring progress. For me, software engineering usually has more explicit objectives, and it’s easy to make a plan to get from 0 to 100. This post will share some tools I’ve been using to help me “do research” and explore potential research project ideas.&lt;/p&gt;

&lt;p&gt;I’ve been trying to write down as many of my thoughts as possible. As a software engineer, it was rare to have a day where I was not writing code. As a researcher, it’s common to have days where you’re consuming papers and thinking. It’s easy to think you haven’t done much all day when you don’t have any output of your work. I’ve found that writing helps me solidify my learnings while clarifying any ideas and questions. Since my notes are just for me, I’ve been writing down all and any thoughts I have as I’ve been brainstorming and learning. I’ve been using &lt;a href=&quot;https://obsidian.md/&quot;&gt;Obsidian&lt;/a&gt;, which is a notetaking editor similar to Roam. Things I like about Obsidian is that it’s all local, and I can write notes on my &lt;a href=&quot;https://forum.obsidian.md/t/how-do-i-work-with-obsidian-on-mobile/471&quot;&gt;other devices&lt;/a&gt; as well. It’s effortless to find mentions of an idea by using backlinks. Obsidian has helped to add structure to my day as I’ve created a &lt;a href=&quot;https://forum.obsidian.md/t/how-i-use-daily-notes/3057&quot;&gt;daily note template&lt;/a&gt; and added a set of morning questions to help focus my day and a set of evening questions to reflect on what I’ve worked on. It’s easy to lose momentum in research, so I’ve been trying to have an exact next to-do item for each day, so I have something to work on.&lt;/p&gt;

&lt;p&gt;I’ve been trying to read as many papers as I can to get exposed to new ideas. As someone new to research, it’s easier to find inspiration from other work. Many papers discuss potential future directions from their results, and that’s been an excellent source for my own project brainstorming. Another great reason to read papers is that it’ll give you a better idea of how researchers think about things. Being able to (quickly) evaluate work critically seems to be an essential skill as a researcher. Two features have been necessary for me regarding papers - searching through papers and taking notes. I’ve used &lt;a href=&quot;https://www.zotero.org/&quot;&gt;Zotero&lt;/a&gt; to keep track of papers I’ve read/skimmed, but since using Obsidian, I’ve used Obsidian to keep track of my papers. I’ll copy the title, abstract, and link to the paper, so it’s easy to search. I’ve been using &lt;a href=&quot;https://www.marginnote.com/&quot;&gt;MarginNote&lt;/a&gt; for taking notes for papers. Some excellent features it has are that you can import websites to markup and create flashcards. They have many other exciting features, such as mindmaps, which I haven’t used as much.&lt;/p&gt;

&lt;p&gt;As I’ve been learning new concepts, I’ve been heavily relying on &lt;a href=&quot;https://apps.ankiweb.net/&quot;&gt;Anki&lt;/a&gt;, which uses &lt;a href=&quot;http://augmentingcognition.com/ltm.html&quot;&gt;space repetition&lt;/a&gt; to augment your memory and learning. It’s easy to export cards directly into Anki from MarginNote. I’ll try to spend at least 15 minutes every day going through my notecards. There are many different ways to organize your Anki cards. I don’t have any strong suggestions for how you should use Anki, but I recommend making your cards instead of downloading other people’s decks. Writing learnings in my own words help me to solidify new facts. With spaced repetition, it’s become easier and less intimidating to learn important key concepts at a high volume.&lt;/p&gt;

&lt;p&gt;Using all of these tools have been useful in validating potential research ideas. It’s easy to track new ideas and expand upon them. During project exploration, I’ve consumed a lot of information. Finding tools to process and efficiently learn the new information has made this exploration phase less hectic and added more structure.&lt;/p&gt;

&lt;p&gt;I’ve also found these reads useful for how to think about your research:
http://joschu.net/blog/opinionated-guide-ml-research.html
https://web.mit.edu/tslvr/www/lessons_two_years.html&lt;/p&gt;

&lt;p&gt;Let me know if there are any tools you’d recommend for research!&lt;/p&gt;
</description>
        <pubDate>Fri, 20 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/11/20/research-tools/</link>
        <guid isPermaLink="true">https://christina.kim/2020/11/20/research-tools/</guid>
      </item>
    
      <item>
        <title>Transformers, Roll Out!</title>
        <description>&lt;p&gt;I’ve spent a good majority of my time (when not constantly refreshing for election results) thinking about transformers. There are already many articles describing transformers and implementing them, so I won’t go into too much detail about that here. Instead, I want to share some questions I’ve had while playing around with transformers and LSTMs on small datasets this past week. I tried to get &lt;a href=&quot;https://gist.github.com/christinakim/26c5ae3b22eb599b4fb5575918ff7a3b&quot;&gt;models of the same size&lt;/a&gt; for these experiments roughly. When tested on variable context lengths from training in my small datasets experiments, LSTMs performed better than transformers. The intuition here is that LSTMs generalize better on context length due to their recurrence.&lt;/p&gt;

&lt;p&gt;There are transformer architectures that try to add recurrence to the models, like the Universal Transformer. It’s interesting to note which tasks the Universal Transformer performed well on and didn’t perform well on. For example, on machine translation, the Universal Transformer performed a bit worse. The Universal Transformer is computationally more expensive than the traditional transformer architecture. In the case of machine translation, my mentor suggested that it might just essentially need to do a lookup into the weights for the correct word (aka memorization). However, the added recurrence did help for other tasks. So, what is the actual trade-off between compute and performance?&lt;/p&gt;

&lt;p&gt;Besides adding some idea of recurrence in the Universal Transformer, many other transformer architectures try to improve on the original implementation and performance. I’m curious about evaluating and understanding the different architecture trade-offs in the many transformers’ papers. I hypothesize that autoregressive transformer models can learn some positional information, so they might benefit more from other types of positional encodings than non-autoregressive transformer models. It’d also be interesting to compare different attention mechanisms, such as the Reformer’s v.s. self-attention. I’m interested in learning the answers to these questions since I think it’ll hopefully elucidate what “skills” are essential and what degree of natural language understanding.&lt;/p&gt;

&lt;p&gt;To better understand the performance differences between the different papers and implementation, I focused on
 learning more about the metrics used for language models. The terms I frequently came across were perplexity, bits per word(character), and cross-entropy. Perplexity can be thought of as the measure of uncertainty your model has for predictions. So the lower the perplexity, the higher confidence your model has about it’s predictions. Bits per word, or character, can be thought of as the entropy of the language. BPW measures the average number of bits required to encode the word. Given a language’s probability of P and our model’s learned probability Q, cross-entropy measures the total average amount of bits needed to represent events from Q to P. These terms helped me evaluate papers and helped me think about how to evaluate my toy datasets.&lt;/p&gt;

&lt;p&gt;Below is my self-attention function that uses &lt;a href=&quot;https://pytorch.org/docs/stable/generated/torch.einsum.html&quot;&gt;einsum&lt;/a&gt;, which has been really handy!&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;def self_attention(key, query, value):
   # scores = dotprod of key + query
   # b here stands for batch, l = length, k= nu pixels, num words etc)
   scores = torch.einsum('bkl,bql-&amp;gt;bqk', key, query)

   # note that the dimensions of key query and value
  dimensions_k = key.dim()

   # this helps to create a more stable gradient (you could probably normalize via other constants)
   scores = scores/np.sqrt(dimensions_k)

   # turn scores into probabilities from 0,1
   attention = torch.softmax(scores)

   # dotprod of value vector, and attention vector
   attended_values = torch.einsum('bdl,bad-&amp;gt;bal', value, attention)

   return attended_values
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and here is an obligatory photo of my favorite transformer
&lt;img src=&quot;https://hips.hearstapps.com/digitalspyuk.cdnds.net/17/25/1498134404-transformers-dark-of-the-moon-bumblebee-poster.jpg?resize=980:*&quot; alt=&quot;bumblebee&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Fri, 06 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/11/06/transformers-roll-out/</link>
        <guid isPermaLink="true">https://christina.kim/2020/11/06/transformers-roll-out/</guid>
      </item>
    
      <item>
        <title>Hello from OpenAI</title>
        <description>&lt;p&gt;I’m excited to be joining the Fall 2020 cohort of OpenAI’s Scholars program. I’ll be writing semi-regularly as a log of what I’m learning and thinking about.&lt;/p&gt;

&lt;p&gt;I’m excited to be part of the scholars’ program since I find learning in a group motivating and useful, especially now when everyone is more isolated. It’s also been beneficial to ask questions and learn from people who have already been thinking about my research interests.&lt;/p&gt;

&lt;p&gt;One of the high-level goals I’d like to work on is developing “taste” or “aesthetic” for deep learning research throughout this experience.&lt;/p&gt;

&lt;p&gt;For the past two weeks, I’ve been reading about generalization and language models. I’ve also been working on reimplementing the smaller transformers from the &lt;a href=&quot;https://arxiv.org/pdf/2001.08361.pdf&quot;&gt;Scaling Laws for Neural Languages&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;scaling-laws-for-neural-languages&quot;&gt;Scaling Laws for Neural Languages&lt;/h3&gt;
&lt;p&gt;The paper uses a decoder only transformer for most of its experiments, in addition to LSTM models and the universal transformer. For now, I’ll focus on reproducing the smaller-scale experiments with the transformer architecture. To understand the architecture for the decoder only transformer better, I read the &lt;a href=&quot;https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf&quot;&gt;original GPT paper&lt;/a&gt;. It’s surprising to remember that this paper is only ~2 years old. I plan to use datasets available via &lt;a href=&quot;https://huggingface.co/docs/datasets/&quot;&gt;HuggingFace’s Dataset library&lt;/a&gt; for training initially, and look into this &lt;a href=&quot;https://github.com/jcpeterson/openwebtext&quot;&gt;WebText scraper&lt;/a&gt; later.&lt;/p&gt;

&lt;p&gt;I found these resources really useful for understanding and implementing the transformer architecture.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://jalammar.github.io/illustrated-transformer/&quot;&gt;The Illustrated Transformer – Jay Alammar&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://towardsdatascience.com/illustrated-guide-to-transformers-step-by-step-explanation-f74876522bc0&quot;&gt;Illustrated Guide to Transformers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://nlp.seas.harvard.edu/2018/04/01/attention.html#position-wise-feed-forward-networks&quot;&gt;The Annotated Transformer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Coincidentally, Jared Kaplan, one of the paper’s authors, gave a talk on scaling laws this past Wednesday. The slides and the video from the talk can be accessed here on the &lt;a href=&quot;http://www.physicsmeetsml.org/posts/sem_2020_10_21/&quot;&gt;Physics ∩ ML website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below are papers suggested by my mentor for other relevant language model papers to read:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1706.03762&quot;&gt;Transformer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1901.02860&quot;&gt;Transformer XL&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1807.03819&quot;&gt;Universal Transformer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://s3-us-west-2.amazonaws.com/openai-assets/research-covers/language-unsupervised/language_understanding_paper.pdf&quot;&gt;GPT-1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf&quot;&gt;GPT-2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2005.14165&quot;&gt;GPT-3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2001.04451&quot;&gt;Reformer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2009.01325&quot;&gt;RL from human feedback&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1812.06162v1&quot;&gt;Critical batch size paper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1910.10683&quot;&gt;T5&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1810.04805&quot;&gt;BERT&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1801.06146&quot;&gt;ULMFiT&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1810.08272v1&quot;&gt;BabyAI&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1906.08237&quot;&gt;XLNet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;generalization&quot;&gt;Generalization&lt;/h3&gt;
&lt;p&gt;I’ve also been thinking about model generalization this week. I’ve been thinking about some questions: what are the differences between generalization and memorization for some of these larger models with smaller datasets? what is the minimum amount of data required to generalize? what are other factors that allow models to generalize quickly? are there similar scaling law-esque properties for model generalization? what does it look like for a model to generalize well on out of distribution data?&lt;/p&gt;

&lt;p&gt;Some papers I’ve been reading about generalization:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/1912.01588.pdf&quot;&gt;Leveraging Procedural Generation to Benchmark Reinforcement Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/2010.04650.pdf&quot;&gt;LSTMS Compose—and Learn—Bottom-Up&lt;/a&gt;
-&lt;a href=&quot;https://arxiv.org/abs/1910.07113&quot;&gt;Solving Rubik’s Cube with a Robot Hand
&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://papers.nips.cc/paper/7176-exploring-generalization-in-deep-learning.pdf&quot;&gt;Exploring Generalization in Deep Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://arxiv.org/pdf/1802.05296.pdf&quot;&gt;Stronger generalization bounds for deep nets via a compression
approach&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 23 Oct 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/10/23/hello-from-openai/</link>
        <guid isPermaLink="true">https://christina.kim/2020/10/23/hello-from-openai/</guid>
      </item>
    
      <item>
        <title>The NLP Papers to Read Before ICLR 2020</title>
        <description>&lt;p&gt;Ahead of next week’s ICLR 2020 virtual conference, I went through the 687 accepted papers (out of 2594 submitted - up 63% since 2019!) and identified 9 papers with the potential to advance the use of deep learning NLP models in everyday use cases.&lt;/p&gt;

&lt;p&gt;Here’s what the papers found and why they matter:&lt;/p&gt;

&lt;h4 id=&quot;electra-pre-training-text-encoders-as-discriminators-rather-than-generators&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/2003.10555.pdf&quot;&gt;ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Kevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. Manning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; A commonly used task for pre-training language models is to mask the input and have the model predict what is masked. This paper introduces a new pre-training task called token detection. In the new task, the authors replace some tokens with alternatives by sampling from a generator. They then trained a discriminator to predict whether the generator replaced each token in an input or not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; This task is more data efficient, learning potentially from all tokens in a dataset versus the ~15% masked in the usual approach. It shows there’s still room for additional creativity in how to train a language model.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*ncLPenV1b-Uyd7KI.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;An overview of replaced token detection&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;the-curious-case-of-neural-text-degeneration&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/1904.09751.pdf&quot;&gt;The Curious Case of Neural Text Degeneration&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Ari Holtzman, Jan Buys, Li Du, Maxwell Forbes, Yejin Choi&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; The authors propose a new decoding strategy called nucleus sampling — which truncates the tail of the probability distribution, sampling from the dynamic nucleus of tokens containing the vast majority of the probability mass. The counter-intuitive empirical observation is that even though the use of likelihood as a training objective leads to high-quality models for a broad range of language understanding tasks, using likelihood as a decoding objective leads to text that is bland and strangely repetitive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; Text degeneration is an issue even in the latest cutting edge language models. Decoding strategies are important to create more human-like text generation for various tasks. Moving away from greedy algorithms like beam search will help performance on downstream tasks.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*-hFlV-V0kISGMevs.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Example of beam search based generation vs human generation&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;what-can-neural-networks-reason-about&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/1905.13211.pdf&quot;&gt;What Can Neural Networks Reason About?&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Keyulu Xu, Jingling Li, Mozhi Zhang, Simon S. Du, Ken-ichi Kawarabayashi, Stefanie Jegelka&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main contribution:&lt;/strong&gt; This paper introduces a framework called algorithmic alignment to measure how well neural networks perform on reasoning tasks. Neural networks that “align” with known algorithmic solutions are better able to learn the solutions. The framework roughly states that for the model to be able to learn and successfully generalize on a reasoning task, it needs to be able to easily learn (to approximate) steps of the reasoning tasks. The authors showed graph neural networks are well suited for and therefore can learn to solve dynamic programming problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; This is a dense theoretical paper explaining architectural choices people have been intuitively making and lays the groundwork for future research exploring new architectures to better fit tasks. It creates a new framework to evaluate future algorithms and tasks.&lt;/p&gt;

&lt;h4 id=&quot;sequential-latent-knowledge-selection-for-knowledge-grounded-dialogue&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/2002.07510.pdf&quot;&gt;Sequential Latent Knowledge Selection for Knowledge-Grounded Dialogue&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Byeongchang Kim, Jaewoo Ahn, Gunhee Kim&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; This paper proposes a novel approach to selecting knowledge for open-domain dialogue called Sequential Latent Model which represents knowledge history as some latent representation. They do this because keeping track of knowledge history reduces the ambiguity caused from the diversity in knowledge selection of conversation but can also help better use the response information/utterances.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; This work shows that improving knowledge selection can make a big difference in response generation quality. This has implications for building more robust dialogue applications.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*aVVR0wVL_Fg0SbRu.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Examples of generated responses by the author’s model and baselines on Wizard of Wikipedia. TMN stands for E2E Transformer MemNet, and A and W for apprentice and wizard.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;a-probabilistic-formulation-of-unsupervised-text-style-transfer&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/2002.03912.pdf&quot;&gt;A Probabilistic Formulation of Unsupervised Text Style Transfer&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Junxian He, Xinyi Wang, Graham Neubig, Taylor Berg-Kirkpatrick&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; The authors propose a probabilistic approach to unsupervised text style transfer. This approach works by using non-parallel data from two domains as a partially observed parallel corpus. The authors’ proposed model learns to transform sequences from one domain to another domain. By generating a parallel latent sequence that generates each observed sequence, this allows the model to learn this in an unsupervised way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; The paper had good results for the following tasks: unsupervised sentiment transfer, formality transfer, word decipherment, author imitation, and machine translation. Some of these could be useful features for future writing applications. The approach introduced in the paper does not require paired training data, which makes data collection for style transfer easier.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/1*4nGoftiUFRIIpCLmogXoWA.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Results on the sentiment transfer, author imitation, and formality transfer&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;albert-a-lite-bert-for-self-supervised-learning-of-language-representations&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/1909.11942.pdf&quot;&gt;ALBERT: A Lite BERT for Self-Supervised Learning of Language Representations&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; ALBERT is an extension of BERT that tries to answer the question: are larger models the answer to NLP tasks? Albert achieves SOTA results by cross-layer parameter sharing. By sharing parameters, ALBERT can be smaller with similar performance. The best results from ALBERT are with more parameters — but it still trains faster than BERT. And when they train for the same amount of wall-time, ALBERT performs better than BERT.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; These results are promising, showing that simply building more complex, larger, deeper models is not always the best approach to improving model performance.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*NuXHm6HdZq37TpLS.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;State-of-the-art results on the SQuAD and RACE benchmarks&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;encoding-word-order-in-complex-embeddingshttpsarxivorgpdf191212333pdf&quot;&gt;[Encoding Word Order in Complex Embeddings](https://arxiv.org/pdf/1912.12333.pdf&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Benyou Wang, Donghao Zhao, Christina Lioma, Qiuchi Li, Peng Zhang, Jakob Grue Simonsen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; This paper describes a new language model that captures both the position of words and their order relationships. The paper redefines word embeddings (previously thought of as fixed and independent vectors) to be functions of the word’s position. The author’s Transformer Complex-Order model outperforms the Vanilla Transformer and complex-vanilla Transformer by 1.3 and 1.1 in absolute BLEU score respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; Position embeddings capture the position of individual words, but not the ordered relationship (e.g., adjacency or precedence) between individual word positions. Their approach allows word representations in different positions to correlate with each other in a continuous function.&lt;/p&gt;

&lt;h4 id=&quot;reformer&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/2001.04451.pdf&quot;&gt;Reformer&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Nikita Kitaev, Łukasz Kaiser, Anselm Levskaya&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Main Contribution:&lt;/strong&gt; The authors propose a new transformer model with two major improvements to the architecture: a) using reversible layers to prevent the need of storing the activations of all layers for backpropagation, and b) using locality sensitive hashing to approximate the costly softmax(QK^T) computation in the full dot-product attention&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; The Reformer performs on par with SOTA Transformer models while being much more memory-efficient and much faster on long sequences. For examples, the Vaswani et al. (2017) base model had a BLEU score of 27.3 compared to Reformer’s BLEU score of 27.6 on newstest2014 for WMT English-German.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*hqC0-fCtntP5XLlH.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;On the left, Locality-Sensitive Hashing Attention showing the hash-bucketing, sorting, and chunking steps and the resulting causal attentions. On the right, (a-d) Attention matrices for these varieties of attention.&lt;/em&gt;&lt;/p&gt;

&lt;h4 id=&quot;thieves-on-sesame-street-model-extraction-of-bert-based-apis&quot;&gt;&lt;a href=&quot;https://arxiv.org/pdf/1910.12366.pdf&quot;&gt;Thieves on Sesame Street! Model Extraction of BERT-based APIs&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Kalpesh Krishna, Gaurav Singh Tomar, Ankur P. Parikh, Nicolas Papernot, Mohit Iyyer&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Main Contribution:&lt;/em&gt; This paper highlights an exploit only made feasible by the shift towards transfer learning methods within the NLP community: for a query budget of a few hundred dollars, an attacker can extract a model that performs only slightly worse than the victim model on SST2, SQuAD, MNLI, and BoolQ. On the SST2 task, the victim model had a 93.1% accuracy compared to their extracted model’s 90.1%. They show that an adversary does not need any real training data to mount the attack successfully. The attacker does not even need to use grammatical or semantically meaningful queries. They used random sequences of words coupled with task-specific heuristics to form useful queries for model extraction on a diverse set of NLP tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters:&lt;/strong&gt; Outputs of modern NLP APIs on nonsensical text provide strong signals about model internals, allowing adversaries to train their own models and avoid paying for the API.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cdn-images-1.medium.com/max/1600/0*IJ1Scs21iKWs7cRb.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Overview of the proposed model’s extraction setup for question answering&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Questions? Concerns? Snarky comments about papers I missed? Any and all feedback welcome. Ping me in the comments below or on twitter &lt;a href=&quot;https://twitter.com/christinahkim&quot;&gt;@christinahkim&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Thu, 23 Apr 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/04/23/the-nlp-papers-to-read-before-iclr-2020/</link>
        <guid isPermaLink="true">https://christina.kim/2020/04/23/the-nlp-papers-to-read-before-iclr-2020/</guid>
      </item>
    
      <item>
        <title>Grounded Language Learning</title>
        <description>&lt;!--end_excerpt--&gt;
&lt;h2 id=&quot;what-is-it&quot;&gt;What is it&lt;/h2&gt;
&lt;p&gt;Grounded Language Learning is the process of learning representations for words based on non-linguistic experience.&lt;/p&gt;

&lt;p&gt;Grounded language learning works to make use of language, multimodal information, and interactive environments. This research works toward achieving natural language understanding. Currently, natural language understanding is commonly tested by language models from text-only corpora. This approach with language models is based on the idea that the meaning of a word is based on only its relationship to other words. This is also called a distributional notion of semantics. SOTA language models are incredible for many different tasks and even come close to beating humans at natural language understanding benchmarks. However, there are critiques around NLU benchmarks, and grounded language learning argues that the words are not grounded in anything and, therefore, actually meaningless. With grounded language learning, the hope is to be able to create models that can understand and generalize well to their context.&lt;/p&gt;

&lt;p&gt;From VIGIL: Visually Grounded Interaction and Language&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;“In neuroscience, recent progress in fMRI technology has enabled better understanding of the interaction between language, vision and other modalities suggesting that the brains share neural representations of concepts across vision and language.
In concurrent work, developmental cognitive scientists have argued that word acquisition in children is closely linked to them learning the underlying physical concepts in the real world and that they generalize surprisingly well at this from sparse evidence.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;tasks&quot;&gt;Tasks&lt;/h2&gt;
&lt;h4 id=&quot;visual-qa&quot;&gt;Visual QA&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;/images/posts/visual_qa.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;embodied-qa&quot;&gt;Embodied QA&lt;/h4&gt;
&lt;p&gt;&lt;img src=&quot;/images/posts/embodied_qa.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;captioning&quot;&gt;Captioning&lt;/h4&gt;

&lt;h4 id=&quot;visual-audio-correspondence&quot;&gt;Visual-Audio Correspondence&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;&amp;quot;https://arxiv.org/abs/1705.08168&amp;quot;&quot;&gt;Look, Listen, Learn&lt;/a&gt; “what can be learned by training visual and audio networks simultaneously to predict whether visual information (a video frame) corresponds or not to audio information (a sound snippet)?”&lt;/p&gt;

&lt;h4 id=&quot;embodied-agents-performing-interactive-tasks&quot;&gt;Embodied Agents Performing Interactive Tasks&lt;/h4&gt;
&lt;p&gt;&lt;a href=&quot;https://aihabitat.org/&quot;&gt;AI Habitat&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/deepmind/streetlearn&quot;&gt;StreetLearn&lt;/a&gt;
    &lt;img src=&quot;/images/posts/street_learn.png&quot; alt=&quot;image&quot; /&gt;
    &lt;img src=&quot;/images/posts/street_learn2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/facebookresearch/House3D&quot;&gt;House3D&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;other-games&quot;&gt;Other Games&lt;/h4&gt;
&lt;p&gt;Mechanical Turker Descent (MTD) that trains agents to execute natural language commands grounded in a fantasy text adventure game&lt;/p&gt;
</description>
        <pubDate>Wed, 04 Mar 2020 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2020/03/04/grounded-language-learning/</link>
        <guid isPermaLink="true">https://christina.kim/2020/03/04/grounded-language-learning/</guid>
      </item>
    
      <item>
        <title>Shaping representations through communication: community size effect in artificial learning systems</title>
        <description>&lt;p&gt;paper summary of &lt;a href=&quot;'https://arxiv.org/abs/1912.06208'&quot;&gt;Shaping Representations Through Communication: Community Size Effect in Artificial Learning Systems
&lt;/a&gt;
&lt;!--end_excerpt--&gt;&lt;/p&gt;

&lt;p&gt;This paper is motivated by co-adapation that occurs (information shared between them can become too specific) a) between a single encoder/speaker, and decoder/listener or b) when shared language arises within small groups. Since as long as the encoder, and decoder agree on the information, the learned information doesn’t need to be representative, abstractive, or systematic. This paper explores adding more encoders and decoders that are randomly paired up at each training step to encourage the encoders and decoders to learn a more general representation. They find that increasing the community size of encoders/decoders reduces idiosyncrasies in learned code and prevents co-adaption.&lt;/p&gt;
</description>
        <pubDate>Fri, 13 Dec 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/12/13/shaping-representations-through-communication-community/</link>
        <guid isPermaLink="true">https://christina.kim/2019/12/13/shaping-representations-through-communication-community/</guid>
      </item>
    
      <item>
        <title>Learning Machine Learning</title>
        <description>&lt;p&gt;&lt;em&gt;Written for some coworkers who wanted to learn deep learning&lt;/em&gt;&lt;/p&gt;

&lt;!--end_excerpt--&gt;
&lt;p&gt;&lt;a href=&quot;#how-to-get-started&quot;&gt;How to get started&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#ml-resources&quot;&gt;Classical ML resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#deep-learning-resources&quot;&gt;DL resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#nlp-resources&quot;&gt;NLP resources&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#brushing-up-on-math&quot;&gt;Brushing up on math&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;#paper-reading&quot;&gt;Paper reading&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-manage-papers&quot;&gt;How to manage papers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-figure-out-what-to-read-check-out-these-sources&quot;&gt;How to figure out what to read&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-to-read-a-paper&quot;&gt;How to read a paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;how-to-get-started&quot;&gt;How to get started&lt;/h2&gt;
&lt;p&gt;I spent some time learning classical ML first since it was most relevant for my job. You can learn deep learning first without any other ML experience/knowledge.&lt;/p&gt;

&lt;h3 id=&quot;ml-resources&quot;&gt;ML resources&lt;/h3&gt;
&lt;p&gt;I started off with a homemade ML in 10 weeks course. TL;DR, here’s the course, using content primarily from &lt;a href=&quot;https://github.com/yanshengjia/ml-road/blob/master/resources/Hands%20On%20Machine%20Learning%20with%20Scikit%20Learn%20and%20TensorFlow.pdf&quot;&gt;Hands-On Machine Learning with Scikit-Learn and TensorFlow&lt;/a&gt; and Andrew Ng’s &lt;a href=&quot;https://www.coursera.org/learn/machine-learning&quot;&gt;Coursera course on ML&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;- Chapter 2 End-to-End Machine Learning Project
- Chapter 3 Classification (precision/recall, multiclass)
- Text feature extraction (from sklearn docs)
- Chapter 4 Training Models (linear/logistic regression, regularization)
- Advice for Applying Machine Learning
- Chapter 5 SVMs (plus kernels)
- Chapter 6 Decision Trees (basics)
- Chapter 7 Ensemble Learning and Random Forests (xgboost, RandomForest)
-  Chapter 8 Dimensionality Reduction (PCA, t-SNE, LDA)
- Machine Learning System Design
(Google) Best Practices for ML Engineering A group of friends and I worked through this content at a cadence of one meeting every other Wednesday starting late June 2018 wrapping up at the end of 2018.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;deep-learning-resources&quot;&gt;Deep learning resources&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Neural Networks and Deep Learning by Michael Nielsen &lt;a href=&quot;http://neuralnetworksanddeeplearning.com/index.html&quot;&gt;http://neuralnetworksanddeeplearning.com/index.html&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;fast.ai
    &lt;ul&gt;
      &lt;li&gt;Practical Deep Learning for Coders &lt;a href=&quot;https://course.fast.ai/videos/?lesson=1&quot;&gt;https://course.fast.ai/videos/?lesson=1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;Part 2: Deep Learning from the Foundations &lt;a href=&quot;https://course.fast.ai/videos/?lesson=8&quot;&gt;https://course.fast.ai/videos/?lesson=8&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;distill is a good resource for topics. ex:
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://distill.pub/2017/momentum/&quot;&gt;https://distill.pub/2017/momentum/&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://distill.pub/2016/augmented-rnns/&quot;&gt;https://distill.pub/2016/augmented-rnns/&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;nlp-resources&quot;&gt;NLP resources&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Kyunghyun Cho’s lecture notes on “Natural Language Processing with Representation Learning”: https://github.com/nyu-dl/NLP_DL_Lecture_Note/blob/master/lecture_note.pdf&lt;/li&gt;
  &lt;li&gt;Jacob Eisenstein’s textbook on “Natural Language Processing” (https://github.com/jacobeisenstein/gt-nlp-class/blob/master/notes/eisenstein-nlp-notes.pdf)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;brushing-up-on-math&quot;&gt;Brushing up on math&lt;/h3&gt;
&lt;p&gt;It’s easy to get intimated by the math in papers. I found that taking the time to relearn linear algebra and some calculus has had compounding returns!&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://explained.ai/matrix-calculus/&quot;&gt;Matrix Calculus by Terence Parr and Jeremy Howard&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;backprop chapter in &lt;a href=&quot;http://neuralnetworksanddeeplearning.com/chap2.html&quot;&gt;Neural Networks and Deep Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.quantstart.com/articles/matrix-algebra-linear-algebra-for-deep-learning-part-2&quot;&gt;Matrix Algebra - Linear Algebra for Deep Learning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.3blue1brown.com/essence-of-linear-algebra-page&quot;&gt;3blue1brown for practical and visual linear algebra&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Finite-Dimensional-Vector-Spaces-Paul-Halmos/dp/178139573X&quot;&gt;for theoretical linear algebra: Finite Dimensional Vector Spaces&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;paper-reading&quot;&gt;Paper reading&lt;/h2&gt;

&lt;p&gt;Once you’ve understood common concepts, the best way to keep up to date with research and continue learning beyond courses is by reading and reimplementing papers.&lt;/p&gt;
&lt;h4 id=&quot;how-to-manage-papers&quot;&gt;How to manage papers&lt;/h4&gt;
&lt;p&gt;I recommend you track papers either through &lt;a href=&quot;https://www.zotero.org/&quot;&gt;Zotero&lt;/a&gt; or &lt;a href=&quot;https://www.mendeley.com/&quot;&gt;Mendeley&lt;/a&gt;. I started off using Zotero but switched Mendeley to share folders/papers in groups I was in. I don’t have a strong opinion on which one is better.&lt;/p&gt;

&lt;h4 id=&quot;how-to-figure-out-what-to-read-check-out-these-sources&quot;&gt;How to figure out what to read? Check out these sources:&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;twitter - follow 20+ practitioners/researchers you admire on twitter to find interesting papers&lt;/li&gt;
  &lt;li&gt;ML subreddit&lt;/li&gt;
  &lt;li&gt;AI/DL fb groups&lt;/li&gt;
  &lt;li&gt;arXiv - there’s 10-20 new papers on arXiv every day for AI/computational linguistics so you could just browse arXiv every day for the latest papers in the topics you’re most interested in&lt;/li&gt;
  &lt;li&gt;AI blogs
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://jack-clark.net/&quot;&gt;Import AI&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://github.com/dair-ai/nlp_newsletter&quot;&gt;NLP Newsletter&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;how-to-read-a-paper&quot;&gt;How to read a paper:&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;your objective is to figure out quickly which papers NOT to read&lt;/li&gt;
  &lt;li&gt;spend time in the conclusions&lt;/li&gt;
  &lt;li&gt;try to answer the question &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;what is novel&lt;/code&gt;?&lt;/li&gt;
  &lt;li&gt;create a reading group! Even just one other person can already save you 50% of the time.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Mon, 09 Dec 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/12/09/learning-plan/</link>
        <guid isPermaLink="true">https://christina.kim/2019/12/09/learning-plan/</guid>
      </item>
    
      <item>
        <title>On NMT Search Errors and Model Errors: Cat Got Your Tongue?</title>
        <description>&lt;p&gt;paper summary of &lt;a href=&quot;'https://arxiv.org/abs/1908.10090'&quot;&gt;On NMT Search Errors and Model Errors: Cat Got Your Tongue?&lt;/a&gt;
&lt;!--end_excerpt--&gt;&lt;/p&gt;

&lt;p&gt;Current NMT models may not be working correctly! When mostly given perfect conditions, aka an infinite search space, over half of the time, the models predict no translation (empty sequences).&lt;/p&gt;

&lt;p&gt;In this paper, the authors explore what NMT model’s predict as the best translation when the beam width is “infinite.” When the beam width is infinite, the model can consider all and any possibilities. Their technical contribution was coming up with a way to have models use infinite beam widths when searching. They found that in 51.8% of the cases, the model thought an empty sequence was the best translation! With beam search, longer sequences have lower probabilities, and it appears in many cases lower probabilities than a single EOS token.&lt;/p&gt;

&lt;p&gt;This paper is a startling contribution to NMT. It explores and exposes a very troubling bug of current NMT models. This paper is an exciting contribution since many NLP problems are modeled as a sequence to sequence problems, and many of the SOTA language models involve decoding with beam search. These are exciting implications and bring new questions for NLP research.&lt;/p&gt;
</description>
        <pubDate>Mon, 18 Nov 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/11/18/nmt-search-errors/</link>
        <guid isPermaLink="true">https://christina.kim/2019/11/18/nmt-search-errors/</guid>
      </item>
    
      <item>
        <title>Beam Search</title>
        <description>&lt;!--end_excerpt--&gt;
&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
&lt;p&gt;Beam search is a search algorithm to find the best choice from many options. It explores a graph by expanding the most promising node in a limited set. A beam search is usually used in situations where there isn’t a way to store the entire search tree in memory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;where is it used in DL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;sequence to sequence models like neural machine translation&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;how is it used in DL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;used to find the next best word, can be EOS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In NMT there are lots of possible combinations of words for a translation but we want to pick the best one, aka the one with the max probability distribution, and not one at random.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interesting things to note:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When beam width = 1, then beam search is essentially a greedy algorithm&lt;/p&gt;

&lt;p&gt;Beam search multiplies the log of the probabilities of the words to find the max probability - this leads to beam search favoring very short translations. This is kind of fixed by dividing it by the number of tokens.&lt;/p&gt;

&lt;h2 id=&quot;code&quot;&gt;Code&lt;/h2&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;beam_search_decoder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;encoded_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;beam_width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;sequences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# walk over each step in sequence
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;encoded_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;all_candidates&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# expand each current candidate
&lt;/span&gt;            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sequences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sequences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;j&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)):&lt;/span&gt;
                    &lt;span class=&quot;c1&quot;&gt;# why are we taking the log of the product of the probabilities
&lt;/span&gt;                    &lt;span class=&quot;c1&quot;&gt;# instead of just the product of the probabilities?
&lt;/span&gt;                    &lt;span class=&quot;c1&quot;&gt;# the probabilities are all numbers less than 1,
&lt;/span&gt;                    &lt;span class=&quot;c1&quot;&gt;# multiplying a lot of numbers less than 1 will result in a very smol number
&lt;/span&gt;                    &lt;span class=&quot;n&quot;&gt;candidate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;j&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])]&lt;/span&gt;
                    &lt;span class=&quot;n&quot;&gt;all_candidates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;candidate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# order all candidates by score
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;ordered&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sorted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;all_candidates&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# select beam_width best
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;sequence&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ordered&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;beam_width&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sequence&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;math&quot;&gt;Math&lt;/h2&gt;
&lt;p&gt;How the algorithm works from Andrew Ng’s coursera course:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/beam_search1.png&quot; alt=&quot;image&quot; /&gt;
&lt;img src=&quot;/images/posts/beam_search2.png&quot; alt=&quot;image&quot; /&gt;
&lt;img src=&quot;/images/posts/beam_search3.png&quot; alt=&quot;image&quot; /&gt;
&lt;img src=&quot;/images/posts/beam_search4.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;history&quot;&gt;History&lt;/h2&gt;
&lt;p&gt;The term “beam search” was coined by Raj Reddy, Carnegie Mellon University, 1977.&lt;/p&gt;
</description>
        <pubDate>Mon, 18 Nov 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/11/18/beam-search/</link>
        <guid isPermaLink="true">https://christina.kim/2019/11/18/beam-search/</guid>
      </item>
    
      <item>
        <title>Negated: LAMA Birds cannot fly</title>
        <description>&lt;p&gt;paper summary of &lt;a href=&quot;'https://arxiv.org/abs/1911.03343'&quot;&gt;Negated LAMA: Birds cannot fly&lt;/a&gt;
&lt;!--end_excerpt--&gt;&lt;/p&gt;

&lt;p&gt;When pre-trained language models, such as GPT-2, came out, I was curious about what they were learning and what applications could an LM, like GPT-2, have. What exactly was the model learning?&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;/2019/11/14/lm-as-a-knowledge-base/&quot;&gt;Language Models as a Knowledge Base?&lt;/a&gt; the authors have a possible answer to that question. The idea was that LM is learning facts and understanding some things, and could you used them then as a knowledge base? The experiments they ran focused masking words in a cloze sentence to get the LM to predict what the answer would be. A cloze statement “is generated from a subject- relation-object triple from a knowledge base and from a template statement for the relation that contains variables X and Y for subject and object (e.g., “X was born in Y”).” For instance, “birds can MASK,” would return fly.&lt;/p&gt;

&lt;p&gt;The authors of Negated LAMA find that LM is not great with negation. When given “birds cannot MASK,” it returns fly as well. This suggests that LM are not actually understanding the text shoveled into it. This does show that LM’s are good at answering all questions regardless of accuracy, but the authors suggest that maybe it should not be giving an answer.&lt;/p&gt;
</description>
        <pubDate>Thu, 14 Nov 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/11/14/negated-lama/</link>
        <guid isPermaLink="true">https://christina.kim/2019/11/14/negated-lama/</guid>
      </item>
    
      <item>
        <title>Language Models as a Knowledge Base?</title>
        <description>&lt;p&gt;paper summary of &lt;a href=&quot;'https://arxiv.org/pdf/1909.01066.pdf'&quot;&gt;Language Models as Knowledge Bases?&lt;/a&gt;
&lt;!--end_excerpt--&gt;&lt;/p&gt;

&lt;p&gt;This paper explores using language models as a knowledge base. Structured knowledge bases are pretty restrictive and hard to manage. For that reason, there hasn’t been a lot of research interest in structured knowledge bases since the 80s since it appeared to be impractical for Q/A other fact-based NLP tasks.&lt;/p&gt;

&lt;p&gt;Language models make an attractive substitute for structured knowledge bases since they don’t run into the same issues structured knowledge bases had. They don’t require schema engineering, allow queries about an open class of relations, can easily extend to more data and require no human supervision to train.&lt;/p&gt;

&lt;p&gt;The authors propose LAMA (LAnguage Model Analysis), which is a probe for analyzing the factual and commonsense knowledge contained in pretrained language models. They used this method to evaluate BERT. They found that BERT-large performs on par to a knowledge base from a text. Their experiments found that pretrained BERT-large was able to recall knowledge better than its other pretrained LM competitors and at a level remarkably competitive with non-neural and supervised alternatives.&lt;/p&gt;
</description>
        <pubDate>Thu, 14 Nov 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/11/14/lm-as-a-knowledge-base/</link>
        <guid isPermaLink="true">https://christina.kim/2019/11/14/lm-as-a-knowledge-base/</guid>
      </item>
    
      <item>
        <title>Backpropagation</title>
        <description>&lt;!--end_excerpt--&gt;
&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
&lt;p&gt;Backpropagation is short for backward propagation of errors. It’s used to compute gradients for our loss function in machine learning. It does this by computing the partial derivatives of each training example in regards to the weights and bias. Cost can be written as a function of the outputs from the neural network&lt;/p&gt;

&lt;p&gt;Another neat feature of backpropagation is that relates the neural network’s error and the weights and biases of the neural network’s last layer and it does this for the weights and biases of the last layer to the weights and biases of the second to last layer, and continues, using chain  rule.&lt;/p&gt;

&lt;p&gt;why is it important?&lt;/p&gt;

&lt;p&gt;there’s lots of ways you can compute the gradients for our loss function but most of them take too long for deep learning - requiring us to compute the cost in respects to each parameter each .&lt;/p&gt;

&lt;p&gt;Backpropagation is way faster - it allows us to simultaneously compute all the partial derivatives using one forward pass through the network, then one backward pass through the network.&lt;/p&gt;

&lt;h2 id=&quot;math&quot;&gt;Math&lt;/h2&gt;

&lt;p&gt;The actual algorithm:
&lt;img src=&quot;/images/posts/nielson_backprop.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Taken from Neural Networks and Deep Learning by Michael Nielson&lt;/p&gt;
</description>
        <pubDate>Wed, 06 Nov 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/11/06/backpropagation/</link>
        <guid isPermaLink="true">https://christina.kim/2019/11/06/backpropagation/</guid>
      </item>
    
      <item>
        <title>Skip Connections and Residual Blocks</title>
        <description>&lt;!--end_excerpt--&gt;
&lt;p&gt;&lt;img src=&quot;/images/posts/residual_block.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;
&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;
&lt;p&gt;This is a residual block, or skip connection. The residual is the difference between the predicted and target values. The words &lt;strong&gt;residual&lt;/strong&gt; and &lt;strong&gt;skip&lt;/strong&gt; are used interchangeably in many places. They can also be thought of as an identity block. If there is no residual then H(x) = x (aka the identity).&lt;/p&gt;

&lt;p&gt;A residual block is trying to learn the residual of the true distribution minus the input, while a normal layer tries to learn that true distribution&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;why does this work better?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Theoretically this shouldn’t matter. Neural networks are function approximations. The more layers you add, the better the approximation should be. However, this does not work in reality for many reasons such as exploding or vanishing gradients. By allowing the values to essentially pass through in a linear way, we can use previous gradients.&lt;/p&gt;

&lt;p&gt;In other words, a deeper net is not necessarily optimal because it might not learn the abstractions as the information learned in the earlier layers might disappear in the later layers.&lt;/p&gt;

&lt;p&gt;Less layers means a simpler model which is faster to train.&lt;/p&gt;

&lt;h2 id=&quot;code&quot;&gt;code&lt;/h2&gt;
&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ResidualBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Module&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;expansion&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;


       &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in_planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
           &lt;span class=&quot;nb&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BasicBlock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
           &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conv1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Conv2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;in_planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kernel_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bias&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bn1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BatchNorm2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;conv2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Conv2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kernel_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bias&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
           &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bn2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BatchNorm2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;


           &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shortcut&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
           &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;in_planes&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expansion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
               &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shortcut&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Sequential&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Conv2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;in_planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expansion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;kernel_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stride&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bias&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;nn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;BatchNorm2d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expansion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;planes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;math&quot;&gt;math&lt;/h2&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;R(x) is the residual
H(x) is the output aka true distribution
x is the input in the layer

R(x) = Output — Input = H(x) — x

The residual plus the input is the true distribution
H(x) = R(x) + x
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;history&quot;&gt;history&lt;/h2&gt;

&lt;p&gt;First introduced by microsoft in 2015.&lt;/p&gt;
</description>
        <pubDate>Tue, 29 Oct 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/10/29/residual-blocks-and-skip-connections/</link>
        <guid isPermaLink="true">https://christina.kim/2019/10/29/residual-blocks-and-skip-connections/</guid>
      </item>
    
      <item>
        <title>Human-Like Decision Making: Document-level Aspect Sentiment Classification via Hierarchical Reinforcement Learning</title>
        <description>&lt;p&gt;paper summary of &lt;a href=&quot;'https://arxiv.org/pdf/1910.09260.pdf'&quot;&gt;Human-Like Decision Making: Document-level Aspect Sentiment
Classification via Hierarchical Reinforcement Learning&lt;/a&gt;
&lt;!--end_excerpt--&gt;&lt;/p&gt;

&lt;p&gt;Document-level Aspect Sentient Classification is a task to predict user’s sentiment polarities for different aspects of a product in a review. The authors propose using Hierarchical Reinforcement Learning to do the task as it’s more interpretable than other successful neural nets that perform well on DASC.&lt;/p&gt;

&lt;p&gt;HRL is pretty cool because it makes (more) intuitive sense as to how it works compared to other neural net architecture. Instead of regular RL, there are different tiers of policies. For DASC, the authors propose using a high-level policy to find the relevant clauses. A low-level policy to select sentiment-relevant words inside the selected clauses, they used a sentiment rating predictor that provides the reward signals to both the clause and word selection policies.&lt;/p&gt;

&lt;p&gt;The results of this method were comparable to state of the art methods of aspect sentiment classification. A cool thing that I appreciated the authors, including were ablation studies for HRL. They broke down how each component of the HRL architecture impacted the results.&lt;/p&gt;

&lt;p&gt;It was interesting to note that negated sentences didn’t work well with this method. I think negation is an interesting problem because if a neural net truly understands a sentence/clause, then I’d expect it to understand negations easily.&lt;/p&gt;
</description>
        <pubDate>Tue, 22 Oct 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/10/22/hrl/</link>
        <guid isPermaLink="true">https://christina.kim/2019/10/22/hrl/</guid>
      </item>
    
      <item>
        <title>Natural Language Understanding</title>
        <description>&lt;p&gt;Natural Language Understanding has been a focus in AI since the birth of AI as a field was defined. The 60s and 70s saw a burst of knowledge bases, ontologies, math word problem solvers. NLU is considered an AI hard problem (aka when we figure this out we have figured out general artificial intelligence).&lt;/p&gt;

&lt;p&gt;The tricky part of building a machine reading-comprehension system is that it requires a mostly-accurate (I say mostly accurate because unclear how specific human’s models of the world are) idea of the world, and the ability to generalize to new contexts/situations reasonably well. The ability to reason and make pretty good predictions in new cases given our prior knowledge and understanding of the world is what makes us great general purpose learners (and also helped us to exist till now probably).&lt;/p&gt;

&lt;p&gt;These are the current types of tasks and benchmarks that test for commonsense knowledge and reasoning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Textual Entailment&lt;/strong&gt;
Textual entailment (TE) in natural language processing is a directional relation between text fragments. The relation holds whenever the truth of one text fragment follows from another text. In the TE framework, the entailing and entailed texts are termed text (t) and hypothesis (h), respectively.
examples of tasks:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;RTE Challenges (Dagan, Glickman, &amp;amp; Magnini, 2005),&lt;/li&gt;
  &lt;li&gt;Story Cloze Test (Mostafazadeh, Chambers, He, Parikh, Batra, Vanderwende, Kohli, &amp;amp; Allen, 2016)&lt;/li&gt;
  &lt;li&gt;SWAG (Zellers, Bisk, Schwartz, &amp;amp; Choi, 2018)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Question Answering&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;CommonsenseQA (Talmor, Herzig, Lourie  Berant, 2015)&lt;/li&gt;
  &lt;li&gt;Winograd Schema Challenge (Levesque, 2011)&lt;/li&gt;
  &lt;li&gt;GLUE (Wang, Singh, Michael, Hill, Levy, &amp;amp; Bowman, 2018)&lt;/li&gt;
  &lt;li&gt;Event2Mind (Rashkin, Sap, Allaway, Smith, &amp;amp; Choi, 2018b)&lt;/li&gt;
  &lt;li&gt;bAbI (Weston, Bordes, Chopra, Rush, van Merriënboer, Joulin, &amp;amp; Mikolov, 2015)&lt;/li&gt;
  &lt;li&gt;SuperGLUE(Wang, Pruksachatkun, Nangia, Singh, Michael, Hill, Levy, Bowman, 2019)&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Tue, 18 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2019/06/18/natural-language-understanding/</link>
        <guid isPermaLink="true">https://christina.kim/2019/06/18/natural-language-understanding/</guid>
      </item>
    
      <item>
        <title>Systems Sharing</title>
        <description>&lt;p&gt;A friend asked me the other day, “What are some “systems” that you have incorporated in your life that you felt have been super good ROI?”&lt;/p&gt;

&lt;p&gt;Here was my response:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Weekly review
    &lt;ul&gt;
      &lt;li&gt;Every week I reflect on things that went well, things that didn’t go according to plan, how i could have prevented that. I would highly recommend doing something like this if you don’t already. It’s a really good way to make sure you’re noticing the things that are actually happening in your life/work. During this I try to be as objective as possible and not pass judgement on myself. This is the best way to make sure you’re being honest about why you did something. Attributing negative feelings towards a behavior makes you less incentivized to notice again in the future - no one wants to feel bad and people will go to pretty fascinating lengths to build blind spots for things they want to avoid thinking about. I find that it also makes it easier to implement new habits/goals too. This is a newer system I’ve adopted but so far has been extremely rewarding.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Scheduled deep work time
    &lt;ul&gt;
      &lt;li&gt;I block off mornings as Do Not Disturb blocks of work. No meetings/no notifications. Consistency is important to me and having scheduled deep work time allows me to get in solid hours of programming in vs scattered interrupted work.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Non-violent communication
    &lt;ul&gt;
      &lt;li&gt;I have been practicing (but not yet mastering) non-violent communication. Not really sure if this counts as a “system” but seems worthwhile to think about consistently.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Social spreadsheet
    &lt;ul&gt;
      &lt;li&gt;This sounds creepy but I promise it’s only used for good 🙂I keep a spreadsheet of people and interactions. This helps me remember/keep in contact with folks and helps me to be a more intentional friend/ally.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Fri, 27 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2018/04/27/systems-sharing/</link>
        <guid isPermaLink="true">https://christina.kim/2018/04/27/systems-sharing/</guid>
      </item>
    
      <item>
        <title>Big Habits</title>
        <description>&lt;p&gt;&lt;em&gt;Disclaimer: This post was written in less than 30 mins. I’m writing this for the sake of exploring an idea and am not convinced this is a good idea. Take this as a stream of consciousness&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I’ve been experimenting with doing the extreme version of a habit to make it stickier. I have this idea that instead of doing the easiest version (do 1 pushup a day), doing the harder extreme version (100 pushups a day) makes an idea/habit stickier. The idea behind doing a easy version of a habit you want to adopt is that it makes it lower friction and simple, and eventually you will be able to work more of it into your daily life. This makes sense to me - but I think that the way to make a habit seem achievable and lower friction is actually doing the opposite. By pushing ourselves to the other end of the spectrum, you learn how doable it is and you realize you’re more than capable of actually implementing a more reasonable version of your habit. (I may also enjoy starting off habits like this because I think over indexing is powerful and I generally enjoy exploring my limits 🙂)&lt;/p&gt;
</description>
        <pubDate>Sun, 22 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2018/04/22/big-habits/</link>
        <guid isPermaLink="true">https://christina.kim/2018/04/22/big-habits/</guid>
      </item>
    
      <item>
        <title>Signals</title>
        <description>&lt;p&gt;Today we had Robin Hanson come speak at The Archive. His latest book Elephant in the Brain exposes the hidden motivations and desires in our lives. Hanson posits that in our interactions and decisions we try to signal to others certain things. Universities are an example of signaling intelligence, even if you didn’t learn that much. Even changing the conversation can be signaling.&lt;/p&gt;

&lt;p&gt;The larger ideas from the book include a) we don’t acknowledge our real motivations for our externally-inspired actions and b) being able to recognize the latent motivations and what people actually want is critical to creating effective policies.&lt;/p&gt;

&lt;p&gt;I left his talk with two thoughts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How hard would it be to train yourself to be able to pick up hidden motivations?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;His book and his talk reminded me of my experience in undergrad with HCI research and need-finding. I remember conducting countless user interviews and still not being able to come to a definite conclusion of what was missing, and what to design and build. Even interviewing “super/power” users was not useful. Other than becoming more self-aware, I wonder if there are easier hacks to discover the dissonance between what we say we want and what we actually want. I’m imagining this to work in a similar way as to how we can hear when a note is out of tune.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Given Hanson’s arguments, would publicly shaming bad behavior (e.g. predatory behavior) help create a more net positive world?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It seems to me that publicly shaming behavior would be an effective way to get behavioral outcomes. Disclaimer: his is a half baked thought and will dig into this more when I have a second.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Humans aren’t what they pretend to be. But what they actually are is spectacular” — Hanson&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;What am I signaling by writing about signaling?&lt;/em&gt; 🤔&lt;/p&gt;
</description>
        <pubDate>Fri, 20 Apr 2018 00:00:00 +0000</pubDate>
        <link>https://christina.kim/2018/04/20/signals/</link>
        <guid isPermaLink="true">https://christina.kim/2018/04/20/signals/</guid>
      </item>
    

    
      
        
      
    
      
    
      
    
      
    
      
    
      
        
          <item>
            <title></title>
            <description>researcher at openai, currently on the mid-training team. previously on post-training and reinforcement learning.

i've worked on [webgpt](https://openai.com/research/webgpt), [chatgpt](https://openai.com/blog/chatgpt), [chatgpt with browsing](https://openai.com/blog/chatgpt-plugins#browsing), [gpt-4](https://arxiv.org/abs/2303.08774)
</description>
            <link>https://christina.kim/index</link>
          </item>
        
      
    
      
    
      
    
      
    
      
    
      
    

  </channel>
</rss>