<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[ETHER Labs - Medium]]></title>
        <description><![CDATA[At EtherLabs, we build AI-first collaboration products. Checkout EtherMeet, AI-based video conferencing service for teams who use Slack. Ping us at info@etherlabs.io - Medium]]></description>
        <link>https://medium.com/ether-labs?source=rss----a20e0c163e2d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>ETHER Labs - Medium</title>
            <link>https://medium.com/ether-labs?source=rss----a20e0c163e2d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 17:31:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/ether-labs" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Slack channels with minds of their own]]></title>
            <link>https://medium.com/ether-labs/slack-channels-with-minds-of-their-own-39f742eb0cf2?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/39f742eb0cf2</guid>
            <category><![CDATA[ethermeet]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[video-conferencing]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Krishna Sai]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 09:31:01 GMT</pubDate>
            <atom:updated>2019-10-22T09:31:01.736Z</atom:updated>
            <content:encoded><![CDATA[<p><em>An </em><a href="https://www.etherlabs.io/add-to-slack/"><em>EtherLabs</em></a><em> Innovation — Meaningful Application of AI in the Enterprise</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShywMfT6NYRXijWqbgye2A.jpeg" /><figcaption>EtherMeet Channel Minds</figcaption></figure><blockquote><a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a> ChannelMinds<strong>™</strong> enable contextual processing of ephemeral video/voice conversations in Slack Channels to extract meaningful insights.</blockquote><blockquote>Have you ever had an experience that you had to join a 1.5 hour call to give a 5 minute update, or so that you won’t miss on a 10 minute discussion on the one topic you care about?</blockquote><blockquote>Have you ever missed a completely important discussion from your team because you were on a plane or just out sick?</blockquote><blockquote>Is your default playback speed for Zoom recordings at 1.5 or more, to get through the unimportant stuff quickly?</blockquote><blockquote>Or as one of my investor friends remarked recently, are you looking for a way not have to wake up a colleague at midnight so that you can work through an important update?</blockquote><p>These and many more such examples simply address an important and palpable pain point for teams distributed not only across distance but also time!</p><p>So when we set out to build <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a>, it dawned on us that <strong>‘Context is King</strong>” when it comes to business communications. If we need to filter through the plethora of messages, videos, voice calls, etc and get to the parts that are meaningful and relevant, we need to know the context of the communications and be able to use that effectively.</p><p><a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a> is an AI-enabled video conferencing service for teams on Slack. It is the most powerful conversational intelligence engine for teams that are distributed and need to use video and voice to communicate regularly. When you install <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a> as a Slack app for your workspace, here are the few innovations that you get out of the box with <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a> (in addition to the usual multi-party video &amp; screen sharing, with the ability to connect to many Group Video systems as well):</p><ul><li><a href="https://youtu.be/lyGXwXATQpY"><strong>Tag Call Parts</strong></a> — Topics, Actions, Decisions in a live call, or post-call. In a live call, or post-call. You can also create a “Note to self” that is visible only to you. So you can go back and watch or dive deeper into that one portion of the call, or catch up on something important &amp; specific from a call you missed. Ether will constantly listen to recommend these as well (suggested markers).</li><li><strong>Automatic Summary for the call</strong>: When the call is finished, <a href="https://www.etherlabs.io/add-to-slack/">Ether</a> will (in a matter of seconds), analyze your entire call, extract a summary, and share it within the Slack Channel. You can then click on any of the ‘important moment’ to dive in and respond.</li><li><strong>Automatic Chapter Markers</strong>: As the call proceeds <a href="https://www.etherlabs.io/add-to-slack/">Ether</a> will analyze your call, extract the important key phrases, and mark them in the timeline, so in an hours’ call, you can quickly skim through the chapters and dive into specific one you’re interested in.</li><li><strong>Ether TimeLine™</strong>: When you open <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a>, you will see a collapsible TimeLine on your left that will give a full view of the call summaries and markers along with the full transcripts should you choose to dig deeper.</li><li><strong>Your own Netflix</strong>: Open <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a>, and you will see a list of all your meetings (or ones you missed but have access to) — catch up on that important update from your CEO, or the incident review from the weekend, or a design review for your upcoming project. Of course, all of these will give you the timeline with summaries so that you can quickly get to the portions that you are interested in.</li><li><strong>Smart Search &amp; Alerts</strong>: In the coming weeks <a href="https://www.etherlabs.io/add-to-slack/">EtherMeet</a> will allow you to search semantically and better still get alerted by our AI on an important topic or discussion.</li></ul><p>At the heart of these groundbreaking innovations that shift team collaboration to the next dimension are two key technologies that Ether’s team has pioneered: <strong>Channel Minds™</strong> &amp; <strong>Ether Graph™</strong>.</p><h3>Channel Minds<strong>™</strong></h3><p>Here we will focus on Channel Minds and come back Ether Graph another time. When EtherMeet is invited to a channel, Ether will gently prod you to attach a domain or focus to the channel (e.g., Sales, Software Engineering, Finance, HR etc). These are highly optimized contexts with training from millions of documents that present the first level of context for the channel.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FHDbI2cmMOF0%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHDbI2cmMOF0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FHDbI2cmMOF0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3ebfd3bc20e0fef58f5787452b1f6ea/href">https://medium.com/media/c3ebfd3bc20e0fef58f5787452b1f6ea/href</a></iframe><blockquote>Your Slack channel now has a mind and is alive!</blockquote><p>When a call is finished, <a href="https://www.etherlabs.io/add-to-slack/">Ether</a> will analyze the call in near real-time and within a few seconds, boomerang the summary back into the channel.</p><p>Here’s a high-level view of how Channel Minds work:</p><ol><li>Ether’s global models (Domain Minds) train continuously from a public corpus</li><li>Trained models form our global templates — “Domain Minds” (Software, Product, Marketing, Finance, etc)</li><li>Specific instances of these “Domain Minds” are anchored to each Slack Channel</li><li>Channel or Room specific minds then learn from team behavior/data (what’s said, and what’s typed or shared in the room/channel) which remain local and private</li><li>These Minds provide the context to rank the conversations in a meeting, help derive key phrases from the conversational segments for summaries, alerts, or for search relevance</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*0MByn2EdQ23w0vC_" /></figure><p>Let’s take a look at a real-world example of Channel Minds in action.</p><p>Here’s an example call that talks about a variety of topics ranging from Software, HR &amp; Marketing.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Ftracks%252F699012274%26show_artwork%3Dtrue&amp;url=https%3A%2F%2Fsoundcloud.com%2Fkrishna-sai-705302174%2Fethermeet-channel-minds-demo-speech&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cfbe0055a384d05fad2e2ba08a35415/href">https://medium.com/media/4cfbe0055a384d05fad2e2ba08a35415/href</a></iframe><p>Given the myriad of subjects in this, how does one determine what’s important and what’s not. This is where the context of Ether’s Channel minds work the magic. In the Software Engineering channel, the segments or portions of the call that discuss AWS, Docker, Git, and Database are recognized as more important compared to the others and are more useful for the team that’s working on Software. Similarly, the mind of the HR channel automatically prioritizes discussion on employee benefits, performance etc, and something similar for the marketing channel.</p><h3>Call &amp; summary in Software channel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*MtiaL02Hkaw2UJG0" /></figure><h3>Call &amp; summary in HR channel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*yO-QSRy5lwqmT_Vt" /></figure><h3>Call &amp; summary in Marketing channel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/0*r-5ZfNa4frWmYHy2" /></figure><h3>So how do we do this?</h3><p>We train Language Models (one per domain — state-of-the-art transformer-based architectures — BERT, GPT, ERNIE, fine-tuned on various learning tasks) based on public data related to the domain, and score the data based on frequency, recency, etc. For summarization, the domain Language model as feature extractor and compares the discussions against the domain topics and gleans the most relevant information from the call. When the call ends, the conversational segments are scored according to their relevance to the associated mind — weighing the scores between overall purpose and current priorities (recency relevance). The conversation scoring algorithm is a fine-tuned language model that is optimized to capture the semantic relatedness between the conversations and ChannelMinds — STS Benchmark. Collective user feedback on the call summaries is used to bias the model towards the feedback.</p><h3>Try EtherMeet</h3><p>Visit <a href="http://www.etherlabs.io/">www.etherlabs.io</a> and <a href="https://www.etherlabs.io/add-to-slack/">add EtherMeet to your Slack</a> workspace!</p><h3>Check out these other Articles on Ether’s AI</h3><ul><li><a href="https://www.etherlabs.io/attention-part-1/">Part-1 — Which Attention Architecture do you need?</a></li><li><a href="https://www.etherlabs.io/part-2-which-attention-architecture-do-you-need/">Part 2 — Which Attention Architecture do you need?</a></li><li><a href="https://www.etherlabs.io/bert-for-unsupervised-text-tasks/">BERT for unsupervised text tasks</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39f742eb0cf2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/slack-channels-with-minds-of-their-own-39f742eb0cf2">Slack channels with minds of their own</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Part-2] Which Attention(architecture) do you need?]]></title>
            <link>https://medium.com/ether-labs/part-2-which-attention-architecture-do-you-need-c327aaa771f8?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/c327aaa771f8</guid>
            <category><![CDATA[gpt]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ethermeet]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[bert]]></category>
            <dc:creator><![CDATA[Venkata Dikshit]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 11:31:01 GMT</pubDate>
            <atom:updated>2019-08-13T11:31:01.263Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="http://www.etherlabs.io/">EtherLabs</a>, we build AI-first collaboration products. Checkout <a href="http://www.etherlabs.io/">EtherMeet</a>, AI-based video conferencing service for teams who use Slack.</p><figure><img alt="At EtherMeet (www.etherlabs.io), we apply advanced AI to make video conferences smarter and more relevant." src="https://cdn-images-1.medium.com/max/1024/1*uBaxAKy6fcmr5NyxlK4iVA.jpeg" /><figcaption>Attention Architectures at EtherLabs</figcaption></figure><p><a href="https://medium.com/ether-labs/https-medium-com-ether-labs-attention-architecture-1-60caf491fc8e">Part-1 of this two-part series</a> covered the GPT and BERT based architectures — upper two quadrants in [fig-1]. This post covers the architectures from the lower quadrants — XLNet, MASS and GPT-2 (yes, again) to better understand all the <a href="https://www.theguardian.com/technology/2019/feb/14/elon-musk-backed-ai-writes-convincing-news-fiction">hype around it</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7CkvOjCe3zKTNzEGtlYXA.png" /><figcaption>[fig-1] Transformer-based models segregated by their architectural design</figcaption></figure><h3>GPT-2 and XLNet</h3><p>These two are current state-of-the-art across multiple language tasks and notorious for their data and resource consumption — <a href="https://blog.floydhub.com/gpt2/">[1]</a>, <a href="https://www.reddit.com/r/MachineLearning/comments/c59ikz/r_it_costs_245000_to_train_the_xlnet_model512_tpu/">[2]</a>. These two architectures address some of the limitations of their predecessors — GPT and BERT respectively.</p><p>Before we delve into the details of these architectures, we need to be aware of some of the technical terms:</p><p><strong>Auto-regression Language modeling — </strong>A classical language modeling approach, where the objective is to maximize the likelihood of a sequence of words under the forward autoregressive factorization. GPT is based on left-to-right auto-regression factorization</p><p><strong>Auto-encoder Language modeling — </strong>Aims to reconstruct the input sequence of text and in the process learning the likelihood of word sequences. BERT is based on a variant of auto-encoder called Denoising auto-encoder where the sequence is reconstructed from the corrupted version of the actual input sequence. BERT uses a modified AE approach that predicts only the masked words instead of the entire sequence</p><p><strong>Permutation Language modeling — </strong>A variant of auto-regression approach where instead of using only the right-to-left and/or right-to-left factorization, we use all combination of word sequences possible ie. for a sequence x of length T, there are T! different orders to perform a valid autoregressive factorization. This is an efficient way of encoding deep bi-directional representations of token sequences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LsPeekhQmG_4dGfn8UnZ_Q.png" /><figcaption>[fig-2] Using different factorization sequences as mentioned in the <a href="https://arxiv.org/pdf/1906.08237.pdf">XLNet paper</a></figcaption></figure><p>For example, consider a sequence of length 4 and predicting the token x3 given the same input sequence x but under different factorization orders. [fig-2] shows the combinations in which representations of x3 can be learnt</p><p><strong>XLNet — </strong>Uses <a href="https://arxiv.org/pdf/1901.02860.pdf">Transformer-XL</a> based pre-training paradigm that addresses the following limitations of AR and AE based approaches:</p><p><strong>Independence Assumption</strong> — BERT inherently assumes conditional independence between all the masked tokens as they are separately reconstructed thereby limiting its learning capabilities. In comparison, AR-based models factorize the sequence probabilities using product rule that holds universally without such an independence assumption</p><p><strong>Input noise</strong> — The input to BERT contains artificial symbols like [MASK] that never occur in downstream tasks, which creates a pretrain-finetune discrepancy. Replacing [MASK] with original tokens as mentioned in the original paper does not solve the problem because original tokens can be only used with a small probability. In comparison, AR language modelling does not rely on any input corruption and does not suffer from this issue</p><p><strong>Context dependency — </strong>The AR representation hθ(x1:t−1) is only conditioned on the tokens up to position t (i.e. tokens to the left), while the BERT representation Hθ(x)t has access to the contextual information on both sides. As a result, the BERT objective allows the model to be pretrained to better capture the bidirectional context</p><p>XLNet brings in the best of both worlds — bi-directional capabilities of BERT and fully dependent factorization of AR models.</p><p><strong>XLNet Architecture details</strong></p><ul><li><strong>XLNet uses permutation language model</strong> — during permutation, only the factorization order is permuted and not the sequence — we use the same positional encodings of the original sequence instead of calculating them for permuted sequence. Check out section-3.5 in “<a href="https://www.reddit.com/r/learnmachinelearning/comments/9e4j4q/positional_encoding_in_transformer_model/">Attention is all you need</a>” for details on positional embeddings</li><li><strong>Target-aware representations</strong> — giving XLNet objective additional information about which position it will predict. This is achieved using the Two-Stream Self-Attention as discussed in the paper</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j7gs0Z7CI0iR9e_EeXheuA.png" /><figcaption>XLNet base Objective function with the target position</figcaption></figure><ul><li><strong>Adaptations from Transformer-XL architecture — </strong>The key adaptation from Transformer-XL is the <strong>recurrence mechanism</strong> into the proposed permutation setting and enable the model to reuse hidden states from previous segments. Suppose we have two segments taken from a long sequence s; i.e., x˜ = s1:T and x = sT +1:2T . Let z˜ and z be permutations of [1 · · · T] and [T + 1 · · · 2T] respectively. Then, based on the permutation z˜, we process the first segment and then cache the obtained content representations h˜(m) for each layer m. Then, for the next segment x, the attention update with memory can be written as:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PZfpDg8tydGlpW5M6cFKXg.png" /></figure><p>This allows caching and reusing the memory without knowing the factorization order of the previous segment. In expectation, the model learns to utilize the memory overall factorization orders of the last segment.</p><p><strong>GPT-2 — </strong>Architecturally, GPT-2 is not a major deviation from its predecessor. In the discussion to follow, we highlight some of the notable aspects of GPT-2</p><ul><li>It uses WebText as the pre-training text — a collection of all outbound Reddit links with at least three karma. The input token representations are <a href="https://www.aclweb.org/anthology/P16-1162">Byte Pair Encodings</a> which effectively interpolates between word level inputs for frequent symbol sequences and character level inputs for infrequent symbol sequences. With this approach, GPT-2 gets rid of conventional Language Modelling pre-processing steps such as lowercasing, tokenization, and out-of-vocabulary tokens which restrict the space of model-able strings. This allows GPT/GPT-2 to be evaluated on any dataset regardless of pre-processing, tokenization, or vocab size.</li><li>GPT-2 has an expanded vocab compared to GPT and is trained with a context window of 1024 instead of 512 and a larger batch size of 512 — tons of GPUs!!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*CkqIX3cuowI6fnITng6vDQ.png" /><figcaption>[table-1] GPT-2 architecture experiments with different model sizes</figcaption></figure><ul><li>[table-1] shows models of 4 different sizes. The final GPT-2 architecture is a 48 layer transformer architecture with feature dimensions of 1600 and has ~5X more parameters compared to its predecessor</li><li>GPT-2 hasn’t reported the fine-tuning performance on various datasets instead reported the zero-shot performance on eight datasets out of which it has improved the state-of-the-art in seven tasks. This establishes the baseline for GPT-2 performance and any dataset/task fine-tuning will only improve the performance.</li><li>GPT-2 fails to address the inefficiencies of its uni-directional representations that fail to capture the full context of the text. So, the reported success of GPT-2 should be attributed to the choice of data sources and the ~1.5 B learnable parameters</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*udBO-BDqj0hy45GN" /><figcaption>Image Source: <a href="https://blog.floydhub.com/gpt2/">https://blog.floydhub.com/gpt2/</a></figcaption></figure><h3>MASS</h3><p><strong>Ma</strong>sked <strong>S</strong>equence to <strong>S</strong>equence Pre-training for Language Generation, proposes an extended version of BERT where the objective is modified to predict a series of tokens (aka. fragments) instead of predicting the random tokens as proposed in BERT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-guZp0BJ9Yfx0PWJFF5C1A.png" /><figcaption>MASS Encoder-Decoder framework</figcaption></figure><ul><li>MASS objective makes it outperform most of the current approaches in language generation tasks — by jointly training the encoder and decoder</li><li>The MASS encoder is forced to understand the meaning of unmasked tokens in the context of generating them during the decoder phase</li><li>During decoding, the unmasked tokens from the encoder are masked thereby forcing the decoder to predict the encoder masked tokens only from the encoder output instead of relying on the previous token (not part of the fragment)</li><li>MASS addresses the masked token conditional independence of BERT but fails to achieve the deep bi-directional contextuality as stated in XLNet</li></ul><h3>Conclusion</h3><p>In this two-part series, we have covered various Transformer based architectures, highlighting their architectural difference, training objects and other significant aspects. These architectures have pushed the limits of text understanding engines and fast heading towards generalized understanding and enabling faster task-specific adaptation through effective pre-training strategies. More to come on Language Models, NLP, Geometric Deep Learning, Knowledge Graphs, contextual search and recommendations. Stay tuned!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FS5ZLrGVZ0So&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS5ZLrGVZ0So&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FS5ZLrGVZ0So%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href">https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href</a></iframe><blockquote>Checkout <a href="http://www.etherlabs.io/">EtherMeet</a>, an AI-enabled video conferencing service for teams who use Slack.</blockquote><blockquote>Sign up at <a href="http://etherlabs.io/">etherlabs.io</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c327aaa771f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/part-2-which-attention-architecture-do-you-need-c327aaa771f8">[Part-2] Which Attention(architecture) do you need?</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Part-1] Which Attention(architecture) do you need?]]></title>
            <link>https://medium.com/ether-labs/https-medium-com-ether-labs-attention-architecture-1-60caf491fc8e?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/60caf491fc8e</guid>
            <category><![CDATA[video-conferencing]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ethermeet]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[slack]]></category>
            <dc:creator><![CDATA[Venkata Dikshit]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 11:31:02 GMT</pubDate>
            <atom:updated>2019-08-05T11:31:02.438Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AW5Zsr9SddLeITQ9SI-Wog.png" /></figure><p>When we started working on text tasks at <a href="http://www.etherlabs.io/">Ether Labs</a>, Neural Transfer Learning on the text was still in its nascent stages and we relied on multiple training paradigms for different tasks — Summarization, text similarity, key-phrase extraction, NER etc. The source data being same, this looked redundant and we have played around with approaches to build reusable feature extractor that can be used across multiple tasks. Word/paragraph embeddings are flexible enough to address some of these tasks but their learning capabilities are no match to the deeper architectures. Task-specific Language model fine-tuning has brought in the ImageNet like fine-tuning capabilities to text and paving way for general text understanding. We were quick to adopt this approach, thanks to <a href="https://arxiv.org/pdf/1801.06146.pdf">Howard and Ruder, 2018</a>, we have achieved significant improvements across multiple tasks.</p><p>Our natural next step in adopting cutting edge learning paradigms is Transformer based architectures. The improvements are evident, and there were no second thoughts about replacing our existing Language Model. Of late, Google, Microsoft and Open AI are pushing the performance limits on <a href="https://www.nyu.edu/projects/bowman/glue.pdf">GLUE</a> tasks with their transformer-based learning paradigms. In this post and the next, we highlight the differences between recently proposed transformer-based architectures and enable NLP practitioners to choose the right architecture for their tasks.</p><h3>Introduction</h3><p>Transformer aka. self-attention architectures, proposed by <a href="https://arxiv.org/pdf/1706.03762.pdf">Vaswani et al.</a> in “<strong><em>Attention is All you need</em></strong>” is attention only architectures to draw global dependencies between input and output. This Self-attention/intra-attention mechanism works by relating different positions of a single sequence in order to compute a representation of the sequence. For a detailed explanation on transformers refer to <a href="http://jalammar.github.io/illustrated-transformer/">The Illustrated Transformer</a>, <a href="http://nlp.seas.harvard.edu/2018/04/03/attention.html">The Annotated Transformer</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7CkvOjCe3zKTNzEGtlYXA.png" /><figcaption>[fig-1] Transformer-based models segregated by their architectural design</figcaption></figure><p>Above snapshot shows some of the recently proposed transformer-based architectures. While at their core, every architecture based on multi-headed self-attention, they are different in the following aspects:</p><ul><li>Left-to-right vs. bi-directional contexts</li><li>Pre-training tasks</li><li>Usage of auxiliary tasks</li><li>Generalization strategies adopted</li></ul><p>The models in the same quadrant are not necessarily similar in all aspects — they can be similar in the way they are different from models in other quadrants. For example, GPT-2 is architecturally close to GPT and is similar to XLNet for its emphasis on generalization. This is the best possible grouping I could think of at this point.</p><blockquote>In the literature, the <em>Left-to-right</em> context networks are called “Transformer Decoders” and <em>bi-directional </em>context networks are called “Transformer Encoder”</blockquote><h3>GPT and GPT-2</h3><p>GPT/GPT-2 architecture is a decoder only architecture where every token can attend only attend the tokens to its left in the self-attention layers. <strong><em>The pre-training</em></strong> is based on typical language modelling setup — likelihood maximum of token sequences using <a href="https://arxiv.org/pdf/1801.10198.pdf"><em>multi-layer Transformer decoder</em></a></p><blockquote>Given an unsupervised corpus of tokens U = {u1, . . . , un}, we use a standard language modeling objective to maximize the following likelihood</blockquote><p>The pre-training parameters can be adapted to the supervised tasks by feeding the inputs through the pre-trained model to obtain the final transformer block’s activation, which is then fed into an added linear output layer to predict the label. Including language modelling as an auxiliary objective to the fine-tuning helped in learning by improving generalization of supervised tasks and faster convergence.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*hJDM95Pxk5sz-iW58FQ6yg.png" /><figcaption>Learning objective for supervised tasks</figcaption></figure><p>Architecturally, GPT-2 remain the same with the following modifications:</p><ul><li>Position of layer-normalization</li><li>Modified initialization</li><li>Expanded vocabulary and increased context and batch sizes</li></ul><h4>Usability</h4><p>GPT architecture is effective in featurizing longer text sequences due to its Language model training objective. This can be handy for generating paragraph/document level embeddings.</p><h4>Limitations</h4><p>GPT and GPT-2 fail to capture the full representation of a word due to its usage of left-to-right only context. This yields sub-optimal performance on the token-level tasks such as question answering where bi-directional context is required.</p><h3>BERT and MT-DNN</h3><p><strong>BERT</strong> — <strong>B</strong>idirectional <strong>E</strong>ncoder <strong>R</strong>epresentations from <strong>T</strong>ransformers has pushed the SOTA across various text tasks by addressing the limitations of GPT by going bidirectional and using two novel pre-training tasks:</p><ul><li><strong>Masked LM</strong> — Randomly mask some of the tokens from the input, and the objective is to predict the original vocabulary id of the masked word based only on its context. Masked LM has is not restricted to left-to-right context as the masked token is predicted based on all the unmasked tokens irrespective of their position in the sentence</li><li><strong>Next Sentence Prediction — </strong>A binary classifier based fine-tuning to predict whether a sentence pair can occur in a sequence. This fine-tuning helps to address NLP tasks involving two or more inputs — Question Answering, Natural Language Inference etc.</li></ul><p>Task-specific fine-tuning is same as in GPT with minor modifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcP0-nU6JV8HdgyvbeAWAg.png" /><figcaption>[fig-2] BERT Pre-training input for Masked LM + NSP</figcaption></figure><p><strong>MT-DNN — M</strong>ulti-<strong>T</strong>ask <strong>D</strong>eep <strong>N</strong>eural <strong>N</strong>etworks takes inspiration from BERT for pre-training and uses novel Multi-task learning approach for fine-tuning.</p><blockquote>Multi-Task Learning (MTL) is inspired by human learning activities where people often apply the knowledge learned from previous tasks to help learn a new task. For example, it is easier for a person who knows how to ski to learn skating than the one who does not. Similarly, it is useful for multiple (related) tasks to be learned jointly so that the knowledge learned in one task can benefit other tasks.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rx928AiinRDmRTPBiCJpvQ.png" /><figcaption>[fig-3] Overview of MT-DNN Learning strategy</figcaption></figure><p>[fig-3] shows the learning strategy of MT-DNN — during fine-tuning each batch uses one of the pre-selected objective functions to optimize on instead of one. The performance gains for MT-DNN come from this fine-tuning strategy which gives MT-DNN ability to use learnings from one fine-tuning task in others, unlike GPT and BERT where task-specific fine-tuning independent of other tasks. This generalized learning strategy aligns with the task agnostic learning paradigm. Please refer to this <a href="https://bair.berkeley.edu/blog/2017/07/18/learning-to-learn/">link</a> for more details</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*VK9hUMHgoGGU3qKq1gb-Ow.png" /><figcaption>Model Agnostic Meta-learning approach</figcaption></figure><p><em>MAML trains over a wide range of tasks. It trains for a representation that can be quickly adapted to a new task, via a few gradient steps. The meta-learner seeks to find an initialization that is not only useful for adapting to various problems but also can be adapted quickly (in a small number of steps) and efficiently (using only a few examples).</em></p><h4>Usability</h4><p>BERT addresses the limitations of GPT using both left-to-right and right-to-left context for learning token representations in a sentence. This makes BERT efficient for most text tasks — Q&amp;A, sentence similarity, POS tagging etc.</p><h4><strong>Limitations</strong></h4><ul><li>BERT suffers from a training-inference mismatch as the [MASK] token used during Masked LM training does not appear during inference. This is alleviated to some extent using the following strategy:</li></ul><blockquote>A downside is that we are creating a mismatch between pre-training and fine-tuning, since the [MASK] token does not appear during fine-tuning. To mitigate this, we do not always replace “masked” words with the actual [MASK] token. The training data generator chooses 15% of the token positions at random for prediction. If the i-th token is chosen, we replace the i-th token with (1) the [MASK] token 80% of the time (2) a random token 10% of the time (3) the unchanged i-th token 10% of the time. Then, Ti will be used to predict the original token with cross entropy loss.</blockquote><ul><li>One more constraint on learning capabilities of BERT is that it assumes conditional independence between the masked tokens and this limits the quality of sentence representations learnt by BERT.</li><li>BERT is not effective for encoding longer text sequence as the pre-training tasks are restricted to the sentence level tasks.</li></ul><h3>Contd.</h3><p>In Part-2, we will cover rest of the Transformer based architectures from [fig-1] — discuss how they address the limitations of GPT and BERT based approaches, the path forward for generalized text understanding and lot more.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FS5ZLrGVZ0So&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS5ZLrGVZ0So&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FS5ZLrGVZ0So%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href">https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href</a></iframe><blockquote>Checkout EtherMeet, an AI-enabled video conferencing service for teams who use Slack.</blockquote><blockquote>Sign up at <a href="http://etherlabs.io/">etherlabs.io</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60caf491fc8e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/https-medium-com-ether-labs-attention-architecture-1-60caf491fc8e">[Part-1] Which Attention(architecture) do you need?</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BERT for unsupervised text tasks]]></title>
            <link>https://medium.com/ether-labs/bert-for-unsupervised-text-tasks-fa6e9ce5d133?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/fa6e9ce5d133</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ethermeet]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[bert]]></category>
            <dc:creator><![CDATA[Venkata Dikshit]]></dc:creator>
            <pubDate>Thu, 18 Jul 2019 11:31:01 GMT</pubDate>
            <atom:updated>2019-07-18T11:31:01.331Z</atom:updated>
            <content:encoded><![CDATA[<p>This post discusses how we use BERT and similar self-attention architectures to address various text crunching tasks at <a href="https://etherlabs.io/">Ether Labs</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3_6-5GQvlBQFYLtFDfSbA.jpeg" /></figure><p>Self-attention architectures have caught the attention of NLP practitioners in recent years, first proposed in <a href="https://arxiv.org/pdf/1706.03762.pdf">Vaswani et al</a>., where the authors have used <strong>multi-headed</strong> self-attention architecture for machine translation tasks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzL6kyBXsH4fzLveUaYstA.png" /><figcaption>BERT’s Attention of the word ‘It’ in one of the layers</figcaption></figure><blockquote>Multi-headed attention enhances the ability of the network by giving attention layer multiple subspace representations — each head weights are randomly initialised and after training, each set is used to project input embedding into different representation subspace</blockquote><p><strong>BERT Architecture Overview</strong></p><ul><li>BERT’s model architecture is a multi-layer bidirectional Transformer encoder based on the original implementation described in <a href="https://arxiv.org/pdf/1706.03762.pdf">Vaswani et al</a>.</li><li>Each word in BERT gets “n_layers*(num_heads*attn.vector) “ representations that capture the representation of the word in the current context</li><li>For example, in BERT base: n_layers = 12, N_heads = 12, attn.vector = dim(64)</li><li>In this case, we have 12X12X(64) representational sub-spaces for each word to leverage</li><li>This leaves us with a challenge and opportunity to leverage such rich representations unlike any other LM architectures proposed earlier</li></ul><h3>Sentence relatedness with BERT</h3><p>BERT representations can be double-edged sword gives the richness in its representations. In our experiments with BERT, we have observed that it can often be misleading with conventional similarity metrics like cosine similarity. For example, consider pair-wise cosine similarities in below case (from the BERT model fine-tuned for HR-related discussions):</p><blockquote><strong>text1:</strong> Performance appraisals are both one of the most crucial parts of a successful business, and one of the most ignored.</blockquote><blockquote><strong>text2:</strong> On the other, actual HR and business team leaders sometimes have a lackadaisical “I just do it because I have to” attitude.</blockquote><blockquote><strong>text3:</strong> If your organization still sees employee appraisals as a concept they need to showcase just so they can “fit in” with other companies who do the same thing, change is the order of the day. How can you do that in a way that everyone likes?</blockquote><blockquote>text1&lt;&gt;text2–0.613270938396454</blockquote><blockquote>text1&lt;&gt;text3–0.634544332325459</blockquote><blockquote>text2&lt;&gt;text3–0.772294402122498</blockquote><p>A metric that ranks text1&lt;&gt;text3 higher than any other pair would be desirable. How do we get there?</p><p>OOTB, BERT is pre-trained using two unsupervised tasks, <strong>Masked LM</strong> and <strong>Next Sentence Prediction (NSP)</strong> tasks.</p><p><strong>Masked LM</strong> is a spin-up version of conventional language model training setup — next word prediction task. For more details, please refer to section 3.1 in the <a href="https://arxiv.org/pdf/1810.04805.pdf">original paper</a>.</p><p><strong>Next Sentence Prediction (NSP)</strong> task is a novel approach proposed by authors to capture the relationship between sentences, beyond the similarity.</p><p>For the above text pair relatedness challenge, NSP seems to be an obvious fit and to extend its abilities beyond a single sentence, we have formulated a new training task.</p><h4>From NSP to Context window</h4><p>In a context window setup, we label each pair of sentences occurring within a window of n sentences as 1 and zero otherwise. For example, consider the following paragraph:</p><blockquote>As a manager, it is important to develop several soft skills to keep your team charged. Invest time outside of work in developing effective communication skills and time management skills. Skills like these make it easier for your team to understand what you expect of them in a precise manner. Check in with your team members regularly to address any issues and to give feedback about their work to make it easier to do their job better. Encourage them to give you feedback and ask any questions as well. Effective communications can help you identify issues and nip them in the bud before they escalate into bigger problems.</blockquote><blockquote><strong>For context window n=3, </strong>we generate following training examples</blockquote><blockquote><em>Invest time outside of work in developing effective communication skills and time management skills. </em><strong><em>&lt;SEP&gt; </em></strong><em>Check in with your team members regularly to address any issues and to give feedback about their work to make it easier to do their job better. </em><strong><em>Label: 1</em></strong></blockquote><blockquote><em>As a manager, it is important to develop several soft skills to keep your team charged. </em><strong><em>&lt;SEP&gt; </em></strong><em>Effective communications can help you identify issues and nip them in the bud before they escalate into bigger problems. </em><strong><em>Label: 0</em></strong></blockquote><blockquote><em>Effective communications can help you identify issues and nip them in the bud before they escalate into bigger problems. </em><strong><em>&lt;SEP&gt; </em></strong><em>Check in with your team members regularly to address any issues and to give feedback about their work to make it easier to do their job better. </em><strong><em>Label: 1</em></strong></blockquote><p>This training paradigm enables the model to learn the relationship between sentences beyond the pair-wise proximity. After context window fine-tuning BERT on HR data, we got following pair-wise relatedness scores</p><p><em>text1&lt;&gt;text2–0.1215614</em></p><p><em>text1&lt;&gt;text3–0.899943</em></p><p><em>text2&lt;&gt;text3–0.480266</em></p><p>This captures the sentence relatedness beyond similarity. In practice, we use a weighted combination of cosine similarity and context window score to measure the relationship between two sentences.</p><h3>Document Embeddings</h3><p>Generating feature representations for large documents (for retrieval tasks) has always been a challenge for the NLP community. Approaches like concatenating sentence representations make them impractical for downstream tasks and averaging or any other aggregation approaches (like p-means word embeddings) fail beyond certain document limit. We have explored several ways to address these problems and found the following approaches to be effective:</p><h4>BERT+RNN Encoder</h4><p>We have set up a supervised task to encode the document representations taking inspiration from RNN/LSTM based sequence prediction tasks.</p><p><strong>[step-1] </strong>extract BERT features for each sentence in the document</p><p><strong>[step-2]</strong> train RNN/LSTM encoder to predict the next sentence feature vector in each time step</p><p><strong>[step-3] </strong>use final hidden state of the RNN/LSTM as the encoded representation of the document</p><p>This approach works effectively for smaller documents and is not effective for larger documents due to the limitations of RNN/LSTM architectures.</p><h4>Distributed Document Representations</h4><p>Generating a single feature vector for an entire document fails to capture the whole essence of the document even when using BERT like architectures. We have reformulated the problem of Document embedding to identify the candidate text segments within the document which in combination captures the maximum information content of the document. We use the following approaches to get the distributed representations — <strong>Feature clustering, Feature Graph Partitioning</strong></p><p><strong><em>Feature clustering</em></strong></p><p><strong>[step-1] </strong>split the candidate document into text chunks</p><p><strong>[step-2] </strong>extract BERT feature for each text chunk</p><p><strong>[step-3]</strong> run k-means clustering algorithm with relatedness score (discussed in the previous section) as a similarity metric on candidate document until convergence</p><p><strong>[step-4] </strong>use the text segments closest to each centroid as the document embedding candidate</p><p>A general rule of thumb is to have a large chunk size and a smaller number of clusters. In practice, these values can be fixed for a specific problem type</p><p><strong><em>Feature Graph Partitioning</em></strong></p><p><strong>[step-1] </strong>split the candidate document into text chunks</p><p><strong>[step-2] </strong>extract BERT feature for each text chunk</p><p><strong>[step-3] </strong>build a graph with nodes as text chunks and relatedness score between nodes as edge scores</p><p><strong>[step-4] </strong>run community detection algorithms (eg. <a href="https://neo4j.com/docs/graph-algorithms/current/algorithms/louvain/">The Louvain algorithm)</a> to extract community subgraphs</p><p><strong>[step-5] </strong>use graph metrics like node/edge centrality, PageRank to identify the influential node in each sub-graph — used as document embedding candidate</p><h3>Conclusion</h3><p>This post highlights some of the novel approaches to use BERT for various text tasks. These approaches can be easily adapted to various usecases with minimal effort. More to come on Language Models, NLP, Geometric Deep Learning, Knowledge Graphs, contextual search and recommendations. Stay tuned!!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FS5ZLrGVZ0So&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DS5ZLrGVZ0So&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FS5ZLrGVZ0So%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href">https://medium.com/media/f8d486bfb235c4348fe016cab69d6e19/href</a></iframe><blockquote>Checkout EtherMeet, an AI-enabled video conferencing service for teams who use Slack.</blockquote><blockquote>Sign up at <a href="http://etherlabs.io/">etherlabs.io</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa6e9ce5d133" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/bert-for-unsupervised-text-tasks-fa6e9ce5d133">BERT for unsupervised text tasks</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TradeBot: Stock Trading using Reinforcement Learning — Part1]]></title>
            <link>https://medium.com/ether-labs/tradebot-stock-trading-using-reinforcement-learning-part1-8b67c9603f33?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/8b67c9603f33</guid>
            <category><![CDATA[ai-in-finance]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Shivam Akhauri]]></dc:creator>
            <pubDate>Sun, 03 Mar 2019 15:30:36 GMT</pubDate>
            <atom:updated>2019-03-03T17:46:17.196Z</atom:updated>
            <content:encoded><![CDATA[<h3>TradeBot: Stock Trading using Reinforcement Learning — Part1</h3><p><strong>Aim</strong>: To develop an AI to predict the stock prices and accordingly decide on buying, selling or holding stock. The AI algorithm should be flexible to consider various trading environmental factors like stock price changes, latency, gaining protection from future price movements.</p><p><strong>Introduction</strong>: To develop a TradeBot, you have to model stock prices correctly, so as a stock buyer you can reasonably decide when to buy stocks and when to sell them to make a profit, which involves developing a Time-Series model. Thus, the problem statement can also be loosely handled in a ‘Supervised learning approach using LSTM’.</p><blockquote>What’s LSTM?</blockquote><p>Humans don’t start their thinking from scratch every second. As you read this essay, you understand each word based on your understanding of previous words. We don’t throw everything away and start thinking from scratch again. The LSTM or Long Short-Term Memory neural networks allow us to learn the context required to make predictions in time series forecasting problems, rather than having this context pre-specified and fixed. LSTM thus can look at the history of a sequence of Trading data and predict what the future elements of the sequence are going to be.</p><blockquote>Why Reinforcement Learning over Supervised approaches (LSTM)?</blockquote><p>As described in my other post, Reinforcement learning is a branch of ML which involves taking suitable action to maximize reward in a particular situation. RL differs from the supervised learning in a way that in supervised learning the training data has the answer key with it so the model is trained with the correct answer itself whereas in reinforcement learning, there is no answer but the reinforcement agent decides what to do to perform the given task.</p><p>While the problem statement can also be loosely handled in a supervised learning approach using LSTM, RL is more robust as it allows flexibility to take into account various other environmental factors which affect the stock prices, like latency etc.</p><p>A forecast <strong>predicts </strong>future events whereas an RL agent <strong>optimizes </strong>future outcomes.</p><p><strong>Approach:</strong></p><p>I have used Deep Q learning RL algorithm to train the TradeBot. The goal of Q-learning is to learn a policy, which tells an agent what action to take under what circumstances. In general, Q learning involves the following flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*DxH619SNauRh5lxvRdl2ZQ.png" /><figcaption>Q-Learning General Flow</figcaption></figure><p><strong>FlowChart :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*_g-8AUeLYBvUgBu01XkhOg.png" /><figcaption>Bellman Approximation</figcaption></figure><ol><li>Start with an empty table, mapping states to values of actions.</li><li>By interacting with the environment, obtain the tuple s, a, r, s’ (state, action, reward, new state). In this step, we need to decide which action to take, and there is no single proper way to make this decision. I have taken one of the approaches. There has to be a balance between exploration vs exploitation for any RL Bot.</li><li>Update the Q(s, a) value using the Bellman approximation described above.</li><li>Repeat from step 2</li></ol><p><strong>Implementation:</strong></p><p>The implementation is done using Pytorch and the code can be found <a href="https://github.com/shivamakhauri04/TradingBot/blob/master/1_dqn.ipynb">here</a>.</p><p>To formulate RL problem, we need to define three things: observation of the environment, possible actions and a reward system. In this implementation, I took a basic trading agent in its simplest form. This is to establish the Q-Learning algorithm on the trading environment.</p><p>The observation will include the following information: a) N past bars, where each has open, high, low and close prices. b) An indication of the current position value of the trading agent. c) Profit or loss we currently have from our current position. Note: to develop an advanced Trading Bot, one can extend the observations and change the hyperparameters of the Q-Learning network accordingly.</p><p>At every step, the agent can take one of the following actions: a) Do Nothing (Hold): Skip the bar without taking actions. b) Buy a share: Appended in the agent’s position. c) Close the position(Sell)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*kiA1uPXoLa_yVI2xYRJRJw.png" /><figcaption>Data preview</figcaption></figure><p>The dataset used in the implementation is an opensource dataset. The code above reads the stock data and arranges it based on the ‘Date’ column. We then split this data into ‘Train’ and ‘Test’ set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*UqYtrIrd6IjgSN1SnK3n9w.png" /><figcaption>Establishing the Trading Environment</figcaption></figure><p>The Environment class establishes the trading environment. The position list includes the list of current stocks with the trading bot. The position value of the trade bot and the delta of the stock prices changes contribute to the observation set for the Tradebot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*fWePEZMfzCas0OL9OiHwog.png" /><figcaption>Setting the actions</figcaption></figure><p>As described before, the agent has 3 options for taking action. If the agent decides to buy the stock, its position increases. If the agent decides to sell, its profit is calculated as a difference between the price it decided to sell and the buying price. To ensure that the tradebot doesn’t learn to sell the bot while having no positions, it is penalised with a reward of -1.</p><p>In the next step, the tradebot updates its history with the delta of stock prices. Also, a track of the bot’s position is maintained at each step. If the current step leads to a profit, the agent is rewarded with a +1 and if the current action leads to a loss, then the agent is penalized with a -1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*A8RtoaeFTj1m2Q3hedGF9g.png" /><figcaption>model network</figcaption></figure><p>The model involves a 3 layer neural network. The hidde_size is a hyperparameter and was set 100 for my experiment. The network projects the observation vector to 3 classes (number of actions).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*3HbmB02FgoVb8DGjyGOCyw.png" /><figcaption>Training Pipeline</figcaption></figure><p>The first step is to initialize the environment, including its observation and rewards. The model (Q function) predicts the highest probable action for the initial set of observations using argmax. The predicted action is passed through the environment and generates the new set of observations(s’), the reward for carrying the step and the done flag which indicates whether the episode is over (which involves reading through the entire training set). The memory is buffer which keeps a record of the last 200 actions and its corresponding observations, rewards and the new set of observations obtained upon doing the action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*aaKrnAviYCEr9zrU50N-sA.png" /><figcaption>Update q value</figcaption></figure><p>The above code involves creating batches of the ‘b_pobs’ (s), b_pact (a’), b_reward(r), b_obs(s’) and the done flag.</p><p>The target is the Q table where we update the Q values for each set of action and its corresponding state according to the Belmann equation described in the flowchart above. The loss function is a Mean squared error function. The optimizer aims to update the Q values for minimizing the loss.</p><p>In the next post, I will try to implement advanced extensions of Q-Learning as well as Actor-Critic approach. Stay Tuned.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b67c9603f33" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/tradebot-stock-trading-using-reinforcement-learning-part1-8b67c9603f33">TradeBot: Stock Trading using Reinforcement Learning — Part1</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Learning: Reinforcing a Bot to learn to puzzle out a Maze-Part 1]]></title>
            <link>https://medium.com/ether-labs/robot-learning-reinforcing-a-bot-to-learn-to-puzzle-out-a-maze-part-1-b6bdd8c7bca3?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/b6bdd8c7bca3</guid>
            <category><![CDATA[robot-learning]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shivam Akhauri]]></dc:creator>
            <pubDate>Sun, 27 Jan 2019 09:13:15 GMT</pubDate>
            <atom:updated>2019-01-27T09:13:15.541Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*-kqZYvrCCF6CpX2vvWsj8w.png" /><figcaption>Problem Overview</figcaption></figure><p><strong>Aim</strong> : To develop a Reinforcement Learning algorithm, to make a Bot(Agent) learn its way to solve a maze. The Bot is naive to the maze and its environment.</p><p><strong>Logic</strong>: The logic in its core involves, letting a Bot start from the Starting point <strong>(S)</strong>, with the freedom to move in any direction. Its end goal is to reach the end point <strong>(G)</strong> through the most optimised path. Hence, at each step, the Bot can perform 4 actions — go Left, right, top or bottom. To add to the trouble, the maze also has Holes (H), which the Bot has to avoid.</p><p>If you are a fan of Big Bang Theory Tv Series, you would remember the episode where Sheldon ‘trains’ Penny to behave according to his liking, by rewarding her with chocolate (positive reinforcement) and punishing her if she doesn’t act accordingly (negative reinforcement). Similarly, when kids do something nice, we reward them and if they are mischevious, we punish them. This same logic drives our Bot to learn its way to solve the maze.</p><p>The Bot is given a reward if it successfully reaches <strong>G </strong>and the episode ends. If the Bot falls in a hole<strong> (H)</strong>, it gains no reward and the episode ends. At any other state of the maze, the bot can perform the above mentioned 4 actions.</p><p>The above logic explains Reinforcement Learning(RL). RL is an aspect of Machine learning where an agent learns to behave in an environment, by performing certain actions and observing the rewards/results which it gets from those actions. It’s important to note that while RL at its core aims to maximize rewards/gains, implementing a greedy approach, doesn’t always lead to successful learning.</p><p><strong>Algorithm illustrated:</strong> In this Part 1, I take the “ <strong>Cross Entropy</strong>” algorithm to make the Bot learn to do the task. The Cross-Entropy approach has the following features:</p><ul><li>Model-free: In this type of ML algorithm, the RL doesn’t create a model of the training steps. Rather, it says to the agent what to do at each step.</li><li>Policy-Based: A policy is the Bot’s (Agent) strategy to take the next steps. It’s basically represented as a probability distribution of the available 4 actions of the Bot. The action which has the maximum probability becomes the next step’s action for the Bot.</li><li>On-Policy approach: This means that the agent requires fresh data to be obtained from the maze environment. The algorithm doesn’t dwell on old historic data.</li></ul><p><strong>Challenge of using Cross Entropy in the given setting</strong>:</p><p>The approach gains a reward(+1) if the Bot reaches the endpoint, but doesn’t tell anything about whether the Bot chose the most optimized route or whether it was just wandering around and ended up at endpoint just by chance. The algorithm doesn’t take into account whether the Bot was quick and efficient or did it go round the maze five times and randomly entered G. A reward of 0001 (Bot reaching endpoint in 4 steps) and reward of 0000000000001(Bot reaching endpoint in 13 steps) are given the same preference.</p><p>Also, the distribution of rewards is not good. There is only +1 or the 0 reward state. There are no intermediate state rewards.</p><p><strong>Implementation:</strong></p><p>The RL algorithm is implemented in PyTorch framework for Deep Learning implementation. To simulate the maze, I have used <a href="https://gym.openai.com/docs/">FastAI FrozenLake Gym Environment</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*wDI_yu5MNIBcMtUYC9j8FA.png" /><figcaption>Necessary imports</figcaption></figure><p>The FrozenLake Env is a 4*4 maze. This gives 16 possible unknown states for the Bot. The discreteoneHotWrapper function aims to create a One-Hot Encoding for each of these 16 states by inheriting the Observation wrapper from gym environment. The inherited observation space is a representation of a fixed range of non-negative numbers (spaces.Discrete) and is converted to One Hot Encoding using the spaces.Box (represents an n-dimensional Box)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*XhUBgqWAyIPbdMVB9wGOcA.png" /><figcaption>One Hot encoding of observation states</figcaption></figure><p>The Deep learning network implemented here is a basic one, with two linear layers and a ReLU. The network takes a single observation from the environment as the input vector (one hot encoded) and gives a probability distribution upon a softmax, for the 4 possible actions of the Bot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*HaPA_qV45L5nowy5HsEYxg.png" /><figcaption>DL Network</figcaption></figure><p>Here, I define two classes. The EpisodeStep helper class represents every step that the Bot takes in an episode, keeping a track of the observation from the environment and the action that the Bot takes. The Episode helper class represents a single episode and stores the Episode Total reward and the collection of the EpisodeStep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*634I2hnPUwjKknMc9uhPRA.png" /><figcaption>Helper Classes</figcaption></figure><p>The iterate_batches function generates batches of episodes. The batch list accumulates the list of episode instances. The env.reset function resets the environment and generates the first observation. The observation tensor is then passed through the neural network which generates a probability distribution for the actions. The act_prob_v is a tensor which tracks gradients. Hence, the tensor.data is used to unpack the tensor into an array of 2-dim with batch dimension on axis 0. Hence, the first batch is accessed to obtain the one-dimensional vector for action probabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*msZrFfNpBB1EldPJCl2gzw.png" /><figcaption>Batch generation</figcaption></figure><p>To make sure that the total reward depends on the length of the episode and to make the agent learn to find the most optimized route, a <strong>Discount Factor</strong> is applied to the reward (Gamma of 0.9 or 0.95). This will ensure that the reward for shorter episodes will be higher than the rewards of longer episodes. The elite_batch is used to accumulate the best episodes based on whether the discounted reward for a particular episode is greater than top 70 percentile of the total rewards across batches. This ensures that the elite episodes are kept over several iterations, thus overcoming the challenge poor reward distribution associated with the problem statement (Only +1 or 0 and no intermediate rewards).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*F9o1r6LXcMlxFagUz0Po7Q.png" /><figcaption>Filtering Batches</figcaption></figure><p>The following main function instantiates the functions defined above. To give the network more time to average more training samples, the learning rate is kept pretty low. The gym.envs.toy_text ‘makes’ and instantiates the FrozenLake environment. The Adam optimiser is chosen for gradient descent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*K8GDo1c2Sl5PdTjSXozbcg.png" /><figcaption>main function</figcaption></figure><p>The elite batch catches the last 500 most elite episodes to be fed again and again to the network . The batch size is kept high. The gradients are calculated on these best training samples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*OSajSCcndm1LJduAEyxJqQ.png" /></figure><p><strong>Conclusion:</strong></p><p>To handle the shortcomings of cross-entropy approach on FrozenLake env, we can allow the elite episodes to be kept in training iterations for a longer duration. Keeping a low learning rate while maintaining a larger batch size, also helps. The discount rate of around .9 helps the agent to learn the optimal path.</p><p>The link to the code can be found <a href="https://github.com/shivamakhauri04/Cross_Entropy_RL/blob/master/01_cross_entropy_Frozen_lake.ipynb">here</a>.</p><p>In the part 2, we will discover a more sophisticated approach that can be taken to solve the problem statement and advanced concepts of Reinforcement learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6bdd8c7bca3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/robot-learning-reinforcing-a-bot-to-learn-to-puzzle-out-a-maze-part-1-b6bdd8c7bca3">Robot Learning: Reinforcing a Bot to learn to puzzle out a Maze-Part 1</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quora Smart Compose of Sincere Questions]]></title>
            <link>https://medium.com/ether-labs/quora-smart-compose-of-sincere-questions-e3398ce59688?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/e3398ce59688</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <dc:creator><![CDATA[Shivam Akhauri]]></dc:creator>
            <pubDate>Tue, 25 Dec 2018 10:27:11 GMT</pubDate>
            <atom:updated>2018-12-25T10:32:14.433Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Aim</strong>: To develop a predictive feature, called smart compose, which tries to understand typed text so that AI can suggest words and phrases to finish your Quora questions/answers with sincere words. The recommended words from the AI mollifies Quora users from using a non-neutral tone or having an exaggerated tone to underscore a point about a group of people or making a rhetorical, disparaging, discriminatory, inflammatory statement on Quora platform.</p><blockquote><strong>What you will learn in this post:</strong></blockquote><ul><li><strong>Transfer learning implementation in NLP tasks:</strong> <em>Transfer learning is a machine learning method where a deep learning model developed for a task is reused as the starting point for a model on a second task.</em> In the vision, it has been in practice for some time now, with people using models trained to learn features from the huge ImageNet dataset, and then training it further on smaller data for different tasks. Recently advances in NLP shows that <strong><em>transfer learning in NLP leads to better accuracies, faster convergence and lesser training data requirement </em></strong>than a conventional word embeddings approach.</li><li>Bare <strong>Pytorch implementation of the pipeline</strong> without the use of TorchText for data pre-processing and batch processing: This allows complete control of the pipeline and flexibility in building the language model. TorchText is still under active development and is having some issues that you might need to solve yourself.</li><li><strong>Language model implementation:</strong> The implementation can be extrapolated to generate encoded representations of Quora ‘sincere text’ dataset (general embeddings of the Sincere text dataset) and determine if a new question/statement made on Quora portal is Insincere. This can be achieved by calculating the cosine distance between the new user input(question/statement) and the general encoded representations, which can be obtained from my Language model described below.</li></ul><blockquote><strong>What’s language model and what’s my dataset :</strong></blockquote><ul><li>LM models the probability of word sequences. “Go.See the doctor” is more probable than “walk. pair REd”.</li><li><strong>The dataset involves 1225332 lines of non_spam data (sincere questions/statements) from Quora</strong>. The dataset can be obtained from the <a href="https://www.kaggle.com/c/quora-insincere-questions-classification/data">Kaggle competition</a>. You can write a simple script to extract the sincere text from the classification dataset shared in the competition portal. In the implementation described below, I am taking a subset of this data. You might want to apply some data filtering and removing noise if you take the whole dataset for your experimentation.</li></ul><blockquote><strong>Logic :</strong></blockquote><p>By keying in on common speech patterns, my AI model predicts the next probable words. Since the LM inherits its features from a dataset of sincere questions/statements, the recommended words from the AI model will have its range in non-inflammatory/non-discriminatory vocabulary.</p><p>The model is seeded from transfer learning, inheriting the encoder representations of the <a href="http://files.fast.ai/models/wt103/">wiki-103</a> pre-trained model, shared by <a href="http://nlp.fast.ai/">fast.ai NLP</a> <a href="https://course.fast.ai/lessons/lesson10.html">[here]</a>. This helps to achieve better convergence. This is because wiki-103 has already learned language characteristics from a larger dataset and my aim here is to funnel it to learn features related to sincere comments.</p><p><em>Keep reading for more details.</em></p><blockquote><strong>Implementation<em>:</em></strong></blockquote><p>The code can be accessed <a href="https://github.com/shivamakhauri04/Quora-Smart-Compose-of-Sincere-Questions/blob/master/Quora%20Smart%20Compose%20of%20Sincere%20Questions.ipynb">here</a>.</p><h4>Data Preprocessing, Training data preparation and Training Batch formation :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*tGYLAmzkRDTPO7hN9rcyKA.png" /><figcaption>Necessary imports for my implementation</figcaption></figure><p>A <strong>Variable</strong> wraps a Tensor. Variable also provides a <em>backward</em> method to perform backpropagation. Torch.optim inherits the loss optimizer for our DL. The flatten function is for word tokenization. Tokenization later facilitates the conversion of word tokens to indices. The word tokens enter into the training model in the form of these numerals(indices).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*BJxTbvWpoh213t4xAFlaiA.png" /><figcaption>Loading dataset, building vocabulary</figcaption></figure><p>The above function reads lines from the dataset, tokenizes the words using the flatten function, and creates a vocabulary of each unique word in the dataset. Each unique word has a unique index associated with it. This word index pair is stored in the word2index dictionary. Note that the index 0 is assigned to &lt;unk&gt;. Any word which may arise during the testing/inference, which never appeared in the training set, will be associated with the &lt;unk&gt;. The &lt;/s&gt; is appended to the end of each line to mark the end of the sentence to the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*T4txbLIGGXbHPqgqePJBDg.png" /><figcaption>Conversion of word tokens to indexes and storing it into Tensors for training data preparation</figcaption></figure><p>The above function does a conversion of word tokens to indices and stores it into Tensors for training data preparation. Any word token whose index is not found in the word2index dictionary is assigned index 0 (&lt;unk&gt;)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*qmBDxgNABNEJKXYqk1V03w.png" /><figcaption>vocab_size and index2word</figcaption></figure><p>For my implementation and with the sincere text dataset, I get a vocab size of 45,462 words. The LM will predict the next word in the form of indices. We need to trace back the words associated with these indices. The index2word function facilitates this task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*XFun6w6pgtBL6CZxikAqtA.png" /><figcaption>Storing the word2index and index2word</figcaption></figure><p>It&#39;s always safe to store the word2index. Sometimes, you may end up training your model, putting in the time and may end up losing the word2index. Then, even though your model might be giving correct predictions, but you may not be able to trace it if you end up generating new word2vec.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*m_YOFqG-l_Tuz-ZnjwZXfg.png" /><figcaption>Batch formation</figcaption></figure><p>Starting from sequential data, batchify arranges the dataset into columns. For instance, with the alphabet as the sequence and batch size 4, we’d get as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/124/1*tlYc2rdVIX58_f1cp0T1UA.png" /><figcaption><a href="https://github.com/pytorch/examples/blob/master/word_language_model/main.py">These columns are treated as independent by the model, which means that the dependence of e. g. ‘g’ on ‘f’ can not be learned, but allows more efficient batch processing</a></figcaption></figure><p>In the batchify function above, suppose my batch_size=4, and my word tokens are like above, as shown in the image. Then, nbatch calculates the length of the columns, in order to maintain the batch size of 4. The ‘data.narrow’ chunks data, which did not fit in nbatch. The data.cuda() allows running our training batches on the GPU. The training set prepared from the ‘prepare_dataset’ function is passed through the batchify function for batch processing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*9bTnjqgY-5U_mMSScZQvVQ.png" /><figcaption>Define my training labels</figcaption></figure><p>The above function defines the labels for the training data.So if my training input is “I have a question&lt;/s&gt;”, the label would be “I have a question &lt;/s&gt;Next”.</p><h4>Transfer Learning Implementation:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*0PFeU8qTDZ7T54dAy55gvA.png" /><figcaption>Transfer learning from wiki-103</figcaption></figure><p>The wiki-103 is basically an auto-encoder model with encoder weights and the decoder weights, pre-trained on large Wikipedia and other datasets shared by fast.ai. The pre-trained LM weights have an embedding size of 400, 1150 hidden units and 3 layers. We need to match the embedding size values with the target Quora LM so that the weights can be loaded up. Torch.load loads the pre-trained model. So the embedding size for the LM model= 400. The rest of the parameters can be tuned as per GPU available and the training data size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*jxhRyls3x7pS3MKFQo1NKQ.png" /><figcaption>Initializing Quora LM model with pre-trained weights</figcaption></figure><p>The pre-trained model comes along with the index2word, for the dataset on which it was trained(itos2). We use that to generate the corresponding word2index(stoi2). Now, for the words which belong to the Quora dataset vocabulary, which I built earlier, if those are present in the stoi2, I initialize the Quora LM model with the weights as given in stoi2. And for the words which don’t belong to stoi2, are initialized with the mean weight values of the pre-trained model. These combined weights are stored in new_w.</p><h4>Network Architecture:</h4><p>I have implemented a fairly simple model, to analyze the power of transfer learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JkdHcML7yQ1LJGW7O-GsCg.png" /><figcaption>Lstm model</figcaption></figure><p>The super function inherits the functions of nn. Module incorporated in pytorch for LSTM implementation. The init_weight is where I initialize my Quora LM model with pre-trained weights stored in ‘new_w’. The linear function weights are initialized with xavier_uniform. The shape of hidden state for the LSTM model is [Num_layers,batch_size,hidden_size]. The detach_hidden solves the exploding gradients problem. The LSTM returns an output value and the hidden state.<strong> The hidden state encompasses the encoded representations for the entire Quora sincere dataset and can be extracted later to generate text embeddings. The embeddings can be used to find the cosine distance from any new input on Quora to predict if the statement is insincere or sincere.</strong></p><p>The output returned from the LSTM is reshaped to [sequence_length*batch_size,hidden_size] and passed through a linear function for calculating the loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*pQHVfCRziLe76Py24hopbQ.png" /><figcaption>My Hyper-parameters</figcaption></figure><p>The Embed-size remains equal to the embedding size of the pre-trained model. My experiments yielded me better results at Hidden_Size values less than or equal to 200 for the subset data I took for training. The num_layers in my LSTM model was 2, but I want to test on 3 as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*dYwjb-UgQBhvyW16Un-qMw.png" /><figcaption>Model Training</figcaption></figure><p>This is the standard Pytorch pipeline for training the model. The getBatch function returns the input and target labels. Since the backward() function accumulates gradients, and we don’t want to mix up gradients between mini-batches, we have to zero them out at the start of a new minibatch. This is taken care by the zero_grad function. The loss function used in the implementation is nn.CrossEntropyLoss().</p><p>The testing and inference code can be accessed from the <a href="https://github.com/shivamakhauri04/Quora-Smart-Compose-of-Sincere-Questions/blob/master/Quora%20Smart%20Compose%20of%20Sincere%20Questions.ipynb">github link</a>.</p><p>If you liked this article, feel free to give it a clap. If you are<strong> interested in AI behind Humanoid Robotics and Reinforcement Learning</strong>, follow me on medium as I would soon be publishing contents and implementations on the same.</p><p>References :</p><ol><li><a href="https://course.fast.ai/lessons/lesson10.html">https://course.fast.ai/lessons/lesson10.html</a></li><li><a href="https://github.com/pytorch/examples/blob/master/word_language_model/main.py">https://github.com/pytorch/examples/blob/master/word_language_model/main.py</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3398ce59688" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/quora-smart-compose-of-sincere-questions-e3398ce59688">Quora Smart Compose of Sincere Questions</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a health-check API]]></title>
            <link>https://medium.com/ether-labs/designing-a-health-check-api-a98784eb6a07?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a98784eb6a07</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Karthik Muralidharan]]></dc:creator>
            <pubDate>Fri, 29 Dec 2017 14:29:05 GMT</pubDate>
            <atom:updated>2017-12-30T06:18:36.632Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are working on a web application, be it a monolith, micro-service or even serverless architecture, you should be able to find out very easily whether your application is healthy or not, and if it isn’t, then it shouldn’t be serving any traffic at all. Implementing a simple health-check API will allow you to do just that.</p><h4>Why do we need it?</h4><ul><li>It informs the load balancer distributing traffic to your application or a service discovery (a registry that among other things may periodically checks health of the application hosts) that your application running on a specific host will be unable to serve traffic when it’s unhealthy. If found unhealthy, a load balancer may take that host running the application out of rotation, or in case of a service discovery, <a href="https://www.consul.io/intro/getting-started/checks.html#checking-health-status">web service query using DNS</a> will omit the unhealthy host.</li><li>In case of some weird behaviour with the application on a specific host, you could take that host out of rotation manually, so that you can debug the application without having to shut down the process.</li></ul><h4>Design Considerations</h4><ul><li>Always check if any of your core application dependencies are failing and return an HTTP status code of 503 (Service Unavailable)<em> </em>along with a list of errors raised by the failing dependencies. <br>Eg: connection to a database, invalid S3 credential, low disk space (if your application saves files temporarily to disk).</li><li>Health-check endpoints are called frequently and within fixed intervals, therefore your latencies should ideally be small. Enforce an overall upper bound for your health-check response and make sure to cancel any pending checks to the downstream dependencies in case of timeout.</li><li>If you are performing multiple dependency checks over the network, try to process them concurrently, if possible, to reduce the overall response time.</li><li>As mentioned previously, providing the ability to toggle traffic for a specific host can help in debugging the app on the host without having to shut the process down. <br>Eg: A simple file existence check on the host is one traditional approach.</li><li>By default, any core dependency error leads to a 503 HTTP status code. But certain dependencies failures may not completely make our application non-operational(e.g. metrics service, external service failures, etc.). For such failures, we should be able to simply <strong>observe</strong> the errors in the API response without having to take the host out of rotation, but still be captured in logs for alerts.</li></ul><p>At Ether, we use <strong>Golang</strong> as the primary language of our back-end services (why? well that’s another topic of discussion, so stay tuned!!) and we’ve created a simple library that returns an HTTP handler implementing the health-check API for Go based web services.</p><p><a href="https://github.com/etherlabsio/healthcheck">etherlabsio/healthcheck</a></p><p>The library defines a <strong>Checker </strong>interface that takes in a <strong>context.Context</strong> object which is used for signalling request cancellation to the checker functions in case of timeout/request cancellation and returns an <strong>error </strong>in case if any were detected.</p><p>You can define your own custom implementation of the checker and inject it while creating the handler.</p><pre>type Checker interface {<br><strong>    Check</strong>(ctx context.Context) <em>error<br></em>}</pre><pre>type CheckerFunc func(ctx context.Context) <em>error</em></pre><p>The library uses <a href="https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis">functional options</a> to accept optional arguments during initiation of the HTTP Handler for overall timeout, observers and custom checkers.</p><pre>// For the sake of brevity, error check is being omitted here.<br>db, _ := sql.Open(&quot;mysql&quot;, &quot;user:password@/dbname&quot;)<br>defer db.Close()</pre><pre>r := mux.NewRouter()<br>r.Handle(&quot;/healthcheck&quot;, healthcheck.Handler(</pre><pre>    // WithTimeout option allows you to set a max overall timeout<br>    healthcheck.WithTimeout(5*time.Second),</pre><pre>    // Checkers fail the status in case of any error.<br>    healthcheck.WithChecker(<br>        &quot;database&quot;, healthcheck.CheckerFunc(<br>            func(ctx context.Context) error {<br>                return db.PingContext(ctx)<br>            },<br>        ),<br>    ),</pre><pre>    // Observers do not fail the status in case of error.<br>    healthcheck.WithObserver(<br>        &quot;diskspace&quot;, checkers.DiskSpace(&quot;/var/log&quot;, 90),<br>    ),<br>))</pre><p>In case of an error from the database, you should see the following response with the status code <strong>503</strong>.</p><pre>{<br>  &quot;status&quot;: &quot;Service Unavailable&quot;,<br>  &quot;errors&quot;: {<br>    &quot;database&quot;: &quot;dial tcp 127.0.0.1:3306: getsockopt: connection refused&quot;<br>  }<br>}</pre><p>A more complete example is provided on our <a href="https://github.com/etherlabsio/healthcheck">GitHub</a> page. Please do check it out and help us make it better with your contributions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a98784eb6a07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/designing-a-health-check-api-a98784eb6a07">Designing a health-check API</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Machine @ Ether]]></title>
            <link>https://medium.com/ether-labs/time-machine-ether-d7f295d4cb27?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/d7f295d4cb27</guid>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[collaboration]]></category>
            <category><![CDATA[ether]]></category>
            <category><![CDATA[video-conferencing]]></category>
            <category><![CDATA[enterprise-technology]]></category>
            <dc:creator><![CDATA[Krishna Sai]]></dc:creator>
            <pubDate>Wed, 20 Dec 2017 15:01:02 GMT</pubDate>
            <atom:updated>2017-12-20T15:01:02.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RUGdZYlmr-0ms172Sl1f4g.jpeg" /></figure><p>Several years ago, I was working with teams across 8 time zones — I was in India at that time, and I had to meet with teams in the Pacific, Mountain, Central, Eastern time zones in the Continental US, as well as Israel, China, Singapore and India, almost on a daily basis. I was doing all of this using the best of breed High Definition Room Telepresence system at my home office, which made the real time experience really nice, but I hardly slept and it was really difficult to say no, since these activities required high engagement, and participation to be successful.</p><p>The scale and quality may be different, but this is a very common experience for many folks working with distributed teams across multiple time zones. We used to joke in those days that we needed a time machine! Jokes aside, those initial days of frustration got us thinking about elegant ways to solve these problems. Then, over the next few years, a new era of non-real time conversational platforms came out like Facebook and messaging systems like Hipchat and Slack. These ushered in a new era of connected relationships, and organized messaging and sharing that allowed for people and groups to be more connected over distances and time zones.</p><p>Fast forward to mid 2017, when the entrepreneurial itch struck the founding team at <a href="http://www.etherlabs.io/">Ether</a> again, and we set about solving the problem of getting teams to collaborate across distance and time zones, not only using text, but also rich media — audio, video, content.</p><p>Ether is a one of a kind video collaboration service that leverages powerful media analytics and machine learning innovations to allow participants in a call to route important call parts as the call occurs back into the Slack channel or DM with messages and @mentions for others to watch, listen, read, or reply — as well as auto-summarizes each conversation. Just what the doctor ordered — full context, clear follow ups, and easy time zone catch up.</p><p>Now, when <a href="https://www.linkedin.com/in/cullen-childress-a4b8a">Cullen</a> from <a href="https://www.texassports.com/">Austin, TX</a>, needs <a href="https://www.linkedin.com/in/karthikmuralidharan">Karthik</a> &amp; <a href="http://www.linkedin.com/in/krishnasai">I</a> (in <a href="https://www.royalchallengers.com/">Bangalore</a>) to be aware of a request, issue, or cool moment from a video call — he can just mark and route that call part to us in the Slack channel with a message, and we can get to that specific moment when we click on that notification the next morning. We can view that specific moment, and reply, share, like, etc. Cullen is notified of our response — and the conversation continues. All context of that conversation is quickly at our fingertips — it’s never lost even though we weren’t on the call and we are 2000 miles apart. Easy follow up, and super cool time zone coordination.</p><p>Here in Bangalore, we have our standups in the middle of Cullen’s night (even though he never sleeps), and during our call we mark and route the important topics, actions, decisions, and “heads up” items that are relevant — and Ether auto-summarizes our discussions for us. It’s great for our own benefit for context capture, but when Cullen gets up — he can zero in on what he deems relevant to him from that particular call from the call parts distributed into the Slack channel. He can watch/listen/read those parts — and reply on any part in channel as he sees fit. It’s a pretty cool way to solve the collaboration challenges of not only distance, but also time. This is all powered by our persistence and analytics engine, aptly code named <a href="http://www.backtothefuture.com/delorean">DeLorean</a> :)</p><p>More on #ethermagic coming soon.. If you’re interested in checking us out, sign up for our private Beta at <a href="http://www.etherlabs.io./">www.etherlabs.io.</a> We are currently on top of Slack, but Atlassian Stride and Microsoft Teams are coming!</p><p>See you soon in the continuum! In the meanwhile, keep calm and /ether.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7f295d4cb27" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/time-machine-ether-d7f295d4cb27">Time Machine @ Ether</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ether Private Beta]]></title>
            <link>https://medium.com/ether-labs/ether-private-beta-ae99b5afe32b?source=rss----a20e0c163e2d---4</link>
            <guid isPermaLink="false">https://medium.com/p/ae99b5afe32b</guid>
            <category><![CDATA[enterprise-ai]]></category>
            <category><![CDATA[video-conferencing]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[enterprise-collaboration]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Krishna Sai]]></dc:creator>
            <pubDate>Thu, 14 Dec 2017 11:01:01 GMT</pubDate>
            <atom:updated>2017-12-14T11:01:01.436Z</atom:updated>
            <content:encoded><![CDATA[<p>We are excited to announce our new adventure! We just entered private beta with Ether — a highly unique video collaboration service initially built on top of Slack. We have all the table stake items: best in class group video/audio, content sharing, etc. — but we also have some magic. Ether leverages powerful <strong>media analytics and machine learning innovations </strong>to allow users to route important call parts <strong>as the call occurs</strong> back into the Slack channel or DM with messages and @mentions for others to watch, listen, read, or reply — as well as auto-summarizes each conversation. Atlassian Stride and Microsoft Teams support is right around the corner!</p><p>If your team uses Slack, go to <a href="http://www.etherlabs.io/beta">www.etherlabs.io</a> to get on the private beta list — or do us a solid and share this with others! Let’s go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*DMg_B2SV9_w_OuYewuUMOA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae99b5afe32b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ether-labs/ether-private-beta-ae99b5afe32b">Ether Private Beta</a> was originally published in <a href="https://medium.com/ether-labs">ETHER Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>