<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>foldl</title>
    <link>http://foldl.me</link>
    <atom:link href="http://foldl.me/rss.xml" rel="self" type="application/rss+xml" />
    <language>en-US</language>
    <pubDate>Fri, 23 Jan 2026 18:25:14 +0000</pubDate>
    <lastBuildDate>Fri, 23 Jan 2026 18:25:14 +0000</lastBuildDate>

    
    
    
    
    
    
    
    
    <item>
      <title>Motivating the rules of the game for adversarial example research</title>
      <link>http://foldl.me/2018/adversarial-examples/</link>
      <pubDate>Fri, 17 Aug 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/adversarial-examples/</guid>
      <description>&lt;p&gt;&lt;a href=&quot;https://arxiv.org/abs/1807.06732&quot;&gt;&lt;em&gt;Motivating the Rules of the Game for Adversarial Example Research&lt;/em&gt;&lt;/a&gt; is one of the most level-headed things I&amp;rsquo;ve read on AI safety/security in a while. It&amp;rsquo;s 25 pages, which is long for a machine learning paper — but it&amp;rsquo;s worth it. My brief take-away from the paper, which I totally support:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Adversarial example research has been framed in two ways:&lt;/p&gt;

  &lt;ol&gt;
    &lt;li&gt;an experimental method for pure research which helps us better understand neural network architectures and their learned representations&lt;/li&gt;
    &lt;li&gt;a practical method for securing machine learning models against attacks from adversaries in the wild.&lt;/li&gt;
  &lt;/ol&gt;

  &lt;p&gt;Adversarial examples are the least of our problems in the latter practical framing. We ought to either (1) re-cast adversarial example work as a pure research problem, or (2) build better &amp;ldquo;rules of the game&amp;rdquo; which actually motivate popular adversarial defense methods as sufficient security solutions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here are some more extracts that I think summarize the push of the paper (emphasis mine):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We argue that adversarial example defense papers have, to date, mostly considered abstract, toy games that do not relate to any specific security concern (1).&lt;/p&gt;

  &lt;p&gt;Much of the adversarial perturbation research arose based on observations that even small perturbations can cause significant mistakes in deep learning models, &lt;em&gt;with no security motivation attached&lt;/em&gt;. &amp;hellip; Goodfellow et al. intended $l_p$ adversarial examples to be a toy problem where evaluation would be easy, with the hope that the solution to this toy problem would generalize to other problems. &amp;hellip; Because solutions to this metric have not generalized to other settings, it is important to now find other, better more realistic ways of evaluating classifiers in the adversarial [security] setting (20).&lt;/p&gt;

  &lt;p&gt;Exploring robustness to a whitebox adversary [i.e. $l_p$-norm attacks] should not come at the cost of ignoring defenses against high-likelihood, simplistic attacks such as applying random transformations or supplying the most difficult test cases. &amp;hellip; Work primarily motivated by security should first build a better understanding of the attacker action space (23).&lt;/p&gt;

  &lt;p&gt;An appealing alternative for the machine learning community would be to recenter defenses against restricted adversarial perturbations &lt;em&gt;as machine learning contributions and not security contributions&lt;/em&gt; (25).&lt;/p&gt;

  &lt;p&gt;To have the largest impact, we should both recast future adversarial example research as a contribution to core machine learning functionality and develop new abstractions that capture realistic thread models (25).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Some other notes:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;The authors correctly point out that &amp;ldquo;content-preserving&amp;rdquo; perturbations are difficult to identify. $l_p$-norm is just a proxy (and a poor one at that!) this criterion. If we try to formalize this briefly, it seems like a content-preserving perturbation $\delta_{O,T}(x)$ on an input $x$ for some task $T$ is one which does not push $x$ out of some perceptual equivalence class according to a &lt;em&gt;system-external observer&lt;/em&gt; $O$ who knows $T$.&lt;/p&gt;

    &lt;p&gt;If that&amp;rsquo;s right, then concretely defining $\delta$ for any domain requires that we construct the relevant perceptual equivalence classes for $O$ on $T$. Is this any easier than reverse-engineering the representations that $O$ uses to solve $T$ in the first place? If not, then posing the &amp;ldquo;correct&amp;rdquo; perturbation mechanism is just as difficult as learning the &amp;ldquo;correct&amp;rdquo; predictive model in the first place.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;I think the definition of &amp;ldquo;adversarial example&amp;rdquo; begins to fall apart as we expand its scope. See e.g. this quote:&lt;/p&gt;

    &lt;blockquote&gt;
      &lt;p&gt;for many problem settings, the existence of non-zero test error implies the existence of adversarial examples for sufficiently powerful attacker models (17).&lt;/p&gt;
    &lt;/blockquote&gt;

    &lt;p&gt;This is true for a maximally broad notion of &amp;ldquo;adversarial example,&amp;rdquo; which just means &amp;ldquo;an example that the system gets wrong.&amp;rdquo; If we expand the definition that way, the line between a robust system (in the security sense) and a well-generalizing model begins to get fuzzy.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Conceptual issues in AI safety&#58; the paradigmatic gap</title>
      <link>http://foldl.me/2018/conceptual-issues-ai-safety-paradigmatic-gap/</link>
      <pubDate>Thu, 21 Jun 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/conceptual-issues-ai-safety-paradigmatic-gap/</guid>
      <description>&lt;p&gt;&lt;small&gt;&lt;em&gt;tl;dr&lt;/em&gt;: I question the assumption that technical solutions to mid-term safety problems will be relevant to the long-horizon problems of AI safety. This assumption fails to account for a potential paradigmatic change in technology between now and the date at which these long-horizon problems will become pressing. I present a historical example of paradigmatic change and suggest that the same is possible for AI, and argue that our bets on the importance of present-day safety work ought to incorporate our beliefs over the strength of the current paradigm.&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m back from a brief workshop on technical issues in AI safety, organized by the &lt;a href=&quot;https://www.openphilanthropy.org/blog/potential-risks-advanced-artificial-intelligence-philanthropic-opportunity&quot;&gt;Open Philanthropy Project&lt;/a&gt;. The workshop brought together the &lt;a href=&quot;https://www.openphilanthropy.org/focus/global-catastrophic-risks/potential-risks-advanced-artificial-intelligence/announcing-2018-ai-fellows&quot;&gt;new class of AI Fellows&lt;/a&gt; with researchers from industry labs, nonprofits, and academia to discuss actionable issues in AI safety.&lt;/p&gt;

&lt;p&gt;Discussions at the workshop have changed and augmented my views on AI safety in fundamental ways. Most importantly, they have revealed to me several critical conceptual issues at the foundation of AI safety research, involving work with both medium time horizons (e.g. adversarial attacks, interpretability) and much longer horizons (e.g. aligning the incentives of superintelligent AIs to match our own values). I believe that these are blocking issues for safety research: I don&amp;rsquo;t know how to value the various sorts of safety work until I arrive at satisfying answers to these questions. Over the next months, I&amp;rsquo;ll formalize these questions in separate single-authored and co-authored blog posts.&lt;/p&gt;

&lt;p&gt;This post addresses the first critical of these critical conceptual issues. This issue is the least technical – and possibly the least deep-cutting – of those which I want to raise. Because it touches on one of the most common safety arguments, though, I thought it&amp;rsquo;d be best to publish this one first.&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;AI safety is a very diverse field, encompassing work targeted at vastly different time horizons. I identify three in this post:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Short-term:&lt;/strong&gt; This work involves immediately practical safety risks in deploying machine learning systems. These include &lt;a href=&quot;https://arxiv.org/abs/1706.03691&quot;&gt;data poisoning&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1802.08232&quot;&gt;training set inference&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1606.03490&quot;&gt;lack of model interpretability&lt;/a&gt;, and &lt;a href=&quot;https://www.propublica.org/article/machine-bias-risk-assessments-in-criminal-sentencing&quot;&gt;undesirable model bias&lt;/a&gt;.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Mid-term:&lt;/strong&gt; This work targets potential safety risks of future AI systems that are more powerful and more broadly deployed than those used today. Relevant problems in this space include &lt;a href=&quot;https://arxiv.org/abs/1805.00899&quot;&gt;scalably specifying&lt;/a&gt; and &lt;a href=&quot;https://blog.openai.com/deep-reinforcement-learning-from-human-preferences/&quot;&gt;supervising reward-based learning&lt;/a&gt;, &lt;a href=&quot;https://arxiv.org/abs/1606.06565&quot;&gt;preventing unwanted side effects&lt;/a&gt;, &lt;a href=&quot;https://deepmind.com/blog/specifying-ai-safety-problems/&quot;&gt;safely generalizing out of domain&lt;/a&gt;, and &lt;a href=&quot;https://arxiv.org/abs/1611.08219&quot;&gt;ensuring that systems remain under our control&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Long-term:&lt;/strong&gt; This theoretical work addresses the risks posed by artificially engineered (super)intelligences. It asks, for example, how we might ensure that a system is &lt;a href=&quot;https://intelligence.org/stanford-talk/&quot;&gt;aligned with our values&lt;/a&gt;, and &lt;a href=&quot;https://ai-alignment.com/iterated-distillation-and-amplification-157debfd1616&quot;&gt;proposes procedures for conserving this alignment&lt;/a&gt; while supporting recursive self-improvement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post is mainly concerned with the value of mid-term work.&lt;/p&gt;

&lt;h2 id=&quot;mid-term-ai-safety&quot;&gt;Mid-term AI safety&lt;/h2&gt;

&lt;p&gt;Many mid-term researchers assume that their work is well aligned with solving longer-horizon safety risks — that is, that technical solutions to mid-term problems will also help us make progress on the most concerning long-horizon risk scenarios. &lt;a href=&quot;https://paulfchristiano.com/&quot;&gt;Paul Christiano&lt;/a&gt; has made statements about the likely alignment of mid-term and long-term issues — see, for example, &lt;a href=&quot;https://ai-alignment.com/prosaic-ai-control-b959644d79c2&quot;&gt;his 2016 article on prosaic AI&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;It now seems possible that we could build &amp;ldquo;prosaic&amp;rdquo; AGI, which can replicate human behavior but doesn’t involve qualitatively new ideas about &amp;ldquo;how intelligence works&amp;rdquo; …
If we build prosaic superhuman AGI, &lt;strong&gt;it seems most likely that it will be trained by reinforcement learning&lt;/strong&gt; … But &lt;strong&gt;we don’t have any shovel-ready approach to training an RL system to autonomously pursue our values.&lt;/strong&gt;&lt;/p&gt;

  &lt;p&gt;To illustrate how this can go wrong, imagine using RL to implement a decentralized autonomous organization (DAO) which maximizes its profit. If we had very powerful RL systems, such a DAO might be able to outcompete human organizations at a wide range of tasks — producing and selling cheaper widgets, but also influencing government policy, extorting/manipulating other actors, and so on.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This sort of argument is used to motivate mid-term technical work on controlling AI systems, aligning their values with our own, and so on. In particular, this argument is used to motivate technical work in small-scale synthetic scenarios which connect to these long-term concerns. &lt;a href=&quot;https://arxiv.org/abs/1711.09883&quot;&gt;Leike et al. (2017)&lt;/a&gt; propose minimal environments for checking the safety of reinforcement learning agents, for example, and justify the work as follows:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;While these [proposed grid-world safety environments] are highly abstract and not always intuitive, their simplicity has two advantages: it makes the learning problem very simple and it limits confounding factors in experiments. Such simple environments could also be considered as minimal safety checks: an algorithm that fails to behave safely in such simple environments is also unlikely to behave safely in real-world, safety-critical environments where it is much more complicated to test. Despite the simplicity of the environments, &lt;strong&gt;we have selected these challenges with the safety of very powerful artificial agents (such as artificial general intelligence) in mind.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These arguments gesture at the successes of modern machine learning technology—especially reinforcement learning—and recognize (correctly!) that we don’t yet have good procedures for ensuring that these systems behave the way that we want them to when they are deployed in the wild. We need to have safety procedures in place, they claim, far before more powerful longer-horizon systems arrive that can do much more harm in the real world. This argument rests on the assumption that our technical solutions to mid-term problems will be relevant at the long-horizon date when such systems arrive.&lt;/p&gt;

&lt;p&gt;This post questions that assumption. I claim that this assumption fails to account for a potential &lt;em&gt;paradigmatic change&lt;/em&gt; in our engineered AI systems between now and the date at which these long-horizon problems become pressing.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; A substantial paradigmatic change — which could entail a major change in the way we engineer AI systems, or the way AI is used and deployed by corporations and end users — may make irrelevant any mid-term work done now which aims to solve those long-horizon problems.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ll make the argument by historical analogy, and circle back to the issue of AI safety at the end of this post.&lt;/p&gt;

&lt;h2 id=&quot;paradigmatic-change-an-example&quot;&gt;Paradigmatic change: an example&lt;/h2&gt;

&lt;p&gt;At the end of the 19th century, some of the largest cities in the world relied on horses as a central mode of transportation. A city horse was tasked with driving everything from the private &lt;a href=&quot;https://en.wikipedia.org/wiki/Hansom_cab&quot;&gt;hansom cab&lt;/a&gt; (a Sherlock Holmes favorite) to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Horsebus&quot;&gt;double-decker horsebus&lt;/a&gt;, which could tow dozens of passengers.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://c2.staticflickr.com/8/7362/9472641326_2ef9976ccc_z.jpg&quot; alt=&quot;A double-decker horsebus in Sydney, 1895.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;1890s New York City, for example, housed over a hundred thousand horses for transporting freight and humans. While this massive transportation industry helped to continue an era of explosive city growth, it also posed some serious novel logistical problems. Many of those horses were housed directly in urban stables, taking up valuable city space. Rats and other city rodents flocked to the urban granaries established to support these stables.&lt;/p&gt;

&lt;p&gt;But the most threatening problem posed by this industry by far was the &lt;a href=&quot;https://cityroom.blogs.nytimes.com/2008/06/09/when-horses-posed-a-public-health-hazard/&quot;&gt;&lt;strong&gt;waste&lt;/strong&gt;&lt;/a&gt;. The massive horse population produced a similarly massive daily output of excrement and urine. Because the average city horse survived &lt;a href=&quot;https://web.archive.org/web/20080509133928/https://www.fathom.com/feature/121636/&quot;&gt;fewer than three years of work&lt;/a&gt;, horse carcasses would commonly be found abandoned in the streets.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;This sort of waste had the potential to doom New York and similar cities to an eventual crisis of public health. On dry days, piles of horse excrement left in the streets would turn to dust and pollute the air. Rainstorms and melting snow would precipitate floods of horse poop, meeting the especially unlucky residents of ground-floor apartments. In all climates, flies flocked to the waste and helped to spread typhoid fever.&lt;/p&gt;

&lt;p&gt;Enterprising Americans were quick to respond to the problem—or, rather, to the business opportunities posed by the problem. &lt;a href=&quot;https://enviroliteracy.org/environment-society/transportation/the-horse-the-urban-environment/&quot;&gt;&amp;ldquo;Crossing sweepers&amp;rdquo;&lt;/a&gt; paved the way through the muck for the classiest of street-crossers. Urban factories cropped up to &lt;a href=&quot;https://www.nytimes.com/1865/09/09/archives/the-boneboiling-nuisance.html&quot;&gt;process horse carcasses&lt;/a&gt;, producing glue, gelatin, and fertilizer. Services carted away as much horse poop as possible to pre-designated &amp;ldquo;manure blocks,&amp;rdquo; in order to keep at least part of the city presentable.&lt;/p&gt;

&lt;p&gt;Horse waste posed a major looming public health risk for the 19th-century city. I assume there were two clear roads forward here:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Reduce the horse population.&lt;/strong&gt; With cities around the world booming in population, banning or restricting horse-based transportation would stall a city&amp;rsquo;s growth. Not a viable option, then.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Eliminate the waste.&lt;/strong&gt; New technical solutions would need to be future-proof, robust even in the face of a continuously growing horse population. While the technical solutions of the day only mitigated some of the worst effects of the waste, this would have seemed like the only viable technical solution to pursue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I certainly would have voted for #2 as an 1890s technologist or urban planner. But neither of these solutions ended up saving New York City, London, and friends from their smelly 19th-century fates. What saved them?&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/2/23/Ford1903.jpg/640px-Ford1903.jpg&quot; alt=&quot;An ad for the Ford Model A, the first car produced by the Ford Motor Company.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The automobile&lt;/strong&gt;, of course. The internal combustion engine offered a fast, efficient, and increasingly cheap alternative to the horse. Urban horses were replaced somewhat slowly, only as market pressures forced horse owners to close up shop. By the final decade of the 19th century, most major cities had switched from horse-pulled streetcars to electrified trolleys. Over the following decades, increasingly economical engines replaced horses in buses, cabs, and personal vehicles. Automobiles introduced a novel technological paradigm, leading to entirely new &lt;a href=&quot;https://en.wikipedia.org/wiki/Assembly_line&quot;&gt;manufacturing methods&lt;/a&gt;, service jobs, and — most importantly — safety issues.&lt;/p&gt;

&lt;p&gt;The introduction of the automobile dealt a final blow to the previous transportation paradigm, and &lt;em&gt;rendered irrelevant&lt;/em&gt; the safety issues it had imposed on modern cities: automobiles did not leave excrement, urine, or horse carcasses in the streets. Automobiles introduced entirely new safety issues, no doubt, which still trouble us today: car exhaust pollutes our atmosphere, and drunk car drivers do far more damage to pedestrians than a drunk hansom driver ever could. But it&amp;rsquo;s critical to note for our purposes that technologists of the horse-era &lt;em&gt;could not have foreseen&lt;/em&gt; such safety problems, let alone develop solutions to them.&lt;/p&gt;

&lt;h2 id=&quot;potential-paradigmatic-changes-in-ai&quot;&gt;Potential paradigmatic changes in AI&lt;/h2&gt;

&lt;p&gt;Modern machine learning and AI are likewise built within a relatively fixed paradigm, which specifies how systems are constructed and used. I want to suggest that substantial changes to the present paradigm might invalidate the assumed alignment between mid-term AI safety work and the longer-term goals. But first, I’ll identify the relevant features of the paradigm that contains modern ML work.&lt;/p&gt;

&lt;p&gt;What are some assumptions of the assumed paradigm which might change in the future? Any answer is bound to look silly in hindsight. In any case, here are a few candidate concepts which are currently central to machine learning, and to AI safety by association. I’ve heard all of these concepts questioned in conversations with reasonable machine learning researchers. Many of these assumptions have even been questioned/subverted in published papers. In short, I don&amp;rsquo;t think any of these concepts are set in stone.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;the train/test regime — the notion that a system is &amp;ldquo;trained&amp;rdquo; offline and then &amp;ldquo;deployed&amp;rdquo; to the real world&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;reinforcement learning; (discrete-time) &lt;a href=&quot;https://en.wikipedia.org/wiki/Markov_decision_process&quot;&gt;MDPs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Stationary_process&quot;&gt;stationarity&lt;/a&gt; as a default assumption; &lt;a href=&quot;https://en.wikipedia.org/wiki/Independent_and_identically_distributed_random_variables&quot;&gt;IID&lt;/a&gt; data sampling as a default assumption&lt;/li&gt;
  &lt;li&gt;RL agents with discrete action spaces&lt;/li&gt;
  &lt;li&gt;RL agents with actions whose effects are pre-specified by the system’s designer&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Gradient_descent&quot;&gt;gradient-based learning&lt;/a&gt; / local parameter search&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;parametric models&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;the notion of discrete &amp;ldquo;tasks&amp;rdquo; or &amp;ldquo;objectives&amp;rdquo; that systems optimize&lt;/li&gt;
  &lt;li&gt;(heresy!) probabilistic inference as a framework for learning and inference&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I believe that, while many of the above axiomatic elements of modern machine learning seem foundational and unshakable, &lt;strong&gt;most&lt;/strong&gt; are likely to be obsolete within decades. Before you disagree with that last sentence, think of what futures a horse-drawn cab driver or an 1890s urban planner would have predicted. Consider also what sort of futures that &lt;a href=&quot;https://ieeexplore.ieee.org/document/110446/?arnumber=110446&quot;&gt;expert systems&lt;/a&gt; developers and &lt;a href=&quot;https://en.wikipedia.org/wiki/Connection_Machine&quot;&gt;Lisp machine engineers&lt;/a&gt; from past decades of AI research would have sketched. (Would they have mentioned MDPs?)&lt;sup id=&quot;fnref:8&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:8&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;You may not agree that &lt;em&gt;all&lt;/em&gt; or &lt;em&gt;most&lt;/em&gt; of the above concepts are about to be subverted any time soon. If you do agree that &lt;em&gt;any&lt;/em&gt; foundational axiom A has the chance of disappearing, though, it is imperative that 1) your safety questions are still relevant, and 2) your technical solutions are successful both in a world where $A$ holds and $\neg A$ holds.&lt;/p&gt;

&lt;h2 id=&quot;consequences-of-paradigmatic-change&quot;&gt;Consequences of paradigmatic change&lt;/h2&gt;

&lt;p&gt;The argument I am suggesting here is different from the standard &amp;ldquo;technical gap&amp;rdquo; argument.&lt;sup id=&quot;fnref:9&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:9&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;8&lt;/a&gt;&lt;/sup&gt; I am instead pointing out a &lt;strong&gt;paradigmatic gap&lt;/strong&gt;: the technical solutions we develop now may be fatally attached to the current technological paradigm. Let $T_S$ be the future time at which long-horizon AI safety risks – say, prosaic AGI or superintelligence – become a reality. Here are two consequences of granting this as a possibility:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Our current technological paradigm may &lt;strong&gt;mislead us to consider safety problems that won&amp;rsquo;t be at all relevant&lt;/strong&gt; at $T_S$, due to paradigmatic change.&lt;/p&gt;

    &lt;p&gt;Excrement evacuation seemed like a pressing issue in the late 19th century; the problem is entirely irrelevant in the present-day automobile paradigm. We instead deal with an entirely different set of modern automobile safety issues.&lt;/p&gt;

    &lt;p&gt;The task of &lt;a href=&quot;https://arxiv.org/abs/1711.02827&quot;&gt;scalable reward specification&lt;/a&gt; likewise appears critically important to the mid-term and long-term AI safety crowds. Such a problem is only relevant, however, if many of the paradigmatic axioms from the previous section hold (at least #2–5).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Technical solutions developed now may be irrelevant&lt;/strong&gt; at $T_S$. Even if the pressing safety issues overlap with the pressing safety issues at $T_S$ (i.e., #1 above doesn&amp;rsquo;t hold), it&amp;rsquo;s possible that our technical solutions will still be fatally tied to elements of the current paradigm.&lt;/p&gt;

    &lt;p&gt;Pedestrians and riders alike faced collision risks in the horse era — &lt;a href=&quot;https://trove.nla.gov.au/newspaper/article/8428803&quot;&gt;runaway horses&lt;/a&gt; might kick and run over people in their way. But the technical solutions to horse collision look nothing like those which save lives today (for example, airbags and stop lights).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There&amp;rsquo;s room to disagree on this question of a &lt;strong&gt;paradigmatic gap&lt;/strong&gt;. But it certainly needs to be part of the AI safety discussion: our bets on the importance of present-day technical safety work ought to incorporate our beliefs over the strength of the current paradigm. Here are some concrete questions worth debating once we’ve granted the possibility of paradigmatic change:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How much are different risks and research directions actually tied to the current paradigm?&lt;sup id=&quot;fnref:10&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:10&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;9&lt;/a&gt;&lt;/sup&gt; (How can we get  more specific about this &amp;ldquo;fatal attachment?&amp;rdquo;)&lt;/li&gt;
  &lt;li&gt;Do our current paradigm-bets look good, or should we be looking to diversify across possible paradigm changes or weaken the connection to the current paradigm?
    &lt;ul&gt;
      &lt;li&gt;What does &amp;ldquo;diversify&amp;rdquo; mean here? Would it entail doing more or less work under the framing of AI safety?&lt;/li&gt;
      &lt;li&gt;We need to arrive at a consensus on the pessimistic meta-induction argument here (see footnote #8). Are we justified in assuming the current paradigm (or &lt;em&gt;any candidate future paradigm&lt;/em&gt;) is the right one in which to do mid-term safety work? Can empirical evidence help here? How can we get more concrete, in any case, about our uncertainty about the strength of a technological paradigm?&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Are there ways to do research that’s likely to survive a paradigm shift?&lt;sup id=&quot;fnref:11&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:11&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;10&lt;/a&gt;&lt;/sup&gt; (What are the safety problems which are likely to survive a paradigm shift?)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Future posts will address some of the above questions in detail. For now, I look forward to the community’s response!&lt;/p&gt;

&lt;h2 id=&quot;follow-ups&quot;&gt;Follow-ups&lt;/h2&gt;

&lt;p&gt;Here I&amp;rsquo;ll respond to various comments from reviewers which I couldn&amp;rsquo;t fit nicely into the above narrative.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://stanford.edu/~aditir/&quot;&gt;&lt;strong&gt;Aditi&lt;/strong&gt;&lt;/a&gt; and &lt;a href=&quot;http://alexlew.net/&quot;&gt;&lt;strong&gt;Alex&lt;/strong&gt;&lt;/a&gt; suggested that AI safety work might be what actually brings about the paradigmatic change I&amp;rsquo;m talking about. Under this view, the safety objective motivates novel work which otherwise would have come more slowly (or not at all). I think that&amp;rsquo;s possible for some sorts of AI safety research — for example, the quest to build systems which are robust to open-ended / real-world adversarial attacks (&lt;a href=&quot;https://arxiv.org/abs/1707.08945&quot;&gt;stop sign graffiti&lt;/a&gt;) might end up motivating substantial paradigm changes. This is a possibility worth considering. My current belief is that many of these sorts of safety research could be just as well branded as &amp;ldquo;doing machine learning better&amp;rdquo; or &amp;ldquo;better specifying the task.&amp;rdquo;
 In other words, the &amp;ldquo;safety&amp;rdquo; framing adds nothing new. At best, it’s distracting; at worst, it gives AI safety an undeserved poor reputation. (As &lt;a href=&quot;https://cs.brown.edu/people/mlittman/&quot;&gt;&lt;strong&gt;Michael&lt;/strong&gt;&lt;/a&gt; suggested: I’d rather say &amp;ldquo;I’m working on X because it makes AI more robust / ethical / fair&amp;rdquo; than &amp;ldquo;I’m working on X because it will help stave off an existential threat to the human race.&amp;rdquo;) This is a very compressed argument, and I&amp;rsquo;ll expand it in a future post in this series.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cs.brown.edu/people/mlittman/&quot;&gt;&lt;strong&gt;Michael&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://cs.stanford.edu/~jsteinhardt/&quot;&gt;&lt;strong&gt;Jacob&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;https://scholar.google.com/citations?user=o1qFlsgAAAAJ&amp;amp;hl=en&quot;&gt;&lt;strong&gt;Max&lt;/strong&gt;&lt;/a&gt;, and &lt;a href=&quot;https://paulfchristiano.com/&quot;&gt;&lt;strong&gt;Paul&lt;/strong&gt;&lt;/a&gt; suggested that mid- and long-term AI safety research might transfer across paradigm shifts. This is certainly true for the most philosophical parts of AI safety research. I am not convinced it applies in more &lt;a href=&quot;https://arxiv.org/abs/1711.09883&quot;&gt;mid-term&lt;/a&gt; &lt;a href=&quot;https://arxiv.org/abs/1611.08219&quot;&gt;work&lt;/a&gt;. I’m not certain about the answer here, but I am certain that this is a live question and ought to play an important role in debates over AI timelines.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://cs.stanford.edu/~jsteinhardt/&quot;&gt;&lt;strong&gt;Jacob&lt;/strong&gt;&lt;/a&gt;, &lt;a href=&quot;http://www.mit.edu/~tomeru/&quot;&gt;&lt;strong&gt;Tomer&lt;/strong&gt;&lt;/a&gt;, and &lt;a href=&quot;http://www.danieldewey.net/&quot;&gt;&lt;strong&gt;Daniel&lt;/strong&gt;&lt;/a&gt; pointed out the possible link to &lt;a href=&quot;https://plato.stanford.edu/entries/thomas-kuhn/#3&quot;&gt;Kuhnian paradigm shifts&lt;/a&gt;. See footnote #2 for a response. In a future post, I intend to address the separate danger of failing to acknowledge dependence on the current scientific paradigm (i.e., on our present notion of &amp;ldquo;what intelligence is&amp;rdquo;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post benefited from many discussions at the Open Philanthropy AI safety workshop, as well as from reviews from colleagues across the world. Thanks to Paul Christiano, Daniel Dewey, Roger Levy, Alex Lew, Jessy Lin, João Loula, Chris Maddison, Maxinder Kanwal, Michael Littman, Thomas Schatz, Amir Soltani, Jacob Steinhardt, Tomer Ullman, and all of the &lt;a href=&quot;http://www.danieldewey.net/&quot;&gt;AI Fellows&lt;/a&gt; for enlightening discussions and feedback on earlier drafts of this post.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I prefer to separate these practical issues under the name &amp;ldquo;machine learning security,&amp;rdquo; which has a more down-to-earth ring compared to &amp;ldquo;AI safety.&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I don’t intend to refer to &lt;a href=&quot;https://plato.stanford.edu/entries/thomas-kuhn/#3&quot;&gt;Kuhnian paradigm shifts&lt;/a&gt; by using this term. Kuhn makes the strong claim that shifts between &lt;em&gt;scientific&lt;/em&gt; paradigms (which establish standards of measurement, theory evaluation, common concepts, etc.) render theories incommensurable. I am referring to a much simpler sort of &lt;em&gt;technological&lt;/em&gt; paradigm (the toolsets and procedures we use to reach our engineering targets). This post is only concerned with the latter sort of paradigmatic change.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;From &lt;a href=&quot;http://www.hup.harvard.edu/catalog.php?isbn=9780674031296&quot;&gt;Greene (2008)&lt;/a&gt;, cited in &lt;a href=&quot;https://www.quora.com/Were-city-streets-filled-with-horse-manure-peoples-shoes-caked-with-horse-manure-before-the-car-was-invented/answer/Kingshuk-Bandyopadhyay&quot;&gt;this Quora answer&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;see e.g. online learning / lifelong learning&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;see e.g. &lt;a href=&quot;https://eng.uber.com/deep-neuroevolution/&quot;&gt;neuroevolution&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;see e.g. nonparametric models :)&amp;nbsp;&lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:8&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This belief is at present no more than an intuition from my experience as a computer scientist / member of the ML/NLP community / reading on the history of science and technology. I hope future posts and discussion can make these beliefs more concrete — though the only way to prove that the future will be radically different is to go ahead and make that future a reality! Arguments for and against &lt;a href=&quot;https://plato.stanford.edu/entries/scientific-realism/#PessIndu&quot;&gt;pessimistic meta-induction&lt;/a&gt; in the philosophy of science might be a good place to start for developing both the positive and negative views here. (Thanks to &lt;a href=&quot;http://joaoloula.github.io/&quot;&gt;João&lt;/a&gt; for the suggestion.)&amp;nbsp;&lt;a href=&quot;#fnref:8&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:9&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;AI safety skeptic: &amp;ldquo;We&amp;rsquo;re decades or centuries away from developing superintelligent machines. Why work on safety now?&amp;rdquo; AI safety non-skeptic: &amp;ldquo;We have no idea how to solve this issue, and it&amp;rsquo;s likely to take decades before we arrive at anything near robust. Thus we need to start now.&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:9&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:10&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I’ve found it difficult to quantify the probability of a paradigm shift. Given the way that I’ve presented paradigm-shift, indeed, these are extremely difficult to imagine and develop by definition. I’d very much like to figure out how to be more concrete about these ideas.&amp;nbsp;&lt;a href=&quot;#fnref:10&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:11&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;See &lt;a href=&quot;http://effective-altruism.com/ea/1ca/my_current_thoughts_on_miris_highly_reliable/#s4&quot;&gt;Daniel Dewey’s evaluation of the MIRI HRAD approach&lt;/a&gt; for an example answer to this question.&amp;nbsp;&lt;a href=&quot;#fnref:11&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Do brains represent words?</title>
      <link>http://foldl.me/2018/word-representations/</link>
      <pubDate>Mon, 16 Apr 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/word-representations/</guid>
      <description>&lt;p&gt;Jack Gallant&amp;rsquo;s group published &lt;a href=&quot;http://doi.org/10.1038/nature17637&quot;&gt;a Nature paper&lt;/a&gt; several years back which caused quite a buzz. It presented interactive &amp;ldquo;semantic maps&amp;rdquo; spanning the human cortex, mapping out how words of different semantic categories were represented in different places. From the abstract:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Our results suggest that most areas&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; within the [brain&amp;rsquo;s] semantic system represent information about specific semantic domains, or groups of related concepts, and our atlas [an interactive web application] shows which domains are represented in each area. This study demonstrates that data-driven methods – commonplace in studies of human neuroanatomy and functional connectivity – provide a powerful and efficient means for mapping functional representations in the brain.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The paper is worth a read, but is unfortunately behind a paywall. The group also produced the video below, which gives a brief introduction to the methods and results.&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/k61nJkx5aDQ?rel=0&quot; frameborder=&quot;0&quot; allow=&quot;autoplay; encrypted-media&quot; allowfullscreen=&quot;&quot; style=&quot;display: block; margin: 0 auto;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;In extremely abbreviated form, here&amp;rsquo;s what happened: the authors of the paper put people in a &lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_magnetic_resonance_imaging&quot;&gt;functional magnetic resonance imaging&lt;/a&gt; machine and took snapshots of their brain activity while they listened to podcasts. They tracked the exact moments at which each subject heard each word in a podcast recording, yielding a large dataset mapping individual words to the brain responses of subjects who heard those words.&lt;/p&gt;

&lt;p&gt;They combined this dataset with several fancy computational models to produce maps of &lt;em&gt;semantic selectivity&lt;/em&gt;, charting which parts of the brain respond especially strongly to which sorts of words. You can see the video for examples, or try out their online &lt;a href=&quot;http://gallantlab.org/huth2016/&quot;&gt;3D brain viewer&lt;/a&gt; yourself.&lt;/p&gt;

&lt;p&gt;This systems neuroscience paper managed to reach people all the way out in the AI community, as it seemed to promise a comprehensive account of actual neural word representations.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; There has since been plenty of criticism of the paper on multiple levels – in experimental design, in modeling choices, in scientific value, and so forth. In this post, I&amp;rsquo;ll raise a simple philosophical issue with the claims of the paper. That issue has to do with the central concept of &amp;ldquo;representation.&amp;rdquo; This paper&amp;rsquo;s claims to representation bring us to what I think is one of the most important open questions in the philosophy of cognitive science and neuroscience.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;This post is intended to serve as a non-philosopher-friendly introduction to the problem of neural representation. Rather than advancing any new theory in this post, I&amp;rsquo;ll just chart out the problem and end with some links to further reading.&lt;/small&gt;&lt;/p&gt;

&lt;!--Unfortunately, while representation is such an important topic, it&apos;s also one of the most difficult to communicate. I&apos;ll do my best, grounding the discussion in the claims of this particular paper.--&gt;

&lt;h2 id=&quot;the-essential-argument&quot;&gt;The essential argument&lt;/h2&gt;

&lt;p&gt;The authors repeatedly allude to &amp;ldquo;(functional) representations&amp;rdquo; of words in the brain. This term is often bandied about in systems neuroscience, but it is much more philosophically troubling than you might think at first glance. Let&amp;rsquo;s spell out the high-level logic of the paper:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;We play subjects some podcasts and make sure they pay attention.&lt;/li&gt;
  &lt;li&gt;At the same time, we record physical traces of their brain activity.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;After we have collected our dataset matching words spoken in the podcasts to brain activity, we build a mathematical model relating the two. We find that we can predict the brain activity of a subject (in particular regions) based on the words that they heard at that moment.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;When we can predict the brain activity of a region with reasonable accuracy based on the identity of the word being heard alone, we can say that the region serves to &lt;em&gt;represent&lt;/em&gt; that word.&lt;/li&gt;
  &lt;li&gt;Our derived semantic map shows how the brain represents words from different semantic domains in different areas.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let&amp;rsquo;s step back and put on our philosopher-hats here.&lt;/p&gt;

&lt;h2 id=&quot;things-bumping-around&quot;&gt;Things bumping around&lt;/h2&gt;

&lt;p&gt;What we &lt;em&gt;actually&lt;/em&gt; observe in this experiment are two different types of physical events. First, a word is played through a pair of headphones, vibrating the air around the ears of the subject in particular way. Next, we see some neurons firing in the brain, spewing out neurotransmitters and demanding extra nutrients to replenish their strength.&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; We find that there is some regular relationship between the way the air vibrates (that is, the particular words a subject hears) and the way particular populations of neurons respond.&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s make an even higher-level gloss of the core logic in this spirit:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;We make some atoms bump around in pattern \( A \) near the subject&amp;rsquo;s ears.&lt;/li&gt;
  &lt;li&gt;We watch how some atoms bump around at the same time in a nearby area (the subject&amp;rsquo;s brain). Call this pattern \( B(A) \). Note that \( B \) is a function of \( A \) – we group the atom-bumps in the brain according to the particular patterns \( A \) presented to the subject.&lt;/li&gt;
  &lt;li&gt;We build a mathematical model relating how the ear-atom-bumping \( A \) relates to the brain-atom-bumping \( B(A) \)_.&lt;/li&gt;
  &lt;li&gt;When our model accurately predicts the bumping \( B(A) \) given the bumping \( A \), we say that \( B(A) \) &lt;em&gt;represents&lt;/em&gt; some aspect of \( A \).&lt;/li&gt;
  &lt;li&gt;The brain activity pattern \( B(A) \) represents the ear-bumping pattern \( A \).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At this level of abstraction—a level which might sound a little silly, but which preserves the essential moves of the argument—we might be able to draw out a strange logical leap. Point #4 takes a correlation between different bumping-patterns \( A \) and \( B(A) \) and concludes that \( B(A) \) &lt;em&gt;represents&lt;/em&gt; \( A \).&lt;/p&gt;

&lt;h2 id=&quot;correlation-as-representation&quot;&gt;Correlation as representation&lt;/h2&gt;

&lt;p&gt;That notion of representation captures the relevant relation in the paper. But it also captures quite a bit more – namely, any pair of physical events \( A \), \( B(A) \) for which some aspect of \( B(A) \) correlates with some aspect of \( A \). Here&amp;rsquo;s a random list of pairs of physical events or states which satisfy this requirement:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The length of a tree&amp;rsquo;s shadow (\( B(A) \)) and the time of day (\( A \))&lt;/li&gt;
  &lt;li&gt;My car&amp;rsquo;s engine temperature (\( B(A) \)) and the position of the key in my car&amp;rsquo;s ignition (\( A \))&lt;/li&gt;
  &lt;li&gt;The volume of a crowd in a restaurant (\( B(A) \)) and the number of eggs broken in the last hour of that restaurant&amp;rsquo;s kitchen (\( A \))&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In none of the above cases would we say that the atom/molecule/photon-bumps \( B(A) \) &lt;em&gt;represent&lt;/em&gt; an aspect of \( A \). So why do we make the claim so confidently when it comes to brains? Our model of the brain as an information-processor needs this notion of representation to be rather strong – to not also include random physical relationships between shadows and time, or volumes and egg-cracking.&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-quest&quot;&gt;The quest&lt;/h2&gt;

&lt;p&gt;We could just declare by fiat, of course, that the relationships between the brain and the outside world are the ones we are interested in explaining. But as scientists we are interested in developing explanations that are maximally &lt;em&gt;observer-independent&lt;/em&gt;. The facts we discover – that region \( X \) of the brain exhibiting a pattern \( B(A) \) represents some aspect \( A \) of the outside world – ought to be true whether or not any scientist cares to investigate it. Our desired notion of representation should emerge &lt;em&gt;naturally&lt;/em&gt; from a description how \B(A)\) and \(A\) relate, without selecting the silly cases from above. For this reason, people generally think of this theoretical program as a quest for &lt;strong&gt;naturalistic&lt;/strong&gt; representation.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2018/escher.jpg&quot; alt=&quot;M.C. Escher &amp;mdash; Hand with Reflecting Sphere.&quot; /&gt;&lt;figcaption&gt;M.C. Escher &amp;mdash; Hand with Reflecting Sphere.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;strong&gt;A first response:&lt;/strong&gt; Sure, the details of \( B(A) \) can be used to infer the details of \( A \) in all of these cases, including the case of the Nature paper. The difference between the Nature paper and the silly examples given above is that the correlation between \( B(A) \) and \( A \) is &lt;em&gt;relevant&lt;/em&gt; or important in some sense. We&amp;rsquo;re capturing some actual mechanistic relationship in the case of the brain, whereas the other examples simply pick on chance correlations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A counter:&lt;/strong&gt; I don&amp;rsquo;t see a principled difference between your &amp;ldquo;mechanistic relationships&amp;rdquo; and your &amp;ldquo;chance correlations.&amp;rdquo; There are certainly &lt;a href=&quot;https://en.wikipedia.org/wiki/Trigonometry&quot;&gt;mechanistic explanations which link the length of a tree&amp;rsquo;s shadow and the time of day&lt;/a&gt;, or any of the other pairs given above. Why privilege the neural relationship with the label of &amp;ldquo;mechanism?&amp;rdquo;&lt;/p&gt;

&lt;p&gt;Our answer to that question can&amp;rsquo;t fall back on claims about the brain being a more &amp;ldquo;interesting&amp;rdquo; or &amp;ldquo;relevant&amp;rdquo; system of study in any respect. We need to find a naturalistic account of why the brain as a data-processor is any different than those (admittedly silly) examples above.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;This, then, is the critical problem of representation in the brain: we need to find some way to assert that the brain is doing something substantial in responding to its inputs, over and above the way a tree or a car engine &amp;ldquo;respond&amp;rdquo; to their &amp;ldquo;inputs.&amp;rdquo; (Why do we need scare-quotes in the second case, but not in the first?)&lt;/p&gt;

&lt;p&gt;Future posts on this blog will characterize some of the most popular responses
to this conceptual issue. In particular, I&amp;rsquo;ll explore notions of representation
which require an account of how content is &lt;em&gt;used&lt;/em&gt; or &lt;em&gt;consumed&lt;/em&gt;. For now, though, I&amp;rsquo;ll
link to some relevant writing:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;From neuroscientists:&lt;/strong&gt; &lt;a href=&quot;https://doi.org/10.1146/annurev.neuro.23.1.613&quot;&gt;deCharms &amp;amp; Zador (2000)&lt;/a&gt;, &lt;a href=&quot;https://doi.org/10.1146/annurev.neuro.21.1.227&quot;&gt;Parker &amp;amp; Newsome (1998)&lt;/a&gt; – more sophisticated operational definitions of neural representation.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;From philosophers:&lt;/strong&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://doi.org/10.1080/0952813021000055630&quot;&gt;Ramsey (2003)&lt;/a&gt; – difficult, but very exciting, attack on the idea of neural representation.&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;https://doi.org/10.1007/s11098-013-0172-0&quot;&gt;Egan (2013)&lt;/a&gt;, see also &lt;a href=&quot;https://vimeo.com/groups/neuphi/videos/60800468&quot;&gt;video here&lt;/a&gt; – argues that talk of representational content is simply a useful &amp;ldquo;gloss&amp;rdquo; on actual theories. (Directed at mental representation, but applies just as well to neural representation.)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Here &amp;ldquo;area&amp;rdquo; means a particular region of the cortex of the human brain.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is absolutely not the first paper on how words are represented neurally – see e.g. &lt;a href=&quot;https://doi.org/10.1146/annurev.psych.57.102904.190143&quot;&gt;Martin (2007)&lt;/a&gt;. It may be unique as of 2016, though, in its breadth and its spread into the AI community. The first author of the paper presented this work, for example, at the NIPS conference in the winter of 2016.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;In this particular case, those traces consist of changes in blood flow to different regions of the brain, detected by a machine with an enormous magnet surrounding the person&amp;rsquo;s head. For more, check out the &lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_magnetic_resonance_imaging&quot;&gt;Wikipedia article on functional magnetic resonance imaging (fMRI)&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Technical note: &amp;ldquo;at that moment&amp;rdquo; is not exactly correct, since fMRI data only tracks the pooled responses of samples of neurons over the span of several seconds.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Another hedge: what we &lt;em&gt;actually&lt;/em&gt; observe is the flow of oxygenated and deoxygenated blood around the brain. I&amp;rsquo;ll stop making these technical hedges now; the neuroscientists can grant me a bit of loose language, and the non-neuroscientists nerdy enough to read these footnotes are hopefully motivated by this point to go &lt;a href=&quot;https://en.wikipedia.org/wiki/Functional_magnetic_resonance_imaging&quot;&gt;read about the details of fMRI&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;M.H. points out that this naïve notion of neural representation also fails to pick out cases we would call proper representation. Consider entertaining an arbitrary thought, which (presumably) activates neural populations in such a way that we&amp;rsquo;d say those activations &lt;em&gt;represent&lt;/em&gt; the thought. It&amp;rsquo;s not possible in this case to point out any stimulus or action correlated with that neural activity, since the actual represented content of the thought is unobservable to the scientist.&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>This is not an academic post</title>
      <link>http://foldl.me/2018/non-academic/</link>
      <pubDate>Thu, 29 Mar 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/non-academic/</guid>
      <description>&lt;p&gt;A friend remarked recently that the majority of the recent posts on this were rather &amp;ldquo;academic.&amp;rdquo; Well, I&amp;rsquo;m an academic, aren&amp;rsquo;t I? I didn&amp;rsquo;t see any problem with this label at the time.&lt;/p&gt;

&lt;p&gt;But it turns out that academics are people, too—and, as genuine people, might benefit from exploring outside the ivory tower every once in a while. In celebration of my own human-ness, then, this week&amp;rsquo;s post has zero intellectual content.&lt;/p&gt;

&lt;p&gt;I was sitting earlier tonight at &lt;a href=&quot;https://cambridgezen.org/&quot;&gt;Cambridge Zen Center&lt;/a&gt; in a weekly community meeting. It&amp;rsquo;s a nice, humble get-together where Zen Center members and a few dozen people from the community come to talk about meditation and Buddhism.&lt;/p&gt;

&lt;blockquote class=&quot;instagram-media&quot; data-instgrm-captioned=&quot;&quot; data-instgrm-permalink=&quot;https://www.instagram.com/p/BTekS3gjTTI/&quot; data-instgrm-version=&quot;8&quot; style=&quot; background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:650px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);&quot;&gt;&lt;div style=&quot;padding:8px;&quot;&gt; &lt;div style=&quot; background:#F8F8F8; line-height:0; margin-top:40px; padding:50.0% 0; text-align:center; width:100%;&quot;&gt; &lt;div style=&quot; background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5/P8/t9FuRVCRmU73JWlzosgSIIZURCjo/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;&quot;&gt;&lt;/div&gt;&lt;/div&gt; &lt;p style=&quot; margin:8px 0 0 0; padding:0 4px;&quot;&gt; &lt;a href=&quot;https://www.instagram.com/p/BTekS3gjTTI/&quot; style=&quot; color:#000; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none; word-wrap:break-word;&quot; target=&quot;_blank&quot;&gt;Springtime at Cambridge Zen Center. Always a good time for practice! #spring #springtime #cherry #cherryblossom #cambridge #zen #meditation #practice #rightnow #justdoit&lt;/a&gt;&lt;/p&gt; &lt;p style=&quot; color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;&quot;&gt;Ein Beitrag geteilt von &lt;a href=&quot;https://www.instagram.com/cambridgezencenter/&quot; style=&quot; color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px;&quot; target=&quot;_blank&quot;&gt; Cambridge Zen Center&lt;/a&gt; (@cambridgezencenter) am &lt;time style=&quot; font-family:Arial,sans-serif; font-size:14px; line-height:17px;&quot; datetime=&quot;2017-04-29T17:27:06+00:00&quot;&gt;Apr 29, 2017 um 10:27 PDT&lt;/time&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; defer=&quot;&quot; src=&quot;//www.instagram.com/embed.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;Each meeting begins with a five-minute meditation. We had an unusually large crowd tonight, and the room was packed as we settled in for our sit. A clap from the leader signaled the start of the five minutes, and the room fell silent.&lt;/p&gt;

&lt;p&gt;But that silence tonight was &lt;a href=&quot;/etc/sound/&quot;&gt;by no means the absence of sound&lt;/a&gt;. I&amp;rsquo;ve been going to these meetings for about 9 months, but somehow never noticed within the stillness all this &lt;em&gt;noise&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A man behind me pushed air back and forth slowly over tensed vocal cords, singing a high-frequency static like that of a distant sea. A girl to my breathed quickly, occasionally voicing little falsetto squeaks. In front of me, a man exhaled in quick bursts, like a horse just after a gallop. Beneath these solos swayed a textured chorus of &lt;em&gt;in&lt;/em&gt;s and &lt;em&gt;out&lt;/em&gt;s, &lt;em&gt;in&lt;/em&gt;s and &lt;em&gt;out&lt;/em&gt;s.&lt;/p&gt;

&lt;p&gt;The symphony at the Zen Center cued a memory of a quiet forest, with the wind filtering through the leaves of the trees: &lt;em&gt;in&lt;/em&gt; and &lt;em&gt;out&lt;/em&gt;, &lt;em&gt;in&lt;/em&gt; and &lt;em&gt;out&lt;/em&gt;.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2018/suttama.650px.jpg&quot; alt=&quot;The forest behind Dhamma Suttama. Montebello, Québec.&quot; /&gt;&lt;figcaption&gt;The forest behind Dhamma Suttama. Montebello, Québec.&lt;time&gt;August 2017&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;It was a unique moment. After five precious minutes, we separated ourselves from our branched brethren and began to talk.&lt;/p&gt;

&lt;p&gt;This post shall have no conclusion attempting to induce any general lessons from the above story. Instead, without a whiff of conceptual analysis or other &amp;ldquo;academic&amp;rdquo; hullabaloo, it will simply end.&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>I saw a dog</title>
      <link>http://foldl.me/2018/dog/</link>
      <pubDate>Tue, 13 Mar 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/dog/</guid>
      <description>&lt;p&gt;—as I walked down a quiet side-street in Cambridge, not far from Central
Square. I was glued to my phone and couldn&amp;rsquo;t make out so many details without
looking up, but I could see that it was middle-sized and black, facing me and angled to the north-east.&lt;/p&gt;

&lt;p&gt;I could tell this was a dog not only from its shape, but also from that
primitive &lt;em&gt;thwang&lt;/em&gt; that dogs trigger in my bones. I&amp;rsquo;m not afraid of dogs – I&amp;rsquo;ve spent most of my life around them – but I&amp;rsquo;m still wary around arbitrary canines on the street, leashed or not.&lt;/p&gt;

&lt;p&gt;I felt that &lt;em&gt;thwang&lt;/em&gt; as I registered the dog&amp;rsquo;s basic features. Black, medium size – maybe a black labrador. I raised my head, ready to step out of the way, smile at the owner, follow the basic program. But there was no dog in front of me.&lt;/p&gt;

&lt;p&gt;What was in front of me was not a black labrador, but a commuter bike locked to
a slightly oblique street sign. The bike had a thin black seat and narrow road
tires, with a rusty pannier rack framing its back wheel. Its handlebars – drop
bars, taped black – were angled away from me. No recognizable dog-features in sight, let alone an actual dog.&lt;/p&gt;

&lt;p&gt;How could my own experience of the world be so &lt;em&gt;wrong?&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Am I pathological? I don&amp;rsquo;t think so. I&amp;rsquo;ve been noticing more of these
experiences over the past few months. Sights, sounds, and sensations occasionally reveal themselves to be little fibs: reasonable, but ultimately inaccurate, pictures of what is &lt;em&gt;actually&lt;/em&gt; out there in the real world.&lt;/p&gt;

&lt;p&gt;There are at least two pictures of perception that such fib-experiences might suggest. Both views suggest that sensations and beliefs combine to produce our visual experience—this much is uncontroversial. They differ, though, on how much credit is assigned to each of those sources.&lt;/p&gt;

&lt;p&gt;In one picture, my brain takes in an &lt;a href=&quot;http://schwitzsplinters.blogspot.com/2018/02/is-consciousness-sparse-or-abundant.html&quot;&gt;&lt;strong&gt;abundant&lt;/strong&gt;&lt;/a&gt; amount of detail about the visual world at all times. On top of that abundant stream of information, some higher-level system sprinkles on the conceptual details: &lt;em&gt;that cube is a cardboard box&lt;/em&gt;, &lt;em&gt;that wiggling object is dangerous&lt;/em&gt;, and so on. Serious mistakes in those higher-level attributions – like the dog-percept presented above – can temporarily paint over my sensory inputs and cause me to see things that aren&amp;rsquo;t there.&lt;/p&gt;

&lt;p&gt;A second picture suggests that the sensory information reaching my brain at any moment is actually quite &lt;strong&gt;sparse&lt;/strong&gt;. On top of this sparse stream, most of the work of perception is performed at higher levels, with the mind &amp;ldquo;filling in&amp;rdquo; all of the gaps in my sensory data on the basis of beliefs and expectations. In this view, it&amp;rsquo;s not that the mind overwrites sensory data that is already there — rather, the mind is continuously tasked with &lt;em&gt;filling in&lt;/em&gt; perceptual information not present in the original sensory data.&lt;/p&gt;

&lt;p&gt;To further develop these two pictures, I&amp;rsquo;ll turn to some details on the human eye.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;The human retina contains two major types of &lt;a href=&quot;https://en.wikipedia.org/wiki/Photoreceptor_cell&quot;&gt;light-sensitive cells&lt;/a&gt;:&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; rods and cones. Rods are responsible for vision in low light, and are not sensitive to color. Cones function well only in high-light situations, and uniquely support color vision.&lt;/p&gt;

&lt;p&gt;It turns out that these two types of cells are distributed unequally in the retina. Cones cluster around the area of the retina which maps to the center of our visual field (the &lt;a href=&quot;https://en.wikipedia.org/wiki/Fovea&quot;&gt;fovea&lt;/a&gt;), while rods dominate everywhere else.&lt;/p&gt;

&lt;figure&gt;&lt;a href=&quot;https://commons.wikimedia.org/wiki/File:Human_photoreceptor_distribution.svg#/media/File:Human_photoreceptor_distribution.svg&quot;&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/3/3c/Human_photoreceptor_distribution.svg&quot; width=&quot;480&quot; height=&quot;480&quot; alt=&quot;Human photoreceptor distribution.svg&quot; /&gt;&lt;/a&gt;&lt;figcaption&gt;Spatial distribution of rods and cones in the human retina. From &lt;a href=&quot;//commons.wikimedia.org/wiki/User:Cmglee&quot; title=&quot;User:Cmglee&quot;&gt;Cmglee on Wikipedia&lt;/a&gt;.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This spatial distribution suggests that, at any moment, the majority of the color information my retina receives only picks out points in the very center of my visual field.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;This is one case, then, in which the brain seems to receive rather &lt;strong&gt;sparse&lt;/strong&gt; sensory information. That&amp;rsquo;s puzzling, because it doesn&amp;rsquo;t seem to map onto my experience.  I certainly don&amp;rsquo;t think that my color vision is limited to the very center of my visual field—I really hope yours isn&amp;rsquo;t, either.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;How is it that I perceive the world as fully colored, if my sensory machinery cannot possibly yield such an image? If that underlying hardware is yielding only a sparse picture of the real world, why does color feel so abundant in my visual experience?&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/13506280701295453&quot;&gt;Balas &amp;amp; Sinha (2007)&lt;/a&gt; present a simple experiment which will help us better draw out this sparse view. Their results offer behavioral evidence that some higher-level mental module actively fills in color information, turning what is originally a rather sparse sensory representation into an abundant visual experience.&lt;/p&gt;

&lt;p&gt;(Unfortunately, the paper is not open-access, and the publisher demands hundreds of dollars for the rights to reproduce the figures. So I&amp;rsquo;ll do my best to summarize the procedure and results here.)&lt;/p&gt;

&lt;p&gt;The authors prepared modified images of natural scenes like the one in the figure below. They took full-color images and imposed a randomly sized color mask, such that a circle in the center of the image remained in color while the rest of the image appeared in grayscale.&lt;/p&gt;

&lt;figure&gt;&lt;a href=&quot;/uploads/2018/chimera.jpg&quot;&gt;&lt;img src=&quot;/uploads/2018/chimera.jpg&quot; alt=&quot;Partially-colored chimera like those used in Balas &amp;amp; Sinha (2007).&quot; /&gt;&lt;/a&gt;&lt;figcaption&gt;Partially-colored chimera image like those used in Balas &amp;amp; Sinha (2007).&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;These &amp;ldquo;chimera&amp;rdquo; images were rapidly presented to adult subjects, and the subjects  were asked after each presentation to report whether the image they had just seen was in grayscale, full color, or a mix of the two.&lt;/p&gt;

&lt;p&gt;The crucial metric of interest here is the rate of color &amp;ldquo;false alarms&amp;rdquo; — that is, how often subjects perceive an image with only its center in color as a fully colored picture. These false alarms be evidence of the brain filling in color percepts.&lt;/p&gt;

&lt;p&gt;What would we expect to find? We know that the actual sensory data is rather sparse — recall that the majority of color-sensitive photoreceptors cluster in the fovea, in the center of the visual field. We might guess, then, that if the region of the image perceived by this color-sensitive area is appropriately colored, then the brain would serve to fill in the rest of the percept.&lt;/p&gt;

&lt;!--&lt;figure&gt;&lt;a href=&quot;/uploads/2018/balas_sinha_2007-results.simple.png&quot;&gt;&lt;img src=&quot;/uploads/2018/balas_sinha_2007-results.simple.png&quot; alt=&quot;False alarm rates from Balas &amp;amp; Sinha (2007).&quot;&gt;&lt;/a&gt;&lt;figcaption&gt;False alarm rates from Balas &amp; Sinha (2007): false alarms increase as the color mask covers more of the center of the subjects&apos; visual fields. Reproduced from Figure 2.&lt;/figcaption&gt;
&lt;/figure&gt;--&gt;

&lt;p&gt;This is what Balas &amp;amp; Sinha find in their main result: &lt;strong&gt;even when nontrivial portions of the image are presented in grayscale, people are likely to report that the entire image is in color.&lt;/strong&gt; For example, when the color mask covers 17.5 degrees of the visual field, subjects report that the entire image is colored almost 40% of the time. These false alarm rates reach 60% as the size of the color mask increases.&lt;/p&gt;

&lt;p&gt;There&amp;rsquo;s much more to the paper: the authors present further experiments attempting to work out the source of the information used to fill in color. For our purposes, though, this headline result is already interesting.&lt;/p&gt;

&lt;p&gt;We have evidence from both directions for the sparse view, then:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;At the neural level we can see that the hardware to support color vision is clustered around a small central area of the retina, yielding rather sparse information about color in the rest of the visual field.&lt;/li&gt;
  &lt;li&gt;At the behavioral level we see that people often perceive these partially-colored images as fully colored.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It seems, then, that higher-level mechanisms are doing quite a bit of work in the brain to &amp;ldquo;fill in&amp;rdquo; the sparse information which manages to filter through the retina.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Why am I writing about this? I think the &amp;ldquo;filling in&amp;rdquo; metaphor is a useful tool for the mental toolbox.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; While this sort of phenomenon shows up again and again in psychology, I feel like I&amp;rsquo;ve only just begun to internalize it — to start to actually &lt;em&gt;see&lt;/em&gt; footprints of the process in my own experience.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s likely due only in small part to my intellectual understanding of the process. It&amp;rsquo;s more likely, I think, that regular meditation and introspection is what is actually helping me see my own experience more clearly.&lt;/p&gt;

&lt;p&gt;In any case, it&amp;rsquo;s quite the thrilling ride. I am catching my mind for the regular fibber that it is, as it paints pretty pictures over messy and sparse arrays of input from my sensory hardware. Happy hallucinating!&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Fun fact. There is actually a third type with quite a long name: &lt;a href=&quot;https://en.wikipedia.org/wiki/Intrinsically_photosensitive_retinal_ganglion_cells&quot;&gt;intrinsically photosensitive retinal ganglion cells&lt;/a&gt;. These cells (a ~1% minority in the retina) help regulate circadian rhythms and contribute to melatonin production/suppression. They were first hypothesized after scientists discovered that supposedly blind mice were still able to respond to changes in their visual environment.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is not exactly correct, of course. We rapidly and subconsciously &lt;a href=&quot;https://www.tandfonline.com/doi/abs/10.1080/13506280701295453&quot;&gt;microsaccade&lt;/a&gt;, even when we feel we are fixating our eyes on one position in our visual field. It&amp;rsquo;s possible that these microsaccades function in part to gather information about colors and forms in our periphery. I don&amp;rsquo;t pretend to cover all my bases as a vision scientist here – I only hope to get the broad strokes of this argument correct.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I also don&amp;rsquo;t think that my peripheral vision is especially acute in low-light conditions.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Psychologists and cognitive scientists might be reminded of terms like &amp;ldquo;top-down processing&amp;rdquo; and &amp;ldquo;predictive processing.&amp;rdquo; I&amp;rsquo;m not sure this metaphor adds anything on top of those, but it does sound quite a bit more intuitive. Anyway, the point of this post is to share some fun facts and ideas, not to present a novel metaphor.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>LeCun&#58; Language is the next frontier for AI—or not</title>
      <link>http://foldl.me/2018/language-is-the-next-frontier/</link>
      <pubDate>Fri, 23 Feb 2018 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2018/language-is-the-next-frontier/</guid>
      <description>&lt;p&gt;&lt;a href=&quot;http://www.abigailsee.com/&quot;&gt;Abi See&lt;/a&gt; recently hosted a debate between Yann LeCun (Facebook/NYU) and
Chris Manning (Stanford) on the importance of linguistic structure and innate
priors in systems for natural language understanding. The video, along with a
nice write-up from Abi herself, are available &lt;a href=&quot;http://www.abigailsee.com/2018/02/21/deep-learning-structure-and-innate-priors.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used to have strong opinions on the use of linguistic structure in NLP
systems.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; I&amp;rsquo;m no longer so passionate about that debate, but I still found
something interesting in this particular discussion. Yann made a striking
remark near the end of the debate (beginning in the video at &lt;a href=&quot;https://youtu.be/fKk9KhGRBdI?t=59m54s&quot;&gt;59:54&lt;/a&gt;):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Language is sort of an epiphenomenon [of human intelligence] &amp;hellip; it&amp;rsquo;s
not that complicated &amp;hellip; There is a lot to intelligence that has
absolutely nothing to do with language, and that&amp;rsquo;s where we should attack
things first. &amp;hellip; [Language] is number 300 in the list of 500 problems
that we need to face.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Wow. Those words come from the man who regularly claimed a few years ago (circa
2014) that language was the &amp;ldquo;next frontier&amp;rdquo; of artificial intelligence.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Four years is quite a long time in the world of AI — enough to legitimately
change your mind in the light of evidence (or lack thereof). Recall that NLP in
2014 was awash in the first exciting results in neural machine translation.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;
LeCun rode the wave, too: in 2015 he and one of his students put up a rather
ambitiously titled preprint called &lt;a href=&quot;https://arxiv.org/abs/1502.01710&quot;&gt;&amp;ldquo;Text Understanding from Scratch.&amp;rdquo;&lt;/a&gt;
(No, they didn&amp;rsquo;t solve &amp;ldquo;text understanding.&amp;rdquo;)&lt;/p&gt;

&lt;p&gt;Yann seems to have had a change of heart since those brave words. I think the
natural language processing community as a whole has begun to brush off the
deep learning hype, too.&lt;/p&gt;

&lt;p&gt;One can hope.&lt;/p&gt;

&lt;!--Chris actually took part in a similar debate in 2014 with Andrew Ng, back when
he was still around at Stanford. In that (private) discussion Andrew used the
success of end-to-end ASR systems to argue that the notion of &quot;phonemes&quot; was no
longer relevant to--&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Heck, it was a central motivation for &lt;a href=&quot;/2016/spinn-hybrid-tree-sequence-models&quot;&gt;my research&lt;/a&gt; at that time. I suppose that was a natural consequence of being directly advised by Chris. :)&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The &amp;ldquo;we&amp;rdquo; in this quote is ambiguous. I&amp;rsquo;d guess from context that he was referring to Facebook AI, but he could have also meant to refer to the larger AI research community.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I recall this distinctive phrasing from several public talks, but we also have some text records. Source 1, &lt;a href=&quot;https://www.reddit.com/r/MachineLearning/comments/25lnbt/ama_yann_lecun/chif3ys/&quot;&gt;Yann&amp;rsquo;s response to a 2014 AMA&lt;/a&gt;: &amp;ldquo;The next frontier [sic] for deep learning are language understanding, video, and control/planning.&amp;rdquo; Source 2, quoted in a &lt;a href=&quot;https://www.wired.com/2015/06/ais-next-frontier-machines-understand-language/&quot;&gt;2015 article from Cade Metz&lt;/a&gt;: &amp;ldquo;Yann LeCun &amp;hellip; calls natural language processing &amp;lsquo;the next frontier.&amp;rsquo;&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;See e.g. &lt;a href=&quot;https://www.semanticscholar.org/paper/Recurrent-Continuous-Translation-Models-Kalchbrenner-Blunsom/4b9b7eed30feee37db3452b74503d0db9f163074&quot;&gt;Kalchbrenner &amp;amp; Blunsom (2013)&lt;/a&gt;; &lt;a href=&quot;https://arxiv.org/abs/1409.3215&quot;&gt;Sutskever, Vinyals, &amp;amp; Le (2014)&lt;/a&gt;; and &lt;a href=&quot;https://arxiv.org/abs/1409.0473&quot;&gt;Bahdanau, Cho, &amp;amp; Bengio (2014)&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    
    
    <item>
      <title>How to prepare for a Vipassana retreat</title>
      <link>http://foldl.me/2017/vipassana-preparation/</link>
      <pubDate>Mon, 11 Sep 2017 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2017/vipassana-preparation/</guid>
      <description>&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2017/vipassana/meditation-hall.jpg&quot; alt=&quot;The meditation hall at Dhamma Suttama in Montebello, Québec.&quot; /&gt;&lt;figcaption&gt;The meditation hall at Dhamma Suttama in Montebello, Québec.&lt;time&gt;August 2017&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Several weeks ago I sat a 10-day Vipassana meditation retreat at the &lt;a href=&quot;http://suttama.dhamma.org&quot;&gt;Dhamma
Suttama&lt;/a&gt; in Montebello, Québec. In an explicitly secular setting, a team of
volunteer teachers demonstrated to around 100 of us students the basics of a
meditation technique recovered directly from the teachings of the Buddha.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; These
10 days were excruciating – painful both physically and mentally. But out of
the pain and maddening boredom emerged an inner stillness and peace I had never
felt before.&lt;/p&gt;

&lt;p&gt;I could write a lot more about my personal experience at the retreat. I could
document how days of sitting in silence brought about such heightened sensory
perception that I felt I had acquired superpowers. I could recall my dreams
during those 10 days, more vivid and bizarre than I had ever experienced.
Unsurprisingly, there is already plenty of writing like this all over the
Internet.  &lt;strong&gt;And I suggest you read none of it.&lt;/strong&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Meditation is fundamentally a solitary practice. The mission, after all, is to
discover a new way to see the world through your own eyes. This can&amp;rsquo;t be
accomplished by reading blog posts or books, or by discussing your practice
with teachers or fellow students. You can only find your own way.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve been reading other people&amp;rsquo;s accounts of Vipassana retreats after
returning from my own, and frankly, a lot of this content underserves the
experience. It&amp;rsquo;s not that there is a dearth of skilled writers discussing the
topic. It&amp;rsquo;s simply that extended meditation yields effects that really can&amp;rsquo;t be
conveyed through language, no matter the skill of the writer.&lt;/p&gt;

&lt;p&gt;I can sympathize if that last sentence sounds a little loosey-goosey to you. My
analytical-philosopher-mind of early 2017 would have thought the same. But try
to think of meditation as a method of practicing a skill – the skill of seeing
clearly into your own, first-person experience.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; It&amp;rsquo;s a skill just like
improvisational jazz, or cooking, or racecar driving. If you ask a master of
any of these skills to describe &lt;em&gt;what it&amp;rsquo;s like&lt;/em&gt; to engage their mastery, you
might be able to get a detailed description of the sights, sounds, tastes,
      smells, and thoughts involved in the experience. But hearing such a
      description is not the same thing as having these feelings first-hand, no
      matter how lengthy or beautifully worded.&lt;/p&gt;

&lt;p&gt;The special thing about meditation as skill practice, then, is that the skill
we are practicing is &lt;em&gt;necessary&lt;/em&gt; for grasping the original lessons of the
Buddha. It&amp;rsquo;s quite fun to study Buddhist notions of &lt;a href=&quot;https://en.wikipedia.org/wiki/Dukkha&quot;&gt;suffering&lt;/a&gt;,
    &lt;a href=&quot;https://en.wikipedia.org/wiki/Impermanence&quot;&gt;impermanence&lt;/a&gt;, and &lt;a href=&quot;https://en.wikipedia.org/wiki/Anatta&quot;&gt;&amp;ldquo;not-self&amp;rdquo;&lt;/a&gt; at an intellectual level. But we
    can&amp;rsquo;t fully grasp these concepts until we directly experience their
    effects — until we sit down and listen.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;So go sit down and listen for yourself! Retreats organized by the international
&lt;a href=&quot;http://www.dhamma.org&quot;&gt;Dhamma&lt;/a&gt; organization are free of charge.&lt;/p&gt;

&lt;h2 id=&quot;but-am-i-prepared&quot;&gt;But am I prepared?&lt;/h2&gt;

&lt;p&gt;Good question. I was anxiously asking this question as my own retreat
approached. By this point, I had a daily meditation practice but had never
participated in any retreat longer than several hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You are not prepared&lt;/strong&gt; if you&amp;rsquo;re like I was. But this is no reason at all to
despair. Even those students returning for their second or third retreat feel
they are not physically or mentally prepared for the experience. I suppose the
only way to really be prepared for this sort of experience is to achieve
enlightenment. Unless you think can accomplish that before your trip, I think
you ought to settle for less.&lt;/p&gt;

&lt;p&gt;That being said, I would like to end the post with some actual advice on how to
be ready for your own retreat.&lt;/p&gt;

&lt;h3 id=&quot;physical-preparation&quot;&gt;Physical preparation&lt;/h3&gt;

&lt;p&gt;First: resign yourself to the fact that &lt;strong&gt;you are not—and will not
be—physically prepared&lt;/strong&gt;.
Experienced meditators and newbies alike complain of extreme physical pain
during the one-hour sits over the ten days. You are no different.&lt;/p&gt;

&lt;p&gt;Having said that, here are some basic items I think it&amp;rsquo;d be wise to follow in
order to minimize your risk of injury.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Research &lt;a href=&quot;https://www.mindful.org/find-right-meditation-posture-body/&quot;&gt;proper meditation posture&lt;/a&gt;&lt;/strong&gt;. There are lots of ways to sit in
meditation, and you need to find one (or two, or more) which work well for
your body. Whichever position you pick, &lt;em&gt;make sure that it is safe&lt;/em&gt;! Your
best bet is probably to visit a local meditation group and rely on the
teacher&amp;rsquo;s advice here. An unsafe posture can do real damage to your muscles,
bones, and nerves. Be safe!&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Sit!&lt;/strong&gt; Establish a daily meditation practice. You can sit for 5 minutes or
50 minutes at first – just make sure you keep it up every day. As your
retreat approaches, begin increasing your daily sit time. You should be
comfortable sitting in some position &amp;ndash; whichever works for you &amp;ndash; for at
least 20 or 30 minutes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;mental-preparation&quot;&gt;Mental preparation&lt;/h3&gt;

&lt;p&gt;Again: resign yourself to the fact that &lt;strong&gt;you are not—and will not
be—mentally prepared&lt;/strong&gt;. But you can do your best with the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Remove stressors.&lt;/strong&gt; Try to leave for your retreat on good terms with your
family, friends, and colleagues. Finish big work projects or life projects.
Pay off your bills.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Keep a journal.&lt;/strong&gt; Write about your daily experience and think about what
you want to get out of your meditation practice.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Share your journey.&lt;/strong&gt; Tell your friends and family about your plans and
let them interrogate you. Some will be surprised, some won&amp;rsquo;t understand at
all, and some might want to come with you. You can use your social network
to help work out for yourself what the retreat is &lt;em&gt;for&lt;/em&gt; in the first place.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;It&amp;rsquo;s up to you to begin the exploration. Good luck!&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2017/vipassana/bridge.jpg&quot; alt=&quot;A wooden bridge in the forest near the Dhamma Suttama meditation center in Montebello, Québec.&quot; /&gt;&lt;figcaption&gt;A wooden bridge in the forest near the Dhamma Suttama meditation center in Montebello, Québec.&lt;time&gt;August 2017&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Wikipedia has fairly good coverage on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Vipassana_movement&quot;&gt;Vipassana movement&lt;/a&gt; and its relation to Buddhism. We were given rather orthodox lessons in the tradition of &lt;a href=&quot;https://en.wikipedia.org/wiki/Theravada&quot;&gt;Theravāda Buddhism&lt;/a&gt;, with lectures drawing almost entirely on content from the &lt;a href=&quot;https://en.wikipedia.org/wiki/P%C4%81li_Canon&quot;&gt; Pāli Canon&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;In Pali, &lt;em&gt;vipassana&lt;/em&gt; actually means something like &amp;ldquo;seeing into [your own experience].&amp;rdquo; Those interested can read an entire article on &lt;a href=&quot;https://tricycle.org/magazine/vipassana-meditation/&quot;&gt;the meaning of &lt;em&gt;vipassana&lt;/em&gt;&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday links</title>
      <link>http://foldl.me/2017/sunday-links-13/</link>
      <pubDate>Sun, 26 Feb 2017 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2017/sunday-links-13/</guid>
      <description>&lt;ol&gt;
  &lt;li&gt;I like plants. Plants are nice. But are they conscious? Do they think?
Follow this very beginner-friendly series on the Brains Blog:
&lt;a href=&quot;http://philosophyofbrains.com/2017/02/22/remembering-plants.aspx&quot;&gt;Can plants remember?&lt;/a&gt; &lt;a href=&quot;http://philosophyofbrains.com/2017/02/21/perceiving-plants.aspx&quot;&gt;Perceive?&lt;/a&gt; &lt;a href=&quot;http://philosophyofbrains.com/2017/02/23/representing-plants.aspx&quot;&gt;Represent?&lt;/a&gt; &lt;a href=&quot;http://philosophyofbrains.com/2017/02/19/do-plants-have-minds.aspx&quot;&gt;Think?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;How is cognitive function distributed across the human brain? A meta-study
&lt;a href=&quot;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3756684/&quot;&gt;applies a simple entropy measure&lt;/a&gt; over distributions of activations for
brain regions across tasks. The findings: both cortical and subcortical
regions vary greatly in their task diversity. An &lt;a href=&quot;https://en.wikipedia.org/wiki/Assortativity&quot;&gt;assortativity&lt;/a&gt; measure
also varies greatly across cortex; some regions are functionally cohesive,
while others seem to yield a patchwork of different functions.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Bridging principles</title>
      <link>http://foldl.me/2017/bridging-principles/</link>
      <pubDate>Thu, 23 Feb 2017 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2017/bridging-principles/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s been quiet here for a while! I have a new series of posts coming up soon, in which I&amp;rsquo;ll try to specify some desiderata for agents which &lt;em&gt;understand&lt;/em&gt; language. That word &lt;em&gt;understand&lt;/em&gt; gets thrown around a lot in my circles, with too little critical thought about it&amp;rsquo;s meaning.&lt;/p&gt;

&lt;p&gt;But enough foreshadowing—for now, I wanted to just share some philosophizing thoughts which have been rolling around in my head for the past few days.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;&lt;a href=&quot;http://www.foldl.me/2016/situated-language-learning/&quot;&gt;Language is defined by its use.&lt;/a&gt; The meaning of the words we use can be derived from the way that they are deployed and the way that people react to them in conversation.&lt;/p&gt;

&lt;p&gt;But it&amp;rsquo;s certainly necessary that this language &lt;em&gt;bottom out&lt;/em&gt; in uses that are nonlinguistic. Language doesn&amp;rsquo;t happen in a vacuum: we deploy it as a tool in all sorts of situations in order to &lt;em&gt;get things done&lt;/em&gt;. Take the standard &lt;a href=&quot;https://en.wikipedia.org/wiki/Language-game_(philosophy)&quot;&gt;Wittgensteinian language game&lt;/a&gt; example:&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The language is meant to serve for communication between a builder A and an assistant B. A is building with building-stones: there are blocks, pillars, slabs and beams. B has to pass the stones, and that in the order in which A needs them. For this purpose they use a language consisting of the words &amp;ldquo;block&amp;rdquo;, &amp;ldquo;pillar&amp;rdquo;, &amp;ldquo;slab&amp;rdquo;, &amp;ldquo;beam&amp;rdquo;. A calls them out;—B brings the stone which he has learnt to bring at such-and-such a call.——Conceive this as a complete primitive language.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think Wittgenstein—and many others—would readily agree that this game is not just a game of words but a game of words &lt;em&gt;causing&lt;/em&gt; things and of other things &lt;em&gt;causing&lt;/em&gt; words. We can&amp;rsquo;t fully define the meaning of a word like &amp;ldquo;slab&amp;rdquo; without referring to the physical actions of A and B. In this way, linguistic meaning has to &lt;em&gt;bottom out&lt;/em&gt; at some point in nonlinguistic facts.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;h3 id=&quot;bridging-principles&quot;&gt;Bridging principles&lt;/h3&gt;

&lt;p&gt;Call the above argument a defense of a &lt;strong&gt;bridging principle&lt;/strong&gt;. Generally speaking, a bridge principle is some statement which links entities from a domain or mode A to a domain or mode B, and thereby gives items in B some new sort of meaning. In the case above, we have that nonlinguistic things—grounded objects, physical actions, nonlinguistic cognitive states, etc.—exist in a domain &lt;em&gt;A&lt;/em&gt;, and link to words, sentences, etc. in domain &lt;em&gt;B&lt;/em&gt;, thereby giving them their meaning.&lt;/p&gt;

&lt;p&gt;I wanted to make this post simply to point out that this search for bridging principles is by no means one unique to language. There are at least three parallels within philosophy that I can think of off of the top of my head:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A central open question in &lt;strong&gt;moral philosophy&lt;/strong&gt; asks whether normative/evaluative statements (&amp;ldquo;you should be politically involved,&amp;rdquo; &amp;ldquo;it is bad to kill people,&amp;rdquo; …; domain &lt;em&gt;B&lt;/em&gt;) &lt;em&gt;bottom out&lt;/em&gt; in non-normative statements (physical states of our brain, etc.; domain &lt;em&gt;A&lt;/em&gt;). Some people believe that this non-normative domain is the only thing that we can actually use to make our normative statements meaningful. Concretely, the bridge here is from &lt;em&gt;non-normative&lt;/em&gt; to &lt;em&gt;normative&lt;/em&gt; statements.&lt;/li&gt;
  &lt;li&gt;In &lt;strong&gt;epistemology&lt;/strong&gt;, we ask whether our (inferential) justified beliefs (&amp;ldquo;I see a rock over there,&amp;rdquo; &amp;ldquo;I am in pain,&amp;rdquo; …; domain &lt;em&gt;B&lt;/em&gt;) might &lt;em&gt;bottom out&lt;/em&gt; in things that are not beliefs at all (the perceptual experience of seeing a rock, the sense of pain; domain &lt;em&gt;A&lt;/em&gt;). Concretely, the bridge here is from &lt;em&gt;&lt;a href=&quot;https://plato.stanford.edu/entries/epistemology/#FOU&quot;&gt;nondoxastic&lt;/a&gt; experiences&lt;/em&gt; to &lt;em&gt;justified beliefs&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;In &lt;strong&gt;philosophy of mind&lt;/strong&gt;, theories of intentional representation attempt to explain how our &lt;a href=&quot;https://plato.stanford.edu/entries/content-causal/&quot;&gt;items of mental content&lt;/a&gt; (thinking of the color blue, wanting pizza; domain &lt;em&gt;B&lt;/em&gt;) represent things in the real world (blue things, the state of wanting pizza; domain &lt;em&gt;A&lt;/em&gt;). These theories explain how our representations &lt;em&gt;bottom out&lt;/em&gt; in the real world by some direct causal chain, normative conditions, etc. Concretely, the bridge here is from &lt;em&gt;real-world things&lt;/em&gt; to &lt;em&gt;representations of those things&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The case of linguistic meaning is certainly very close to #3, though I&amp;rsquo;m not yet sure how to unify the two (or if they can be unified).&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I&amp;rsquo;m not sure what to do next with this information. In any way, I find it pleasing to recognize that a pile of nominally separate disciplines are actually all engaged in rather similar activities at a high level.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Philosophical Investigations&lt;/em&gt;, §2&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;John Searle calls this system of nonlinguistic facts a cognitive &amp;ldquo;Background.&amp;rdquo; Where we locate the Background — whether in the brain or in the real world — is not very relevant for the purposes of this post.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday links</title>
      <link>http://foldl.me/2016/sunday-links-12/</link>
      <pubDate>Sun, 06 Nov 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/sunday-links-12/</guid>
      <description>&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://digitalcollections.library.cmu.edu/awweb/awarchive?type=file&amp;amp;item=355202&quot;&gt;Whither Speech Recognition?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://philosophyofbrains.com/2016/10/26/is-the-mind-just-an-accident-of-the-universe.aspx&quot;&gt;&lt;strong&gt;Is the mind just an accident of the universe?&lt;/strong&gt;&lt;/a&gt; A very brief
introduction to panpsychism.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://schwitzsplinters.blogspot.com/2016/11/three-ways-to-be-not-quite-free-of.html&quot;&gt;&lt;strong&gt;Three ways you might still be racist.&lt;/strong&gt;&lt;/a&gt; Eric Schwitzgebel spells out
how eliminating consistent overt racist behavior is not the same thing as
not being a racist. I think it&amp;rsquo;s very good to clearly designate these other
less obvious moral violations. As a result, we&amp;rsquo;ll be forced to recognize our
own &amp;ldquo;moral mediocrity&amp;rdquo; (Eric&amp;rsquo;s phrase). The unacceptable alternative is to
pretend we are morally perfect and not leave any room to keep learning. This
is the default state of the non-critical modern liberal.&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Situated language learning</title>
      <link>http://foldl.me/2016/situated-language-learning/</link>
      <pubDate>Fri, 07 Oct 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/situated-language-learning/</guid>
      <description>&lt;p&gt;&lt;em&gt;Update: this content (and more) is now available as &lt;a href=&quot;https://arxiv.org/abs/1610.03585&quot;&gt;a more thorough abstract
on arXiv&lt;/a&gt;, co-authored with my OpenAI colleague Igor Mordatch&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve been really pleased with the response to my last post, &lt;a href=&quot;http://www.foldl.me/2016/solving-language/&quot;&gt;&lt;em&gt;On &amp;ldquo;solving
language.&amp;rdquo;&lt;/em&gt;&lt;/a&gt; While I certainly wasn&amp;rsquo;t saying anything revolutionary, it
does seem that I managed to capture some very common sentiment floating around
in the AI community today. I think the post has served as a clear checkpoint
for me and for people with similar interests: it&amp;rsquo;s time to focus on language
in a situated, interactive setting!&lt;/p&gt;

&lt;p&gt;Since that time in mid-August, I&amp;rsquo;ve been working on a paradigm for simulating
situated language acquisition. This post will give a brief overview of the
motivating ideas, and I&amp;rsquo;ll follow up shortly with more concrete details on some
experiments I&amp;rsquo;ve been doing recently.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;(Before I get started: this space is rapidly increasing in activity,
        which is certainly a good thing for science! Facebook Research just
        released their &lt;a href=&quot;https://github.com/facebookresearch/CommAI-env&quot;&gt;Environment for Communication-based AI&lt;/a&gt;, and there
        have been murmurs of other similar environments around the Internets.)
&lt;/small&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-paradigm&quot;&gt;The paradigm&lt;/h2&gt;

&lt;p&gt;One of the key points of &lt;a href=&quot;http://www.foldl.me/2016/solving-language/&quot;&gt;&lt;em&gt;&amp;ldquo;Solving language&amp;rdquo;&lt;/em&gt;&lt;/a&gt; was that natural language
dialogue is necessarily situated in some grounded context. We use language (and
other tools) to accomplish real-world goals, which are themselves often not
linguistic. The reference-game example in that post gave one instance of
linguistic behavior that was strongly tied to nonlinguistic world knowledge —
something we can&amp;rsquo;t solve as a language problem in isolation.&lt;/p&gt;

&lt;p&gt;If we&amp;rsquo;re interested in building language agents which can eventually cooperate
with us via language in similarly grounded contexts, then the learning tasks we
design should reflect this goal.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve followed this idea through to design a general paradigm for situated
language acquisition. In this paradigm, cooperative agents teach or learn a
language in order to accomplish some nonlinguistic goal. Here are the details:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;A &lt;em&gt;child&lt;/em&gt; agent lives in some grounded world and has some goal which is
&lt;strong&gt;nonlinguistic&lt;/strong&gt; (e.g. reach a goal region, get food, etc.).&lt;/li&gt;
  &lt;li&gt;The child has only partial observations of its environment, and can take
only a subset of the necessary actions to reach its goal.&lt;/li&gt;
  &lt;li&gt;A &lt;em&gt;parent&lt;/em&gt; agent also exists in this world. The parent speaks some fixed
language and wants to cooperate with the child (to help it reach its goal).&lt;/li&gt;
  &lt;li&gt;The parent has full observations from the environment, and can take actions
which the child cannot take on its own.&lt;/li&gt;
  &lt;li&gt;The child and parent can communicate via a language channel.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The environment is designed such that the child cannot accomplish the goal on
its own; it must employ the help of its parent. The child acquires language
&lt;strong&gt;as a side effect of accomplishing its grounded goal&lt;/strong&gt;: it is the most
efficient (or perhaps the only efficient) mechanism for reaching its main goal.&lt;/p&gt;

&lt;h2 id=&quot;philosophizing&quot;&gt;Philosophizing&lt;/h2&gt;

&lt;p&gt;To clearly restate: a critical and distinguishing factor of this framework is
that the child acquires language only as a side effect of striving for some
grounded, nonlinguistic goal.&lt;/p&gt;

&lt;p&gt;The environment is designed in particular to avoid &lt;strong&gt;reifying&lt;/strong&gt; &amp;ldquo;language.&amp;rdquo; I
think it is misleading to see language as some sort of unitary &lt;em&gt;thing&lt;/em&gt; to be
solved — as just one of a few isolated tools in the toolbox of cognition that
need to be picked up on the way to general artificial intelligence.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Language-game_(philosophy)&quot;&gt;&lt;strong&gt;Language is defined by its use.&lt;/strong&gt;&lt;/a&gt; Language-enabled agents are not identified
their next-word prediction perplexity or their part-of-speech tag confusion
matrix, but by their ability to cooperate with other agents through language.
We shouldn&amp;rsquo;t expect the latter to magically emerge from hill-climbing on any of
the former.&lt;/p&gt;

&lt;p&gt;As I&amp;rsquo;ll show in my next post, it&amp;rsquo;s within our reach to design simple environments
that let us directly hill-climb on this objective of cooperation through language.
Stay tuned!&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;And please get in touch! I always enjoy hearing new ideas from my readers. (All four of you. ;) )&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2016/sunday-links-11/</link>
      <pubDate>Sun, 18 Sep 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/sunday-links-11/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;Writing about writing about writing about language: John McWhorter helps kick
off Vox&amp;rsquo;s new &amp;ldquo;Big Idea&amp;rdquo; section with &lt;a href=&quot;http://www.vox.com/the-big-idea/2016/9/14/12910180/noam-chomsky-tom-wolfe-linguist&quot;&gt;a review of Tom Wolfe&amp;rsquo;s evaluation of
Chomskyan linguistics&lt;/a&gt;. This is a nice opinionated summary of a
decades-long debate.&lt;/li&gt;
  &lt;li&gt;C.A.R. Hoare reflects on software engineering experiences in &lt;a href=&quot;http://zoo.cs.yale.edu/classes/cs422/2010/bib/hoare81emperor.pdf&quot;&gt;&amp;ldquo;The Emperor&amp;rsquo;s
Old Clothes&amp;rdquo;&lt;/a&gt;:
    &lt;blockquote&gt;Our main failure was overambition. &quot;The goals which we have
attempted have obviously proved to be far beyond our grasp.&quot; ...  What was
amazing was that a large team of highly intelligent programmers could labor
so hard and so long on such an unpromising project. You know, you shouldn’t
trust us intelligent programmers. We can think up such good arguments for
convincing ourselves and each other of the utterly absurd. Especially don’t
believe us when we promise to repeat an earlier success, only bigger and
better next time.&lt;/blockquote&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://nlpers.blogspot.com/2016/08/debugging-machine-learning.html&quot;&gt;Debugging machine learning.&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.reddit.com/r/askscience/comments/4v6rhu/whats_going_on_in_my_head_when_im_thinking_of_an/&quot;&gt;What&amp;rsquo;s going on in my head when I&amp;rsquo;m thinking of an image?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>On "solving language"</title>
      <link>http://foldl.me/2016/solving-language/</link>
      <pubDate>Tue, 16 Aug 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/solving-language/</guid>
      <description>&lt;p&gt;Some of my more ambitious machine-learning colleagues often have a tendency to
get misty-eyed and talk about language as the &amp;ldquo;next frontier&amp;rdquo; of artificial
intelligence. I can completely agree at a high level: building practical
language-enabled agents which can use real language with real people will be a
huge breakthrough for our field.&lt;/p&gt;

&lt;p&gt;But too frequently people seem to see language as a mere box to be checked
along the way to general artificial intelligence. As soon as we break through
some perplexity floor on our language models, apparently, we&amp;rsquo;ll have dialogue
agents that can communicate just like we do.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve been exposed to this exhausting view often enough&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; that I&amp;rsquo;ve decided to
start working to actively counter it.&lt;/p&gt;

&lt;h2 id=&quot;what-does-it-mean-to-solve-language&quot;&gt;What does it mean to &amp;ldquo;solve language?&amp;rdquo;&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;m not even sure what people are trying to say when they talk about
&amp;ldquo;solving language.&amp;rdquo; It&amp;rsquo;s as vague and underspecified as the quest to &amp;ldquo;solve
AI&amp;rdquo; as a whole. We already have &lt;a href=&quot;https://www.rebellionresearch.com/&quot;&gt;systems that build investment strategies by
reading the news&lt;/a&gt;, &lt;a href=&quot;http://www.apple.com/ios/siri/&quot;&gt;intelligent personal assistants&lt;/a&gt;, and &lt;a href=&quot;https://x2.ai/&quot;&gt;automated
psychologists which aid the clinically depressed&lt;/a&gt;. Are we done?&lt;/p&gt;

&lt;p&gt;It depends on your measure of done-ness, I suppose. I&amp;rsquo;m partial to a
utilitarian stopping criterion here. That is, we&amp;rsquo;ve &amp;ldquo;solved language&amp;rdquo; &amp;mdash; we&amp;rsquo;ve
built an agent which &amp;ldquo;understands language&amp;rdquo; &amp;mdash; when the agent can embed itself
into any &lt;strong&gt;real-world&lt;/strong&gt; environment and interact with us humans via language to
make us more productive.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;On that measure we&amp;rsquo;ve actually made some good progress, as shown by the linked
examples above. But there&amp;rsquo;s plenty of room for improvement which will likely
amount to decades of collaborative work.&lt;/p&gt;

&lt;p&gt;If you can show me how your favorite NLP/NLU task connects directly to this
measure of progress, then that&amp;rsquo;s great. I unfortunately don&amp;rsquo;t think this is the
case for much current work, including several of the tasks popular in deep
learning for NLP.&lt;/p&gt;

&lt;p&gt;&lt;small&gt;(See the &lt;a href=&quot;#addenda&quot;&gt;addenda&lt;/a&gt; to the post for some juicy follow-up to
        the claims in this section.)&lt;/small&gt;&lt;/p&gt;

&lt;h2 id=&quot;situated-language-use&quot;&gt;Situated language use&lt;/h2&gt;

&lt;p&gt;If I believe in the definition of &amp;ldquo;solving language&amp;rdquo; given above, I am led to
focus on tasks of &lt;strong&gt;situated language use&lt;/strong&gt;: cases where agents are
influencing or being influenced by other actors in grounded scenarios through
language.&lt;/p&gt;

&lt;p&gt;This setting seems extremely fertile for new language problems that aren&amp;rsquo;t
currently seriously considered as major tasks of understanding. I&amp;rsquo;ll end this
post with a simple thought experiment demonstrating how far behind we are on
real situated tasks &amp;mdash; or rather, how much exciting work there still is to be
done!&lt;/p&gt;

&lt;h2 id=&quot;generalization-in-reference-games&quot;&gt;Generalization in reference games&lt;/h2&gt;

&lt;p&gt;Here&amp;rsquo;s a simple example of situated learning that should reveal the great
complexity of language we have yet really to start solving.&lt;/p&gt;

&lt;p&gt;Consider a &lt;a href=&quot;https://en.wikipedia.org/wiki/Language-game_(philosophy)&quot;&gt;Wittgensteinian reference game&lt;/a&gt; with two agents, &lt;em&gt;Alexa&lt;/em&gt; and
&lt;em&gt;Bill&lt;/em&gt;. Alexa is using words that Bill doesn&amp;rsquo;t know to pick out referents in
their environment. It&amp;rsquo;s a cooperative game: Alexa tries to use words that will
make Bill most successful, Bill knows that Alexa is cooperating, Alexa knows
that Bill knows that she is cooperating, and so on.&lt;/p&gt;

&lt;h3 id=&quot;round-1&quot;&gt;Round 1&lt;/h3&gt;

&lt;p&gt;Alexa selects some object in the environment and speaks a word to Bill, say,
&lt;em&gt;BLOOP&lt;/em&gt;. Here&amp;rsquo;s what Bill has observed in this first round of the game:&lt;/p&gt;

&lt;div style=&quot;text-align:center&quot;&gt;
&lt;h4&gt;Possible referents:&lt;/h4&gt;
&lt;div style=&quot;margin-top:10px&quot;&gt;
&lt;div style=&quot;width:50%;float:left;&quot;&gt;&lt;img src=&quot;http://www.foldl.me/uploads/2016/reference-game/glass.png&quot; style=&quot;border:none&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;width:50%;float:left;&quot;&gt;&lt;img src=&quot;http://www.foldl.me/uploads/2016/reference-game/pen.png&quot; style=&quot;border:none;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br style=&quot;clear:left&quot; /&gt;
&lt;h4&gt;Alexa said: &lt;em&gt;BLOOP&lt;/em&gt;&lt;/h4&gt;
&lt;/div&gt;

&lt;p&gt;Now Bill has to select the object he thinks Alexa was referring to. The
dialogue is a &amp;ldquo;success&amp;rdquo; if Alexa and Bill pick the same object.&lt;/p&gt;

&lt;p&gt;Suppose Bill has to predict some distribution over the objects given Alexa&amp;rsquo;s
utterance \(\pi(o \mid u)\). Since Bill doesn&amp;rsquo;t know any of Alexa&amp;rsquo;s words
in the first round, we would expect his distribution then to be roughly
uniform:&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/reference-game/round1-policy.png&quot; alt=&quot;&quot; /&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Let&amp;rsquo;s say he randomly chooses the cup, and the two are informed that they have
succeeded. That means Alexa used &lt;em&gt;BLOOP&lt;/em&gt; to refer to the cup. Both internalize
that information and proceed to the next round.&lt;/p&gt;

&lt;h3 id=&quot;round-2&quot;&gt;Round 2&lt;/h3&gt;

&lt;p&gt;Now suppose we begin round 2 with different objects. Alexa, still trying to
maximize the chance that Bill understands what she is referring to, makes
&lt;strong&gt;the same utterance&lt;/strong&gt;: &lt;em&gt;BLOOP&lt;/em&gt;.&lt;/p&gt;

&lt;div style=&quot;text-align:center&quot;&gt;
&lt;h4&gt;Possible referents:&lt;/h4&gt;
&lt;div style=&quot;margin-top:10px&quot;&gt;
&lt;div style=&quot;width:50%;float:left;&quot;&gt;&lt;img src=&quot;http://www.foldl.me/uploads/2016/reference-game/mug.png&quot; style=&quot;border:none&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;width:50%;float:left;&quot;&gt;&lt;img src=&quot;http://www.foldl.me/uploads/2016/reference-game/rabbit.png&quot; style=&quot;border:none;&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br style=&quot;clear:left&quot; /&gt;
&lt;h4&gt;Alexa said: &lt;em&gt;BLOOP&lt;/em&gt;&lt;/h4&gt;
&lt;/div&gt;

&lt;p&gt;I would argue that, despite the fact that &lt;strong&gt;both objects are novel&lt;/strong&gt; (at least
at a perceptual level), Bill&amp;rsquo;s probabilities would look something like this:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/reference-game/round2-policy.png&quot; alt=&quot;&quot; /&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;What happened? Bill learned something about Alexa&amp;rsquo;s language in round 1: that
her word &lt;em&gt;BLOOP&lt;/em&gt; can refer to a glass. In round 2, he was forced to
&lt;strong&gt;generalize&lt;/strong&gt; that information and use it to pick the most cup-like object
among the referents.&lt;/p&gt;

&lt;h3 id=&quot;what-just-happened&quot;&gt;What just happened?&lt;/h3&gt;

&lt;p&gt;How do we model this? There&amp;rsquo;s a lot going on. Here are the three most important
properties I can recognize.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;As is often the case in reference game examples, Bill had to reason
&lt;strong&gt;pragmatically&lt;/strong&gt; in round 2 in order to understand what Alexa might mean.&lt;/li&gt;
  &lt;li&gt;This pragmatic reasoning relied on a &lt;strong&gt;model of the world&lt;/strong&gt;. Bill had to
reason that the mug was similar to the cup, not because they look alike but
because they are both used for drinking.&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;Bill made his inference using &lt;strong&gt;a single previous example&lt;/strong&gt;. This inductive
inference relied mostly on his model of the world, as opposed to an enormous
dataset of in-domain examples.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These are three basic properties of Bill the language agent. These are three
properties that we haven&amp;rsquo;t come anywhere close to solving in a general way.&lt;/p&gt;

&lt;p&gt;(These goals have been recognized in the past, of course; there&amp;rsquo;s been some
 &lt;a href=&quot;https://arxiv.org/abs/1604.00562&quot;&gt;good&lt;/a&gt; &lt;a href=&quot;http://www.mit.edu/~rplevy/papers/potts-levy-2015-bls.pdf&quot;&gt;recent&lt;/a&gt; &lt;a href=&quot;https://papers.nips.cc/paper/4929-learning-and-using-language-via-recursive-pragmatic-reasoning-about-other-agents&quot;&gt;work&lt;/a&gt; on the specific problems above. But I think
 these objectives should get much more focus under the utilitarian motivation
 underlying this post.)&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;That rather long example was my first stab at picking out &lt;strong&gt;situated&lt;/strong&gt; learning
problems, where language is a mean rather than an end in itself. It&amp;rsquo;s just one
sample from what I see as a large space of underexplored problems. Any language
researcher worth her salt could engineer a quick solution to this particular
scenario. The real challenge is to tackle the whole problem class with an
integrated solution. Why don&amp;rsquo;t we start working on &lt;em&gt;that?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Keep posted for updates in this space &amp;mdash; I&amp;rsquo;m working hard every day
on projects related to this goal at &lt;a href=&quot;https://openai.com&quot;&gt;OpenAI&lt;/a&gt;. If you&amp;rsquo;re interested in
collaborating or sharing experiences, feel free to get in touch via the
comments below or via email.&lt;/p&gt;

&lt;h4 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h4&gt;

&lt;p&gt;&lt;small&gt;
I&amp;rsquo;ve been mulling these ideas over for most of the summer, and a whole lot of
people from several institutions have helped me to sharpen my thinking: Gabor
Angeli, Phil Blunsom, Sam Bowman, Arun Chaganty, Danqi Chen, Kevin Clark,
    Prafulla Dhariwal, Chris Dyer, Jonathan Ho, Rafal Jozefowicz, Nal
    Kalchbrenner, Andrej Karpathy, Percy Liang, Alireza Makhzani, Christopher
    Manning, Igor Mordatch, Allen Nie, Craig Quiter, Alec Radford, Zain Shah,
    Ilya Sutskever, Sida Wang, and Keenon Werling.
&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;&lt;small&gt;
Special thanks to Gabor Angeli, Sam Bowman, Roger Levy, Christopher Manning,
Sida Wang, and a majority of the OpenAI team for reviewing early drafts of
this post.
&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;&lt;small&gt;
The sketch images in the post are taken from the &lt;a href=&quot;http://cybertron.cg.tu-berlin.de/eitz/projects/classifysketch/&quot;&gt;TU Berlin human sketching
dataset&lt;/a&gt;.
&lt;/small&gt;&lt;/p&gt;

&lt;h3 id=&quot;addenda&quot;&gt;Addenda&lt;/h3&gt;

&lt;p&gt;Many of my trusted colleagues who reviewed this post made interesting and
relevant points which are worth mentioning. I&amp;rsquo;ve included them in a separate
section in order to prevent the main post from getting too long and full of
hedging clauses.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;I claimed in this post that work in natural language understanding often
seems too disconnected from the real downstream utilitarian goal&amp;mdash;in the
case of our field, to actually &lt;strong&gt;use language&lt;/strong&gt; in order to cooperate with
human beings. &lt;a href=&quot;http://www.mit.edu/~rplevy/&quot;&gt;Roger&lt;/a&gt; and &lt;a href=&quot;https://www.nyu.edu/projects/bowman/&quot;&gt;Sam&lt;/a&gt; pointed out that many people in
the field do feel this to be true at a broader scale &amp;mdash; that is, there are
several such related divergences (e.g. the divergence between modern NLP and
its computational linguistics roots) that ought to be unified.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://nlp.stanford.edu/manning/&quot;&gt;Chris&lt;/a&gt; pointed out that there are other uses of language which could
be used to likewise argue for different lines of research. For example,
language also functions as an information storage mechanism, and my
situated approach doesn&amp;rsquo;t capture this. We can actually use this
information-storage view to motivate many of the tasks central to NLP or,
more specifically, information extraction.&lt;/li&gt;
&lt;/ol&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
MathJax.Hub.Config({TeX: { equationNumbers: { autoNumber: &quot;AMS&quot; } } });
&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;It&amp;rsquo;s a view that&amp;rsquo;s quite hard to escape in Silicon Valley for sure. I actually wasn&amp;rsquo;t able to find the clarity to write this post until now, after a week of travel and late-night conference discussions in Europe.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I&amp;rsquo;m aware this is not only a utilitarian aim but also an &lt;em&gt;anthropocentric&lt;/em&gt; one. I&amp;rsquo;m not sure it&amp;rsquo;s totally right, and am certainly open to belief updates from my readers.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Interestingly, if both Alexa and Bill have English as a native language, I would guess that phonaesthetic effects would lead Bill to prefer the round object over the long, pointy one. That&amp;rsquo;s how I would behave, anyway. Don&amp;rsquo;t ask me how to model that.&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Importantly, this is more than a linguistic model. The facts which Bill exploits are nonlinguistic properties learned from embodied experience.&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Hybrid tree-sequence neural networks with SPINN</title>
      <link>http://foldl.me/2016/spinn-hybrid-tree-sequence-models/</link>
      <pubDate>Wed, 22 Jun 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/spinn-hybrid-tree-sequence-models/</guid>
      <description>&lt;p&gt;We&amp;rsquo;ve finally published a neural network model which has been under development
for over a year at Stanford.  I&amp;rsquo;m proud to announce &lt;strong&gt;SPINN&lt;/strong&gt;: the
&lt;strong&gt;S&lt;/strong&gt;tack-augmented &lt;strong&gt;P&lt;/strong&gt;arser-&lt;strong&gt;I&lt;/strong&gt;nterpreter &lt;strong&gt;N&lt;/strong&gt;eural &lt;strong&gt;N&lt;/strong&gt;etwork. The
project fits into what has long been the Stanford research program, mixing deep
learning methods with principled approaches inspired by linguistics. It is the
result of a substantial collaborative effort also involving &lt;a href=&quot;https://www.nyu.edu/projects/bowman/&quot;&gt;Sam Bowman&lt;/a&gt;,
Abhinav Rastogi, Raghav Gupta, and our advisors &lt;a href=&quot;http://nlp.stanford.edu/manning/&quot;&gt;Christopher Manning&lt;/a&gt; and
&lt;a href=&quot;http://web.stanford.edu/~cgpotts/&quot;&gt;Christopher Potts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This post is a brief introduction to the SPINN project from a particular angle,
one which is likely of interest to researchers both inside and outside of the
NLP world. I&amp;rsquo;ll focus here on the core SPINN theory and how it enables a
&lt;strong&gt;hybrid tree-sequence architecture&lt;/strong&gt;.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; This architecture blends the otherwise
separate paradigms of &lt;a href=&quot;https://en.wikipedia.org/wiki/Recursive_neural_network&quot;&gt;recursive&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Recurrent_neural_network&quot;&gt;recurrent&lt;/a&gt; neural networks into a
structure that is stronger than the sum of its parts.&lt;/p&gt;

&lt;p style=&quot;text-align:center;font-size:88%&quot;&gt;(quick links: &lt;a href=&quot;#model&quot;&gt;model description&lt;/a&gt;,
&lt;a href=&quot;/uploads/papers/acl2016-spinn.pdf&quot;&gt;full paper&lt;/a&gt;,
&lt;a href=&quot;https://github.com/stanfordnlp/spinn&quot;&gt;code&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Our task, broadly stated, is to build a model which outputs compact,
sufficient&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; representations of natural language. We will use these
representations in downstream language applications that we care about.&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;
Concretely, for an input sentence \(\mathbf x\), we want to learn a powerful
representation function \(f(\mathbf x)\) which maps to a vector-valued
representation of the sentence. Since this is a deep learning project,
\(f(\mathbf{x})\) is of course parameterized by a neural network of some
sort.&lt;/p&gt;

&lt;p&gt;Voices from Stanford have been suggesting for a long time that basic linguistic
theory might help to solve this representation problem. &lt;a href=&quot;https://en.wikipedia.org/wiki/Recursive_neural_network&quot;&gt;Recursive neural
networks&lt;/a&gt;, which combine simple grammatical analysis with the power of
&lt;a href=&quot;https://en.wikipedia.org/wiki/Recurrent_neural_network&quot;&gt;recurrent neural networks&lt;/a&gt;, were strongly supported here by &lt;a href=&quot;http://www.socher.org/&quot;&gt;Richard
Socher&lt;/a&gt;, &lt;a href=&quot;http://nlp.stanford.edu/manning/&quot;&gt;Chris Manning&lt;/a&gt;, and colleagues. SPINN has been developed in
this same spirit of merging basic linguistic facts with powerful neural network
tools.&lt;/p&gt;

&lt;h2 id=&quot;model&quot;&gt;Model&lt;/h2&gt;

&lt;p&gt;Our model is based on an insight into representation. Recursive neural networks
are centered around tree structures (usually binary &lt;a href=&quot;https://en.wikipedia.org/wiki/Parse_tree#Constituency-based_parse_trees&quot;&gt;constituency trees&lt;/a&gt;)
like the following:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/tree.png&quot; alt=&quot;&quot; /&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;In a standard recursive neural network implementation, we compute the
representation of a sentence (equivalently, the root node &lt;em&gt;S&lt;/em&gt;) as a recursive
function of its two children, and so on down the tree. The recursive function
is specified like this, for a parent representation \(\vec p\) with child
representations \(\vec c_1, \vec c_2\):
\[\vec p = \sigma(W [\vec c_1, \vec c_2])\]
where \(\sigma\) is some nonlinearity such as the \(\tanh\) or sigmoid
function. The obvious way to implement this recurrence is to visit each triple
of a parent and two children, and compute the representations bottom-up.  The
graphic below demonstrates this computation order.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/tree-recursive.gif&quot; alt=&quot;The computation defined by a standard recursive neural network. We compute representations bottom-up, starting at the leaves and moving to nonterminals.&quot; /&gt;&lt;figcaption&gt;The computation defined by a standard recursive neural network. We compute representations bottom-up, starting at the leaves and moving to nonterminals.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;This is a nice idea, because it allows linguistic structure to &lt;strong&gt;guide
computation&lt;/strong&gt;. We are using our prior knowledge of sentence structure to
simplify the work left to the deep learning model.&lt;/p&gt;

&lt;p&gt;One substantial practical problem with this recursive neural network, however,
is that it can&amp;rsquo;t easily be batched. Each input sentence has its own unique
computation defined by its parse tree. At any given point, then, each
example will want to compose triples in different memory locations. This is
what gives recurrent neural networks a serious speed advantage. At each
timestep, we merely feed a big batch of memories through a matrix
multiplication. This work can be easily farmed out on a GPU, leading to
order-of-magnitude speedups. Recursive neural networks unfortunately don&amp;rsquo;t work
like this. We can&amp;rsquo;t retrieve a single batch of contiguous data at each
timestep, since each example has different computation needs throughout the
process.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;h3 id=&quot;shift-reduce-parsing&quot;&gt;Shift-reduce parsing&lt;/h3&gt;

&lt;p&gt;The fix comes from the change in representation foreshadowed earlier. To make
that change, I need to introduce a parsing formalism popular in natural
language processing, originally stolen from the compiler/PL crowd.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Shift-reduce_parser&quot;&gt;&lt;strong&gt;Shift-reduce parsing&lt;/strong&gt;&lt;/a&gt; is a method for building parse structures from
sequence inputs in linear time. It works by exploiting an auxiliary &lt;em&gt;stack&lt;/em&gt;
structure, which stores partially-parsed subtrees, and a &lt;em&gt;buffer&lt;/em&gt;, which stores
input tokens which have yet to be parsed.&lt;/p&gt;

&lt;p&gt;We use a shift-reduce parser to apply a sequence of &lt;em&gt;transitions&lt;/em&gt;,
moving items from the buffer to the stack and combining multiple stack elements
into single elements. In the parser&amp;rsquo;s initial state, the stack is empty and the
buffer contains the tokens of an input sentence. There are just two legal
transitions in the parser transition sequence.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Shift&lt;/strong&gt; pulls the next token from the buffer and pushes it onto the stack.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt; combines the top two elements of the stack into a single element,
producing a new subtree. The top two elements of the stack become the left
and right children of this new subtree.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The animation below shows how these two transitions can be used to construct
the entire parse tree for our example sentence.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/tree-shift-reduce.gif&quot; alt=&quot;A shift-reduce parser produces the pictured constituency tree. Each timestep is visualized before and then after the transition is taken. The text at the top right shows the transition at each timestep, and yellow highlights indicate the data involved in the transition. The table at the right displays the stack contents before and after each transition.&quot; /&gt;&lt;figcaption&gt;A shift-reduce parser produces the pictured constituency tree. Each timestep is visualized before and then after the transition is taken. The text at the top right shows the transition at each timestep, and yellow highlights indicate the data involved in the transition. The table at the right displays the stack contents before and after each transition.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Rather than running a standard bottom-up recursive computation, then, we can
execute this table-based method on transition sequences. Here&amp;rsquo;s the buffer and
accompanying transition sequence we used for the sentence above. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S&lt;/code&gt; denotes a
shift transition and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R&lt;/code&gt; denotes a reduce transition.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Buffer: The, man, picked, the, vegetables
Transitions: S, S, R, S, S, S, R, R, R
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Every binary tree has a unique corresponding shift-reduce transition sequence.
For a sentence with \(n\) tokens, we can produce its parse with a
shift-reduce parser in exactly \(2n - 1\) transitions.&lt;/p&gt;

&lt;p&gt;All we need to do is build a shift-reduce parser that combines &lt;strong&gt;vector
representations&lt;/strong&gt; rather than subtrees. This system is a pretty simple
extension of the original shift-reduce setup:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Shift&lt;/strong&gt; pulls the next &lt;em&gt;word embedding&lt;/em&gt; from the buffer and pushes it onto
the stack.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Reduce&lt;/strong&gt; combines the top two elements of the stack \(\vec c_1, \vec
c_2\) into a single element \(\vec p\) via the standard recursive
neural network feedforward: \(\vec p = \sigma(W [\vec c_1, \vec c_2])\).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we have a shift-reduce parser, deep-learning style.&lt;/p&gt;

&lt;p&gt;This is really cool for several reasons. The first is that this shift-reduce
recurrence &lt;strong&gt;computes the exact same function&lt;/strong&gt; as the recursive neural network
we formulated above. Rather than making the awkward bottom-up tree-structured
computation, then, we can just run a recurrent neural network over these
shift-reduce transition sequences.&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;If we&amp;rsquo;re back in recurrent neural network land, that means we can make use of
all the batching goodness that we were excited about earlier. It gains us quite
a bit of speed, as the figure below from our paper demonstrates.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/spinn-speed.png&quot; alt=&quot;Massive speed-ups over a competitive recursive neural network implementation (from Irsoy and Cardie, 2014). A baseline RNN implementation, which ignores parse information, is also shown. The y-axis shows feedforward speed on random input sequence data.&quot; /&gt;&lt;figcaption&gt;Massive speed-ups over a competitive recursive neural network implementation (from &lt;a href=&quot;http://www.cs.cornell.edu/~oirsoy/files/nips14drsv.pdf&quot;&gt;Irsoy and Cardie, 2014&lt;/a&gt;). A baseline RNN implementation, which ignores parse information, is also shown. The &lt;em&gt;y&lt;/em&gt;-axis shows feedforward speed on random input sequence data.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;That&amp;rsquo;s &lt;a href=&quot;https://docs.google.com/spreadsheets/d/17BRX32FQjP2Blk3zNSZyGpUWYAr4h0xhwec23dnQaCM/pubhtml&quot;&gt;up to a 25x improvement&lt;/a&gt; over our comparison recursive neural
network implementation. We&amp;rsquo;re between two to five times slower than a recurrent
neural network, and it&amp;rsquo;s worth discussing why. Though we are able to batch
examples and run an efficient GPU implementation, this computation is
fundamentally divergent &amp;mdash; at any given timestep, some examples require a
&amp;ldquo;shift&amp;rdquo; operation, and other examples require a &amp;ldquo;reduce.&amp;rdquo; When computing
results for all examples in bulk, we&amp;rsquo;re fated to throw away at least half of
our work.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m excited about this big speedup. Recursive neural networks have often been
dissed as too slow and &amp;ldquo;not batchable,&amp;rdquo; and this development proves both points
wrong. I hope it will make new research on this model class a practical
opportunity.&lt;/p&gt;

&lt;h3 id=&quot;hybrid-tree-sequence-networks&quot;&gt;Hybrid tree-sequence networks&lt;/h3&gt;

&lt;p&gt;I&amp;rsquo;ve been hinting throughout this post that our new shift-reduce feedforward is
really just a recurrent neural network computation. To be clear, here&amp;rsquo;s the
&amp;ldquo;sequence&amp;rdquo; that the recurrent neural network traverses when it reads in our
example tree:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img class=&quot;noborder&quot; src=&quot;http://www.foldl.me//uploads/2016/tree-shift-reduce-with-trace.gif&quot; alt=&quot;Visualization of the post-order tree traversal performed by a shift-reduce parser.&quot; /&gt;&lt;figcaption&gt;Visualization of the post-order tree traversal performed by a shift-reduce parser.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;This is a &lt;a href=&quot;https://en.wikipedia.org/wiki/Tree_traversal#Post-order&quot;&gt;post-order&lt;/a&gt; tree traversal, where for a given parent node we
recurse through the left subtree, then the right, and then finally visit the
parent.&lt;/p&gt;

&lt;p&gt;We had a simple idea with a big result after looking at this diagram: why not
have a &lt;strong&gt;recurrent&lt;/strong&gt; neural network follow along this path of arrows?&lt;/p&gt;

&lt;p&gt;Concretely, that means that at every timestep, we update some RNN memory
regardless of the shift-reduce transition. We call this the &lt;strong&gt;tracking
memory&lt;/strong&gt;. We can write out the algorithm mathematically for clarity. At any
given timestep \(t\), we compute a new tracking value \(\vec m_t\) by
combining the top two elements of the stack \(\vec c_1, \vec c_2\), the top
of the buffer \(\vec b_1\), and the previous tracking memory \(\vec
m_{t-1}\):
\begin{equation}
\vec m_t = \text{Track}(\vec m_{t-1}, \vec c_1, \vec c_2, \vec b_1) \\
\end{equation}
We can then pass this tracking memory onto the recursive composition function,
via a simple extension like this:
\begin{equation}
\vec p = \sigma(W [\vec c_1; \vec c_2; \vec m_t]) \\
\end{equation}
What have we done? We&amp;rsquo;ve just interwoven a recurrent neural network into a
recursive neural network computation. The recurrent memories are used to
augment the recursive computation (\(m_t\) is passed to the recursive
composition function) and vice versa (the recurrent memories are a function of
the recursively computed values on the stack).&lt;/p&gt;

&lt;p&gt;We show in &lt;a href=&quot;http://www.foldl.me/uploads/papers/acl2016-spinn.pdf&quot;&gt;our paper&lt;/a&gt; how these two paradigms turn out to have
&lt;strong&gt;complementary&lt;/strong&gt; power on our test data. By combining the recurrent and
recursive models into a single feedforward, we get a model that is more
powerful than the sum of its parts.&lt;/p&gt;

&lt;p&gt;What we&amp;rsquo;ve built is a new way to build a representation \(f(\mathbf x)\) for
an input sentence \(\mathbf x\), like we discussed at the beginning of this
post. In our paper, we use this representation to reach a high-accuracy result
on the &lt;a href=&quot;http://nlp.stanford.edu/projects/snli/&quot;&gt;Stanford Natural Language Inference dataset&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This post managed to cover about one section of our full paper. If you&amp;rsquo;re
interested in more details about how we implemented and applied this model,
related work, or a more formal description of the algorithm discussed here,
&lt;a href=&quot;http://www.foldl.me/uploads/papers/acl2016-spinn.pdf&quot;&gt;take a read&lt;/a&gt;. You can also check out &lt;a href=&quot;https://github.com/stanfordnlp/spinn&quot;&gt;our code repository&lt;/a&gt;, which has
several implementations of the SPINN model and models which you can run to
reproduce or extend our results.&lt;/p&gt;

&lt;p&gt;We&amp;rsquo;re continuing active work on this project in order to learn better
end-to-end models for natural language processing. I always enjoy hearing ideas
from my readers &amp;mdash; if this project interests you, get in touch via email or in
the comment section below.&lt;/p&gt;

&lt;h2 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h2&gt;

&lt;p&gt;I have to first thank my collaborators, of course &amp;mdash; this was a team of strong
researchers with nicely complementary skills, and I look forward to pushing
this further together with them in the future.&lt;/p&gt;

&lt;p&gt;The SPINN project has been supported by a Google Faculty Research Award, the
Stanford Data Science Initiative, and the National Science Foundation under
grant numbers &lt;a href=&quot;http://www.nsf.gov/awardsearch/showAward?AWD_ID=1456077&quot;&gt;BCS 1456077&lt;/a&gt; and &lt;a href=&quot;http://www.nsf.gov/awardsearch/showAward?AWD_ID=1514268&quot;&gt;IIS 1514268&lt;/a&gt;. Some of the Tesla K40s
used for this research were donated to Stanford by the NVIDIA Corporation.
&lt;a href=&quot;http://kelvinguu.com/&quot;&gt;Kelvin Gu&lt;/a&gt;, &lt;a href=&quot;http://cocolab.stanford.edu/ndg.html&quot;&gt;Noah Goodman&lt;/a&gt;, and many others in the &lt;a href=&quot;http://nlp.stanford.edu&quot;&gt;Stanford NLP
Group&lt;/a&gt; contributed helpful comments during development. &lt;a href=&quot;https://twitter.com/crizcraig&quot;&gt;Craig Quiter&lt;/a&gt;
and &lt;a href=&quot;https://www.nyu.edu/projects/bowman/&quot;&gt;Sam Bowman&lt;/a&gt; helped review this blog post.&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
MathJax.Hub.Config({TeX: { equationNumbers: { autoNumber: &quot;AMS&quot; } } });
&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is only a brief snapshot of the project focusing on modeling and algorithms. For details on the task / data, training, related work etc., check out &lt;a href=&quot;http://www.foldl.me/uploads/papers/acl2016-spinn.pdf&quot;&gt;our full paper&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I mean &lt;em&gt;sufficient&lt;/em&gt; here in a formal sense &amp;mdash; i.e., powerful enough to answer questions of interest in isolation, without looking back at the original input value.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;In this first paper, we use the model to answer questions from the &lt;a href=&quot;http://nlp.stanford.edu/projects/snli/&quot;&gt;Stanford Natural Language Inference dataset&lt;/a&gt;.)&amp;nbsp;&lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;A non-naïve approach might involve maintaining a queue of triples from an input batch and rapidly dequeuing them, batching together all of these dequeued values. This has already been pursued (of course) by colleagues at Stanford, and it shows some promising speed improvements on a CPU. I doubt, though, that the gains from this method will offset the losses on the GPU, since this method sacrifices all data locality that a &lt;em&gt;recurrent&lt;/em&gt; neural network enjoys on the GPU.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For a more formal and thorough definition of shift-reduce parsing, I&amp;rsquo;ll refer the interested reader to &lt;a href=&quot;http://www.foldl.me/uploads/papers/acl2016-spinn.pdf&quot;&gt;our paper&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The catch is that the recurrent neural network must maintain the per-example stack data. This is simple to implement in principle. We had quite a bit of trouble writing an efficient implementation in Theano, though, which is not really built to support complex data structure manipulation.&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2016/sunday-links-10/</link>
      <pubDate>Sun, 19 Jun 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/sunday-links-10/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Look_Who%27s_Back&quot;&gt;&lt;strong&gt;&lt;em&gt;Er ist wieder da&lt;/em&gt; (Look Who&amp;rsquo;s Back)&lt;/strong&gt;&lt;/a&gt; is available on Netflix.
It&amp;rsquo;s based off a popular book in Germany by the same name. Adolf Hitler is
plopped into a modern Berlin and becomes a comedy star as he reproduces his
tirades on television shows. The country receives him as a talented
impressionist who sometimes says things that sound sort of accurate.&lt;/p&gt;

    &lt;p&gt;It&amp;rsquo;s supposed to be a comedy. It&amp;rsquo;s funny, sure, but it&amp;rsquo;s also a very timely
reminder in the current political climates of Europe and of the US. I&amp;rsquo;ll
translate two scenes below. These are translated from the subtitles; the
actual spoken dialogue is much better.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;Two colleagues (C) from a TV station bring home the Hitler &amp;ldquo;impostor,&amp;rdquo; and
they run into their German grandmother (G). The grandmother launches into a
tirade: &lt;table&gt;&lt;tr&gt;&lt;td&gt;G&lt;/td&gt;&lt;td&gt;Sie haben alle vergast!&lt;/td&gt;&lt;td&gt;You gassed
everyone!&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;C&lt;/td&gt;&lt;td&gt;Oma, das ist Satire.&lt;/td&gt;&lt;td&gt;Grandma,
it&apos;s just satire.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;G&lt;/td&gt;&lt;td&gt;Er sieht aus wie
früher.&lt;/td&gt;&lt;td&gt;He looks just like he used to.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Er
sagt die gleichen Sachen wie früher.&lt;/td&gt;&lt;td&gt;He&apos;s saying the same things he
used to.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Damals lachten die Leute anfangs
auch.&lt;/td&gt;&lt;td&gt;Back then, people laughed at first, too.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;The protagonist (P) has realized that the impostor Hitler is the real
Hitler, and holds a pistol at Hitler&amp;rsquo;s face.
&lt;table&gt;&lt;tr&gt;&lt;td&gt;H&lt;/td&gt;&lt;td&gt;Haben Sie sich nie gefragt, warum die
Leute mir folgen?&lt;/td&gt;&lt;td&gt;Have you never asked yourself why people follow
me?&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Weil sie im Kern genauso sind wie
ich.&lt;/td&gt;&lt;td&gt;Because they&apos;re at the core just like
me.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Sie teilen die gleichen Werte.&lt;/td&gt;&lt;td&gt;We have the
same values.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Darum schießen Sie auch
nicht.&lt;/td&gt;&lt;td&gt;That&apos;s why you won&apos;t shoot me.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;3&quot;
style=&quot;text-align: center&quot;&gt;&lt;em&gt;P shoots. Hitler collapses and vanishes, reappearing
behind P.&lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;H&lt;/td&gt;&lt;td&gt;Sie können mich nicht
loswerden.&lt;/td&gt;&lt;td&gt;You can&apos;t get rid of me.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Ich bin
ein Teil von Ihnen.&lt;/td&gt;&lt;td&gt;I am a part of you.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Von
euch allen.&lt;/td&gt;&lt;td&gt;Of all of you.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;Worth a watch.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Tom Vanderbilt tells his story of discovering cycling in &lt;a href=&quot;https://www.1843magazine.com/features/the-long-and-winding-road&quot;&gt;&lt;strong&gt;The Long and
Winding Road&lt;/strong&gt;&lt;/a&gt;. He recounts his humble road-biker beginnings, and
accurately describes the pain and glory on the way to a life of serious
pedaling. It&amp;rsquo;s a nice tribute to the crazy, maybe-masochistic sport I&amp;rsquo;ve come
to love. The long article ends with a brief tour from San Francisco to Santa
Barbara.&lt;/li&gt;
  &lt;li&gt;An introduction to the &lt;a href=&quot;https://prufrocksdilemma.wordpress.com/2013/08/29/seeking-shostakovich-introduction/&quot;&gt;&lt;strong&gt;work of composer Dmitri Shostakovich&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Life update</title>
      <link>http://foldl.me/2016/life-update/</link>
      <pubDate>Tue, 14 Jun 2016 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2016/life-update/</guid>
      <description>&lt;p&gt;Hello world! I&amp;rsquo;m coming back up to the surface after over a year of silence on
this blog. As always, I have things about technology and my work to rant
about&amp;hellip; but I&amp;rsquo;d like to first make a (public) review of what&amp;rsquo;s happened in all
this time. This will be a smorgasbord of professional and personal happenings,
probably too strangely interwoven to be of interest to anyone in particular. I
feel nevertheless I should get some words out on this blog, and update the,
ahem, public record.&lt;/p&gt;

&lt;p&gt;Just about the time of my last post in &lt;strong&gt;March 2015&lt;/strong&gt;, the Stanford NLP Group
went on its first lab retreat in a long time to &lt;a href=&quot;https://en.wikipedia.org/wiki/Point_Reyes&quot;&gt;Point Reyes&lt;/a&gt;. The lead
picture of this post shows a beautiful section of the Pacific Coast Highway I
captured on the way north.&lt;/p&gt;

&lt;p&gt;At this lab retreat I spoke with &lt;a href=&quot;https://www.nyu.edu/projects/bowman/&quot;&gt;Sam Bowman&lt;/a&gt; and &lt;a href=&quot;http://kelvinguu.com/&quot;&gt;Kelvin Gu&lt;/a&gt; about
end-to-end systems for deep learning for NLP. Inspired by a recent debate
between Andrew Ng and Christopher Manning, I tried to argue an aggressive
(though not original) thesis about our long-term approach to language
understanding systems. My claim, which now sounds rather stale in 2016, was
that we should drop tasks like parsing and part-of-speech tagging. Natural
language processing should solve language understanding tasks that non-experts
actually care about. In short, we should focus on &amp;ldquo;end-to-end&amp;rdquo; systems where
the output is something of interest to real people.&lt;/p&gt;

&lt;p&gt;The counter to that argument (then and still now) is that intermediate
representations like constituency parses &lt;em&gt;actually work&lt;/em&gt; to produce useful
results downstream. They help us practically reason about extremely complicated
linguistic patterns. I can point at a parse or a part-of-speech tag and
recognize that it tells me something meaningful about a piece of language.
Building deep-learning systems that learn to model such complexity, while
theoretically feasible, is pretty darn hard.&lt;/p&gt;

&lt;p&gt;But &amp;ldquo;pretty darn hard&amp;rdquo; had never stopped any of us before. We started to discuss
ways to simplify the end-to-end learning problem by adding structure (less
constraining than the structure of a parse) to the computation problem. That
discussion was the basis for our recently published &lt;a href=&quot;/uploads/papers/acl2016-spinn.pdf&quot;&gt;SPINN model&lt;/a&gt;. More on
that later.&lt;/p&gt;

&lt;p&gt;The Stanford Symbolic Systems Program is often described as the study of &amp;ldquo;minds
and machines.&amp;rdquo; My spring 2015 quarter at Stanford turned out to be rather
mind-heavy in this sense. I took a seminar on theoretical neuroscience with
&lt;a href=&quot;https://web.stanford.edu/dept/app-physics/cgi-bin/person/surya-gangulijanuary-2012/&quot;&gt;Surya Ganguli&lt;/a&gt; which opened my eyes to the deep connections between modern
machine learning and what we know so far about systems neuroscience. A class by
&lt;a href=&quot;https://psychology.stanford.edu/awagner&quot;&gt;Anthony Wagner&lt;/a&gt; introduced me to theories of human learning, memory, and
attention.  The synergies between these theories and popular models in neural
networks are impressive, but there is still plenty of room for more cross-talk.
I am now convinced that we do have much more to learn from cognitive
neuroscience.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/google.jpg&quot; alt=&quot;A summer at Google. I did some work, too &amp;mdash; not pictured here.&quot; /&gt;&lt;figcaption&gt;A summer at Google. I did some work, too &amp;mdash; not pictured here.&lt;time&gt;August 2015&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;I spent my summer as a research intern at &lt;a href=&quot;https://research.google.com/teams/brain/&quot;&gt;Google Brain&lt;/a&gt;, co-advised by &lt;a href=&quot;http://www.cs.toronto.edu/~ilya/&quot;&gt;Ilya
Sutskever&lt;/a&gt; and &lt;a href=&quot;http://research.google.com/pubs/OriolVinyals.html&quot;&gt;Oriol Vinyals&lt;/a&gt;.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; The Brain team was an outstanding place
for young aspiring researchers like myself. Around 15 interns came to work with
the motivated and creative members of the team, using some seriously beefy
Google infrastructure to attack challenging problems in machine learning.&lt;/p&gt;

&lt;p&gt;As a first non-work-related note, it&amp;rsquo;s certainly worth mentioning that I
discovered a new road biking obsession that summer. I joined up with a team of
Googlers riding &lt;a href=&quot;http://www.wavestowine.org&quot;&gt;Waves to Wine&lt;/a&gt; and trained with them for the whole summer.
I learned to climb mountains and speed down descents, leveling up from
newbie-cyclist to slightly-less-newbie cyclist.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/bikes.jpg&quot; alt=&quot;Yay, bikes!&quot; /&gt;&lt;figcaption&gt;Yay, bikes!&lt;time&gt;October 2015 / July 2015&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;Cycling was a great release for me. While I loved working on the Brain team, I
found the work environment on the Google campus rather stifling. It&amp;rsquo;s truly a
paradise in Mountain View, for better and for worse. With a road bike I was able
to escape that sprawling land of perfection and explore everywhere from &lt;a href=&quot;https://www.strava.com/activities/390877625&quot;&gt;China
Camp in the North Bay&lt;/a&gt; to &lt;a href=&quot;https://www.strava.com/activities/380561190&quot;&gt;Santa Cruz on the opposite end&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I kept biking when I got back to Stanford in the fall. It&amp;rsquo;s become a reliable
way for me to escape the messy, mathy world of artificial intelligence.  The
Stanford cycling community is very supportive of motivated beginners, and I was
able to level up again with some very impressive skilled riders.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/stanford-cycling.jpg&quot; alt=&quot;A fraction of the Stanford group on a ride in Southern California.&quot; /&gt;&lt;figcaption&gt;A fraction of the Stanford group on &lt;a href=&quot;https://www.strava.com/activities/471935405&quot;&gt;a ride in Southern California&lt;/a&gt;.&lt;time&gt;January 2016&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;In the fall, &lt;a href=&quot;https://www.nyu.edu/projects/bowman/&quot;&gt;Sam&lt;/a&gt; and I started working seriously on what would later be
called SPINN (the &lt;strong&gt;S&lt;/strong&gt;tack-augmented &lt;strong&gt;P&lt;/strong&gt;arser-&lt;strong&gt;I&lt;/strong&gt;nterpreter &lt;strong&gt;N&lt;/strong&gt;eural
&lt;strong&gt;N&lt;/strong&gt;etwork). The idea began as a very simple one &amp;mdash; we wanted to exploit a
&lt;strong&gt;stack&lt;/strong&gt; as a structured memory model for end-to-end deep learning for NLP
tasks, possibly using existing linguistic data to guide exactly how the stack
was used. We saw this approach&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; as a first step toward a totally parse-free,
fully-differentiable end-to-end system.&lt;/p&gt;

&lt;p&gt;We designed a model that would follow a shift-reduce parse sequence (generated
from a gold constituency parse) and build vector representations of the parse
nodes along the way. At some point in front of a whiteboard, Sam realized that
this model computed exactly the same function as a recursive neural network.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;
That was when we knew we were onto something interesting. Sam ran some
preliminary experiments on toy data and the results suggested we should move
forward.&lt;/p&gt;

&lt;p&gt;Near the end of the year, Abhinav Rastogi and Raghav Gupta, two masters
students, joined us on the project. With double the manpower, we charged ahead
and sicced various evolved forms of the model on Sam&amp;rsquo;s baby, the &lt;a href=&quot;http://nlp.stanford.edu/projects/snli/&quot;&gt;Stanford
Natural Language Inference dataset&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We wrote the whole thing in Theano, and ended up having some serious problems
with training runtime performance. Months of toil in code optimization,
Theano-hacking, and writing CUDA code taught us a good lesson: if you&amp;rsquo;re doing
anything remotely unusual in terms of neural network structure, you probably
should ditch abstractions like Theano and work down at the layer of the metal.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/nips-keenon.jpg&quot; alt=&quot;Keenon Werling and I in Montréal during NIPS 2015.&quot; /&gt;&lt;figcaption&gt;Keenon Werling and I in Montréal during NIPS 2015.&lt;time&gt;December 2015&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;I escaped Stanford for a bit in the winter to attend NIPS 2015. This was my
my first machine learning conference, and I really enjoyed socializing and
participating in casual brain-storm sessions with people from across the world.
The conference itself was pretty exhausting &amp;mdash; there were way, way too many
people, and we all had to squeeze into a single gigantic conference room for a
single-track oral presentation schedule. In any case, it was nice to slip out of
California for a while and revive my seriously broken French in Montréal.&lt;/p&gt;

&lt;p&gt;After a comfortable holiday break at home with the family, I returned to the
bike heaven / ridiculous economic bubble / home of an artificial intelligence
renaissance that is the San Francisco Bay Area. I made a big life decision that
had been sitting around in the queue for a while and &lt;strong&gt;became a vegetarian&lt;/strong&gt;.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/veggies.jpg&quot; alt=&quot;A yummy vegetarian meal from Ricker, a Stanford dining hall near the Gates CS building. Stanford has been voted the &apos;Favorite Vegan-Friendly Large College&apos; by peta2.&quot; /&gt;&lt;figcaption&gt;A yummy vegetarian meal from Ricker, a Stanford dining hall near the Gates CS building. Stanford has been voted the &lt;a href=&quot;http://www.stanforddaily.com/2015/04/28/stanford-voted-most-vegan-friendly-campus/&quot;&gt;&apos;Favorite Vegan-Friendly Large College&apos;&lt;/a&gt; by &lt;a href=&quot;http://www.peta2.com/&quot;&gt;peta2&lt;/a&gt;.&lt;time&gt;February 2016&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;This isn&amp;rsquo;t the place for me to wage an anti-meat campaign &amp;mdash; interested readers
can just take a good look at e.g. &lt;a href=&quot;http://www.ncifap.org/reports/&quot;&gt;the report of the Pew Commission on
Industrial Farm Animal Production&lt;/a&gt; to see why this might be a reasonable
thing to do.&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; I had seen these reports and become acquainted with the facts
long before 2016. But, like many people, I had settled to live with the
cognitive dissonance of at once enjoying meat and knowing that it was a harmful
and ethically wrong habit. That changed after I read Jonathan Safran Foer&amp;rsquo;s
&lt;a href=&quot;https://www.amazon.com/gp/product/0316069884/ref=as_li_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0316069884&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&amp;amp;linkId=579d4d5ea33b87f32c49a996a47fce36&quot;&gt;&lt;em&gt;Eating Animals&lt;/em&gt;&lt;/a&gt;. Jonathan&amp;rsquo;s situation was much the same: before writing
his book, he was a meat eater with a guilty conscience who had made several
failed attempts at vegetarianism. While I was already familiar with the
high-level facts of the modern meat industry, Jonathan&amp;rsquo;s personal story
motivated me even further &amp;mdash; enough to actually move forward and make the
change.&lt;/p&gt;

&lt;p&gt;The SPINN team &amp;mdash; now six strong, including our advisors &amp;mdash; toiled throughout
the winter to develop the model theory and evaluate it on natural language data.
When not outside on a bike saddle, I spent the season cooped up in my office in
the Gates building, writing code, reading relevant papers, and hoping for
success. It slowly became clear during the quarter that things were going to
work out in our favor. We submitted a report of our work to the Association for
Computational Linguistics in March, and will present it at the conference this
summer.&lt;/p&gt;

&lt;p&gt;And then I was off to Berlin!&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/berlin.jpg&quot; alt=&quot;Riding a vintage roadie in central Berlin.&quot; /&gt;&lt;figcaption&gt;Riding a vintage roadie in central Berlin.&lt;time&gt;April 2016&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;I had long ago applied to the Stanford overseas study &lt;a href=&quot;https://undergrad.stanford.edu/programs/bosp/explore/berlin&quot;&gt;program in Berlin&lt;/a&gt;.
After several years of mostly tunnel-vision intellectual focus on artificial
intelligence, I knew that my brain needed some novel content in order to keep
functioning. I wanted to return to my dormant love of language learning. I had
obsessively taught myself languages during high school, but mostly dropped the
activity at university, where time for leisure-learning was rather scarce. A
language-immersion trip to Germany was a perfect way to slip back into the old
hobby &amp;mdash; and, no less important, to slip out of the fast-paced world of AI
research for a short while.&lt;/p&gt;

&lt;p&gt;A generous and welcoming family hosted me in the peaceful city quarter of
&lt;a href=&quot;https://en.wikipedia.org/wiki/Friedenau&quot;&gt;Friedenau&lt;/a&gt;. I studied German at a Stanford satellite in Berlin and spent my
free time exploring the city and cycling, sometimes &lt;a href=&quot;https://www.strava.com/activities/571930933&quot;&gt;with the Freie Universität
Berlin riding group&lt;/a&gt;.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2016/lutherstadt-wittenberg.jpg&quot; alt=&quot;Lutherstadt Wittenberg, in Saxony-Anhalt. Taken at the halfway point on a bike trip to Leipzig.&quot; /&gt;&lt;figcaption&gt;Lutherstadt Wittenberg, in Saxony-Anhalt. Taken at the halfway point on &lt;a href=&quot;https://www.strava.com/activities/582949905&quot;&gt;a bike trip to Leipzig&lt;/a&gt;.&lt;time&gt;May 2016&lt;/time&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;The immersion experience was a wonderful challenge, though I probably wouldn&amp;rsquo;t
have chosen the adjective &amp;ldquo;wonderful&amp;rdquo; as I was going through it. I learned (the
hard way!) to trust myself to speak fluently in another language &amp;mdash; to be
willing to make some mistakes and fail in front of other people, that is, in
order to convey what I want to say. This was a fully intellectually engaging
task. I found every day quickly filled up with conversations, literature,
television, and movies, and everything that might have been banal or boring in
English was an important and interesting part of my studies in Berlin.&lt;/p&gt;

&lt;p&gt;Of course, there is more to Berlin than the German language. The city has a dark
and complex past, and the modern Berlin, no longer physically divided, still
shows scars of its turbulent history. Exploring this history in person &amp;mdash;
through conversation and travel &amp;mdash; added a new dimension to formerly dry
textbook knowledge in my mind.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s a happy coincidence that this year&amp;rsquo;s &lt;a href=&quot;http://acl2016.org/&quot;&gt;ACL conference&lt;/a&gt; takes place in
Berlin in a few months. I have an excuse, then, to go back and ensure that my
German hasn&amp;rsquo;t rusted!&lt;/p&gt;

&lt;p&gt;But for now, I&amp;rsquo;m off to San Francisco for what is sure to be an exciting summer.
I&amp;rsquo;m joining the rapidly growing reseach team at &lt;a href=&quot;https://openai.com/about/&quot;&gt;OpenAI&lt;/a&gt;, which has managed
to already release a swathe of papers on generative models and a platform for
open reinforcement learning research. I believe I&amp;rsquo;m expected to add some
linguistic nuance and NLP fun to the mix. We&amp;rsquo;ll see what I come up with.&lt;/p&gt;

&lt;p&gt;Well, I&amp;rsquo;ve reached the present day, so this brings my whirlwind review of over a
year to a close. I certainly wouldn&amp;rsquo;t have managed to make this progress without
the support of my family and friends. With thanks to them and to my readers,
I&amp;rsquo;ll end the review here. Until next time.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;//ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=am2&amp;amp;o=1&amp;amp;a=0316069884&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I could point out in particular that our current memory models and representation choices are extremely limited compared to what is available in the human brain. Some (but not enough) work has been done on differential-speed learning models (comparable to e.g. complementary learning systems theory in neuroscience).&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Things move quickly in today&amp;rsquo;s world of AI research. Ilya is now at OpenAI, and Oriol works at Google DeepMind in London.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;very similar to e.g. &lt;a href=&quot;http://www.aclweb.org/anthology/P15-1033&quot;&gt;Chris Dyer&amp;rsquo;s work from ACL&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I think this is a good example of how &amp;ldquo;nonlinear&amp;rdquo; research work often feels. We were totally surprised by this finding, and it certainly changed the direction of the project. These sort of discontinuous jumps are often omitted in the terse final write-ups, where it generally pays off to appear as if you knew the whole thing from the start&amp;hellip;&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;And why eating vegan may also be reasonable, if you have more willpower than I do.&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Conditional generative adversarial networks for face generation</title>
      <link>http://foldl.me/2015/conditional-gans-face-generation/</link>
      <pubDate>Tue, 17 Mar 2015 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2015/conditional-gans-face-generation/</guid>
      <description>&lt;p&gt;This week marks the end of the winter quarter at Stanford, and with it ends the
class &lt;a href=&quot;http://cs231n.stanford.edu/index.html&quot;&gt;CS 231N: Convolutional Neural Networks for Visual Recognition&lt;/a&gt;. The
teaching team, led by &lt;a href=&quot;http://cs.stanford.edu/people/karpathy/&quot;&gt;Andrej Karpathy&lt;/a&gt; and &lt;a href=&quot;http://vision.stanford.edu/feifeili/&quot;&gt;Fei-Fei Li&lt;/a&gt;, did an
outstanding job putting together a course on neural networks and CNNs from
scratch.&lt;/p&gt;

&lt;p&gt;This post is a high-level overview of the project I submitted for the course,
titled &lt;em&gt;Conditional generative adversarial networks for convolutional face
generation&lt;/em&gt;. For those interested in a technical deep dive, check out
&lt;a href=&quot;/uploads/2015/conditional-gans-face-generation/paper.pdf&quot;&gt;my full paper&lt;/a&gt; and the &lt;a href=&quot;https://github.com/hans/adversarial&quot;&gt;code on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p style=&quot;text-align:center;font-size:88%&quot;&gt;(jump to: &lt;a href=&quot;#introduction&quot;&gt;introduction&lt;/a&gt;, &lt;a href=&quot;#model&quot;&gt;model&lt;/a&gt;)&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;a href=&quot;/uploads/2015/conditional-gans-face-generation/axis_incremental.png&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2015/conditional-gans-face-generation/axis_incremental.png&quot; alt=&quot;Example of faces sampled from the generative model. We draw random faces in the first row. In the second row we ask the model to &apos;age&apos; the faces, and in the third row we ask the model to add a smile.&quot; /&gt;&lt;/a&gt;&lt;figcaption&gt;Example of faces sampled from the generative model. We draw random faces in the first row. In the second row we ask the model to &apos;age&apos; the faces, and in the third row we ask the model to add a smile.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;A major task in machine learning is to learn &lt;a href=&quot;http://en.wikipedia.org/wiki/Probability_density_function&quot;&gt;&lt;em&gt;density models&lt;/em&gt;&lt;/a&gt; of
particular distributions. Ideally, we want to have a machine that accepts
arbitrary inputs and says either &amp;ldquo;Yes, that&amp;rsquo;s an &lt;em&gt;x&lt;/em&gt;,&amp;rdquo; or &amp;ldquo;No, that&amp;rsquo;s not an
&lt;em&gt;x&lt;/em&gt;.&amp;rdquo; We might name this density model mathematically as \(p(\mathbf{x})\),
where \(\mathbf{x}\) is the data we&amp;rsquo;re interested in modeling.&lt;/p&gt;

&lt;p&gt;In this project, we learn a density model of &lt;strong&gt;human faces&lt;/strong&gt;. Given some image
\(\mathbf{x}\), our precise task here is to determine whether \(\mathbf{x}\)
is a picture of a face or not. Every seeing human has such a model in her brain,
and uses it effortlessly every day. Like many tasks in computer vision and
artificial intelligence, what is ridiculously simple for humans turns out to be
notoriously difficult for computers to crack.&lt;/p&gt;

&lt;p&gt;There are two important extensions in this project:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We want to be able to &lt;em&gt;sample&lt;/em&gt; from the model &amp;mdash; to ask it to &amp;ldquo;imagine&amp;rdquo; new
faces that we haven&amp;rsquo;t ever showed it. (Again, this is something that humans
can do easily.)&lt;/li&gt;
  &lt;li&gt;We want the model to &lt;em&gt;condition&lt;/em&gt; on external data. This means that we should
be able to specify particular facial attributes as we sample. (Once again,
this is trivial for humans. Imagining an old white male with a mustache takes
little apparent cognitive effort.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Images are traditionally represented in digital form as large matrices of
numbers. Our density model in particular is expected to deal with images with
3072 different dimensions of variation.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; Our task, then, (as is the task in
much of &lt;a href=&quot;http://en.wikipedia.org/wiki/Unsupervised_learning&quot;&gt;unsupervised learning&lt;/a&gt;) is to find and exploit structure in the
data that help us reason efficiently and accurately about what is and isn&amp;rsquo;t a
face.&lt;/p&gt;

&lt;h3 id=&quot;the-project&quot;&gt;The project&lt;/h3&gt;

&lt;p&gt;We train on human face images like these:&lt;/p&gt;

&lt;p style=&quot;text-align:center&quot;&gt;
&lt;img style=&quot;width: 100px; display: inline;&quot; src=&quot;/uploads/2015/conditional-gans-face-generation/lfwcrop/Akbar_Al_Baker_0001.jpg&quot; /&gt;
&lt;img style=&quot;width: 100px; display: inline;&quot; src=&quot;/uploads/2015/conditional-gans-face-generation/lfwcrop/Catherine_Zeta-Jones_0004.jpg&quot; /&gt;
&lt;img style=&quot;width: 100px; display: inline;&quot; src=&quot;/uploads/2015/conditional-gans-face-generation/lfwcrop/Igor_Ivanov_0005.jpg&quot; /&gt;
&lt;img style=&quot;width: 100px; display: inline;&quot; src=&quot;/uploads/2015/conditional-gans-face-generation/lfwcrop/Milo_Maestrecampo_0001.jpg&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;The above images are samples from a dataset called
&lt;a href=&quot;http://vis-www.cs.umass.edu/lfw/&quot;&gt;Labeled Faces in the Wild&lt;/a&gt;, which contains about 13,000 images of random
people in uncontrollled settings.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;As mentioned before, we intend to build a density model in this project that is
&lt;em&gt;conditional&lt;/em&gt;. Rather than answering the question &amp;ldquo;Is this an &lt;em&gt;x&lt;/em&gt;,&amp;rdquo; we now
answer &amp;ldquo;Is this an &lt;em&gt;x&lt;/em&gt; given &lt;em&gt;y&lt;/em&gt;?&amp;rdquo; Formally, we build a density model
\(p(\mathbf{x} \mid \mathbf{y})\). \(\mathbf{y}\) is the &amp;ldquo;conditional
information&amp;rdquo; &amp;mdash; any external information that might cue us on what we should be
looking for in the provided data \(\mathbf{x}\).&lt;/p&gt;

&lt;p&gt;Concretely, in this project \(\mathbf{y}\) specifies facial attributes, such
as the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Age: baby, youth, middle-aged, senior, &amp;hellip;&lt;/li&gt;
  &lt;li&gt;Emotion: frowning, smiling, &amp;hellip;&lt;/li&gt;
  &lt;li&gt;Race: Asian, Indian, black, white, &amp;hellip;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Informally, when we ask about \(p(\mathbf{x} \mid \mathbf{y})\) in this
setting, we ask the question: If we&amp;rsquo;re looking for faces of type
\(\mathbf{y}\) (e.g. frowning people with mustaches), should we accept
\(\mathbf{x}\) as a good example or not?&lt;/p&gt;

&lt;h3 id=&quot;why-is-this-interesting&quot;&gt;Why is this interesting?&lt;/h3&gt;

&lt;p&gt;Good question! Recall that we&amp;rsquo;re learning a &lt;em&gt;generative&lt;/em&gt; model of faces while we
do this density modeling. The interesting implication is that we can &lt;strong&gt;sample
brand-new faces&lt;/strong&gt; from the learned density model. Like these ones:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2015/conditional-gans-face-generation/samples_cgan_fixed.png&quot; alt=&quot;&quot; /&gt;&lt;figcaption&gt;&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;The faces above are created by the model from scratch. These faces are entirely
new, and don&amp;rsquo;t resemble faces in the training data provided to the model. That&amp;rsquo;s
right &amp;mdash; once our model learns what a face looks like, it can &lt;strong&gt;learn to draw
new ones&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Hooked? Let&amp;rsquo;s get into the model.&lt;/p&gt;

&lt;h2 id=&quot;model&quot;&gt;Model&lt;/h2&gt;

&lt;p&gt;The model used in this project is an extension of the &lt;em&gt;generative adversarial
network&lt;/em&gt;, proposed by &lt;a href=&quot;http://www-etud.iro.umontreal.ca/~goodfeli/&quot;&gt;Ian Goodfellow&lt;/a&gt; and colleagues (see their &lt;a href=&quot;http://papers.nips.cc/paper/5423-generative-adversarial-nets&quot;&gt;paper&lt;/a&gt;
and associated &lt;a href=&quot;https://github.com/goodfeli/adversarial&quot;&gt;GitHub repo&lt;/a&gt;). Here&amp;rsquo;s the basic pitch:&lt;/p&gt;

&lt;p&gt;Suppose you want to build a generative model of some dataset with data points
called \(\mathbf{x}\). Let&amp;rsquo;s create two players and set them against each
other in an adversarial game:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A &lt;strong&gt;discriminator&lt;/strong&gt; &amp;ndash; call it &lt;em&gt;D&lt;/em&gt;. &lt;em&gt;D&lt;/em&gt;&amp;rsquo;s job is to accept an input
\(\mathbf{x}\) and determine whether the input came from the dataset, or
whether it was simply made up. &lt;em&gt;D&lt;/em&gt; wins points when he detects real
dataset values correctly, and loses points when he approves fake values or
denies real dataset values.&lt;/li&gt;
  &lt;li&gt;A &lt;strong&gt;generator&lt;/strong&gt; &amp;ndash; call it &lt;em&gt;G&lt;/em&gt;. &lt;em&gt;G&lt;/em&gt;&amp;rsquo;s job is to &lt;em&gt;make up&lt;/em&gt; new values
\(\mathbf{x}\). &lt;em&gt;G&lt;/em&gt; wins points when he tricks &lt;em&gt;D&lt;/em&gt; into thinking that his
made-up values are real.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We now let &lt;em&gt;D&lt;/em&gt; and &lt;em&gt;G&lt;/em&gt; take turns in the game, and teach both how to correct
their mistakes after each turn. Here&amp;rsquo;s what we expect to happen:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;em&gt;G&lt;/em&gt; begins as a completely stupid generator. He outputs some random noise in
a weak attempt to trick &lt;em&gt;D&lt;/em&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;D&lt;/em&gt; quickly learns to make a lazy distinction between &lt;em&gt;G&lt;/em&gt;&amp;rsquo;s random noise and
things that look like human faces. But &lt;em&gt;D&lt;/em&gt; trains only long enough to make a
basic distinction &amp;mdash; to look for a skin tone, for example.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;G&lt;/em&gt; learns from its mistakes and starts producing images with skin tone color
in them.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;D&lt;/em&gt; picks up on basic facial structure, and uses this to distinguish between
real face images and &lt;em&gt;G&lt;/em&gt;&amp;rsquo;s fake data.&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;G&lt;/em&gt; follows &lt;em&gt;D&lt;/em&gt;&amp;rsquo;s cue, and learns to draw face shapes (and perhaps some basic
features like noses and eye-holes).&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;D&lt;/em&gt; notices other features in the real face images that distinguish them from
&lt;em&gt;G&lt;/em&gt;&amp;rsquo;s data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This process continues on forever, with &lt;em&gt;D&lt;/em&gt; learning new discriminative features
and &lt;em&gt;G&lt;/em&gt; promptly learning to copy them.&lt;/p&gt;

&lt;p&gt;What we end up with (after several hours of training on GPUs) is a &lt;strong&gt;generative
model&lt;/strong&gt; &lt;em&gt;G&lt;/em&gt; which can make convincing images of human faces like the ones
presented earlier. Ideally, this model &lt;em&gt;G&lt;/em&gt; can also serve as a generative
density model as described earlier.&lt;/p&gt;

&lt;h3 id=&quot;conditional-data&quot;&gt;Conditional data&lt;/h3&gt;

&lt;p&gt;But there&amp;rsquo;s more! I mentioned earlier that our key extension is to add a
&lt;em&gt;conditioning&lt;/em&gt; feature. In the setting of face images, this means we can specify
particular facial attributes. Both the generator &lt;em&gt;G&lt;/em&gt; and the discriminator &lt;em&gt;D&lt;/em&gt;
learn to operate in certain &lt;em&gt;modes&lt;/em&gt;. For example, with a particular conditional
information input \(\mathbf{y}\), we might ask the generator &lt;em&gt;G&lt;/em&gt; to generate a
face with a smile, and likewise ask the discriminator &lt;em&gt;D&lt;/em&gt; whether a particular
image contains a face with a smile.&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;a href=&quot;/uploads/2015/conditional-gans-face-generation/axis_incremental.png&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/2015/conditional-gans-face-generation/axis_incremental.png&quot; alt=&quot;Demonstration of deterministic control of image samples. We tweak conditional information to first make the sampled faces age, then again to make them smile.&quot; /&gt;&lt;/a&gt;&lt;figcaption&gt;Demonstration of deterministic control of image samples. We tweak conditional information to first make the sampled faces age, then again to make them smile.&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;The final consequence of all of this is that we can directly control the output
of the generator &lt;em&gt;G&lt;/em&gt;. The image above shows a figure from the paper. We begin
with a random row of faces sampled from the model. (Note that these are not
faces from the training data.) We then tweak \(\mathbf{y}\) in two ways:
first, along an axis that corresponds to old age, and second, along an axis that
corresponds to smiling. You can see in the second and third rows that the
subjects first grow older and then put on a smile.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;ll end my brief overview here. There&amp;rsquo;s much more to say &amp;mdash; for example, on
training dynamics, on evaluation, and on the role of convolution in both &lt;em&gt;G&lt;/em&gt; and
&lt;em&gt;D&lt;/em&gt; &amp;mdash; and if you&amp;rsquo;ve reached this far in the blog post you would probably enjoy
reading &lt;a href=&quot;/uploads/2015/conditional-gans-face-generation/paper.pdf&quot;&gt;the paper&lt;/a&gt; in full.&lt;/p&gt;

&lt;p&gt;It is still early days for generative models, and I&amp;rsquo;m excited to explore both
new architectures and new possibilities in model applications. Watch this space
for more soon, and let me know if you&amp;rsquo;re working on similar ideas!&lt;/p&gt;

&lt;h3 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h3&gt;

&lt;p&gt;Thanks to my colleagues &lt;a href=&quot;http://keenon.github.io&quot;&gt;Keenon Werling&lt;/a&gt; and &lt;a href=&quot;http://cs.stanford.edu/~danqi&quot;&gt;Danqi Chen&lt;/a&gt;, who put up with
persistent requests for advice on the project throughout the quarter. None of
this would have happened without &lt;a href=&quot;http://cs.stanford.edu/people/karpathy/&quot;&gt;Andrej&amp;rsquo;s&lt;/a&gt; advice at the start of the
quarter, which set me off in the right direction.&lt;/p&gt;

&lt;p&gt;This project would have taken twice as long were it not for the developers of
&lt;a href=&quot;http://deeplearning.net/software/pylearn2/&quot;&gt;Pylearn2&lt;/a&gt; and &lt;a href=&quot;http://deeplearning.net/software/theano/&quot;&gt;Theano&lt;/a&gt;. This kind of machine learning framework
development is certain to accelerate the progress of the field &amp;mdash; exciting
stuff! Of course, &lt;a href=&quot;http://www-etud.iro.umontreal.ca/~goodfeli/&quot;&gt;Ian Goodfellow&lt;/a&gt; deserve credit for the original
generative adversarial net code, published with their NIPS &amp;lsquo;14 paper.&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
MathJax.Hub.Config({TeX: { equationNumbers: { autoNumber: &quot;AMS&quot; } } });
&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;3072 = 32 by 32 by 3. Our images are 32 by 32, with three RGB color channels.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;These images were cropped by &lt;a href=&quot;http://conradsanderson.id.au/lfwcrop/&quot;&gt;Conrad Sanderson&lt;/a&gt; at NICTA.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Machine learning and technical debt</title>
      <link>http://foldl.me/2015/machine-learning-technical-debt/</link>
      <pubDate>Mon, 12 Jan 2015 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2015/machine-learning-technical-debt/</guid>
      <description>&lt;p&gt;&lt;a href=&quot;http://research.google.com/pubs/archive/43146.pdf&quot;&gt;&lt;em&gt;Machine Learning: The High Interest Credit Card of Technical Debt&lt;/em&gt;&lt;/a&gt; is a
great non-technical paper from this past NIPS conference that is being passed
around online and off among people in my network. For me, the paper centers
around the claim that machine learning systems are fundamentally different from
traditional software in how they are developed and used:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Arguably the most important reason for using a machine learning system is
precisely that &lt;em&gt;the desired behavior cannot be effectively implemented in
software logic without dependency on external data.&lt;/em&gt; (p. 2, italics theirs)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Machine learning models are useful because they can encode complex world
knowledge that would be near-impossible to handle in a deterministic, rule-based
setting. But this precise distinction is what makes them enormously brittle in
the face of change. Repeated throughout the paper is the principle of &amp;ldquo;Changing
Anything Changes Everything&amp;rdquo; (CACE):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;To make this concrete, imagine we have a system that uses features
&lt;em&gt;x&lt;sub&gt;1&lt;/sub&gt;, &amp;hellip; x&lt;sub&gt;n&lt;/sub&gt;&lt;/em&gt; in a model. If we change the
input distribution of values in &lt;em&gt;x&lt;sub&gt;1&lt;/sub&gt;&lt;/em&gt;, the importance,
weights, or use of the remaining &lt;em&gt;n - 1&lt;/em&gt; features may all change
&amp;hellip; &lt;strong&gt;No inputs are ever really independent.&lt;/strong&gt; (p. 2)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;CACE can be a problem for all sorts of reasons, and if you&amp;rsquo;ve gotten this far in
my post I strongly suggest you read &lt;a href=&quot;http://research.google.com/pubs/archive/43146.pdf&quot;&gt;the full paper&lt;/a&gt; to understand the
implications of building and depending on software which can often be
fundamentally opaque and unstable by design.&lt;/p&gt;

&lt;p&gt;This is useful to me as a researcher in helping me to understand the divide
between research and practice, and to recognize which elements of my methods
might be incompatible with those of a practitioner.&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>A GloVe implementation in Python</title>
      <link>http://foldl.me/2014/glove-python/</link>
      <pubDate>Wed, 24 Sep 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/glove-python/</guid>
      <description>&lt;p&gt;&lt;a href=&quot;http://www-nlp.stanford.edu/projects/glove/&quot;&gt;GloVe (&lt;strong&gt;Glo&lt;/strong&gt;bal &lt;strong&gt;Ve&lt;/strong&gt;ctors for Word Representation)&lt;/a&gt; is a tool recently
released by Stanford NLP Group researchers &lt;a href=&quot;http://stanford.edu/~jpennin/&quot;&gt;Jeffrey Pennington&lt;/a&gt;,
&lt;a href=&quot;http://www.socher.org&quot;&gt;Richard Socher&lt;/a&gt;, and &lt;a href=&quot;http://nlp.stanford.edu/manning/&quot;&gt;Chris Manning&lt;/a&gt; for learning continuous-space vector
representations of words.&lt;/p&gt;

&lt;p style=&quot;text-align:center;font-size:88%&quot;&gt;(jump to: &lt;a href=&quot;#theory&quot;&gt;theory&lt;/a&gt;, &lt;a href=&quot;#implementation&quot;&gt;implementation&lt;/a&gt;)&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;These real-valued word vectors have proven to be useful for all sorts of natural
language processing tasks, including parsing,&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; named entity recognition,&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;
and (very recently!) machine translation.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s been shown (and widely shared by this point) that these word
vectors exhibit interesting &lt;strong&gt;semantic and syntactic regularities&lt;/strong&gt;. For
example, we find that claims like the following hold for the associated
word vectors:&lt;/p&gt;

&lt;p&gt;\[\begin{align*}\text{king} - \text{man} + \text{woman} &amp;\approx \text{queen} \\ \text{brought} - \text{bring} + \text{seek} &amp;\approx \text{sought}\end{align*}\]&lt;/p&gt;

&lt;p&gt;There&amp;rsquo;s quite a bit of buzz around the tools which build these word
vectors at the moment, so I figured it would be worth it to provide a
down-to-earth coverage of GloVe, one of the newest methods.&lt;/p&gt;

&lt;p&gt;The GloVe authors &lt;a href=&quot;http://www-nlp.stanford.edu/projects/glove/glove.pdf&quot;&gt;present some results&lt;/a&gt; which suggest that their
tool is competitive with Google&amp;rsquo;s popular &lt;a href=&quot;https://code.google.com/p/word2vec/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;word2vec&lt;/code&gt;&lt;/a&gt; package. In
order to better understand how GloVe works and to make available a nice
learning resource, I decided to port the open-source (yay!) but somewhat
difficult-to-read (no!) &lt;a href=&quot;http://www-nlp.stanford.edu/software/glove.tar.gz&quot;&gt;GloVe source code&lt;/a&gt; from C to Python.&lt;/p&gt;

&lt;p&gt;In this post I&amp;rsquo;ll give an explanation by intuition of how the GloVe method
works&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; and then provide a quick overview of the implementation in Python. You
can find the complete Python code (just 187 SLOC, including command-line
argument processing, IO, etc.) in &lt;a href=&quot;http://github.com/hans/glove.py&quot;&gt;the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;glove.py&lt;/code&gt; GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A quick disclaimer before we begin: I wrote this code for tutorial purposes. It
is nowhere near production-ready in terms of efficiency. If you would like to
parallelize and optimize it as an exercise, be my guest &amp;mdash; just be sure to
share the results!&lt;/p&gt;

&lt;h2 id=&quot;theory&quot;&gt;Theory&lt;/h2&gt;

&lt;p&gt;The GloVe model learns word vectors by examining &lt;em&gt;word co-occurrences&lt;/em&gt; within a
text corpus. Before we train the actual model, we need to construct a
&lt;em&gt;co-occurrence matrix&lt;/em&gt; \(X\), where a cell \(X_{ij}\) is a &amp;ldquo;strength&amp;rdquo; which
represents how often the word \(i\) appears in the context of the word
\(j\). We run through our corpus just once to build the matrix \(X\), and
from then on use this co-occurrence data in place of the actual corpus. We will
construct our model based only on the values collected in \(X\).&lt;/p&gt;

&lt;p&gt;Once we&amp;rsquo;ve prepared \(X\), our task is to decide vector values in continuous
space for each word we observe in the corpus. We will produce vectors with a
soft constraint that for each word pair of word \(i\) and word \(j\),&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;\[\begin{equation}\vec{w}_i^T \vec{w}_j + b_i + b_j = \log X_{ij}.\end{equation}\]&lt;/p&gt;

&lt;p&gt;where \(b_i\) and \(b_j\) are scalar bias terms associated with words
\(i\) and \(j\), respectively. Intuitively speaking, we want to build word
vectors that retain some useful information about how every pair of words
\(i\) and \(j\) co-occur.&lt;/p&gt;

&lt;p&gt;We&amp;rsquo;ll do this by minimizing an objective function \(J\), which evaluates the
sum of all squared errors based on the above equation, weighted with a function
\(f\):&lt;/p&gt;

&lt;p&gt;\[\begin{equation}J = \sum_{i=1}^V \sum_{j=1}^V \; f\left(X_{ij}\right) \left( \vec{w}_i^T \vec{w}_j + b_i + b_j - \log X_{ij} \right)^2 \end{equation}\]&lt;/p&gt;

&lt;p&gt;We choose an \(f\) that helps prevents common word pairs (i.e., those with
large \(X_{ij}\) values) from skewing our objective too much:&lt;/p&gt;

&lt;p&gt;\[\begin{equation}f\left(X_{ij}\right) = \left\{ \begin{array}{cl}\left(\frac{X_{ij}}{x_{\text{max}}}\right)^\alpha &amp; \text{if } X_{ij} &lt; x_{\text{max}} \\ 1 &amp; \text{otherwise.} \end{array}\right. \end{equation} \]&lt;/p&gt;

&lt;p&gt;When we encounter extremely common word pairs (where \(X_{ij} &gt;
x_{\text{max}}\)) this function will cut off its normal output and simply
return \(1\). For all other word pairs, we return some weight in the range
\((0, 1)\), where the distribution of weights in this range is decided by
\(\alpha\).&lt;/p&gt;

&lt;h2 id=&quot;implementation&quot;&gt;Implementation&lt;/h2&gt;

&lt;p&gt;Now for the code! I&amp;rsquo;ll skip the boring parts which do things like model saving
and argument parsing, and focus on the three most meaty functions in the code:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build_cooccur&lt;/code&gt; accepts a corpus and yields a list of
co-occurrence blobs (the \(X_{ij}\) values). It calculates
co-occurrences by moving a &lt;em&gt;sliding n-gram window&lt;/em&gt; over each
sentence in the corpus.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;train_glove&lt;/code&gt;, which prepares the parameters of the model and manages
training at a high level, and&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;run_iter&lt;/code&gt;, which runs a single parameter update step.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First, our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build_cooccur&lt;/code&gt; function accepts a vocabulary (mapping words to
integer word IDs), a corpus (a simple iterator over sentences), and some
optional parameters: a context window size and a minimum count (used to
drop rare word co-occurrence pairs). We&amp;rsquo;ll start by building a sparse
matrix for collecting cooccurrences \(X_{ij}\) and some simple helper
data.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;build_cooccur&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;corpus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;id2word&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;dict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iteritems&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Collect cooccurrences internally as a sparse matrix for
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# passable indexing speed; we&apos;ll convert into a list later
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;cooccurrences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sparse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lil_matrix&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                                      &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;For each line in the corpus, we&amp;rsquo;ll conjure up a sequence of word IDs:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;corpus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;tokens&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strip&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;token_ids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokens&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now for each word ID \(i\) in the sentence, we&amp;rsquo;ll extract a window of context
words to the left of the word.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center_id&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;token_ids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;# Collect all word IDs in left window of center word
&lt;/span&gt;            &lt;span class=&quot;n&quot;&gt;context_ids&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;token_ids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center_i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;window_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                                    &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;contexts_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context_ids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;For each word ID \(j\) in the context, we&amp;rsquo;ll add on weight to the
cell \(X_{ij}\). The increment for the word pair
is inversely related to the distance between the two words in
question. This means word instances which appear next to each other
see higher \(X_{ij}\) increments than word
instances which appear with many words in between.&lt;/p&gt;

&lt;p&gt;One last technical point: we build this matrix \(X_{ij}\)
&lt;em&gt;symmetrically&lt;/em&gt;. This means that we treat word co-occurrences where the
context word is to the left of the main word exactly the same as
co-occurrences where the context word is to the right of the main word.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;            &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left_i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left_id&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;enumerate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;context_ids&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
                &lt;span class=&quot;c1&quot;&gt;# Distance from center word
&lt;/span&gt;                &lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;contexts_len&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left_i&lt;/span&gt;

                &lt;span class=&quot;c1&quot;&gt;# Weight by inverse of distance between words
&lt;/span&gt;                &lt;span class=&quot;n&quot;&gt;increment&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

                &lt;span class=&quot;c1&quot;&gt;# Build co-occurrence matrix symmetrically (pretend
&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;# we are calculating right contexts as well)
&lt;/span&gt;                &lt;span class=&quot;n&quot;&gt;cooccurrences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;center_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;left_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;increment&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;cooccurrences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;left_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;center_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;increment&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That&amp;rsquo;s about it &amp;mdash; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build_cooccur&lt;/code&gt; finishes with
&lt;a href=&quot;https://github.com/hans/glove.py/blob/582549ddeeeb445cc676615f64e318aba1f46295/glove.py#L171-182&quot;&gt;a bit more code to yield co-occurrence pairs from this sparse matrix&lt;/a&gt;, but
I won&amp;rsquo;t bother to show it here.&lt;/p&gt;

&lt;p&gt;Next, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;train_glove&lt;/code&gt; initializes the model parameters given the fully
constructed co-occurrence data. We expect the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vocab&lt;/code&gt; object as
before as a first parameter. The second parameter, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cooccurrences&lt;/code&gt;,
is a co-occurrence iterator produced in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;build_cooccur&lt;/code&gt;, which
yields co-occurrence tuples of the form &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(main_word_id,
context_word_id, x_ij)&lt;/code&gt;, where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;x_ij&lt;/code&gt; is an \(X_{ij}\)
co-occurrence value as introduced above.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_glove&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cooccurrences&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vector_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We next prepare the primary model parameters: the word vector matrix \(W\) and
a collection of bias scalars. Note that our word matrix has twice as many rows
as the number of words in the corpus. We will find out why later in describing
the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;run_iter&lt;/code&gt; function.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;len&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Word vector matrix. This matrix is (2V) * d, where N is the
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# size of the corpus vocabulary and d is the dimensionality of
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# the word vectors. All elements are initialized randomly in the
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# range (-0.5, 0.5]. We build two word vectors for each word:
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# one for the word as the main (center) word and one for the
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# word as a context word.
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# It is up to the client to decide what to do with the resulting
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# two vectors. Pennington et al. (2014) suggest adding or
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# averaging the two for each word, or discarding the context
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# vectors.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;W&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vector_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
         &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vector_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Bias terms, each associated with a single vector. An array of
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# size $2V$, initialized randomly in the range (-0.5, 0.5].
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;biases&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
              &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vector_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We will be training using adaptive gradient descent (AdaGrad),&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; and so we&amp;rsquo;ll
also need to initialize helper matrices for \(W\) and the bias vector which
track gradient histories. Note that these all are initialized as blocks of ones.
By starting with every gradient history equal to one, our first training step in
AdaGrad will simply use the global learning rate for each example. (See footnote
7&lt;sup id=&quot;fnref:7:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; to work this out from the AdaGrad definition.)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# Training is done via adaptive gradient descent (AdaGrad). To
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# make this work we need to store the sum of squares of all
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# previous gradients.
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# Like `W`, this matrix is (2V) * d.
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# Initialize all squared gradient sums to 1 so that our initial
&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# adaptive learning rate is simply the global learning rate.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;gradient_squared&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vector_size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
                               &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Sum of squared gradients for the bias terms.
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;gradient_squared_biases&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ones&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab_size&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                      &lt;span class=&quot;n&quot;&gt;dtype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;float64&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Next, we begin training by iteratively calling the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;run_iter&lt;/code&gt; function.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iterations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;run_iter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vocab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;kwargs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;run_iter&lt;/code&gt; accepts this pre-fetched data and begins by shuffling it and
establishing a global cost for the iteration:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;global_cost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;# Iterate over data in random order
&lt;/span&gt;    &lt;span class=&quot;n&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now for every co-occurrence data tuple, we compute the weighted cost as
described in the above theory section. Each tuple has the following elements:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v_main&lt;/code&gt;: the word vector for the main word in the co-occurrence&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;v_context&lt;/code&gt;: the word vector for the context word in the co-occurrence&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b_main&lt;/code&gt;: bias scalar for main word&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b_context&lt;/code&gt;: bias scalar for context word&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gradsq_W_main&lt;/code&gt;: a vector storing the squared gradient history for the main
word vector (for use in the AdaGrad update)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gradsq_W_context&lt;/code&gt;: a vector gradient history for the context word vector&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gradsq_b_main&lt;/code&gt;: a scalar gradient history for the main word bias&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gradsq_b_context&lt;/code&gt;: a scalar gradient history for the context word bias&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cooccurrence&lt;/code&gt;: the \(X_{ij}\) value for the co-occurrence pair, described
at length above&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We retain an intermediate &amp;ldquo;inner&amp;rdquo; cost (not squared or weighted) for
use in calculating the gradient in the next section.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gradsq_W_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;gradsq_W_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gradsq_b_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;gradsq_b_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
         &lt;span class=&quot;n&quot;&gt;cooccurrence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Calculate weight function $f(X_{ij})$
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cooccurrence&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alpha&lt;/span&gt;
                  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cooccurrence&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x_max&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Compute inner component of cost function, which is used in
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# both overall cost calculation and in gradient calculation
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#   $$ J&apos; = w_i^Tw_j + b_i + b_j - log(X_{ij}) $$
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                      &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                      &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cooccurrence&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Compute cost
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#   $$ J = f(X_{ij}) (J&apos;)^2 $$
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;cost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Add weighted cost to the global cost tracker
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;global_cost&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cost&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With the cost calculated, we now need to compute gradients. From our
original cost function \(J\) we derive gradients with respect to the
relevant parameters \(\vec w_i\), \(\vec w_j\), \(b_i\), and \(b_j\).
(Note that since \(f(X_{ij})\) doesn&amp;rsquo;t depend on any of these
parameters, the derivations are quite simple.) Below we use the operator
\(\odot\) to denote elementwise vector multiplication.&lt;/p&gt;

&lt;p&gt;\[\begin{align*}J &amp;= \sum_{i=1}^V \sum_{j=1}^V \; f\left(X_{ij}\right) \left( \vec{w}_i^T \vec{w}_j + b_i + b_j - \log X_{ij} \right)^2 \\ \nabla_{\vec{w}_i} J &amp;= \sum_{j=1}^V f\left(X_{ij}\right) \vec{w}_j \odot \left( \vec{w}_i^T \vec{w}_j + b_i + b_j - \log X_{ij}\right) \\ \frac{\partial J}{\partial b_i} &amp;= \sum_{j=1}^V f\left(X_{ij}\right) \left(\vec w_i^T \vec w_j + b_i + b_j - \log X_{ij}\right) \end{align*} \]&lt;/p&gt;

&lt;p&gt;Now let&amp;rsquo;s put that in code! We use the earlier-calculated intermediate
value &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cost_inner&lt;/code&gt;, which stores the value being squared and weighted in
the full cost function.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# Compute gradients for word vector terms.
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;#
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# NB: `v_main` is only a view into `W` (not a copy), so our
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# modifications here will affect the global weight matrix;
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# likewise for v_context, biases, etc.
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;grad_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v_context&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;grad_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v_main&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Compute gradients for bias terms
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;grad_bias_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;grad_bias_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;weight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cost_inner&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Finally, we update weights with AdaGrad&lt;sup id=&quot;fnref:7:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; and add the calculated
gradients to the gradient history variables.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# Now perform adaptive updates
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;v_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_main&lt;/span&gt;
                   &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gradsq_W_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;v_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_context&lt;/span&gt;
                      &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gradsq_W_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;n&quot;&gt;b_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_bias_main&lt;/span&gt;
                   &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gradsq_b_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;b_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;learning_rate&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_bias_context&lt;/span&gt;
                      &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gradsq_b_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

        &lt;span class=&quot;c1&quot;&gt;# Update squared gradient sums
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;gradsq_W_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grad_main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;gradsq_W_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;square&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grad_context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;gradsq_b_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_bias_main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;gradsq_b_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;grad_bias_context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;**&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After we&amp;rsquo;ve processed all data for the iteration, we return the global cost and relax for a while.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# -- continued --
&lt;/span&gt;    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;global_cost&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;hr /&gt;

&lt;p&gt;That&amp;rsquo;s it for code! If you&amp;rsquo;d like to see word vectors produced by this Python
code in action, check out &lt;a href=&quot;http://nbviewer.ipython.org/github/hans/glove.py/blob/master/demo/glove.py%20exploration.ipynb&quot;&gt;this IPython notebook&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you found this all fascinating, I highly recommend digging into the
&lt;a href=&quot;http://www-nlp.stanford.edu/projects/glove/&quot;&gt;official GloVe documentation&lt;/a&gt;, especially the &lt;a href=&quot;http://www-nlp.stanford.edu/projects/glove/glove.pdf&quot;&gt;original paper&lt;/a&gt;, which is
due to be published at &lt;a href=&quot;http://emnlp2014.org&quot;&gt;this year&amp;rsquo;s EMNLP conference&lt;/a&gt;. A quality general
coverage of word representations and their uses is Peter Turney and Patrick
Pantel&amp;rsquo;s paper,
&lt;a href=&quot;http://www.aaai.org/Papers/JAIR/Vol37/JAIR-3705.pdf&quot;&gt;&amp;ldquo;From frequency to meaning: Vector space models of semantics.&amp;rdquo;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Distributed word representations such as those which GloVe produces are really
revolutionizing natural language processing. I&amp;rsquo;m excited to see what happens as
more and more tools of this sort are disseminated outside of academia and put to
real-world use.&lt;/p&gt;

&lt;p&gt;If you&amp;rsquo;re making use of GloVe or similar tools in your own projects, let me
know. Until next time, happy coding!&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
MathJax.Hub.Config({TeX: { equationNumbers: { autoNumber: &quot;AMS&quot; } } });
&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Richard Socher et al., &lt;a href=&quot;http://www.aclweb.org/anthology/P13-1045&quot;&gt;&amp;ldquo;Parsing with Compositional Vector Grammars,&amp;rdquo;&lt;/a&gt; in &lt;em&gt;Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)&lt;/em&gt; (Sofia, Bulgaria: Association for Computational Linguistics, 2013), 455&amp;ndash;65.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Joseph Turian, Lev Ratinov, and Yoshua Bengio, &lt;a href=&quot;http://www.aclweb.org/anthology/P10-1040&quot;&gt;&amp;ldquo;Word Representations: A Simple and General Method for Semi-Supervised Learning,&amp;rdquo;&lt;/a&gt; in &lt;em&gt;Proceedings of the 48th Annual Meeting of the Association for Computational Linguistics&lt;/em&gt; (Association for Computational Linguistics, 2010), 384&amp;ndash;94.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio, &lt;a href=&quot;http://arxiv.org/abs/1409.0473.&quot;&gt;&amp;ldquo;Neural Machine Translation by Jointly Learning to Align and Translate,&amp;rdquo;&lt;/a&gt; &lt;em&gt;arXiv:1409.0473 [cs, Stat]&lt;/em&gt;, September 1, 2014.&lt;br /&gt;&lt;br /&gt;This is what I&amp;rsquo;m working on right now&amp;mdash;if this sounds interesting to you, get in touch!&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;There is still quite a bit of debate, however, over the best way to construct these vectors. The popular tool &lt;a href=&quot;https://code.google.com/p/word2vec/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;word2vec&lt;/code&gt;&lt;/a&gt;, which has seen wide use and wide success in the past year, builds so-called &lt;em&gt;neural&lt;/em&gt; word embeddings, whereas GloVe and others construct word vectors based on &lt;em&gt;counts&lt;/em&gt;. I won&amp;rsquo;t get into the controversy in this post, but feel free to read up and pick a side.&lt;br /&gt;&lt;br /&gt;See e.g. Marco Baroni, Georgiana Dinu, and Germán Kruszewski, &lt;a href=&quot;http://www.aclweb.org/anthology/P14-1023&quot;&gt;&amp;ldquo;Don&amp;rsquo;t Count, Predict! A Systematic Comparison of Context-Counting vs. Context-Predicting Semantic Vectors,&amp;rdquo;&lt;/a&gt; in &lt;em&gt;Proceedings of the 52nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)&lt;/em&gt; (Baltimore, Maryland: Association for Computational Linguistics, 2014), 238&amp;ndash;47; Omer Levy and Yoav Goldberg, &lt;a href=&quot;http://www.aclweb.org/anthology/W14-1618&quot;&gt;&amp;ldquo;Linguistic Regularities in Sparse and Explicit Word Representations,&amp;rdquo;&lt;/a&gt; in &lt;em&gt;Proceedings of the Eighteenth Conference on Computational Natural Language Learning&lt;/em&gt; (Ann Arbor, Michigan: Association for Computational Linguistics, 2014), 171&amp;ndash;80.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I hope this post is a useful supplement to the &lt;a href=&quot;http://www-nlp.stanford.edu/projects/glove/glove.pdf&quot;&gt;original paper&lt;/a&gt;. If you have the time, read the original too &amp;mdash; it has a lot of useful and well-stated insights about the task of word representations in general.&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I am skipping over a lot of interesting / beautiful details here &amp;mdash; please read the paper if you are interested in more than the implementation!&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;AdaGrad is a modified form of stochastic gradient descent which attempts to guide learning in the proper direction by weighting rarely occurring features more often than those that always fire. Briefly, for a gradient component \(g_{t,i}\) at training step \(t\), AdaGrad defines the gradient descent update to be \[x_{t+1, i} = x_{t, i} - \dfrac{\eta}{\sqrt{\sum_{t&apos;=1}^{t-1} g_{t&apos;, i}^2}} g_{t, i}.\] For a more thorough coverage see &lt;a href=&quot;http://www.ark.cs.cmu.edu/cdyer/adagrad.pdf&quot;&gt;this AdaGrad tutorial&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;#fnref:7:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&amp;nbsp;&lt;a href=&quot;#fnref:7:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Summarizing Spanish with Stanford CoreNLP</title>
      <link>http://foldl.me/2014/spanish-summarizer-corenlp/</link>
      <pubDate>Sat, 13 Sep 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/spanish-summarizer-corenlp/</guid>
      <description>&lt;p&gt;After a summer replete with feature-engineering and corpus processing, the
Stanford NLP Group has just released &lt;a href=&quot;http://nlp.stanford.edu/software/corenlp.shtml&quot;&gt;CoreNLP 3.4.1&lt;/a&gt;, which includes support
for Spanish-language text. In this post I&amp;rsquo;ll show how to make use of these tools
to make a dead-simple document summarizer.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Our end goal will be to take a news article of significant length and reduce it
to its two or three most important points. We&amp;rsquo;ll run through each sentence and
assign it a score based on two factors:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;tf&amp;ndash;idf weights.&lt;/strong&gt; The &lt;a href=&quot;http://en.wikipedia.org/wiki/Tf%E2%80%93idf&quot;&gt;tf&amp;ndash;idf metric&lt;/a&gt; is a formula which explains how
important a particular word is in the context of its containing document.
We&amp;rsquo;ll calculate the sum of tf&amp;ndash;idf scores for all nouns in each sentence, and
consider those sentences with the greatest sums to be the most important.&lt;/p&gt;

    &lt;p&gt;The tf&amp;ndash;idf metric is the product of two factors:&lt;/p&gt;

\[\text{tf–idf}_{t, d} = tf_{t, d} \; idf_t\]

    &lt;p&gt;The first is a &lt;em&gt;term frequency&lt;/em&gt; factor, which tracks how often the word
appears in its containing document. It is some scaled version of the number
of times the word appears in the given document. We&amp;rsquo;ll use a logarithm form
here:&lt;/p&gt;

\[\text{tf}_{t, d} = \log(1 + \text{count of $t$ in $d$})\]

    &lt;p&gt;The second is an &lt;em&gt;inverse document frequency&lt;/em&gt; (IDF) factor. This measures the
informativeness of the word based on how often it appears in total across an
entire corpus. The inverse document frequency factor is a logarithm as well:&lt;/p&gt;

\[\text{idf}_{t} = \log\left( \frac{\text{count of total documents}}{\text{count of documents containing $t$}} \right)\]

    &lt;p&gt;Note that IDF values will be exactly 0 for common words like &amp;ldquo;the,&amp;rdquo; as they
are likely to appear in every document in the corpus. Meaningful and less
common words like &amp;ldquo;transmogrify&amp;rdquo; and &amp;ldquo;incinerate&amp;rdquo; will yield higher IDF
values.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Positional weight.&lt;/strong&gt; For news articles, another easy measure of the
importance of a sentence is its position in the document: important sentences
tend to appear before less crucial ones. We can model this by scaling our
original tf&amp;ndash;idf score by the index of the sentence within the document.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With theory over, let&amp;rsquo;s get to the code. I&amp;rsquo;m going to walk through a Java class
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Summarizer&lt;/code&gt;, the full source code of which is available in a &lt;a href=&quot;https://github.com/hans/corenlp-summarizer&quot;&gt;GitHub repo&lt;/a&gt;.
Our only dependency here is &lt;a href=&quot;http://nlp.stanford.edu/software/corenlp.shtml&quot;&gt;Stanford CoreNLP 3.4.1&lt;/a&gt;. We begin by
instantiating the CoreNLP pipeline statically.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;nc&quot;&gt;Properties&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;props&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Properties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// We need part-of-speech annotations (and tokenization /&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// sentence-splitting, which are required for POS tagging)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;annotators&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;tokenize,ssplit,pos&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Tokenize using Spanish settings&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;tokenize.language&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;es&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Load the Spanish POS tagger model (rather than the&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// default English model)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;setProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;pos.model&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;s&quot;&gt;&quot;edu/stanford/nlp/models/pos-tagger/spanish/spanish-distsim.tagger&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;pipeline&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StanfordCoreNLP&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As we discussed earlier, the summarizer depends upon document frequency data,
which must be precalculated from a corpus of Spanish text. In the constructor of
the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Summarizer&lt;/code&gt;, we receive a prebuilt &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dfCounter&lt;/code&gt; and determine the total
number of documents in the training corpus.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Summarizer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dfCounter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;dfCounter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dfCounter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;numDocuments&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dfCounter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;__all__&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Our main routine, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;summarize&lt;/code&gt;, accepts a document string and a number of
sentences to return.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;summarize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numSentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Process the document with the constructed pipeline; get&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// a list of tokenized sentences&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;Annotation&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;annotation&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pipeline&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;annotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;CoreAnnotations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;SentencesAnnotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Collect raw term frequencies from this document (method&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// not shown here)&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getTermFrequencies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Rank sentences of the document by descending importance&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rankSentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Build a single string with our results&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;StringBuilder&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StringBuilder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numSentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot; &quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The method &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rankSentences&lt;/code&gt; sorts the provided sentence collection using a custom
comparator &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SentenceComparator&lt;/code&gt;, which contains the bulk of our actual logic for
sentence importance. Here&amp;rsquo;s the framework:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rankSentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt;
                                    &lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;Collections&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sort&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SentenceComparator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tfs&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentences&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SentenceComparator&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;implements&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Comparator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;termFrequencies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SentenceComparator&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;termFrequencies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;termFrequencies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;termFrequencies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;nd&quot;&gt;@Override&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;compare&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;o2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;o2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;o1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;cm&quot;&gt;/**
   * Compute sentence score (higher is better).
   */&lt;/span&gt;
  &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;score&lt;/code&gt; and the following methods are the meat of the entire code. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;score&lt;/code&gt;
accepts a sentence and returns a floating-point value indicating the sentence&amp;rsquo;s
importance.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Get the sum of tf-idf weights for the nouns in this&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// sentence&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfIdf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfIDFWeights&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Scale weight based on the position of this sentence in&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// its containing document&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreAnnotations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;SentenceIndexAnnotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indexWeight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;5.0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Return a scaled tf-idf weight. Note that we multiply all scores&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// by 100 to avoid the case where two sentences with 0 &amp;lt; |score| &amp;lt; 1&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// being marked as &quot;equal&quot; by the comparator function&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;indexWeight&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfIdf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;score&lt;/code&gt; calls a method &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tfIDFWeights&lt;/code&gt;, which determines the total tf&amp;ndash;idf scores
for all the nouns in the given sentence:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-java&quot; data-lang=&quot;java&quot;&gt;&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tfIDFWeights&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;nc&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreLabel&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokens&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sentence&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreAnnotations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TokensAnnotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreLabel&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cl&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tokens&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreAnnotations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;PartOfSpeechAnnotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// Nouns in the Spanish POS tagset begin with the letter&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// &quot;n.&quot;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;isNoun&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pos&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;startsWith&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;n&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isNoun&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;CoreAnnotations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;TextAnnotation&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

      &lt;span class=&quot;c1&quot;&gt;// Calculate the tf-idf weight for this particular&lt;/span&gt;
      &lt;span class=&quot;c1&quot;&gt;// word, and add it to the sentence total&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;total&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tfIDFWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;total&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
 * Calculate the tf-idf weight for a single word.
 */&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;tfIDFWeight&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// Skip unknown words&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dfCounter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Scale the raw term frequency (stored in an instance&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// variable of the comparator)&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;termFrequencies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// Scale the document frequency (pre-built with a Spanish&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;// corpus)&lt;/span&gt;
  &lt;span class=&quot;kt&quot;&gt;double&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;numDocuments&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;
      &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dfCounter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getCount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)));&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idf&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That&amp;rsquo;s it for the code. You can see the entire class in
&lt;a href=&quot;https://github.com/hans/corenlp-summarizer/blob/master/src/me/foldl/corenlp_summarizer/Summarizer.java&quot;&gt;this public GitHub repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ll end with a quick unscientific test of the code. I built document-frequency
counts (using a helper &lt;a href=&quot;https://github.com/hans/corenlp-summarizer/blob/master/src/me/foldl/corenlp_summarizer/DocumentFrequencyCounter.java&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentFrequencyCounter&lt;/code&gt; class&lt;/a&gt;) from the
&lt;a href=&quot;https://catalog.ldc.upenn.edu/LDC2011T12&quot;&gt;Spanish Gigaword&lt;/a&gt;, which contains about 1.5 billion words of Spanish. It
took several days (running on a 16-core machine) to POS-tag each sentence and
collect the nouns in a global counter.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;I next tested with a few recent Spanish news articles, requesting a two-sentence
summary of each. Here&amp;rsquo;s the output summary of
&lt;a href=&quot;http://www.rtve.es/noticias/20140903/equipo-cientificos-definen-supercumulo-galaxias-esta-via-lactea/1005222.shtml&quot;&gt;an article on the Laniakea supercluster&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Las galaxias no están distribuidas al azar en todo el universo, sino que se
encuentran en grupos, al igual que nuestro propio Grupo Local, que contiene
docenas de galaxias, y en cúmulos masivos, que poseen cientos de galaxias,
todas interconectadas en una red de filamentos en la que se ensartan como
perlas. Estos expertos han bautizado al supercúmulo con el nombre de
&amp;lsquo;Laniakea&amp;rsquo;, que significa &amp;ldquo;cielo inmenso&amp;rdquo; en hawaiano, como informan en un
artículo de la edición de este jueves de Nature. Una galaxia entre dos
estructuras de este tipo puede quedar atrapada en un tira y afloja
gravitacional en el que el equilibrio de las fuerzas gravitacionales que
rodean las estructuras a gran escala determina el movimiento de la galaxia.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And &lt;a href=&quot;http://www.elmundo.es/economia/2014/09/03/54074ed5268e3ec7168b4595.html&quot;&gt;another on Argentinian debt&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;La inclusión de la capital de Francia como nueva jurisdicción para hacer
efectivos los desembolsos a los acreedores ha sido una iniciativa del bloque
&amp;lsquo;cristinista&amp;rsquo; para ganar los votos de algunos legisladores opositores. Por
ejemplo, los legisladores del Frente Renovador, también peronista pero no
&amp;lsquo;cristinista&amp;rsquo;, según la prensa, acordarían con la inclusión de París, por
considerar que allí los pagos estarían a salvo de los fondos especulativos o
&amp;lsquo;buitre&amp;rsquo;. Con esta iniciativa el gobierno de la presidenta Cristina Fernández,
viuda de Kirchner, pretende esquivar a la justicia de los Estados Unidos y a
los fondos especulativos o &amp;lsquo;buitre&amp;rsquo; que ganaron a Argentina un juicio y
colocaron al país en &amp;lsquo;default&amp;rsquo; parcial.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I hope this code serves as a useful example for using basic CoreNLP tools in
Spanish. Feel free to follow up below in the comments or by email!&lt;/p&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I won&amp;rsquo;t claim this will always give fantastic summarizations, but it&amp;rsquo;s definitely a quick and easy-to-grasp algorithm.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;If you are interested in how this helper data is constructed, see the &lt;a href=&quot;https://github.com/hans/corenlp-summarizer/blob/master/src/me/foldl/corenlp_summarizer/DocumentFrequencyCounter.java&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentFrequencyCounter&lt;/code&gt; class&lt;/a&gt; in the GitHub repo.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This probably could have been optimized quite a bit down to the level of hours &amp;ndash; but when you&amp;rsquo;ve got the time&amp;hellip;&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>On Metacademy and knowledge graphs</title>
      <link>http://foldl.me/2014/metacademy/</link>
      <pubDate>Thu, 14 Aug 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/metacademy/</guid>
      <description>&lt;p&gt;If there&amp;rsquo;s one complaint I have about starting work as a researcher, it&amp;rsquo;s about
information glut.&lt;/p&gt;

&lt;p&gt;Sure&amp;mdash;the work is scintillating and intellectually stimulating. But it is easy
to be overwhelmed by the sheer volume of knowledge lying ahead, and struggle in
the task of organizing your own plan for learning. While the acronyms and
extended noun phrases that your colleagues drop all sound darn interesting, it&amp;rsquo;s
often unclear how to best acquire all the requisite knowledge you&amp;rsquo;re lacking.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href=&quot;http://metacademy.org&quot;&gt;Metacademy&lt;/a&gt;, an open-source project for creating
&lt;a href=&quot;http://www.metacademy.org/about&quot;&gt;&amp;ldquo;dependency graphs of knowledge.&amp;rdquo;&lt;/a&gt; The site consists of an enormous list of
&lt;em&gt;concepts,&lt;/em&gt; all linked together in a single dependency graph. Each concept
consists of a list of prerequisite concepts and a collection of resources for
learning the concept itself. A picture is worth many words of explanation:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;a href=&quot;http://www.metacademy.org/graphs/concepts/sequential_monte_carlo#focus=sequential_monte_carlo&amp;amp;mode=explore&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/metacademy.png&quot; alt=&quot;Metacademy concept graph&quot; /&gt;&lt;/a&gt;&lt;figcaption&gt;Metacademy concept graph&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;This is an exciting way to think about knowledge acquisition, I think. The graph
itself reminds me of &amp;ldquo;skill trees&amp;rdquo; in MMORPGs or of the &amp;ldquo;technology tree&amp;rdquo; in the
game &lt;a href=&quot;http://en.wikipedia.org/wiki/Civilization_(video_game)&quot;&gt;Civilization&lt;/a&gt;:&lt;/p&gt;

&lt;figure class=&quot;image&quot;&gt;&lt;img src=&quot;http://www.foldl.me//uploads/metacademy-civilization.png&quot; alt=&quot;Civilization technology tree&quot; /&gt;&lt;figcaption&gt;Civilization technology tree&lt;/figcaption&gt;&lt;/figure&gt;

&lt;p&gt;With this kind of ontology defined, we can now think of learning as a slow and
deliberate traversal of a massive graph. I&amp;rsquo;ve been browsing and tracking my
learning on Metacademy for some time now, and I think it&amp;rsquo;s a useful way to
organize my knowledge.&lt;/p&gt;

&lt;h3 id=&quot;the-future&quot;&gt;The future&lt;/h3&gt;

&lt;p&gt;This is just the start for Metacademy. While the site content currently centers
around machine learning and artificial intelligence topics,&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; this won&amp;rsquo;t be
the case for much longer. The plan from the start has been to
&lt;a href=&quot;http://www.metacademy.org/about&quot;&gt;expand to cover all sorts of knowledge&lt;/a&gt;, from music to mathematics.&lt;/p&gt;

&lt;p&gt;In hopes of expanding in this way, the Metacademy founders have just begun a
private beta of a visual knowledge graph editor. This is good news for getting
non-technical visitors to contribute to the graphs for their own fields.&lt;/p&gt;

&lt;p&gt;Some other assorted opportunities that strike me as interesting:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Gamification of learning.&lt;/strong&gt; Provide personal and social incentives (à la
&lt;a href=&quot;http://duolingo.com&quot;&gt;Duolingo&lt;/a&gt;) for users to continue their walk through the knowledge graph.
Imagine &amp;ldquo;leveling up&amp;rdquo; after marking a certain concept as known, and having a
clear view of what your friends and colleagues are learning at the same time.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Inter-disciplinary links.&lt;/strong&gt; Visualize exactly how machine learning overlaps
with natural language processing, or identify the mathematical concepts most
crucial to understanding core artificial intelligence ideas.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Community-curated resources.&lt;/strong&gt; With all the content open and free, this site
has the chance to raise a Wikipedia-style community, where motivated
volunteers work to collect the best resources for each concept and ensure the
entire graph remains well-connected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I&amp;rsquo;m planning to extend the Metacademy database and increase its coverage in
natural language processing (and perhaps linguistics) topics. It&amp;rsquo;s exciting to
think about the opportunities this site will reveal for the thousands of
autodidacts&amp;mdash;students and workers alike&amp;mdash;who wish to continue learning.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Conveniently for me, the exact topics I should be learning!&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Where does ice cream come from?</title>
      <link>http://foldl.me/2014/nlu-world-knowledge/</link>
      <pubDate>Wed, 09 Jul 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/nlu-world-knowledge/</guid>
      <description>&lt;p&gt;Since I was first introduced to the field of natural language understanding
&lt;a href=&quot;http://cs224u.stanford.edu&quot;&gt;this spring&lt;/a&gt;, I&amp;rsquo;ve had an extra voice stuck in my head. It monitors
conversations closely, watching for syntactic, semantic, and &lt;a href=&quot;http://en.wikipedia.org/wiki/Pragmatics&quot;&gt;pragmatic&lt;/a&gt;
oddities. Its utterance is always some variation on the same theme, always
blurted out after I hear a particularly interesting construction:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;How the heck did I just understand what was said?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It&amp;rsquo;s a bit mind-boggling at times to examine what I hear and say, and to
acknowledge that this small brain of mine somehow processes these things
properly.&lt;/p&gt;

&lt;p&gt;A case in point: I was eating with friends at a Stanford dining hall recently.
Aforementioned blurting voice had been quiet all night. A friend returned with
an empty ice cream cone in hand and said the following:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Well, I got a cone, but no ice cream came out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My companions nodded in sympathy. But the voice in my head distracted me,
exploding: &lt;em&gt;World knowledge! World knowledge!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The above is an example of an utterance which requires &lt;em&gt;world knowledge&lt;/em&gt; to
understand correctly. To see this, try to make a literal reading of the quote:
my friend seems to suggest that she expected ice cream to magically emerge from
the cone she was holding, and that she was disappointed when this didn&amp;rsquo;t happen.
We know this interpretation isn&amp;rsquo;t correct, because there is a much more
plausible one: my friend fetched an ice cream cone but found that the ice cream
dispenser failed to dispense.&lt;/p&gt;

&lt;p&gt;Of course, my friend did not mention anything about an ice cream dispenser. The
others who heard this statement all used their own knowledge &amp;mdash; accrued over
years of ice cream consumption &amp;mdash; to infer the crucial details of the story.&lt;/p&gt;

&lt;p&gt;How can we expect an artificial intelligence to do the same? To interpret this
particular statement and feel sympathy (as it should!), an agent needs to
understand the following relatively obscure facts:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;ice cream is often served in cones,&lt;/li&gt;
  &lt;li&gt;dispensers are sometimes available to fill these cones, and&lt;/li&gt;
  &lt;li&gt;it is unfortunate when no ice cream comes out of such a dispenser.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is the minimal world knowledge to get the gist of a &lt;em&gt;single&lt;/em&gt; casual
statement. Sure, Siri may be able to get you directions to the airport, but we
are far from &lt;strong&gt;complete&lt;/strong&gt; natural language understanding.&lt;/p&gt;

&lt;p&gt;Writing about this topic reminds me of Hector Levesque&amp;rsquo;s wonderful IJCAI paper
on natural language understanding and artificial intelligence,
&lt;a href=&quot;http://ijcai13.org/files/summary/hlevesque.pdf&quot;&gt;&lt;em&gt;On our best behavior&lt;/em&gt;&lt;/a&gt;. Do give it a read if you are interested in the
current state of AI. This paper merits some more discussion in a separate post!&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2014/sunday-links-9/</link>
      <pubDate>Sun, 20 Apr 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/sunday-links-9/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;Lots of reading for an NLP-themed week
(&lt;a href=&quot;http://swank.stanford.edu&quot;&gt;Stanford Workshop on AI and Knowledge&lt;/a&gt; was on Wednesday, and preparation
for a big NLU project is ramping up). I&amp;rsquo;ve been reading much of
&lt;a href=&quot;http://www.sics.se/~mange/publications.html&quot;&gt;&lt;strong&gt;Magnus Sahlgren&amp;rsquo;s work&lt;/strong&gt;&lt;/a&gt; on distributed word representations. Also
worth mentioning: &lt;a href=&quot;http://www.socher.org/uploads/Main/HuangSocherManning_ACL2012.pdf&quot;&gt;&lt;strong&gt;Huang, Socher, Manning and Ng (2012)&lt;/strong&gt;&lt;/a&gt; learn word
embeddings using both local and global context;
&lt;a href=&quot;http://www.cs.utexas.edu/~ml/papers/reisinger.naacl-2010.pdf&quot;&gt;&lt;strong&gt;Reisinger and Mooney (2010)&lt;/strong&gt;&lt;/a&gt; show how VSMs can handle polysemy.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.newyorker.com/talk/financial/2014/04/21/140421ta_talk_surowiecki&quot;&gt;&lt;strong&gt;&amp;ldquo;Shut up and deal&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;: Tesla is restricted from selling in New Jersey
due to a statute which requires manufacturers to sell through dealers.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.vox.com/2014/4/14/5610548/the-enhanced-supplementary-leverage-ratio-is-your-new-bicycle&quot;&gt;&lt;strong&gt;&amp;ldquo;The Enhanced Supplementary Leverage Ratio is your new bicycle.&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;
Leverage ratio requirements are being increased for some of the US&amp;rsquo;s
systematically important financial institutions. See &lt;a href=&quot;http://www.federalreserve.gov/newsevents/press/bcreg/20140408a.htm&quot;&gt;Fed press release&lt;/a&gt;,
&lt;a href=&quot;http://www.reuters.com/article/2014/04/08/us-financial-regulations-leverage-idUSBREA3709B20140408&quot;&gt;Reuters coverage&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.washingtonpost.com/lifestyle/style/the-recovery-puzzle-a-new-factory-in-ohio-struggles-to-match-jobs-to-job-seekers/2014/04/05/098d53ec-b44e-11e3-8cb6-284052554d74_story.html?hpid=z1&quot;&gt;&lt;strong&gt;&amp;ldquo;The recovery puzzle.&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2014/sunday-links-9/</link>
      <pubDate>Mon, 14 Apr 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/sunday-links-9/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;Preliminary results from Mexico&amp;rsquo;s National Institute of Statistics and
Geography &lt;a href=&quot;http://mexicovoices.blogspot.com/2014/04/mexican-educational-budget-mismanaged.html&quot;&gt;indicate massive amounts of fraud&lt;/a&gt; in the country&amp;rsquo;s education
system. I can&amp;rsquo;t find credible English sources on this at the moment. See
&lt;a href=&quot;http://www.eluniversal.com.mx/primera-plana/2014/impreso/censo-de-sep-confirma-fallas-44861.html&quot;&gt;&amp;ldquo;Censo en escuelas descubre anomalías&amp;rdquo;&lt;/a&gt; and a campaign to crack down on
this fraud named &lt;a href=&quot;http://www.finalabuso.org/&quot;&gt;&amp;ldquo;Fin al abuso&amp;rdquo;&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/0375756787/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0375756787&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;The Rise of Theodore Roosevelt&lt;/em&gt;&lt;/a&gt; details Roosevelt&amp;rsquo;s growth from an
awkward, squeaky boy obsessed with taxidermy and books into a man of
staggering power and charisma. Inspiring read. Recommended to me by
&lt;a href=&quot;http://www.artofmanliness.com/trunk/1795/some-book-reccomendations-in-honor-of-theodore-roosevelts-birthday/&quot;&gt;Art of Manliness&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.economist.com/news/essays/21600451-finance-not-merely-prone-crises-it-shaped-them-five-historical-crises-show-how-aspects-today-s-fina&quot;&gt;&amp;ldquo;The slumps that shaped modern finance&amp;rdquo;&lt;/a&gt; covers the history of the
financial industry from the late 18th century forward. Really fascinating
read. (For those reading on a desktop, the web reading interface for this
essay is also pretty nice!)&lt;/li&gt;
  &lt;li&gt;An &lt;a href=&quot;http://beta.slashdot.org/story/200403&quot;&gt;interview with John McAfee&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0375756787&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2014/sunday-links-8/</link>
      <pubDate>Sun, 06 Apr 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/sunday-links-8/</guid>
      <description>&lt;p&gt;Happy April! I&amp;rsquo;ve been slacking on these link posts.. I&amp;rsquo;m hoping to launch
myself back into the habit with a varied collection of links today:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://noahpinionblog.blogspot.com/2014/04/no-one-really-knows-if-hft-is-good-or.html&quot;&gt;&lt;strong&gt;No one really knows if HFT is good or bad.&lt;/strong&gt;&lt;/a&gt; The econoblogosphere has
been on fire this past week with the release of Michael Lewis&amp;rsquo; book
&lt;a href=&quot;http://www.amazon.com/gp/product/0393244660/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0393244660&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Flash Boys&lt;/em&gt;&lt;/a&gt;, which exposes to the general public some of the more
nefarious aspects of high-frequency trading. This post by Noah Smith is a
candid admission of the fact that we really don&amp;rsquo;t have the tools at this point
to conclude whether many HFT practices (barring those obviously egregious
techniques like front-running) help or hinder the stock market. See also
&lt;a href=&quot;http://www.cepr.net/index.php/blogs/beat-the-press/high-speed-trading-and-slow-witted-economic-policy&quot;&gt;&amp;ldquo;High Speed Trading and Slow-Witted Economic Policy&amp;rdquo;&lt;/a&gt; and
&lt;a href=&quot;http://www.nytimes.com/2014/04/04/opinion/flash-boys-for-the-people.html&quot;&gt;&amp;ldquo;Flash Boys for the People&amp;rdquo;&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/0143124994/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0143124994&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;strong&gt;&lt;em&gt;The Alchemists: Three Central Bankers and a World On Fire&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; revealed
to me just how pivotal a role central bankers of the world have had in the
recent recession and the subsequent recovery. The amount of engineering that
these institutions&amp;mdash;most notably, the Federal Reserve, ECB, and Bank of
England&amp;mdash;perform in hopes of maintaining stable employment and moderate
inflation is just astounding.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.overcomingbias.com/2012/10/the-value-of-time-as-a-student.html&quot;&gt;&lt;strong&gt;&amp;ldquo;The value of time as a student&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; asks a question that has been
bothering me for some time: why do students of extraordinary intellectual
aptitude (and no immediate financial burdens) take on menial campus jobs?
Katja Grace suggests: &amp;ldquo;It seems that college students generally treat their
time as low value.&amp;rdquo; We trade this time for small immediate returns, perhaps
unable to conceive of how spending this same time on more positive engagements
(reading, meeting with professors, building things) could yield much greater
long-term returns.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.stanford.edu/~jurafsky/pubs/linguistic_change_lifecycle.pdf&quot;&gt;&lt;strong&gt;&amp;ldquo;No country for old members&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; models the linguistic change of
communities, and reaches some interesting conclusions about how language
change tells a story about the &amp;ldquo;age&amp;rdquo; or character of a community.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://arxiv.org/abs/cs/0304027&quot;&gt;&lt;strong&gt;&amp;ldquo;I&amp;rsquo;m sorry Dave, I&amp;rsquo;m afraid I can&amp;rsquo;t do that&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; is now my go-to resource
for explaining some of the struggles of natural language processing. The paper
gives a brief overview of the history of NLP and the challenges which it has
faced or has yet to overcome.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0393244660&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;
&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0143124994&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

</description>
    </item>
    
    
    
    
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2014/sunday-links-7/</link>
      <pubDate>Sun, 02 Feb 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/sunday-links-7/</guid>
      <description>&lt;p&gt;Hello world! Well, &lt;a href=&quot;/2014/sunday-links-6/&quot;&gt;I had a feeling&lt;/a&gt; things would get quiet around here in
the early-quarter crunch, but I failed to predict just how much I would lose
control. The details aren&amp;rsquo;t especially important, but suffice it to say that I
drove myself slightly crazy in these first few weeks. I&amp;rsquo;m just resurfacing now,
and can affirm that my idea of &amp;ldquo;living intentionally&amp;rdquo; has gained entire
unforeseen layers of meaning. I&amp;rsquo;m tracking my progress in January in-depth in a
private log, and the relevant details will likely surface here come my winter
quarter review next month.&lt;/p&gt;

&lt;p&gt;For now, let&amp;rsquo;s focus on the reading! I&amp;rsquo;ve kept up my reading habits over these
past few weeks, though my focus has shifted from online posts and articles to
books.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://studiahumana.com/pliki/wydania/In%20Praise%20of%20Passivity.pdf&quot;&gt;&lt;strong&gt;&amp;ldquo;In Praise of Passivity&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; has been making quite the splash in
libertarian circles recently. Michael Huemer sums up decades of
pro-free-market discourse and asks us to consider the forgotten wisdom of
doing nothing &amp;mdash; of not &amp;ldquo;fighting&amp;rdquo; for the causes we &amp;ldquo;believe&amp;rdquo; in, and of not
pushing current social theory into undue prominence.&lt;/li&gt;
  &lt;li&gt;Michael Nielsen&amp;rsquo;s &lt;a href=&quot;http://www.michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works/&quot;&gt;&lt;strong&gt;&amp;ldquo;How the Bitcoin protocol actually works&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; is a
fascinating intuitive explanation of the innards of the Bitcoin protocol. This
post added much to my understanding of the system, even though I had already
read (and thought I understood) the original Satoshi paper.&lt;/li&gt;
  &lt;li&gt;Friedrich Hayek contrasts two strongly opposed schools which both take the
same name in &lt;a href=&quot;http://mises.org/books/individualismandeconomicorder.pdf&quot;&gt;&lt;strong&gt;&amp;ldquo;Individualism: True and False&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;. He scorns the
individualism which he labels as &amp;ldquo;Cartesian rationalism,&amp;rdquo; which supposes that
a society must promote the search for those pinnacles of human reason who can
serve as &amp;ldquo;wise legislators&amp;rdquo; to lead the rest of us. Hayek puts forth his own
idea of individualism, a measured and exceedingly humble recognition of any
individual&amp;rsquo;s fallibility and the consequent need for free interaction and
group consensus in a political system.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://econfaculty.gmu.edu/wew/articles/13/ThePopeAndCapitalism.htm&quot;&gt;Walter E. Williams defends capitalism&lt;/a&gt; in the face of Pope Francis&amp;rsquo; recent
harsh critique.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Kneser-Ney smoothing explained</title>
      <link>http://foldl.me/2014/kneser-ney-smoothing/</link>
      <pubDate>Sat, 18 Jan 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/kneser-ney-smoothing/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Language models&lt;/strong&gt; are an essential element of natural language processing,
  central to tasks ranging from spellchecking to machine translation. Given an
  arbitrary piece of text, a language model determines whether that text belongs
  to a given language.&lt;/p&gt;

&lt;p&gt;We can give a concrete example with a &lt;strong&gt;probabilistic language model&lt;/strong&gt;, a
specific construction which uses probabilities to estimate how likely any given
string belongs to a language. Consider a probabilistic English language model
\( P_E \). We would expect the probability&lt;/p&gt;

&lt;p&gt;\[P_E(\text{I went to the store})\]&lt;/p&gt;

&lt;p&gt;to be quite high, since we can confirm this is valid English. On the other hand,
we expect the probabilities&lt;/p&gt;

&lt;p&gt;\[P_E(\text{store went to I the}), P_E(\text{Ich habe eine Katz})\]&lt;/p&gt;

&lt;p&gt;to be very low, since these fragments do not constitute proper English text.&lt;/p&gt;

&lt;p&gt;I don&amp;rsquo;t aim to cover the entirety of language models at the moment &amp;mdash; that
would be an ambitious task for a single blog post. If you haven&amp;rsquo;t encountered
language models or &lt;em&gt;n&lt;/em&gt;-grams before, I recommend the following resources:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Language_model&quot;&gt;&amp;ldquo;Language model&amp;rdquo;&lt;/a&gt; on Wikipedia&lt;/li&gt;
  &lt;li&gt;Chapter 4 of Jurafsky and Martin&amp;rsquo;s &lt;a href=&quot;http://www.amazon.com/gp/product/0131873210/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0131873210&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Speech and Language Processing&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Chapter 7 of &lt;a href=&quot;http://www.amazon.com/gp/product/0521874157/ref=as_li_tf_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0521874157&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Statistical Machine Translation&lt;/em&gt;&lt;/a&gt; (see &lt;a href=&quot;http://www.statmt.org/book/slides/07-language-models.pdf&quot;&gt;summary slides&lt;/a&gt; online)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I&amp;rsquo;d like to jump ahead to a trickier subject within language modeling known as
&lt;strong&gt;Kneser-Ney smoothing&lt;/strong&gt;. This smoothing method is most commonly applied in an
&lt;em&gt;interpolated&lt;/em&gt; form,&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; and this is the form that I&amp;rsquo;ll present today.&lt;/p&gt;

&lt;p&gt;Kneser-Ney evolved from &lt;strong&gt;absolute-discounting interpolation&lt;/strong&gt;, which makes use
of both higher-order (i.e., higher-&lt;em&gt;n&lt;/em&gt;) and lower-order language models,
reallocating some probability mass from 4-grams or 3-grams to simpler unigram
models. The formula for absolute-discounting smoothing as applied to a bigram
language model is presented below:&lt;/p&gt;

&lt;p&gt;\[P_{abs}(w_i \mid w_{i-1}) = \dfrac{\max(c(w_{i-1} w_i) - \delta, 0)}{\sum_{w&apos;} c(w_{i-1} w&apos;)} + \alpha\; p_{abs}(w_i)\]&lt;/p&gt;

&lt;p&gt;Here \(\delta\) refers to a fixed &lt;strong&gt;discount&lt;/strong&gt; value, and \(\alpha\) is a
normalizing constant. The details of this smoothing are covered in
&lt;a href=&quot;http://u.cs.biu.ac.il/~yogo/courses/mt2013/papers/chen-goodman-99.pdf&quot;&gt;Chen and Goodman (1999)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The essence of Kneser-Ney is in the clever observation that we can take
advantage of this interpolation as a sort of backoff model. When the first term
(in this case, the discounted relative bigram count) is near zero, the second
term (the lower-order model) carries more weight. Inversely, when the
higher-order model matches strongly, the second lower-order term has little
weight.&lt;/p&gt;

&lt;p&gt;The Kneser-Ney design retains the first term of absolute discounting
interpolation, but rewrites the second term to take advantage of this
relationship. Whereas absolute discounting interpolation in a bigram model would
simply default to a unigram model in the second term, Kneser-Ney depends upon
the idea of a &lt;em&gt;continuation probability&lt;/em&gt; associated with each unigram.&lt;/p&gt;

&lt;p&gt;This probability for a given token \(w_i\) is proportional to the &lt;strong&gt;number of
bigrams which it completes&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;\[P_{\text{continuation}}(w_i) \propto \: \left&amp;#124; \{ w_{i-1} : c(w_{i-1}, w_i) &gt; 0 \} \right&amp;#124;\]&lt;/p&gt;

&lt;p&gt;This quantity is normalized by dividing by the total number of bigram types
(note that \(j\) is a free variable):&lt;/p&gt;

&lt;p&gt;\[P_{\text{continuation}}(w_i) = \dfrac{\left&amp;#124; \{ w_{i-1} : c(w_{i-1}, w_i) &gt; 0 \} \right&amp;#124;}{\left&amp;#124; \{ w_{j-1} : c(w_{j-1},w_j) &gt; 0\} \right&amp;#124;}\]&lt;/p&gt;

&lt;p&gt;The common example used to demonstrate the efficacy of Kneser-Ney is the phrase
&lt;em&gt;San Francisco&lt;/em&gt;. Suppose this phrase is abundant in a given training corpus.
Then the unigram probability of &lt;em&gt;Francisco&lt;/em&gt; will also be high. If we unwisely
use something like absolute discounting interpolation in a context where our
bigram model is weak, the unigram model portion may take over and lead to some
strange results.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=wtB00EczoCM&quot;&gt;Dan Jurafsky&lt;/a&gt; gives the following example context:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I can&amp;rsquo;t see without my reading &lt;strong&gt;__&lt;/strong&gt;___.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A fluent English speaker reading this sentence knows that the word &lt;em&gt;glasses&lt;/em&gt;
should fill in the blank. But since &lt;em&gt;San Francisco&lt;/em&gt; is a common term,
absolute-discounting interpolation might declare that &lt;em&gt;Francisco&lt;/em&gt; is a better
fit: \(P_{abs}(\text{Francisco}) &gt; P_{abs}(\text{glasses})\).&lt;/p&gt;

&lt;p&gt;Kneser-Ney fixes this problem by asking a slightly harder question of our
lower-order model. Whereas the unigram model simply provides how likely a word
\(w_i\) is to appear, Kneser-Ney&amp;rsquo;s second term determines how likely a word
\(w_i\) is to appear in an unfamiliar bigram context.&lt;/p&gt;

&lt;p&gt;Kneser-Ney in whole follows:&lt;/p&gt;

\[P_{\mathit{KN}}(w_i \mid w_{i-1}) = \dfrac{\max(c(w_{i-1} w_i) - \delta, 0)}{\sum_{w&apos;} c(w_{i-1} w&apos;)} + \lambda \dfrac{\left&amp;#124; \{ w_{i-1} : c(w_{i-1}, w_i) &gt; 0 \} \right&amp;#124;}{\left&amp;#124; \{ w_{j-1} : c(w_{j-1},w_j) &gt; 0\} \right&amp;#124;}\]

&lt;p&gt;\(\lambda\) is a normalizing constant&lt;/p&gt;

\[\lambda(w_{i-1}) = \dfrac{\delta}{c(w_{i-1})} \left&amp;#124; \{w&apos; : c(w_{i-1}, w&apos;) &gt; 0\} \right&amp;#124;.\]

&lt;p&gt;Note that the denominator of the first term can be simplified to a unigram count. Here is the final interpolated Kneser-Ney smoothed bigram model, in all its glory:&lt;/p&gt;

\[P_{\mathit{KN}}(w_i \mid w_{i-1}) = \dfrac{\max(c(w_{i-1} w_i) - \delta, 0)}{c(w_{i-1})} + \lambda \dfrac{\left&amp;#124; \{ w_{i-1} : c(w_{i-1}, w_i) &gt; 0 \} \right&amp;#124;}{\left&amp;#124; \{ w_{j-1} : c(w_{j-1},w_j) &gt; 0\} \right&amp;#124;}\]

&lt;h2 id=&quot;further-reading&quot;&gt;Further reading&lt;/h2&gt;

&lt;p&gt;If you enjoyed this post, here is some further reading on Kneser-Ney and other
smoothing methods:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Bill MacCartney&amp;rsquo;s &lt;a href=&quot;http://nlp.stanford.edu/~wcmac/papers/20050421-smoothing-tutorial.pdf&quot;&gt;smoothing tutorial&lt;/a&gt; (very accessible)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://u.cs.biu.ac.il/~yogo/courses/mt2013/papers/chen-goodman-99.pdf&quot;&gt;Chen and Goodman (1999)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Section 4.9.1 in Jurafsky and Martin&amp;rsquo;s &lt;a href=&quot;http://www.amazon.com/gp/product/0131873210/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0131873210&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Speech and Language Processing&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&quot;&gt;&lt;/script&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0131873210&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For the canonical definition of interpolated Kneser-Ney smoothing, see S. F. Chen and J. Goodman, &lt;a href=&quot;http://u.cs.biu.ac.il/~yogo/courses/mt2013/papers/chen-goodman-99.pdf&quot;&gt;&amp;ldquo;An empirical study of smoothing techniques for language modeling,&amp;rdquo;&lt;/a&gt; Computer Speech and Language, vol. 13, no. 4, pp. 359&amp;ndash;394, 1999.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2014/sunday-links-6/</link>
      <pubDate>Sun, 05 Jan 2014 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2014/sunday-links-6/</guid>
      <description>&lt;p&gt;Happy New Year! I&amp;rsquo;m really excited about what 2014 has in store, and interested
to see how a consistent blogging practice might make things better.&lt;/p&gt;

&lt;p&gt;This concludes the final week of Stanford&amp;rsquo;s winter break. I&amp;rsquo;ve been working hard
to make the most of my remaining relatively-free time.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; I made an effort to
read more seriously this week (mostly on more topics in economics), alongside
beginning work on several projects that are important to me, including
&lt;a href=&quot;/2013/german-2014&quot;&gt;learning German&lt;/a&gt;, &lt;a href=&quot;/2013/biphasic-sleep&quot;&gt;experimenting with biphasic sleep&lt;/a&gt;, researching
possible summer work opportunities, and writing a book (post forthcoming!).&lt;/p&gt;

&lt;p&gt;There will likely be an enormous time crunch in these first few weeks as I
re-adjust to the school environment and &amp;ldquo;shop&amp;rdquo; for classes. Expect it to be
quiet around here for a bit.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/014311526X/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=014311526X&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;strong&gt;&lt;em&gt;Nudge: Improving Decisions About Health, Wealth, and Happiness&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; is a
friendly introduction to &amp;ldquo;libertarian paternalism,&amp;rdquo; the strategy of
constructing choice architectures in a way that counters the harmful effects
of acknowledged cognitive biases and allows individuals to better pursue their
own aims. The first several chapters are absolutely worth a read.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B00C8N4FNK/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B00C8N4FNK&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;strong&gt;&lt;em&gt;The Motivation Hacker&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; is a fantastic condensed presentation of the
best points of &lt;a href=&quot;http://lesswrong.com&quot;&gt;LessWrong&lt;/a&gt;-style instrumental rationality: it is packed
with useful &amp;ldquo;hacks&amp;rdquo; which can be used to ramp up motivation and productivity.
This is not a self-help book but rather a descriptive work: an image of the
most promising techniques applied successfully in a single person&amp;rsquo;s life. A
great quick read without the usual condescension or absolute focus on a single
method that usually comes in this self-improvement genre.&lt;/li&gt;
  &lt;li&gt;Russ Roberts hosts an
&lt;a href=&quot;http://www.econtalk.org/archives/2013/12/richard_fisher.html&quot;&gt;outstanding EconTalk interview with Dallas Fed president Richard Fisher&lt;/a&gt;.
Fisher clearly and plainly states his opinion on the Fed&amp;rsquo;s support of &amp;ldquo;too big
to fail&amp;rdquo; banks and exhibits without restraint his strong disapproval of
current monetary policy. I&amp;rsquo;ve listened to this three times already and will be
taking notes on it as I listen again on the plane ride back to Stanford. Pure
gold. (See also &lt;a href=&quot;http://mathbabe.org/2013/12/31/dallas-feds-richard-fisher-talks-tbtf-on-econtalk-ows/&quot;&gt;Mathbabe&amp;rsquo;s summary and response&lt;/a&gt;.)&lt;/li&gt;
  &lt;li&gt;Alex Gaynor gives &lt;a href=&quot;http://alexgaynor.net/2013/dec/30/about-python-3/&quot;&gt;a realist&amp;rsquo;s view&lt;/a&gt; of the state of Python 3, pointing out
that only 2% of PyPI package downloads are for version-3 applications. He
suggests that Python 3 features be backported to a 2.8 release.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.tor.com/blogs/2013/12/bad-for-you-techno-panic-timeline&quot;&gt;&lt;strong&gt;&amp;ldquo;These New-Fangled Books Will Doom Us All!&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; is a fun infographic
that exposes thinkers since the 15th century decrying the horrible social
effects of new technologies. Critics of technology have lamented the impending
destruction of society due to new media since the printing press, but we still
seem to be doing okay.&lt;/li&gt;
  &lt;li&gt;&amp;ldquo;bunnie studios&amp;rdquo; &lt;a href=&quot;http://www.bunniestudios.com/blog/?p=3554&quot;&gt;pries open some SD cards&lt;/a&gt; and reveals some surprisingly
insecure designs.&lt;/li&gt;
  &lt;li&gt;Ben Bernanke gives what may be &lt;a href=&quot;http://www.federalreserve.gov/newsevents/speech/bernanke20140103a.htm&quot;&gt;his final speech&lt;/a&gt; as Fed chairman.&lt;/li&gt;
  &lt;li&gt;Eric Hegelson &lt;a href=&quot;http://erichelgeson.github.io/blog/2013/12/31/i-fought-my-isps-bad-behavior-and-won/&quot;&gt;discovers&lt;/a&gt; that his ISP injects affiliate links into web
pages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00C8N4FNK&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;
&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=014311526X&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I returned to &lt;a href=&quot;http://stremor.com&quot;&gt;Stremor&lt;/a&gt; for these three weeks, so work and commuting still took up a significant portion of each day.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-5/</link>
      <pubDate>Sun, 29 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-5/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;I have just discovered (via &lt;a href=&quot;http://benkuhn.net&quot;&gt;Ben Kuhn&lt;/a&gt;) a wonderful blog called
&lt;a href=&quot;http://ribbonfarm.com&quot;&gt;Ribbonfarm&lt;/a&gt;. While I&amp;rsquo;m still struggling to understand what the site is
really about,&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; I feel obligated to share an outstanding summary of the book
&lt;a href=&quot;http://www.amazon.com/gp/product/0300078153/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0300078153&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Seeing Like a State&lt;/em&gt;&lt;/a&gt; in the post
&lt;a href=&quot;http://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/&quot;&gt;&lt;strong&gt;&amp;ldquo;A Big Little Idea Called Legibility&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;. Ribbonfarm&amp;rsquo;s author presents
the &amp;ldquo;authoritarian high-modernist recipe for failure,&amp;rdquo; a detail of the process
by which leaders throughout history have consistently attempted at utopian
reform for the better and failed miserably. &lt;a href=&quot;http://www.amazon.com/gp/product/0300078153/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0300078153&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Seeing Like a State&lt;/em&gt;&lt;/a&gt; went
onto my reading list immediately after I finished this article.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B00CCGF81Q/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=B00CCGF81Q&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;strong&gt;&lt;em&gt;The Three Languages of Politics&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; presents a &amp;ldquo;three-axis model&amp;rdquo; which
is claimed to chain modern political discourse, restricting the various
political &amp;ldquo;tribes&amp;rdquo; (in this model, progressives, conservatives, and
libertarians) from having real constructive debates. Actively detach yourself
from the axis on which your &lt;a href=&quot;http://www.amazon.com/gp/product/0374533555/ref=as_li_tf_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0374533555&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;System 1&lt;/a&gt; lounges, he suggests, and you&amp;rsquo;ll be
able to better understand the arguments of those who oppose you (and avoid
engaging in the self-reinforcing rhetoric of the tribe you might associate
with for any given issue).&lt;/li&gt;
  &lt;li&gt;Economist Bryan Caplan suggests we give those pushing a certain policy or
perspective an &lt;a href=&quot;http://econlog.econlib.org/archives/2011/06/the_ideological.html&quot;&gt;&lt;strong&gt;&amp;ldquo;ideological Turing test&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;. Here&amp;rsquo;s the test: Take a
person of ideology A and place him in a room of people who strongly support
ideology B. If the person can&amp;rsquo;t convincingly argue for ideology B and blend
in, the person fails the test. Those who fail this kind of test make it
evident that they chose to simply argue for a side rather than examining all
possible lines of reasoning.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.ft.com/cms/s/2/8537d776-664f-11e3-aa10-00144feabdc0.html&quot;&gt;&lt;strong&gt;&amp;ldquo;Lunch with the FT: Peter Thiel&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; gives a brief peek inside Thiel&amp;rsquo;s
mind.&lt;/li&gt;
  &lt;li&gt;The Economist gives a really great overview of the Sapir-Whorf debate in
&lt;a href=&quot;http://www.economist.com/blogs/prospero/2013/11/multilingualism&quot;&gt;&lt;strong&gt;&amp;ldquo;Do different languages confer different personalities?&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;. I&amp;rsquo;ll
definitely refer people to this article when the Whorfian question comes up in
future discussions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0300078153&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;
&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=B00CCGF81Q&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;
&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0374533555&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The site&amp;rsquo;s tagline, &amp;ldquo;experiments in refactored perception,&amp;rdquo; doesn&amp;rsquo;t help me too much.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    
    
    <item>
      <title>The wacky economics of gift-giving</title>
      <link>http://foldl.me/2013/the-wacky-economics-of-gift-giving/</link>
      <pubDate>Tue, 24 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/the-wacky-economics-of-gift-giving/</guid>
      <description>&lt;p&gt;Christmas, birthdays, graduations, housewarming parties &amp;mdash; all wonderful times
to celebrate and reunite with family and friends. But for a certain class of
unlucky revelers, beneath that celebration lies that haunting specter of &lt;em&gt;the
gift.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m terrible at finding good gifts for people. Maybe I was one of those born
without the proper genes. Malls and department stores are scary places for
people of my type at this time of year, where everyone but you seems to be
running from store to store, picking out the perfect products without breaking a
sweat. For people like me, these celebrations always come with a side of dread
as I worry about what gifts to buy for friends and family.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve often asked myself whether it would be appropriate to ditch the standard
plan and simply wrap some cash in an envelope along with a nice handwritten
letter. It makes perfect sense, I think: given that I lack any sort of skill in
selecting goods that other people might enjoy, it would be better to simply let
the giftee decide what he or she wants.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; With cash the recipient can choose
to buy any of the potential gifts I was considering, or &lt;em&gt;anything else&lt;/em&gt; that he
might prefer. Then everyone is better off: I don&amp;rsquo;t sink hours into fruitless
gift searches and end up buying the wrong thing, and the person receiving the
gift instead gets to buy exactly what he has always wanted.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; So cash is okay,
right? The answer, unfortunately for me, is almost universally no.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;h3 id=&quot;why-dont-we-give-cash-gifts&quot;&gt;Why don&amp;rsquo;t we give cash gifts?&lt;/h3&gt;

&lt;p&gt;I began to undertand why this is so just a few weeks ago as I listened to
&lt;a href=&quot;http://www.hoover.org/fellows/10516&quot;&gt;Russ Roberts&lt;/a&gt; and &lt;a href=&quot;http://www.michaelmunger.com/&quot;&gt;Michael Munger&lt;/a&gt; discuss the economics of gifts in an
&lt;a href=&quot;http://www.econtalk.org/archives/2006/04/ticket_scalping.html&quot;&gt;EconTalk episode&lt;/a&gt;. The two discuss the common scenario of a dinner party,
where guests are often expected to arrive with a small gift in hand. Most guests
would arrive with a bottle of wine, chocolates, or maybe some flowers. Wouldn&amp;rsquo;t
the most &amp;ldquo;thoughtful&amp;rdquo; guest be the one that arrives with a $20, though &amp;mdash; the
guest that lets the host decide what would be best for himself? Obviously not,
as anyone with a modicum of training in manners can confirm. But why is this the
case?&lt;/p&gt;

&lt;p&gt;Munger uses Aristotle&amp;rsquo;s theory of value, which decomposes the concept of &amp;ldquo;value&amp;rdquo;
into a subjective and idiosyncratic &lt;em&gt;value in use&lt;/em&gt; and a more universal &lt;em&gt;value
in exchange&lt;/em&gt;, to justify why we are so repulsed by the $20 gift:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;There&amp;rsquo;s an ancient distinction, I think first and most importantly made by
Aristotle, between value in use and value in exchange. Something that you make
as an artisan, or something that you make for the specific purpose of using
it, or having someone else use it, is just better. He claimed it was morally
better. &amp;hellip; What he&amp;rsquo;s comparing that to is value in exchange. And he agreed
that things that we make to exchange have value, but it&amp;rsquo;s a morally much lower
kind of value.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;He implies that when we talk about whether a gift is &amp;ldquo;good&amp;rdquo; or &amp;ldquo;meaningful,&amp;rdquo; we
really are evaluating its value in use. While a $20 bill has a significant value
in exchange, it has little if any value in use. On the other hand, a bottle of
wine brought to a dinner party holds a certain value in use &amp;mdash; it can be put
directly into use at the party &amp;mdash; as well as some value in exchange.&lt;/p&gt;

&lt;h3 id=&quot;what-differentiates-gifts-of-the-same-value&quot;&gt;What differentiates gifts of the same value?&lt;/h3&gt;

&lt;p&gt;All right, so cash doesn&amp;rsquo;t make the cut. But outside of the restricted context
of the dinner party, picking the right gift for a person is just so difficult.
It&amp;rsquo;s possible to establish a fixed value in use and still find two items which
lead to radically different reactions from the recipient. I can&amp;rsquo;t help but use
Munger&amp;rsquo;s example:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Suppose that for your [Russ Roberts] wife&amp;rsquo;s birthday you bought her a new
vacuum cleaner. Let&amp;rsquo;s suppose it&amp;rsquo;s a really, really nice new vacuum cleaner.
It&amp;rsquo;s still a cold night at the Roberts house.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Even the most state-of-the-art vacuum cleaner would still be an offensive gift
in this scenario. It seems in this case that the gift actually has &lt;em&gt;too much&lt;/em&gt;
direct utility. We want gifts, rather, that are something of a surprise:
something we didn&amp;rsquo;t know we wanted.&lt;/p&gt;

&lt;p&gt;Hold on a second &amp;mdash; we&amp;rsquo;re in a society where people try to &amp;ldquo;surprise&amp;rdquo; a
recipient by subverting his idea of what would maximize his own utility? And
the recipient wants (or expects) the surprise? Something is wrong here.&lt;/p&gt;

&lt;p&gt;Munger poses an addition to this theory by holding that the best gift is more
than just a signal: it is a &lt;a href=&quot;http://mungowitzend.blogspot.com/2008/07/is-costly-signal-such-obscure-concept.html&quot;&gt;&lt;em&gt;costly&lt;/em&gt; signal&lt;/a&gt;. In spending more money than is
likely necessary on a gift which we expect to surprise its recipient, we signal
multiple things:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;I am willing to spend my free time searching for a &amp;ldquo;good&amp;rdquo; gift.&lt;/li&gt;
  &lt;li&gt;I am willing to spend more money than the recipient might consider reasonable
on the gift that I find.&lt;/li&gt;
  &lt;li&gt;I know the recipient well enough that I am confident this gift will be a good
surprise.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This act of costly signaling reinforces our altruistic image in the recipient&amp;rsquo;s
eyes, and also distinguishes the gift from what could otherwise be interpreted
as a compensation or bribe &amp;mdash; an idea that no one would want to support in
giving a gift to another.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s not clear that the task of gift-buying will be any less painful now that
the economic principles behind it have been demystified. But at least you can
know exactly what you&amp;rsquo;re talking about as you trod through shopping malls and
grumble to yourself: these costly signals just cost too much!&lt;/p&gt;

&lt;h2 id=&quot;further-reading&quot;&gt;Further reading&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;The incentive for gift-giving as posed here may have its roots in the
&lt;a href=&quot;https://en.wikipedia.org/wiki/Rotten_kid_theorem&quot;&gt;rotten kid theorem&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;David Friedman suggests &lt;a href=&quot;http://daviddfriedman.blogspot.com/2006/12/why-do-we-give-gifts.html&quot;&gt;different signals&lt;/a&gt; that he claims make gift-giving
special.&lt;/li&gt;
  &lt;li&gt;Read more about &lt;a href=&quot;http://www.psych-it.com.au/Psychlopedia/article.asp?id=375&quot;&gt;costly signaling&lt;/a&gt;.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I&amp;rsquo;m operating under the assumption in this post that the primary purpose of giving a gift is to signal &lt;a href=&quot;http://en.wikipedia.org/wiki/Altruism&quot;&gt;altruism&lt;/a&gt; toward the recipient of the gift. In other words: we give gifts to let people know that we care about them.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;And perhaps most importantly, I have signaled by giving this gift that I care about the giftee. So much so, in fact, that I&amp;rsquo;ve prized his/her interest above all in choosing to give a cash gift.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For the record, I have gone through with this strategy several times&amp;hellip; albeit with widely varying degrees of success.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;As this topic is far out of my field I wasn&amp;rsquo;t able to quickly find a canonical article or book on this subject. If anyone knows a better source, please let me know!&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-5/</link>
      <pubDate>Sun, 22 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-5/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.econlib.org/library/Essays/rdPncl1.html&quot;&gt;&lt;strong&gt;&amp;ldquo;I, Pencil&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; trumpets the self-organizing wonders of the free market
in parable form. Not one single person on this earth, it claims, knows how to
produce a pencil from scratch. It takes millions of people working together to
accomplish such a feat. Moreover, all these people working together toil not
in the interest of global pencil production rates but rather in the interest
of feeding their families. The output is a mere side effect!&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
  &lt;li&gt;Scott Alexander&amp;rsquo;s
&lt;a href=&quot;http://slatestarcodex.com/2013/12/08/a-something-sort-of-like-left-libertarianism-ist-manifesto/&quot;&gt;&lt;strong&gt;&amp;ldquo;A Something Sort of Like Left-Libertarianism-ist Manifesto&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; details
how free-market solutions can solve real social problems. I&amp;rsquo;ll have to read
more about this &amp;ldquo;bleeding-heart libertarianism&amp;rdquo; that he discusses.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://krugman.blogs.nytimes.com/2013/12/17/the-facebooking-of-economics/&quot;&gt;&lt;strong&gt;&amp;ldquo;The Facebooking of Economics&amp;rdquo;&lt;/strong&gt;&lt;/a&gt;&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; gives a view into how modern
economics discourse operates. The bleeding edge debates don&amp;rsquo;t always happen in
peer-reviewed journals anymore &amp;mdash; they&amp;rsquo;re also present on the blogs of
economists across the web!&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.jstor.org/stable/4165235&quot;&gt;&lt;strong&gt;&amp;ldquo;On the Folly of Rewarding A, While Hoping for B&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; gives some
interesting examples of perverse incentives in public policy and management.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.nytimes.com/2013/12/17/opinion/brooks-the-thought-leader.html?smid=pl-share&quot;&gt;&lt;strong&gt;&amp;ldquo;The Thought Leader&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; and (published a day later!)
&lt;a href=&quot;https://www.youtube.com/watch?v=wxb-zYthAOA&quot;&gt;&lt;strong&gt;&amp;ldquo;We are nothing (and that is beautiful)&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; air troubling concerns about
what our generation has been taught about success (and how our visions
actually play out in the long run). This topic merits substantial discussion,
but I&amp;rsquo;ll need to think more before putting forth any ideas on this medium.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Except for the pencil vendors, of course.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Yes, I just linked to a Liberty Fund site and a Krugman article in the same post.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Imperat aut servit&#58; Managing our knowledge inheritance</title>
      <link>http://foldl.me/2013/imperat-aut-servit/</link>
      <pubDate>Thu, 19 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/imperat-aut-servit/</guid>
      <description>&lt;p&gt;&lt;em&gt;This was submitted as my final research paper for
 &lt;a href=&quot;https://undergrad.stanford.edu/programs/special-focus-programs/esf&quot;&gt;Education as Self-Fashioning: The Active, Inquiring, Beautiful Life&lt;/a&gt;. See
 my &lt;a href=&quot;https://www.zotero.org/groups/jrgauthiers_public_library/items/collectionKey/2CCDMIRW&quot;&gt;Zotero folder&lt;/a&gt; documenting my research for this essay.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The learning of a Salmasius or a Burman, unless you are its master, will be
your tyrant. &lt;em&gt;&amp;lsquo;Imperat aut servit&amp;rsquo;;&lt;/em&gt; if you can wield it with a strong arm, it
is a great weapon; otherwise, &lt;em&gt;&amp;lsquo;Vis consili expers / Mole ruit suâ.&amp;rsquo;&lt;/em&gt; You will
be overwhelmed, like Tarpeia, by the heavy wealth which you have exacted from
tributary generations.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Cardinal John Newman acknowledges a problem familiar to any student in this
quote from his seminal work, &amp;ldquo;The Idea of a University.&amp;rdquo; Every student is well
acquainted with that intimidating specter&amp;mdash;the constant worry of the weight of
his own reading, the sheer pressure imposed by the great minds of &amp;ldquo;tributary
generations.&amp;rdquo; The student is assailed throughout his undergraduate years with
assignments on the landmark publications of each field. The classics professor
encourages the student to read Homer, while Plato and Descartes are urged on him
by his philosophy lecturer. From the department of economics come aggressive
recommendations of Hayek, Keynes and Friedman. It is easy, and indeed common in
this environment, to feel overwhelmed by the heights we are expected to climb in
order to stand on the proverbial &amp;ldquo;shoulders of giants.&amp;rdquo; In our default
shortsighted mode of vision, it may appear simpler and more efficient to merely
speed through our reading tasks, satisfying short-term goals while neglecting
the long-term. It is indeed tempting to sacrifice those lofty aims when
suffocating under the weight of past minds, their words forever channeled at us
through book after book, article after article. To skim just a few pages or to
read for raw information rather than for meaning is an impulse indeed often too
attractive to resist.&lt;/p&gt;

&lt;p&gt;Newman&amp;rsquo;s essay urges students to avoid this kind of fervent fact-gathering,
however, and instead remain &amp;ldquo;above [their] knowledge.&amp;rdquo; His most central
recommendations are brief and firm: he suggests that &amp;ldquo;we must generalize, we
must reduce to method, we must have a grasp of principles, and group and shape
our acquisitions by means of them.&amp;rdquo;&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; He refers to this entire process concisely
by employing a metaphor of &lt;em&gt;digestion:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The enlargement [of mind] consists, not merely in the passive reception into
the mind of a number of ideas hitherto unknown to it &amp;hellip; it is a &lt;em&gt;digestion&lt;/em&gt;
of what we receive, into the substance of our previous state of thought; and
without this no enlargement is said to follow.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This &amp;ldquo;digestion,&amp;rdquo; according to Newman, is a necessary condition for any actual
improvement in intellect&amp;mdash;or, in his own terms, for any &amp;ldquo;enlargement of mind.&amp;rdquo;
The process at a high level is clear enough: a student wishing to best benefit
from his reading must always synthesize the new facts he acquires with his
existing knowledge, aggregating a cohesive whole of mastery rather than a mere
conglomeration of pieces of information. But Newman does not sufficiently detail
concrete methods for engaging in this &amp;ldquo;digestion.&amp;rdquo; He does not provide practical
suggestions for applying these ideas to any learning practice, let alone reading
in particular. It is the purpose of this paper to show that a reading practice
combined with a slow, thoughtful extraction of passages from the texts being
read satisfies the requirements for Newman&amp;rsquo;s process of &amp;ldquo;digestion.&amp;rdquo; The method
of integrated reading and writing we examine is by no means novel: it has
existed since at latest the era of the Roman Empire, albeit under many unrelated
names.&lt;/p&gt;

&lt;p&gt;It will first be useful, then, to unify the various overlapping terms for the
products of the practice discussed in this essay. The most well-known names
still extant in discourse today are the &lt;em&gt;florilegium&lt;/em&gt;, the &lt;em&gt;hypomnēma&lt;/em&gt;, and the
commonplace book.&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; These media, though published and discussed under distinct
names, are actually quite similar in their methods of composition and the
results of their use. This essay will focus on the properties and consequences
of the practice at the intersection of these three traditions, which will be
termed the &amp;ldquo;commonplace book&amp;rdquo; for convenience and consistency. This &amp;ldquo;commonplace
book&amp;rdquo; under discussion refers to a personal book containing collections of
quotations and passages from texts or dialogues of particular value or interest
to its owner. The book might also contain marginalia referring to the passages
quoted, or a prologue stating the intention of the author or summarizing the
texts included.&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt; Commonplace authors composed these books during their
reading or immediately after completing a text.&lt;/p&gt;

&lt;p&gt;Historical support for this practice of reading and writing intertwined appears
as far back as ancient Rome. Seneca, a major figure in the Stoic school of
philosophy, stresses in his works the importance of &amp;ldquo;continuous writing.&amp;rdquo; He
employs several oft-used analogies, first portraying scholars as bees traveling
from flower to flower and gathering the nectar of knowledge at each:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We also, I say, ought to copy these bees, and sift whatever we have gathered
from a varied course of reading &amp;hellip; then, by applying the supervising care
with which our nature has endowed us &amp;hellip; we should blend those several flavors
into one delicious compound.&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Seneca portrays the collection of ideas as an extremely discerning process, far
from the simple mechanical procedure of facsimile that the description of
commonplacing might first suggest. We must imitate the bees, using our
&amp;ldquo;supervising care&amp;rdquo; to select the nectar most especially sweet to us&amp;mdash;those
passages which send the clearest and most striking messages. Seneca affirms that
writing is the most reliable method for gathering these notes. The various ideas
which readers collect from books, he says, must be &amp;ldquo;reduced to concrete form by
the pen.&amp;rdquo;&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; This conviction appears in equal force among medieval writings
under the name &lt;em&gt;florilegium&lt;/em&gt; (literally, the &amp;ldquo;collection of flowers.&amp;rdquo;)&lt;sup id=&quot;fnref:8&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:8&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;8&lt;/a&gt;&lt;/sup&gt; John
of Wales, a 13th century writer, quotes Seneca directly as he explains his own
practice of compiling quotes and forming &lt;em&gt;florilegia&lt;/em&gt;. He works to collect
&amp;ldquo;examples worthy to be imitated, which are all so many flowers.&amp;rdquo; John stresses
the process of selection in his own explanation, emphasizing that readers must
make selections carefully, avoiding &amp;ldquo;poisonous errors&amp;rdquo; that could otherwise
enter the collection of quotes.&lt;sup id=&quot;fnref:9&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:9&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;9&lt;/a&gt;&lt;/sup&gt; Several centuries later, Erasmus recommends
to his readers a specific method of processing and organizing what they take in
from books. After a student has prepared separate categories for the storage of
ideas, he should proceed to read with &amp;ldquo;a view to extrapolating.&amp;rdquo;&lt;sup id=&quot;fnref:10&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:10&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;10&lt;/a&gt;&lt;/sup&gt; Indeed,
for these authors throughout history, reading without simultaneously writing was
likely not a serious activity in any amount. As they struggled under the weight
of their reading, the commonplace book served as a natural recourse for
distilling and simplifying the massive input which these writers had to
manage.&lt;sup id=&quot;fnref:11&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:11&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;11&lt;/a&gt;&lt;/sup&gt; Reading in this style was an eminently practical
engagement&amp;mdash;students combed through texts with the explicit purpose of
extracting useful morsels of information.&lt;/p&gt;

&lt;p&gt;The result of such extraction was a collection surprisingly personal and unique.
This simple act of rewriting and annotating quotations by hand produced a unique
work which evidenced the individuality of its owner. In selecting and arranging
choice extracts, a reader would construct a personalized image of his
studies&amp;mdash;a concrete projection of how the texts had affected his own ideas and
beliefs. Kevin Sharpe gives a view of how this practice was paralleled in early
modern England:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[T]hough what the compiler copied was extracted from a common storehouse of
wisdom, the manner in which extracts were copied, arranged, juxtaposed,
cross-referenced or indexed was &lt;em&gt;personal and individual&lt;/em&gt; &amp;hellip; The compiler
essentially rewrote, fashioned a new text, which was anything but common,
indeed was unique.&lt;sup id=&quot;fnref:12&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:12&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;12&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sharpe suggests that the way in which any given commonplace author chose to
unify heterogeneous entries from distinct sources was necessarily personal and
idiosyncratic. As Michel Foucault names the practice in his work &amp;ldquo;Self-Writing,&amp;rdquo;
this &amp;ldquo;subjectivation&amp;rdquo; of new knowledge&amp;mdash;the deliberate process by which a
learner would attempt through transcription and further writing to blend the
lessons from a text into his existing worldview&amp;mdash;was absolutely crucial for
proper understanding and assimilation.&lt;sup id=&quot;fnref:13&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:13&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;13&lt;/a&gt;&lt;/sup&gt; This same concept of subjectivation
is cited in Newman&amp;rsquo;s work as a necessary condition for proper &amp;ldquo;digestion&amp;rdquo; of
information. Newman claims that such a process of fusion of ideas makes &amp;ldquo;the
objects of our knowledge subjectively our own.&amp;rdquo;&lt;sup id=&quot;fnref:14&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:14&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;14&lt;/a&gt;&lt;/sup&gt; The process of commonplace
book composition would yield something wholly unique, composed of equal parts
original text and individual impression. The result was so personal, in fact,
that Francis Bacon proposed it would be of little use to other readers: &amp;ldquo;I think
first in general that one man&amp;rsquo;s notes will little profit another, because one
man&amp;rsquo;s conceit doth so much differ from another&amp;rsquo;s; and also because the bare note
itself is nothing so much worth as the suggestion it gives to the reader.&amp;rdquo;&lt;sup id=&quot;fnref:15&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:15&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;15&lt;/a&gt;&lt;/sup&gt;
A man&amp;rsquo;s &amp;ldquo;conceit&amp;rdquo; derived from any text was personal and unique. In the end,
what readers remembered from their texts was what the works meant to them&amp;mdash;the
&amp;ldquo;suggestion&amp;rdquo; they felt&amp;mdash;rather than the exact content of any given paragraph.
By Bacon&amp;rsquo;s claim, then, a commonplace book contained extracts which, as a whole,
were of higher value to their creator than a simple sum of the values of the
book&amp;rsquo;s parts. The artifacts of these Baconian &amp;ldquo;suggestions&amp;rdquo; could exist in the
form of short pieces of commentary, or simply render themselves in the way
commonplace writers chose to give certain quotes extra prominence in their
books. In allowing original text and impression to mix, whether consciously or
not, readers produced a unique view of their own exploration and learning
progress. These personal extracts would prove to be of real use in the weeks,
months, or years after a reader finished a text, when the passages could be
revisited.&lt;/p&gt;

&lt;p&gt;Gathering passages and notes from various works allowed readers to greatly
simplify the otherwise burdensome task of memorizing the most important lessons
they derived from their texts. By perusing their commonplace books, they were
able to not only recall the exact content of their past favorite quotes but also
experience again the impression which the text had made upon them. Through our
modern lens, it is evident that these revision activities were crucial to proper
memorization and assimilation of the ideas most important to a reader. There is
much scientific evidence today, in fact, which supports this idea of periodic
review of important reading content. The phenomenon known as the &lt;em&gt;spacing
effect&lt;/em&gt; is particularly relevant to this rereading practice. According to the
spacing effect, learners who sustain consistent review of content over long
periods of time can memorize more effectively than those who commit to large
amounts of memorization work in a single sitting.&lt;sup id=&quot;fnref:16&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:16&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;16&lt;/a&gt;&lt;/sup&gt; The tradition of the
commonplace book encouraged this kind of regular spaced review, which modern
psychology research has proven to be an effective method for memorization.
Historical support for this revision activity is just as plentiful: nearly every
author who suggests the composition of a commonplace book also stipulates its
constant inspection and revision. The most critical ideas were to be
consistently reread until finally learned by heart. This recall practice, which
slowly brought the most crucial passages of one&amp;rsquo;s reading closer to a
subconscious level, was of obvious utility for students.&lt;sup id=&quot;fnref:17&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:17&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;17&lt;/a&gt;&lt;/sup&gt; Historical sources
show that recall aided not only students but learners of all ages. Aspiring
essayists and professional writers alike benefited in methodically memorizing
the many short bodies of text which they found relevant or especially profound.
A typical citizen could deploy these memorized commonplaces in conversation or
correspondences. Writers could include their own preferred quotations in their
compositions on any topic.&lt;sup id=&quot;fnref:18&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:18&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;18&lt;/a&gt;&lt;/sup&gt; This tradition was an exceptionally useful
practice for readers of any sort to memorize the passages they held most dear.&lt;/p&gt;

&lt;p&gt;While recall was the most visible and straightforward end in revisiting these
collections, the commonplace book also served as a tool to instill proper values
in its owner. Every commonplace book had its own distinctive selections,
carefully gathered and uniquely recorded by their respective authors. Foucault
draws a strong contrast between the product of this writing practice and other
more superficial methods of collection, which he claims yield nothing more than
&amp;ldquo;memory cabinets.&amp;rdquo; Commonplace books were vessels, rather, for the most
meaningful and crucial ideas that readers wished to &amp;ldquo;deeply lodge in the
soul.&amp;rdquo;&lt;sup id=&quot;fnref:19&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:19&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;19&lt;/a&gt;&lt;/sup&gt; To return to this book and rediscover this collection of
commonplaces was a wholly solemn and private task. It offered readers an
opportunity to relive those solitary moments of deep insight which they had
experienced with texts in the past. Furthermore, it allowed them to see their
various transcriptions not as isolated morsels of wisdom but as small parts of a
larger system. Each quote and comment rested in between many others, and readers
who returned to their books for a certain passage could not avoid comparing this
entry with those nearby. This is Newman&amp;rsquo;s digestion forced into action: it is
the unification of new ideas with old beliefs. It trained the reader to never
contemplate any given concept, in Newman&amp;rsquo;s words, &amp;ldquo;without recollecting that it
is but a part [of a larger picture of knowledge], or without the associations
which spring from this recollection.&amp;rdquo;&lt;sup id=&quot;fnref:20&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:20&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;20&lt;/a&gt;&lt;/sup&gt; This process of revision and
subsequent synthesis helped the reader to piece together a more uniform self.&lt;/p&gt;

&lt;p&gt;Commonplace books had their highest end, then, in helping their owners to build
their own characters in the most literal sense: the composition of the book
paralleled the construction of the character. Readers strove through their
commonplace books to synthesize the heterogeneous opinions they acquired through
their reading into a single cohesive statement of identity. Of course, this
deliberate integration of different ideas could not be accomplished without
significant modification. Seneca compares the gathering of ideas to the chemical
process of digestion, wherein no food can benefit us unless it is also changed
in the process:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This is what we see nature doing in our own bodies without any labor on our
part; the food we have eaten, as long as it retains its original quality and
floats in our stomachs as an undiluted mass, is a burden; but &lt;em&gt;it passes into
tissue and blood only when it has been changed from its original form&lt;/em&gt;. So it
is with the food which nourishes our higher nature,&amp;mdash; we should see to it
that &lt;em&gt;whatever we have absorbed should not be allowed to remain unchanged,&lt;/em&gt; or
it will be no part of us. We must digest it; otherwise it will merely enter
the memory and not the reasoning power.&lt;sup id=&quot;fnref:21&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:21&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;21&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Again we return to the abundant metaphors used throughout history in discussion
of this practice. The &amp;ldquo;food which nourishes our higher nature&amp;rdquo; arrives to
readers in the form of well-crafted sentences, aligned in sequence across
sections, chapters, and volumes&amp;mdash;distilled and compressed knowledge, printed
onto lifeless paper. It is our task, suggests Seneca, to revive these ideas,
enliven them: that is, to analyze, transcribe and repeatedly modify them until
they are wholly our own, persisting in their changed state in our private
thoughts. In transcription and subsequent rereading of these copies their owners
could not avoid contemplating exactly how the passage affected them rather than
simply viewing the old ideas in a dry, objective manner.&lt;sup id=&quot;fnref:22&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:22&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;22&lt;/a&gt;&lt;/sup&gt; The process of
revisiting the book was intrinsically reflective and introspective. It was the
catalyst for a &amp;ldquo;personal construction of meaning,&amp;rdquo; says Sharpe&lt;sup id=&quot;fnref:23&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:23&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;23&lt;/a&gt;&lt;/sup&gt;&amp;mdash;a solemn
and meditative activity of recollection and review through which the reader
could &amp;ldquo;[constitute] his own identity.&amp;rdquo;&lt;sup id=&quot;fnref:24&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:24&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;24&lt;/a&gt;&lt;/sup&gt; It is this active review and
constant inquiry into past lessons learned that Newman promotes as a requirement
for &amp;ldquo;digestion.&amp;rdquo; He portrays the process as one of deliberate &amp;ldquo;locomotion&amp;rdquo;: a
&amp;ldquo;gravitat[ion]&amp;rdquo; toward some cohesive personal worldview.&lt;sup id=&quot;fnref:25&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:25&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;25&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Such constant gravitation brought readers ever closer toward a destined balance
in knowledge and identity through reading, writing, and meditation on that
writing. The result, to engage once more in the profusion of metaphor present
among all the writing on this topic, was a &amp;ldquo;choir&amp;rdquo; of past ideas, each memorized
and carefully aligned to fit the theme of the whole:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Let our minds aim at showing the finished product, but conceal all that has
helped to produce it &amp;hellip; take a choir: it consists, as you see, of many voices
and yet all those voices form a unity &amp;hellip; although individual voices do not
emerge, the voices of all are heard and from a number of different sounds
there comes a harmony.&lt;sup id=&quot;fnref:26&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:26&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;26&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The mind as constructed by the commonplace book was purely a synthesis of the
most prized thoughts of the past. After some slight modification, each idea fit
in as a voice in a choir, such that the group as a whole produced a single
harmony. While this &amp;ldquo;harmony&amp;rdquo; is always cited as a beneficial result of
commonplacing, sources across history disagree on the related consequences of
this practice of collection. Mary J. Carruthers observes that the medieval
citizen may have treasured the activity to a fault, seeing himself as precisely
the product of his readings and no more.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;One sometimes gets the impression that a medieval person &amp;hellip; could do nothing
(especially in duress) without rehearsing a whole series of exemplary stories,
the material of their experience built up board by board in memory &amp;hellip; so that
even in moments of stress the counsel of experience will constrain a turbulent
and willful mind.&lt;sup id=&quot;fnref:27&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:27&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;27&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a relatively radical perspective of the effects of commonplacing.
Readers were so extremely dependent on their personal books, Carruthers
suggests, that without those collected quotes we would see unleashed &amp;ldquo;turbulent
and willful mind[s],&amp;rdquo; unbridled and unanchored from their safe havens built up
from the writings of past authors. Some opponents of the practice criticized
this extreme form of the idea. They claimed that those who relied solely on
accepted ideas of the past doomed themselves to weak, impersonal
argumentation.&lt;sup id=&quot;fnref:28&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:28&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;28&lt;/a&gt;&lt;/sup&gt; This contention has merit, but only serves to refute the
particular conception of the practice that Carruthers presents. The portrayal is
indeed unfair to the majority of commonplace book authors, who were not so
absolutely dependent on their books. As we have already learned, commonplace
books were defined by their more primary use in deliberate reflection and
introspection rather than by their purpose as a simple reference. This
particular form of study did not yield some sort of unstable debater completely
dependent on his past notes, but rather, in Seneca&amp;rsquo;s words, a unique
intellectual child of the authors of quotes gathered.&lt;sup id=&quot;fnref:29&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:29&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;29&lt;/a&gt;&lt;/sup&gt; A commonplace writer
was the product of many disparate (and perhaps even disagreeing) voices, whose
precepts were each tweaked and re-aligned by the writer to form a holistic and
coherent compilation. The diligent commonplace book owner was not a lifeless
portrait of the inputs,&lt;sup id=&quot;fnref:30&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:30&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;30&lt;/a&gt;&lt;/sup&gt; but rather a living and breathing entity, carrying
treasures of accumulated wisdom and prepared to deploy them in situations both
trivial and novel.&lt;/p&gt;

&lt;p&gt;In such novel situations the benefit of commonplacing becomes even clearer. To
many writers of the past, those readers who worked to establish concrete moral
codes through their commonplace books proved to be the most resilient in the
face of new or resurgent problems. These types of problems require a stable,
robust mind: one which can rationally evaluate the root of an issue and resolve
it using a combination of past knowledge and new constructions. This thinking,
says Foucault, is patently impossible for a reader who does not maintain control
over the many distinct ideas he derives from his texts. &amp;ldquo;Endless reading&amp;rdquo;
without deliberate writing interspersed would lead to the &amp;ldquo;great deficiency&amp;rdquo; of
&lt;em&gt;stultitia&lt;/em&gt;&amp;mdash;a state of &amp;ldquo;mental agitation&amp;rdquo; and &amp;ldquo;distraction&amp;rdquo; in which the
reader is overwhelmed by the massive amounts of input which he must process,
without the assistance of any external tools.&lt;sup id=&quot;fnref:31&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:31&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;31&lt;/a&gt;&lt;/sup&gt; A program of intense reading
which omits these aids would do little for a student but fill his mind with a
hodgepodge of facts and likely contradictory ideas. Newman&amp;rsquo;s essay claims that
readers who simply hoard knowledge &amp;ldquo;they have not thought through&amp;rdquo; are thus
&amp;ldquo;only possessed &lt;em&gt;by&lt;/em&gt; [it], not possessed &lt;em&gt;of&lt;/em&gt; it; nay, in matter of fact they
are often even carried away by it, without any volition of their own.&amp;rdquo;&lt;sup id=&quot;fnref:32&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:32&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;32&lt;/a&gt;&lt;/sup&gt; The
function of the commonplace book from this perspective, then, is to allow
readers to establish an intellectual anchor&amp;mdash;some definite collection of
precepts and past arguments against which new ideas and new problems can be
compared&amp;mdash;so as to not be &amp;ldquo;carried away&amp;rdquo; by the weight of their own reading.&lt;/p&gt;

&lt;p&gt;The product of commonplacing was a cohesive composition far greater than the sum
of its parts, a physical realization of the identity and intellect of its
discerning author. The practice yielded after years a mind rigorously trained
and exceptionally prepared, forever supported by this anchor of precepts
deliberately assimilated and consciously reaffirmed over time. The commonplace
author was a perfect image of the product of Newman&amp;rsquo;s &amp;ldquo;digestion.&amp;rdquo; He used his
book to process and memorize important information from the texts he
encountered, while simultaneously working to construct a unique, robust self.
Over the years the author built an image of himself through his collection, and
benefited from a clear view into his own intellectual past.&lt;/p&gt;

&lt;p&gt;This is not to say that items once penned in a commonplace book were made
eternally true. On the contrary, the book offered detailed images of a reader&amp;rsquo;s
past thoughts and beliefs, many of which he was likely to see invalidated in the
future. These collections merely provided a snapshot of the reader&amp;rsquo;s worldview
of the past, which upon revisiting he could choose to reinforce or deny using
new evidence or personal experience. In returning to past extractions wielding
new evidence or ideas, the author continued that same process of synthesis and
modification begun during the book&amp;rsquo;s creation even after its pages had been
filled. As such a projection of the past, the book made for the reader a nearly
physical companion out of his former self&amp;mdash;a reification of his earlier
thoughts with whom he could converse and debate.&lt;sup id=&quot;fnref:33&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:33&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;33&lt;/a&gt;&lt;/sup&gt; These images of a past
self were invaluable to a commonplace writer in providing an image of which
intellectual landscapes he had visited and where he had yet to explore. The book
was a depository, moreover, into which the suggestions triggered by each
individual work could be assembled, mixed, rearranged, and investigated as a
cohesive whole. In this way, the commonplace author found a method for managing
his knowledge inheritance&amp;mdash;for lodging deeply in his soul those precepts most
important to him, and thus learning to master the weight of past generations.
&lt;em&gt;Imperat aut servit:&lt;/em&gt; with the commonplace book at hand, the reader was finally
free to choose.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;John Henry Newman, &lt;em&gt;The Idea of a University: Defined and Illustrated&lt;/em&gt; (Oxford: Clarendon Press, 1976), 125. The Latin phrases translate as &amp;ldquo;master or slave&amp;rdquo; and &amp;ldquo;brute force bereft of wisdom / falls to ruin by its own weight,&amp;rdquo; respectively. Newman&amp;rsquo;s &lt;em&gt;Idea&lt;/em&gt;, the work on which this essay is based, has had a profound&amp;mdash;some might say even revolutionary&amp;mdash;effect on our modern view of education. See Cornwell, John. &lt;em&gt;Newman&amp;rsquo;s Unquiet Grave: The Reluctant Saint&lt;/em&gt;. New York: Continuum, 2010, 128.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Ibid.&lt;/em&gt;, 120.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Ibid.&lt;/em&gt;, 120. Emphasis added.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;There are plenty of names for this practice which happen to have fallen out of fashion. A 1964 analysis lists 38 different names which authors of the past used to refer to the same concept of the &lt;em&gt;florilegium&lt;/em&gt;: see Henri-Marie Rochais, &amp;ldquo;Florilèges spirituels,&amp;rdquo; in &lt;em&gt;Dictionnaire de spiritualité ascétique et mystique, doctrine et histoire&lt;/em&gt;., vol. 5 (Paris: Beauchesne, 1964), 438.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Jacqueline Hamesse, &amp;ldquo;Les florilèges philosophiques du XIIIe au XVe siècle,&amp;rdquo; in &lt;em&gt;Les genres littéraires dans les sources théologiques et philosophiques médiévales&lt;/em&gt;, vol. 5, Textes, Études, Congrès 2 (Louvain-la-Neuve: Université catholique de Louvain, 1982), 184.&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Lucius Annaeus Seneca, &amp;ldquo;On Gathering Ideas,&amp;rdquo; in &lt;em&gt;Ad Lucilium epistulae morales&lt;/em&gt;, trans. Richard M. Gummere (Cambridge, Mass.: Harvard University Press, 1970), 279. This metaphor is often stolen by later writers. See for example Ambrosius Aurelius Theodosius Macrobius, &lt;em&gt;The Saturnalia&lt;/em&gt;, trans. Percival Vaughan Davies (New York: Columbia University Press, 1969), 1.5.&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Seneca, &amp;ldquo;On Gathering Ideas,&amp;rdquo; 277.&amp;nbsp;&lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:8&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Alternate names included the flores philosophorum and the flores auctorum. See Ann Moss, &lt;em&gt;Printed Commonplace-Books and the Structuring of Renaissance Thought&lt;/em&gt; (Oxford: Clarendon Press, 1996), 24.&amp;nbsp;&lt;a href=&quot;#fnref:8&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:9&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Quoted in &lt;em&gt;ibid.&lt;/em&gt;, 30.&amp;nbsp;&lt;a href=&quot;#fnref:9&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:10&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;R. R. Bolgar, &lt;em&gt;The Classical Heritage and Its Beneficiaries&lt;/em&gt;. (Cambridge, England: University Press, 1954), 273&amp;ndash;274.&amp;nbsp;&lt;a href=&quot;#fnref:10&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:11&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Rochais, &amp;ldquo;Florilèges spirituels,&amp;rdquo; 457.&amp;nbsp;&lt;a href=&quot;#fnref:11&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:12&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Kevin Sharpe, &lt;em&gt;Reading Revolutions: The Politics of Reading in Early Modern England&lt;/em&gt; (New Haven, CT: Yale University Press, 2000), 278. Emphasis added.&amp;nbsp;&lt;a href=&quot;#fnref:12&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:13&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Michel Foucault, &lt;em&gt;Ethics: Subjectivity and Truth&lt;/em&gt;, vol. 1, The Essential Works of Michel Foucault, 1954&amp;ndash;1984 (New York: New Press, 1997), 210.&amp;nbsp;&lt;a href=&quot;#fnref:13&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:14&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Newman, &lt;em&gt;The Idea of a University&lt;/em&gt;, 120.&amp;nbsp;&lt;a href=&quot;#fnref:14&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:15&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Francis Bacon, &lt;em&gt;The Letters and the Life of Francis Bacon&lt;/em&gt; (Longmans, Green and Co., 1890), 25&amp;ndash;26.&amp;nbsp;&lt;a href=&quot;#fnref:15&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:16&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Douglas L. Hintzman, &amp;ldquo;Repetition and Memory,&amp;rdquo; in &lt;em&gt;Psychology of Learning and Motivation&lt;/em&gt;, by Gordon H. Bower, vol. 10 (Academic Press, 1976), 65.&amp;nbsp;&lt;a href=&quot;#fnref:16&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:17&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Freyja Cox Jensen, &lt;em&gt;Reading the Roman Republic in Early Modern England&lt;/em&gt;, Library of the Written Word v. 22 (Boston: Brill, 2012), 37.&amp;nbsp;&lt;a href=&quot;#fnref:17&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:18&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Ibid.&lt;/em&gt;, 91. John of Salisbury, a writer well known for his commonplacing practice, serves as evidence of the utility of commonplacing for writers. See Rochais, &amp;ldquo;Florilèges spirituels,&amp;rdquo; 462.&amp;nbsp;&lt;a href=&quot;#fnref:18&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:19&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Foucault, &lt;em&gt;Ethics: Subjectivity and Truth&lt;/em&gt;, 210.&amp;nbsp;&lt;a href=&quot;#fnref:19&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:20&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Newman, &lt;em&gt;The Idea of a University&lt;/em&gt;, 123.&amp;nbsp;&lt;a href=&quot;#fnref:20&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:21&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Seneca, &amp;ldquo;On Gathering Ideas,&amp;rdquo; 279&amp;ndash;281. Emphasis added.&amp;nbsp;&lt;a href=&quot;#fnref:21&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:22&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;See Barbara M. Benedict, &lt;em&gt;Making the Modern Reader: Cultural Mediation in Early Modern Literary Anthologies&lt;/em&gt; (Princeton, NJ: Princeton University Press, 1996), 47; Susan Miller, &lt;em&gt;Assuming the Positions: Cultural Pedagogy and the Politics of Commonplace Writing, Pittsburgh Series in Composition, Literacy, and Culture&lt;/em&gt; (Pittsburgh, PA: University of Pittsburgh Press, 1998), 21, 24.&amp;nbsp;&lt;a href=&quot;#fnref:22&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:23&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Sharpe, &lt;em&gt;Reading Revolutions&lt;/em&gt;, 279.&amp;nbsp;&lt;a href=&quot;#fnref:23&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:24&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Foucault, &lt;em&gt;Ethics: Subjectivity and Truth&lt;/em&gt;, 214.&amp;nbsp;&lt;a href=&quot;#fnref:24&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:25&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Newman, &lt;em&gt;The Idea of a University&lt;/em&gt;, 121.&amp;nbsp;&lt;a href=&quot;#fnref:25&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:26&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Macrobius, &lt;em&gt;The Saturnalia&lt;/em&gt;, 1.9.&amp;nbsp;&lt;a href=&quot;#fnref:26&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:27&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Mary J. Carruthers, &amp;ldquo;Memory and the Ethics of Reading,&amp;rdquo; in &lt;em&gt;The Book of Memory: A Study of Memory in Medieval Culture&lt;/em&gt; (Cambridge, England: Cambridge University Press, 1990), 180.&amp;nbsp;&lt;a href=&quot;#fnref:27&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:28&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Moss, &lt;em&gt;Printed Commonplace-Books and the Structuring of Renaissance Thought&lt;/em&gt;, 21.&amp;nbsp;&lt;a href=&quot;#fnref:28&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:29&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Seneca, &amp;ldquo;On Gathering Ideas,&amp;rdquo; 281.&amp;nbsp;&lt;a href=&quot;#fnref:29&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:30&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Ibid.:&lt;/em&gt; &amp;ldquo;I would have you resemble [the authors from whom you collect ideas] &amp;hellip; not as a picture resembles its original, for a picture is a lifeless thing&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:30&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:31&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Foucault, &lt;em&gt;Ethics: Subjectivity and Truth&lt;/em&gt;, 211&amp;ndash;212.&amp;nbsp;&lt;a href=&quot;#fnref:31&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:32&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Newman, &lt;em&gt;The Idea of a University&lt;/em&gt;, 126.&amp;nbsp;&lt;a href=&quot;#fnref:32&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:33&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Kenneth Lockridge, &amp;ldquo;Individual Literacy in Commonplace Books,&amp;rdquo; &lt;em&gt;Interchange&lt;/em&gt; 34, no. 2/3 (September 2003), 338&amp;ndash;339.&amp;nbsp;&lt;a href=&quot;#fnref:33&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-4/</link>
      <pubDate>Sun, 15 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-4/</guid>
      <description>&lt;p&gt;The quarter is over, and I&amp;rsquo;m back at home with the family. Tomorrow I&amp;rsquo;ll return
for a few weeks contracting at &lt;a href=&quot;http://stremor.com&quot;&gt;Stremor&lt;/a&gt;. Here&amp;rsquo;s what I&amp;rsquo;ve been reading this
week:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.jstor.org/stable/2138534&quot;&gt;&lt;strong&gt;Aaron (1994)&lt;/strong&gt;&lt;/a&gt; attacks the idea of treating the preferences and values
of an individual as stable as more of an &amp;ldquo;axiom of religious faith&amp;rdquo; than a
&amp;ldquo;defensible scientific hypothesis&amp;rdquo; (6). He supports approaches such as that of
&lt;a href=&quot;https://en.wikipedia.org/wiki/Sugarscape&quot;&gt;Epstein and Axell&lt;/a&gt;, which avoid unrealistic oversimplified models of
utility that Aaron claims have plagued microeconomics for too long.&lt;/li&gt;
  &lt;li&gt;Bertrand Russell gives the &lt;a href=&quot;http://news.google.com/newspapers?id=NcJVAAAAIBAJ&amp;amp;sjid=tr0DAAAAIBAJ&amp;amp;pg=6918%2C334589&quot;&gt;&lt;strong&gt;10 commandments of &amp;ldquo;true liberalism&amp;rdquo;&lt;/strong&gt;&lt;/a&gt; &amp;mdash;
worth a read for any student, learner, thinker, etc.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://object.cato.org/sites/cato.org/files/serials/files/regulation/1983/5/v7n3-3.pdf&quot;&gt;&lt;strong&gt;Yandle (1983)&lt;/strong&gt;&lt;/a&gt; gives an outline of his catchy concept of &amp;ldquo;bootleggers
and baptists.&amp;rdquo; For those unacquainted with the bridge between public policy
and economics (read: me), this is a really enlightening read.&lt;/li&gt;
  &lt;li&gt;Rudolf Weinstock&amp;rsquo;s &lt;a href=&quot;http://www.winestockwebdesign.com/Essays/Lisp_Curse.html&quot;&gt;&lt;strong&gt;The Lisp Curse&lt;/strong&gt;&lt;/a&gt; makes a poignant statement about
software development: the people developing may be as affected by their tools
as they affect their environment. Technology affects our social behavior.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    
    
    
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-3/</link>
      <pubDate>Sun, 08 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-3/</guid>
      <description>&lt;p&gt;It&amp;rsquo;s finals week here at Stanford. I&amp;rsquo;m just finishing up a research paper
entitled &amp;ldquo;&lt;em&gt;Imperat aut servit&lt;/em&gt;: Managing our knowledge inheritance&amp;rdquo; which will
likely be published here after the quarter has ended. Apart from writing, I&amp;rsquo;m
beginning to think about further independent research. I&amp;rsquo;ve been investigating
patterns in Romanian etymology and am considering engaging in some sort of
formal analysis. Hayek is also still on my mind &amp;mdash; I&amp;rsquo;ve been wondering about
how I can model a particularly interesting statement in &amp;ldquo;The Use of Knowledge in
Society&amp;rdquo; using genetic programming. More on all of this later, I&amp;rsquo;m sure.&lt;/p&gt;

&lt;p&gt;For now, here are the interesting parts of my (very sparse) reading this week:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://www.jstor.org/stable/27740557&quot;&gt;Hoxby (2009)&lt;/a&gt;&lt;/strong&gt; details a trend of &amp;ldquo;re-sorting&amp;rdquo; among college applicants
over the past decades which has led to a more efficient &amp;ldquo;matching&amp;rdquo; between
high-aptitude students and high-selectivity schools. She demonstrates that
per-student resources at highly selective universities have skyrocketed due to
this higher efficiency: as better-matched students arrive at top-tier
colleges, they demand the support they have been looking forward to.
Furthermore, the paper reveals a curious trend in the financials of premier
American colleges: the average student only pays around 20% of the value of
the resources offered to him, while the remainder is repaid by alumni
donations.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://cognet.mit.edu/library/books/view?isbn=0262550253&quot;&gt;&lt;em&gt;Growing Artificial Societies&lt;/em&gt;&lt;/a&gt;&lt;/strong&gt; by Epstein and Axtell has been useful
as I think about developing a system to model problems in economics (see
introduction).&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-2/</link>
      <pubDate>Sun, 01 Dec 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-2/</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://www.jstor.org/stable/10.1086/468061&quot;&gt;Gneezy and Rustichini (2000)&lt;/a&gt;&lt;/strong&gt; examine the effect of imposing a fine on
parents who arrive late to pick up their children from Israeli daycare
centers. They find that parents actually arrive significantly later once this
fine is in place. When what was formerly a fuzzy unwritten social contract is
rewritten with an exact punishment, they suggest that parents feel free to
break the rules and pay the exact fine (where before they were unsure about
the potential consequences of their lateness).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://www.dailymail.co.uk/home/moslive/article-1326286/Facebook-Why-The-Social-Network-brilliant--completely-misses-point.html&quot;&gt;Lawrence Lessig argues&lt;/a&gt;&lt;/strong&gt; that most of the people who watch The Social
Network will miss the really important point in the story of the rise of
Facebook: that is, no innovation of its kind would have been possible without
the Internet, which is not bogged down by monopolies or excessive regulation
(yet?).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://www.wired.com/wiredenterprise/2013/11/bitcoin-and-deflation/&quot;&gt;&amp;ldquo;Bitcoin is Flawed, But It Will Still Take Over the World&amp;rdquo;&lt;/a&gt;&lt;/strong&gt; covers
some of the most recent controversy concerning the booming cryptocurrency. It
is still disputed whether the inevitable deflation of Bitcoin (the total
circulation is limited by design) will doom the
currency.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;A &lt;a href=&quot;https://en.wikipedia.org/wiki/Free_rider_problem&quot;&gt;free rider problem&lt;/a&gt; will also
emerge when this limit is reached: those who currently &amp;ldquo;mine&amp;rdquo; Bitcoin are
actually in effect working to validate real digital transactions. When there
is no more coin to be mined, the incentive to continue supporting the network
in this way drops significantly. There is by design a mechanism by which
spenders can pay transaction fees to miners so that their exchanges are
verified efficiently, but it is not certain that this will be a stable or
sufficient incentive alone. The author ignores the possibility of the problem
in suggesting: &amp;ldquo;They may run them just to keep the Bitcoin system going,
knowing that the system will reward them in other ways.&amp;rdquo;&lt;/li&gt;
  &lt;li&gt;More on Bitcoin:
&lt;strong&gt;&lt;a href=&quot;http://www.wired.com/wiredenterprise/2013/11/bitcoin_hearing/&quot;&gt;&amp;ldquo;As China Looms, the U.S. Ponders Ways Not to Destroy Bitcoin.&amp;rdquo;&lt;/a&gt;&lt;/strong&gt; Robert
McMillan of Wired Enterprise claims that current U.S. regulations are stifling
an industry with great potential. He suggests that as the involvement of the
Chinese with the currency skyrckets, a significant part of the Congressional
support for Bitcoin is fueled by a worry of a China-dominated digital
currency.&lt;/li&gt;
  &lt;li&gt;In the early 20th century, William James&amp;rsquo; &lt;strong&gt;&lt;a href=&quot;https://en.wikisource.org/wiki/The_Ph.D._Octopus&quot;&gt;&amp;ldquo;The Ph.D. Octopus&amp;rdquo;&lt;/a&gt;&lt;/strong&gt; pointed
to a dangerous and popular trend of overdependence on credentials within
academia. I can&amp;rsquo;t say the problem has improved &amp;mdash; it&amp;rsquo;s survived, rather, and
spread into industry as well!&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Sunday Links</title>
      <link>http://foldl.me/2013/sunday-links-1/</link>
      <pubDate>Sun, 24 Nov 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/sunday-links-1/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve decided to join the Internet-wide trend of posting regular updates on
articles, blog posts, etc. that I have read recently and find interesting. I see
multiple benefits in such a practice:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;As a commitment mechanism:&lt;/strong&gt; With the Internet watching, I will (hopefully)
feel more motivated to maintain good reading habits. Furthermore, I&amp;rsquo;ll have an
incentive to write about my insights on each piece (these posts would
otherwise be of no more value than any other news aggregation).&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;As a more effective method of sharing:&lt;/strong&gt; Individual posts on social networks
often seem &amp;ldquo;drowned out&amp;rdquo; to me, quickly eclipsed by the slightly newer
articles displayed immediately above it. This form of more formal publication
should counter that effect.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;As a log of my reading progress:&lt;/strong&gt; I envision an archive of my reading
interests over the weeks / months / years&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; could be very useful to my
future self.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without further ado, here begins the Sunday Links series!&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Sean Trende from RealClearPolitics &lt;a href=&quot;http://www.realclearpolitics.com/articles/2013/11/14/is_the_value_of_campaign_spending_overstated_120667.html&quot;&gt;claims that House campaign spending&lt;/a&gt;
only has significant effects for challengers. This post is based on findings
from the late 80&amp;rsquo;s / early 90&amp;rsquo;s. &lt;a href=&quot;http://www.jstor.org/stable/2138764&quot;&gt;Levitt (1994)&lt;/a&gt; contradicts these ideas
and suggests that the marginal dollar of funding actually does little for both
the incumbent and the challenger, after controlling for candidate quality and
performing more than a simple cross-sectional analysis (as Trende has done).&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://arxiv.org/abs/1311.1213&quot;&gt;Varshney et al. (2013)&lt;/a&gt; describe a system for
&lt;a href=&quot;http://en.wikipedia.org/wiki/Computational_creativity&quot;&gt;computational creativity&lt;/a&gt;. The system combines many disparate datasets on
cuisine and food ingredients (containing data concerning e.g. regional cooking
practices, observed links between chemicals and &amp;ldquo;hedonic &lt;a href=&quot;http://en.wikipedia.org/wiki/Psychophysics&quot;&gt;psychophysical&lt;/a&gt;
effects,&amp;rdquo; olfactory properties, etc. etc.) and automatically designs and
assesses &amp;ldquo;creative&amp;rdquo; novel meal recipes.&lt;/li&gt;
  &lt;li&gt;F. A. Hayek&amp;rsquo;s article &lt;a href=&quot;http://www.econlib.org/library/Essays/hykKnw1.html&quot;&gt;&amp;ldquo;The Use of Knowledge in Society&amp;rdquo;&lt;/a&gt; explains how a
free market can resolve the problem of insufficient knowledge on the part of
any given individual through prices. Hayek claims that a system of central
planning would require a single entity with total knowledge of the
circumstances of all of its constituents, and argues that a decentralized
system which regulates itself by prices is superior.&lt;/li&gt;
  &lt;li&gt;David Luposchainsky &lt;a href=&quot;https://en.wikipedia.org/wiki/Strange_loop&quot;&gt;provides examples&lt;/a&gt; of &lt;a href=&quot;https://github.com/quchen/articles/blob/master/loeb-moeb.md&quot;&gt;strange loops&lt;/a&gt; in Haskell
with two simple functions, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;loeb&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;moeb&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Assuming I can make this a long-term habit, that is!&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Series name shamelessly stolen from &lt;a href=&quot;http://everydayutilitarian.com&quot;&gt;Peter Hurford&lt;/a&gt;, whose Sunday Links posts I always enjoy.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Marcus Aurelius and slavery in the Roman Empire</title>
      <link>http://foldl.me/2013/marcus-aurelius-and-slavery-in-the-roman-empire/</link>
      <pubDate>Tue, 05 Nov 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/marcus-aurelius-and-slavery-in-the-roman-empire/</guid>
      <description>&lt;p&gt;&lt;em&gt;Something of a departure from the usual content today &amp;mdash; what follows is my
 attempt to answer the question, &amp;ldquo;Why didn&amp;rsquo;t Marcus Aurelius the Stoic fight to
 end slavery?&amp;rdquo; I hope you enjoy the read. I&amp;rsquo;d appreciate any and all comments!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;See a &lt;a href=&quot;https://www.zotero.org/groups/jrgauthiers_public_library/items/collectionKey/TVIFI78M&quot;&gt;Zotero folder&lt;/a&gt; documenting my research for this essay.&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;In the &lt;em&gt;Meditations&lt;/em&gt; Marcus Aurelius extols the ideas of independence and
self-determination, echoing many of his Later Stoic intellectual ancestors and
contemporaries. In 1.14 he speaks of the treasures of a &amp;ldquo;balanced constitution&amp;rdquo;
and a &amp;ldquo;monarchy which values above all things the freedom of the subject.&amp;rdquo; It is
difficult to reconcile egalitarian precepts like these, though, with Marcus&amp;rsquo;
behavior as leader of the Roman Empire for 19 years. The Roman institution of
slavery, for example, seems to be in direct contradiction with his own ideals.
Although Aurelius likely interacted with or benefited from the work of slaves
daily while writing the Meditations on campaign, he makes little mention of this
practice in his work. Why would Aurelius not fight against slavery in the Roman
Empire, given his strong commitment to his philosophy and the significant power
he wielded? It may appear at first glance that Aurelius simply refused to
consider any sort of action. But we can&amp;rsquo;t make complete conclusions by scanning
the &lt;em&gt;Meditations&lt;/em&gt; alone. A study of the emperor&amp;rsquo;s philosophical tradition
reveals a much more nuanced picture: the ethics and personal beliefs sourced
from his Stoic predecessors combined to present several substantial obstacles to
an aggressive campaign for the abolition of slavery.&lt;/p&gt;

&lt;p&gt;The practice of slavery was prevalent throughout the Roman Empire at the time of
Aurelius&amp;rsquo; ascension. About 30 percent of the population of the city of Rome
consisted of slaves. The duties of slaves in the empire varied widely. In urban
Rome, those in servitude might be employed by the city to maintain public
buildings or coordinate construction projects. Wealthy private citizens often
owned several slaves who acted as nurses, tutors, or housekeepers. Others would
be sent to work in factories or on farms.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; Slaves acting as domestic servants
often had good chances of economic success or even freedom, while those working
in large groups away from the cities were likely forced to resign to a lifetime
of subjugation.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; Together slaves played a crucial role in sustaining the
empire, supporting projects in both the public and private sectors.&lt;/p&gt;

&lt;p&gt;There is surprisingly little discussion of this slavery so important to the
empire in Later Stoic texts (of which Aurelius&amp;rsquo; &lt;em&gt;Meditations&lt;/em&gt; forms a part). The
Stoics remain curiously quiet on the social and political institution of slavery
in their time, but do make significant comments about how one should best treat
a slave. In Seneca&amp;rsquo;s famous 47th letter to Lucilius, he skirts around the larger
question of the norm of slavery and instead attempts to prescribe how they
should be treated: &amp;ldquo;But this is the kernel of my advice: Treat your inferiors as
you would be treated by your betters.&amp;rdquo;&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; All of the Later Stoic writing on
this specific topic stresses the equality of all men in a spiritual or cosmic
sense. While such a tenet is only implied in Seneca&amp;rsquo;s letter, Marcus Aurelius
states it more plainly in his Meditations. He asks us to &amp;ldquo;[c]onsider how [we]
stand in relation to [our companions], and how we were born to help one
another.&amp;rdquo;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; Though a free Roman and a Roman slave obviously differed in their
social positions, the Stoics thought it important to recognize that both were
humans and both therefore deserved humane treatment.&lt;/p&gt;

&lt;p&gt;But the Stoics seem to feel less direct sympathy than we might expect for their
own fellow human beings, relegated to servitude under a human master. This is
perhaps because they were more concerned with a very different kind of slavery:
that of a free man to desire, emotion, or irrationality. &amp;ldquo;Slavery&amp;rdquo; for the
Stoics referred, rather, to an unacknowledged dependence on an external factor
for internal tranquility and peace. Seneca asks his contemporaries to turn
inward when contemplating slaves, and realize how they too are bound to their
own, more abstract masters:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;‘He is a slave.’ His soul, however, may be that of a freeman. ‘He is a slave.’
But shall that stand in his way? Show me a man who is not a slave; one is a
slave to lust, another to greed, another to ambition, and all men are slaves
to fear. … No servitude is more disgraceful than that which is
self-imposed.&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A slavery &amp;ldquo;self-imposed&amp;rdquo; was more terrifying to the Stoics than any external
social circumstance. Such servitude led man after man astray from his duties,
suffering from a &amp;ldquo;disgraceful&amp;rdquo; irrationality and lack of wisdom. Following
Seneca, Marcus Aurelius uses the same metaphor to describe how one&amp;rsquo;s mind may be
dominated and enslaved by thoughts of an unhappy status quo or an uncertain
future: &amp;ldquo;No longer allow [your ruling center] to act as a slave &amp;hellip; no longer
allow it to be discontented with its present lot or flinch from what will fall
to it in the future.&amp;rdquo;&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt; This other form of captivity, named &amp;ldquo;moral slavery&amp;rdquo; by
later scholars, was of far superior importance to Stoic thinkers. The Stoics
knew that this servitude to such invisible masters pervaded the minds of
plebeians and patricians alike, and they saw righting this malady as a more
primary goal. Moreover, Aurelius and his companions were well aware that while
moral slaves could free themselves immediately of their own volition, this was
not the case with traditional slaves. The Stoics believed, then, that &amp;ldquo;[b]y
comparison with the slavery that was a condition of the soul, legal slavery was
of marginal importance. It was an external&amp;mdash;like health and illness, wealth and
poverty, high and low status&amp;mdash;over which we had no control. As such, it was
neither good nor bad but, rather, indifferent.&amp;rdquo;&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt; The Stoics saw this
distinction between fixed external factors and mutable internal factors as
central to everyday life. They chose to regard the features of their lives not
under their direct control with a knowing indifference&amp;mdash;a relaxed and rational
concession of power over things outside of the individual.&lt;/p&gt;

&lt;p&gt;This indifference was prevalent throughout the writing of the Later Stoics. In
the context of enslavement, they would think it important to recognize the
random chance that could cast one person into slavery and another into a
sedentary life in the aristocracy. Both conditions would be bestowed at birth,
outside of an individual&amp;rsquo;s control. The result of this coin-flip decision by
what the Stoics dub &amp;ldquo;Fortune,&amp;rdquo; then, would ideally not have any bearing on the
happiness of the individual in life. What leads the path of a person&amp;rsquo;s
life&amp;mdash;the rational mind, or the &amp;ldquo;ruling center&amp;rdquo; by Aurelius&amp;rsquo;
terminology&amp;mdash;should be, in the Stoics&amp;rsquo; view, independent from and unhampered by
any physical or social circumstance.&lt;sup id=&quot;fnref:8&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:8&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;8&lt;/a&gt;&lt;/sup&gt; Seneca claims that &amp;ldquo;it is a mistake to
imagine that slavery pervades a man&amp;rsquo;s whole being,&amp;rdquo; because our rational center
&amp;ldquo;cannot be transferred as a chattel.&amp;rdquo;&lt;sup id=&quot;fnref:9&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:9&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;9&lt;/a&gt;&lt;/sup&gt; Once we recognize the independence of
this ruling rationality in ourselves, suggest the Stoics, we are no longer
hindered by the emotions that any circumstance may trigger. Epictetus exhibits
the same sentiment in a more general context in his &lt;em&gt;Encheiridion&lt;/em&gt;, holding that
&amp;ldquo;[m]en are disturbed not by things, but by the views which they take of
things.&amp;rdquo;&lt;sup id=&quot;fnref:10&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:10&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;10&lt;/a&gt;&lt;/sup&gt; Our happiness, according to the Stoics, can be independent from
our physical state. Thus in this view life as a well-treated slave could be just
as tranquil and happy as life as a commoner or an aristocrat.&lt;/p&gt;

&lt;p&gt;However much this philosophical reasoning allows us to excuse our Stoic ruler
from a fight against slavery, Marcus Aurelius did in fact strive to protect the
rights of slaves. Anthony R. Birley indicates a &amp;ldquo;consistent policy&amp;rdquo; throughout
Aurelius&amp;rsquo; reign of giving every slave &amp;ldquo;the maximum possible chance of attaining
freedom.&amp;rdquo; The jurist Marcellus attributed to Aurelius a &amp;ldquo;partiality for freedom&amp;rdquo;
with respect to cases involving manumission.&lt;sup id=&quot;fnref:11&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:11&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;11&lt;/a&gt;&lt;/sup&gt; Other sources state the
leader&amp;rsquo;s preference for the freedom of slaves even more strongly. Arnold M. Duff
indicates a trend of legislating and ruling in the favor of slaves among several
of the Antonines:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Hadrian and his two successors, under the influence of the Stoics, began an
energetic campaign for the amelioration of slavery. &amp;hellip; Hadrian put an end to
the anomaly that provincial towns were not, like the state, allowed to free
their slaves; in the reign of Marcus Aurelius the right of manumission was
granted to collegia. &amp;hellip; [O]ne of the most striking evidences of the
humanitarian movement is the history of fideicommissary manumission which
evolved itself into legal form between Trajan and Marcus Aurelius. About
twenty &lt;em&gt;senatus-consulta&lt;/em&gt; and imperial &lt;em&gt;constitutiones&lt;/em&gt; are known to us with
reference to &lt;em&gt;fideicommissa&lt;/em&gt;. &amp;hellip; Of those twenty rescripts and decisions all
are in favour of the slave. If it was quite clear that the testator wanted a
certain slave to be freed, then he had to be freed, and no legal forms or
theories could prevent it.&lt;sup id=&quot;fnref:12&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:12&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;12&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Duff shows evidence of perhaps weakening support for the institution of slavery
in a specific sector of law, through both decisions of the senate
(&lt;em&gt;senatus-consulta&lt;/em&gt;) and imperial proclamations (&lt;em&gt;constitutiones&lt;/em&gt;). But by
modern standards, this sort of piecemeal progress is maddeningly insufficient.
Marcus Aurelius ruled the Roman Empire for nearly two decades. Why did he not
take further steps to eradicate legal slavery as an institution?&lt;/p&gt;

&lt;p&gt;It is possible, in fact, that Marcus had such a plan in mind but simply refused
to put it into action. Marcus&amp;rsquo; own writing clearly shows that he struggled to
balance ideas sourced from his personal philosophy with the expectations of his
Roman counterparts. Late in the &lt;em&gt;Meditations&lt;/em&gt; he makes an entry, seemingly
resigned to the unfairness of his post: &amp;ldquo;You should not hope for Plato&amp;rsquo;s ideal
state, but be satisfied to make even the smallest advance, and regard such an
outcome as nothing contemptible. For who can change the convictions of
others?&amp;rdquo;&lt;sup id=&quot;fnref:13&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:13&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;13&lt;/a&gt;&lt;/sup&gt; Here we see Marcus as something of a realist, spelling out the
struggle he sees between an ideal government and what his society currently
regards as an acceptable state. The most groundbreaking changes, he says, must
be made in the &amp;ldquo;smallest advance[s].&amp;rdquo; Surprising legislation or sudden imperial
action could lead to political turmoil or even large-scale revolt. Little could
be more groundbreaking, of course, than the abolition of slavery in the Roman
Empire. Aurelius evidently did his part to better the treatment of slaves, but
was likely wary to continue to more involved social change for fear of upsetting
his political allies and the Roman public.&lt;/p&gt;

&lt;p&gt;Aurelius also mentions the hopelessness of attempting to &amp;ldquo;change the convictions
of others.&amp;rdquo; This is perfectly in line with Stoic thought: such a goal would be
marked as unwise and even dangerous by any of his Stoic companions as well,
simply because its fate of success or failure lies outside of the self. Marcus
would see the &amp;ldquo;convictions of others&amp;rdquo; as an external, a factor which deserved no
emotion but indifference. Though he may have had the strongest and most
unorthodox opinions about manumission and the treatment of slaves, it appears
that he kept them to himself, staying in line with his recommendation in 9.29.
Aurelius knew that to impose such a radical change in such a brief period of
time would have wreaked havoc on the Roman economy, and to attempt to force his
&amp;ldquo;convictions&amp;rdquo; on others would be a breach of his own philosophical ideals.&lt;/p&gt;

&lt;p&gt;It is unfortunate that we have only a record of Marcus Aurelius&amp;rsquo; &lt;em&gt;Meditations&lt;/em&gt;
and not also of his unfiltered daily thoughts. But by reading the &lt;em&gt;Meditations&lt;/em&gt;
and understanding the opinions of his intellectual counterparts, we can begin to
glimpse the hard conclusions he must have had to reach on the topic of slavery.
While legal slavery was an institution obviously not befitting an &amp;ldquo;ideal state,&amp;rdquo;
Aurelius knew that such a prevalent practice could not simply be swept away in a
decade, or even a century. The Stoic view of this ancient form of slavery
further deterred the school&amp;rsquo;s thinkers from launching a full attack on the
institution. Through the Stoic lens, we imagine that &amp;ldquo;good&amp;rdquo; slaves would have
been content with their place, pleased with the cards that the proverbial
Fortune had dealt them. The more pressing societal problem in the Stoic view had
to do with the far more numerous &amp;ldquo;moral&amp;rdquo; slaves, bound to their own ephemeral
pleasures. This reasoning is by no means a complete excuse for Marcus Aurelius&amp;rsquo;
inaction. Through this wider historical and philosophical lens, however, we can
understand the enormous and intricate internal conflict which he must have faced
on this issue. Our philosopher-king was a mortal in struggle, permanently torn
between maintaining the status quo and campaigning for such revolutionary
change.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Jo-Ann Shelton, &lt;em&gt;As the Romans Did: A Sourcebook in Roman Social History&lt;/em&gt;, 2nd ed (New York: Oxford University Press, 1998), 166&amp;ndash;167.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Roman Social History: A Sourcebook&lt;/em&gt;, Routledge Sourcebooks for the Ancient World (London; New York: Routledge, 2007), 155.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Lucius Annaeus Seneca, &amp;ldquo;On Master and Slave,&amp;rdquo; in &lt;em&gt;Epistulae morales&lt;/em&gt;, trans. Richard M. Gummere (London Heinemann, 1917), &lt;a href=&quot;http://archive.org/details/adluciliumepistu01seneuoft&quot;&gt;[link]&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Marcus Aurelius, &lt;em&gt;Meditations&lt;/em&gt;, trans. Robin Hard, Oxford World&amp;rsquo;s Classics (Oxford; New York: Oxford University Press, 2011), 11.18.&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Seneca, &amp;ldquo;On Master and Slave.&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Aurelius, &lt;em&gt;Meditations&lt;/em&gt;, 2.2.&amp;nbsp;&lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;em&gt;Hellenistic Constructs: Essays in Culture, History, and Historiography&lt;/em&gt;, Hellenistic Culture and Society v. 26 (Berkeley: University of California Press, 1997), 159.&amp;nbsp;&lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:8&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Miriam T. Griffin, &lt;em&gt;Seneca: A Philosopher in Politics&lt;/em&gt; (Oxford: Clarendon Press, 1976).&amp;nbsp;&lt;a href=&quot;#fnref:8&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:9&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Lucius Annaeus Seneca, &lt;em&gt;De Beneficiis&lt;/em&gt;, trans. John W. Basore (Cambridge, Mass.: Harvard University Press, 1989).&amp;nbsp;&lt;a href=&quot;#fnref:9&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:10&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Epictetus, &lt;em&gt;The Enchiridion&lt;/em&gt;, trans. Thomas W. Higginson, 2d ed. (Indianapolis: Bobbs-Merrill, 1955), 5.&amp;nbsp;&lt;a href=&quot;#fnref:10&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:11&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Anthony R. Birley, &amp;ldquo;Marcus&amp;rsquo; Life as Emperor,&amp;rdquo; in &lt;em&gt;A Companion to Marcus Aurelius&lt;/em&gt;, ed. Marcel van Ackeren, vol. 96 (Wiley-Blackwell, 2012), 160, &lt;a href=&quot;http://onlinelibrary.wiley.com/doi/10.1002/9781118219836.ch9/summary&quot;&gt;[link]&lt;/a&gt;.&amp;nbsp;&lt;a href=&quot;#fnref:11&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:12&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Arnold Mackay Duff, Freedmen in the Early Roman Empire (Clarendon Press, 1928), 195&amp;ndash;196.&amp;nbsp;&lt;a href=&quot;#fnref:12&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:13&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Aurelius, &lt;em&gt;Meditations&lt;/em&gt;, 9.29.&amp;nbsp;&lt;a href=&quot;#fnref:13&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Review&#58; ZeroMQ&#58; Messaging for Many Applications by Pieter Hintjens</title>
      <link>http://foldl.me/2013/zeromq-book/</link>
      <pubDate>Sun, 30 Jun 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/zeromq-book/</guid>
      <description>&lt;p&gt;ZeroMQ is one of those technologies today that have sizeable shares of
breathless adherents. I had been aware of the hubbub over the open-source
messaging library for quite some time when I heard that the popular online
tutorial &amp;ndash; known simply as &lt;a href=&quot;http://zguide.zeromq.org/&quot;&gt;&amp;ldquo;The Guide&amp;rdquo;&lt;/a&gt;, written by Pieter Hintjens, an
author of ZeroMQ &amp;ndash; would be made available in print and ebook. I snagged my
chance to get a nice Kindle edition of the &lt;a href=&quot;http://www.amazon.com/gp/product/1449334067/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1449334067&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;O&amp;rsquo;Reilly release&lt;/a&gt;. Apart from
some serious formatting problems with the ebook (read on), I was extremely
satisfied with the breadth and depth of this guide.&lt;/p&gt;

&lt;p&gt;Hintjens abandons all pretense at the very beginning of Chapter 1, acknowledging
the fervor of the community:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;How to explain ØMQ? Some of us start by saying all the wonderful things it
does. &lt;em&gt;It&amp;rsquo;s sockets on steroids. It&amp;rsquo;s like mailboxes with routing. It&amp;rsquo;s fast!&lt;/em&gt;
Others try to share their moment of enlightenment, that zap-pow-kaboom satori
paradigm-shift moment when it all became obvious. &lt;em&gt;Things just become simpler.
Complexity goes away. It opens the mind.&lt;/em&gt; Others try to explain by comparison.
&lt;em&gt;It&amp;rsquo;s smaller, simpler, but still looks familiar.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yes&amp;ndash;the whole book is like that. Our author has a wonderfully lucid and
light-hearted writing style&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; that keeps you focused during the long stretches
of code.&lt;/p&gt;

&lt;p&gt;And is there code! The majority of the book offers a tour through a dizzying
array of ØMQ network patterns, each accompanied by a cute name and often a
diagram. See, for example, the &amp;ldquo;Majordomo Pattern.&amp;rdquo;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://github.com/imatix/zguide/raw/master/images/fig50.png&quot; alt=&quot;The Majordomo Pattern&quot; /&gt;&lt;/p&gt;

&lt;p&gt;What follows this reasonably simple diagram is no less than 500 lines of C code.
&lt;strong&gt;Inline.&lt;/strong&gt; I appreciate this in some amount &amp;ndash; there&amp;rsquo;s nothing more practical
than a real implementation &amp;ndash; but was blown away (rather, smothered by) the
piles of code in this book. The density of the code hindered my reading
experience, especially in the Kindle edition, where there were no bookmarks
within sub-chapter sections to help me easily jump around between the massive
code blocks. Many of the most important sections of the book that offered real,
usable patterns were difficult to scan and reference later on given the lack of
navigation aids.&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;This publishing error, however serious, is my only major gripe with the book. I
learned quite a lot about the core of ZeroMQ, and am now interested in exploring
the bindings written for my everyday languages.&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; I&amp;rsquo;m excited to see how I can
integrate the library at the core of horizontally scalable systems in the near
future.&lt;/p&gt;

&lt;p&gt;(Disclosure: I received an electronic copy of this book in exchange for writing
a review.)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://ir-na.amazon-adsystem.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1449334067&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is likely something of a rarity, I&amp;rsquo;d assume, when it comes to guides on message-passing libraries.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;To be fair, this would be much less of an issue with a physical book (or in the online guide, where much of the code is held externally and simply referenced by hyperlink). I am still disappointed by O&amp;rsquo;Reilly&amp;rsquo;s apparent lack of concern for the usability of this work&amp;rsquo;s ebook format.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The book does make reference to the large amount of language bindings available, but keeps all code in C.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Review&#58; Clojure Programming by Chas Emerick et al.</title>
      <link>http://foldl.me/2013/programming-clojure/</link>
      <pubDate>Wed, 17 Apr 2013 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2013/programming-clojure/</guid>
      <description>&lt;p&gt;I often run into what you might call &lt;em&gt;closet functional programmers&lt;/em&gt; &amp;ndash; people
who seem to have a genuine interest in acquainting themselves with a new
paradigm, but just can&amp;rsquo;t manage to find the time to do it. Some of those who do
invest the time often end up on something like the &lt;a href=&quot;http://www.haskell.org/haskellwiki/Typeclassopedia&quot;&gt;Typeclassopedia&lt;/a&gt;&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;,
where the combined force of jargon and type signatures kill whatever interest
they began with.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href=&quot;http://www.amazon.com/gp/product/1449394701/ref=as_li_tf_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=1449394701&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;&lt;em&gt;Clojure Programming&lt;/em&gt;&lt;/a&gt;, though, I&amp;rsquo;m happy to report that this will
no longer be a problem. This book gives hope to those who have championed Lisp
and / or functional programming in vain. Emerick et al. provide not only a
thorough tour of the language, but also demonstrate the beauty and conciseness
of its solutions to common problems. The book dedicates an entire section
(&amp;ldquo;Practicum&amp;rdquo;) to describing how Clojure is idiomatically used in different
application domains.&lt;/p&gt;

&lt;p&gt;I was particularly pleased by the stellar coverage of some of Clojure&amp;rsquo;s most
compelling features:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Concurrency primitives (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ref&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;atom&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;agent&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;future&lt;/code&gt;, and friends)&lt;/li&gt;
  &lt;li&gt;The power of the JVM and easy Java interop&lt;/li&gt;
  &lt;li&gt;Lisp syntax (which makes for easy and &lt;em&gt;powerful&lt;/em&gt; metaprogramming)&lt;/li&gt;
  &lt;li&gt;The sequence abstraction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These features are all explained in a bottom-up style (fitting for a Lisp!) &amp;ndash;
the authors build up a sizeable example by providing an implementation in small
increments, explaining along the way. This style is a nice parallel to the
nature of traditional Lisp programming.&lt;/p&gt;

&lt;p&gt;This book would fit best any of these three groups:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Java refugees.&lt;/strong&gt; Give me the JVM, hold the
  &lt;a href=&quot;http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AbstractSingletonProxyFactoryBean&lt;/code&gt;&lt;/a&gt;. &lt;em&gt;Clojure Programming&lt;/em&gt; shows you
  how to take advantage of the vast Java ecosystem while avoiding some of the
  pitfalls of having static typing and OOP forced upon you. The authors make a
  good case for interactive programming with the Clojure REPL, which gives you
  a direct line to the JVM not usually available in Java-land.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Beginning functional programmers.&lt;/strong&gt; For those already acquainted with a
  scripting language like Python, Ruby, etc., your first Clojure programs will
  be a breeze. The book spends a chapter first easing you into Clojure syntax
  before presenting the basics of functional programming in all of their
  greatness. You&amp;rsquo;ll come to love the paradigm and appreciate how Clojure
  facilitates its use so effectively.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Lispers.&lt;/strong&gt; While Clojure is by no means a mainstream language, it provides a
  compelling case of a successful Lisp dialect. The later chapters, which
  provide examples of Clojure applications in all sorts of distinct domains,
  will definitely be of interest.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Beginners, intermediate users and masters alike will find something of use in
&lt;em&gt;Clojure Programming&lt;/em&gt;. It&amp;rsquo;ll be one of the first books I recommend from now on
to anyone curious about Lisp or functional programming.&lt;/p&gt;

&lt;p&gt;(Disclosure: I received an electronic copy of this book in exchange for writing
a review.)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=1449394701&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I&amp;rsquo;ve absolutely nothing against this document &amp;ndash; it&amp;rsquo;s a fascinating and wonderfully helpful piece of work &amp;ndash; but when the first few paragraphs include the words &amp;ldquo;category theory,&amp;rdquo; &amp;ldquo;monoid,&amp;rdquo; etc., etc., beginners will tend to get spooked!&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Parsing sound change rules with Parsec&#58; Part 2</title>
      <link>http://foldl.me/2012/sound-change-parsing-parsec-rules/</link>
      <pubDate>Mon, 17 Dec 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/sound-change-parsing-parsec-rules/</guid>
      <description>&lt;p&gt;&lt;em&gt;This is the second post in a tutorial series on applying Parsec in
 historical linguistics. We&amp;rsquo;ve begun by providing a more formal
 description of sound change rule grammars and will end by building a
 full-fledged sound change applier.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In my &lt;a href=&quot;/2012/sound-change-parsing-bnf-grammar&quot;&gt;last post&lt;/a&gt; we established a BNF grammar for files which
describe sound change rules:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;file&amp;gt;               ::= (&amp;lt;phoneme-class-defn&amp;gt; &amp;lt;EOL&amp;gt;)* (&amp;lt;rule&amp;gt; &amp;lt;EOL&amp;gt;)+
&amp;lt;phoneme-class-defn&amp;gt; ::= &amp;lt;phoneme-class&amp;gt; &quot;:&quot; &amp;lt;phoneme&amp;gt;+
&amp;lt;rule&amp;gt;               ::= &amp;lt;context&amp;gt; &quot;&amp;gt;&quot; &amp;lt;replacement&amp;gt; [&quot;/&quot; &amp;lt;condition&amp;gt;]
&amp;lt;condition&amp;gt;          ::= &amp;lt;context&amp;gt;_&amp;lt;context&amp;gt;
&amp;lt;context&amp;gt;            ::= (&amp;lt;phoneme&amp;gt; | &amp;lt;phoneme-class&amp;gt;)+
&amp;lt;phoneme&amp;gt;            ::= &amp;lt;lowercase-letter&amp;gt;
&amp;lt;phoneme-class&amp;gt;      ::= &amp;lt;uppercase-letter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Before we begin parsing, let&amp;rsquo;s set up some basic datatypes which can be
used to store the parse results.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Data.Map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- A single phoneme.&lt;/span&gt;
&lt;span class=&quot;kr&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- Phoneme class storage, mapping from a single character (&apos;V&apos;, &apos;A&apos;,&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- &apos;F&apos;, etc.) to a collection of phonemes.&lt;/span&gt;
&lt;span class=&quot;kr&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- A string of phonemes used to match a given context.&lt;/span&gt;
&lt;span class=&quot;kr&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- A complete sound change rule.&lt;/span&gt;
&lt;span class=&quot;kr&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Rule&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Rule&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;replacement&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;beforeContext&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;inContext&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Context&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                   &lt;span class=&quot;n&quot;&gt;afterContext&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Context&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kr&quot;&gt;instance&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Show&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Rule&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;where&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Rule&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; &amp;gt; &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot; / &quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
                          &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;_&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;show&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Referencing the BNF grammar, we can use these types to build the returns
for our parsers. Let&amp;rsquo;s start with the simplest Parsec rules,
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhoneme&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhonemeClass&lt;/code&gt;. Any uppercase character in sound
change rules should be interpreted as a phoneme class reference, and any
lowercase character must be a phoneme.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Text.Parsec&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Parsec&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lower&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Parsec&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;upper&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;As evidenced by the given type annotations, our parsers (for the moment)
will have a stream type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;String&lt;/code&gt;, a user state type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;()&lt;/code&gt;, and a
return type that varies based on their purpose.&lt;/p&gt;

&lt;h2 id=&quot;our-first-lift&quot;&gt;Our first lift&lt;/h2&gt;

&lt;p&gt;We need to next build the parser for phoneme class definitions. As a
first try, we could have our parser return a pair of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(Char,
[Phoneme])&lt;/code&gt;, matching with the type of a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PhonemeClassMap&lt;/code&gt;. Let&amp;rsquo;s start:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Parsec&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This doesn&amp;rsquo;t work! What gives?&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s look at the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(,)&lt;/code&gt;, a tuple constructor:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;And check the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhonemeClass&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;many1 anyPhoneme&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;These have the right types &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Char&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Phoneme]&lt;/code&gt;, except they&amp;rsquo;re
contained within a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT&lt;/code&gt; type.&lt;/p&gt;

&lt;p&gt;Good news: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m&lt;/code&gt; is a functor! This means that we can &amp;ldquo;lift&amp;rdquo;
functions into the context defined by the type. Check the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap&lt;/code&gt;
and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap (,)&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;fmap&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Functor&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;fmap&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Functor&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can check that the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(,)&lt;/code&gt; corresponds with the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap
(,)&lt;/code&gt;. (In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap&lt;/code&gt;&amp;rsquo;s type signature, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt; corresponds to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b -&amp;gt; (a, b)&lt;/code&gt; from
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(,)&lt;/code&gt;&amp;rsquo;s type.)&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap (,)&lt;/code&gt; with that first argument &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f a&lt;/code&gt;, where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f&lt;/code&gt; is
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT String () Identity&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Char&lt;/code&gt;. (This looks like the
type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhonemeClass&lt;/code&gt;!)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;fmap&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Great - just as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap&lt;/code&gt;&amp;rsquo;s signature described, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(,)&lt;/code&gt; was lifted into the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT String () Identity&lt;/code&gt; context and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; was clarified to be a
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Char&lt;/code&gt;. We can make our expression look a bit nicer by using an infix
alias for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap&lt;/code&gt; from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Control.Applicative&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;$&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;applying-within-a-context&quot;&gt;Applying within a context&lt;/h2&gt;

&lt;p&gt;Looking at the types, we&amp;rsquo;re almost there: we want our final parser to
have a return type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(Char, [Phoneme])&lt;/code&gt; and the current parser has a
return type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b -&amp;gt; (Char, b)&lt;/code&gt;. How can we supply a type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;The answer comes from the fact that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m&lt;/code&gt; is not only a
functor but an &lt;em&gt;applicative&lt;/em&gt; functor. This means that we can apply
functions already within the context (like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;b -&amp;gt; (Char, b)&lt;/code&gt;!) to values
within the context (like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhoneme&lt;/code&gt;!).&lt;/p&gt;

&lt;p&gt;This contextual application is invoked by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Control.Applicative&lt;/code&gt;&amp;rsquo;s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;*&amp;gt;&lt;/code&gt;.
Compare its type with the type of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$&lt;/code&gt;: the only difference is that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;*&amp;gt;&lt;/code&gt;
operates within a context &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Applicative&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;   &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;                    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;   &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Let&amp;rsquo;s apply the lifted and partially applied function from the last
section to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anyPhoneme&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Close: our return type is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(Char, Phoneme)&lt;/code&gt;. Let&amp;rsquo;s apply with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;many1
anyPhoneme&lt;/code&gt; instead, which will produce a parser that accepts one or
more phonemes.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Great! Our parser returns the proper type. Let&amp;rsquo;s write the actual
implementation of our phoneme class definition rule before continuing:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Control.Applicative&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We must do a bit of bookkeeping. In the original BNF, we stated that a
phoneme class definition was of the form&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;phoneme-class-defn&amp;gt; ::= &amp;lt;phoneme-class&amp;gt; &quot;:&quot; &amp;lt;phoneme&amp;gt;+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We need to account for the &amp;ldquo;useless&amp;rdquo; colon in this expression. It&amp;rsquo;s
useless in that it contributes nothing to the parse result. Using the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&amp;gt;&lt;/code&gt; function from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Control.Applicative&lt;/code&gt;, we can consume a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&apos;:&apos;&lt;/code&gt;
character and discard its result:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Control.Applicative&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(,)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt;
                          &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;:&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;modifying-user-state&quot;&gt;Modifying user state&lt;/h2&gt;

&lt;p&gt;There&amp;rsquo;s one significant problem left with this parser. True, it eats up
strings without a problem:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parse&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;V:aeiou&quot;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;Right&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;&apos;V&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;aeiou&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Our problem is that we need to reference these definitions in another
parser, specifically the &lt;em&gt;context parser&lt;/em&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;context&amp;gt; ::= (&amp;lt;phoneme&amp;gt; | &amp;lt;phoneme-class&amp;gt;)+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since Parsec has no idea of what a phoneme class is, when we build this
parser we&amp;rsquo;ll need to identify exactly what we should look for in test
words given that we saw &amp;ldquo;V&amp;rdquo; or &amp;ldquo;A&amp;rdquo; in a rule. How can we have the
phoneme class definitions &amp;ldquo;carry over?&amp;rdquo;&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s simple using Parsec&amp;rsquo;s built-in &amp;ldquo;user state&amp;rdquo; feature. (It shows up
in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m a&lt;/code&gt;.) Rather than using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;()&lt;/code&gt; as our user
state type, let&amp;rsquo;s carry along a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PhonemeClassMap&lt;/code&gt; as state. Each rule&amp;rsquo;s
type needs to now be redefined (but the implementation for those not
using the state data need not change):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phonemeClassDefinition&lt;/code&gt; we&amp;rsquo;ll need to use Parsec&amp;rsquo;s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;modifyState&lt;/code&gt;
function:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;modifyState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Monad&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This type annotation does a great job of helping us understand what
exactly happens within the function. Given some user state modifier
(i.e., a function which takes an old user state of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt; and creates
a new one), a new parser is yielded which has a user state of type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt;
and returns nothing.&lt;/p&gt;

&lt;p&gt;Now &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phonemeClassDefinition&lt;/code&gt; will return nothing and instead modify the
parser&amp;rsquo;s state (i.e., add entries to the phoneme class map).&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We want to modify this map by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;insert&lt;/code&gt;ing an entry whose contents will
be equal . We run into a familiar problem, however, since &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;insert&lt;/code&gt; was
not built explicitly for use with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m&lt;/code&gt; context:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Let&amp;rsquo;s lift &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;insert&lt;/code&gt; into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m&lt;/code&gt; functor:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Functor&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Ord&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a1&lt;/span&gt;
                                                   &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
                                                  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Close, like before: we can now provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fmap insert&lt;/code&gt; with a first
argument in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ParsecT s u m&lt;/code&gt; context, but the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a1&lt;/code&gt; in the type
annotation has no concept of context. Using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;*&amp;gt;&lt;/code&gt; once more, we can fix
the problem:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;:&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt;
       &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Before continuing, let&amp;rsquo;s give a name to the parser created in this
section.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Char&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Phoneme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Notice that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Map Char [Phoneme]&lt;/code&gt; is equivalent to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PhonemeClassMap&lt;/code&gt;, or
our parser&amp;rsquo;s user state &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;u&lt;/code&gt;. We just did all this work to lift and apply
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;insert&lt;/code&gt; within a context, but now, upon revisiting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;modifyState&lt;/code&gt;&amp;rsquo;s
type, we see we&amp;rsquo;ll need to head in the other direction:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt;               &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;modifyState&lt;/span&gt;            &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Monad&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;binding&quot;&gt;Binding&lt;/h2&gt;

&lt;p&gt;If we simplify the types here, the next step should be obvious. (This is
pseudo-Haskell.)&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt;    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;modifyState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Monad&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We need some function that, with an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f a&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a -&amp;gt; f b&lt;/code&gt;, derive an
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;f b&lt;/code&gt;. This sounds just like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;gt;&amp;gt;=&lt;/code&gt;, the monadic bind operation!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;                    &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Monad&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;modifyState&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;s&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That&amp;rsquo;s it &amp;ndash; we&amp;rsquo;ve found our definition for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;phonemeClassDefinition&lt;/code&gt;!
With some reformatting:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;ParsecT&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;PhonemeClassMap&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Identity&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;phonemeClassDefinition&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;modifyState&lt;/span&gt;
                         &lt;span class=&quot;kr&quot;&gt;where&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;modifier&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;insert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;$&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhonemeClass&lt;/span&gt;
                                          &lt;span class=&quot;o&quot;&gt;&amp;lt;*&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defn&lt;/span&gt;
                               &lt;span class=&quot;n&quot;&gt;defn&lt;/span&gt;     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;:&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;many1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;anyPhoneme&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We&amp;rsquo;ve finished with the hardest parser of the set. In the next post,
we&amp;rsquo;ll tackle the remaining parsers, most of which are simple
combinations of those constructed today.&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Parsing sound change rules with Parsec&#58; Part 1</title>
      <link>http://foldl.me/2012/sound-change-parsing-bnf-grammar/</link>
      <pubDate>Fri, 14 Dec 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/sound-change-parsing-bnf-grammar/</guid>
      <description>&lt;p&gt;&lt;em&gt;This is the first post in a tutorial series on applying Parsec in
 historical linguistics. We&amp;rsquo;ll begin by providing a more formal
 description of sound change rule grammars and end by building a
 full-fledged sound change applier.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Historical linguists&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; use a standard grammar to describe a language&amp;rsquo;s
&lt;a href=&quot;http://en.wikipedia.org/wiki/Sound_change&quot;&gt;sound change&lt;/a&gt; over time (&lt;a href=&quot;http://en.wikipedia.org/wiki/Diachronic_linguistics&quot;&gt;diachronically&lt;/a&gt;) or among different
speakers at the same time (&lt;a href=&quot;http://en.wikipedia.org/wiki/Synchronic_linguistics&quot;&gt;synchronically&lt;/a&gt;). Each individual change
can be explained by a simple replacement rule, but often requires a
certain context to occur. An example &lt;em&gt;unconditioned&lt;/em&gt; sound change rule
follows:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;r &amp;gt; l
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This rule states that, in some language, the /r/ sound becomes /l/ no
matter the context of the /r/ sound. This rule alone can effectively
describe the change from a morph /fara/ to /fala/, or from /rata/ to
/lata/.&lt;/p&gt;

&lt;p&gt;Most sound change in natural languages, however, are &lt;em&gt;conditional&lt;/em&gt;: they
only occur in certain contexts. We can describe required contexts with
an additional clause in sound change rules:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;r &amp;gt; l / a_o
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This rule states that /r/ changes to /l/ only when preceded by an /a/
and succeeded by an /o/. It describes a change from /taro/ to /talo/,
but not from /tar/ to /tal/ or /ero/ to /elo/.&lt;/p&gt;

&lt;p&gt;We can describe this sound change rule format as a simple
&lt;a href=&quot;http://en.wikipedia.org/wiki/Backus%E2%80%93Naur_Form&quot;&gt;BNF grammar&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;rule&amp;gt;          ::= &amp;lt;context&amp;gt; &quot;&amp;gt;&quot; &amp;lt;replacement&amp;gt; [&quot;/&quot; &amp;lt;condition&amp;gt;]
&amp;lt;condition&amp;gt;     ::= &amp;lt;context&amp;gt;_&amp;lt;context&amp;gt;
&amp;lt;context&amp;gt;       ::= (&amp;lt;phoneme&amp;gt; | &amp;lt;phoneme-class&amp;gt;)+
&amp;lt;phoneme&amp;gt;       ::= &amp;lt;lowercase-letter&amp;gt;
&amp;lt;phoneme-class&amp;gt; ::= &amp;lt;uppercase-letter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Close readers will notice that I included in the above grammar the
concept of a &lt;em&gt;phoneme class&lt;/em&gt;. Sound change appliers often accept as
input along with sound change rules a list of phoneme class definitions.
These describe sets of phonemes which, when referenced within a context,
allow any of their members to appear in the specified position.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;V: aeiou
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This line defines a phoneme class &lt;strong&gt;V&lt;/strong&gt; (presumably the &lt;em&gt;vowel&lt;/em&gt; class).
Whenever &lt;strong&gt;V&lt;/strong&gt; appears in a sound change rule, any of /a/, /e/, /i/,
/o/, or /u/ should match.&lt;/p&gt;

&lt;p&gt;Phoneme classes are extremely useful, since most sound changes
(synchronic and diachronic) only apply in certain phonological contexts
rather than standing as a universal fact. Let&amp;rsquo;s amend our grammar so
that we can describe an entire sound change collection:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;file&amp;gt;               ::= (&amp;lt;phoneme-class-defn&amp;gt; &amp;lt;EOL&amp;gt;)* (&amp;lt;rule&amp;gt; &amp;lt;EOL&amp;gt;)+
&amp;lt;phoneme-class-defn&amp;gt; ::= &amp;lt;phoneme-class&amp;gt; &quot;:&quot; &amp;lt;phoneme&amp;gt;+
&amp;lt;rule&amp;gt;               ::= &amp;lt;context&amp;gt; &quot;&amp;gt;&quot; &amp;lt;replacement&amp;gt; [&quot;/&quot; &amp;lt;condition&amp;gt;]
&amp;lt;condition&amp;gt;          ::= &amp;lt;context&amp;gt;_&amp;lt;context&amp;gt;
&amp;lt;context&amp;gt;            ::= (&amp;lt;phoneme&amp;gt; | &amp;lt;phoneme-class&amp;gt;)+
&amp;lt;phoneme&amp;gt;            ::= &amp;lt;lowercase-letter&amp;gt;
&amp;lt;phoneme-class&amp;gt;      ::= &amp;lt;uppercase-letter&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the next installment of this tutorial, we&amp;rsquo;ll use this grammar to
build a Parsec parser that can digest sound change rules.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;And conlangers!&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Hillis β-reduction in Haskell</title>
      <link>http://foldl.me/2012/beta-reduction-in-haskell/</link>
      <pubDate>Sun, 26 Aug 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/beta-reduction-in-haskell/</guid>
      <description>&lt;p&gt;I decided to rewrite my &lt;a href=&quot;/2012/hillis-beta-reduction-in-clojure&quot;&gt;Hillis β-reduction routine&lt;/a&gt; in Haskell. I
was very pleased to find that the rewrite yielded code much more concise
and less &amp;ldquo;hacky&amp;rdquo; than the original Clojure algorithm.&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-haskell&quot; data-lang=&quot;haskell&quot;&gt;&lt;span class=&quot;kr&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Beta&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;kr&quot;&gt;where&lt;/span&gt;

&lt;span class=&quot;kr&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;Data.Map&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;alter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- Used to insert or merge map values. Partially apply this function&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- with a merge function and an initial value, then use it in&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;-- `Data.Map.alter`.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;alterer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Maybe&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Maybe&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;alterer&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Nothing&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Just&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;alterer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Just&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Just&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- beta-reduce a list of keys and values with a given merge function.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Ord&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keys&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vals&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;empty&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;keys&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vals&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;-- Internal recursive function.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;::&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;Ord&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;Map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;_&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;k&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kr&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alter&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;alterer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;k&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&lt;/span&gt;
                            &lt;span class=&quot;kr&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;beta&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;map&apos;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ks&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vs&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;&lt;a href=&quot;http://www.haskell.org/ghc/docs/latest/html/libraries/containers/Data-Map.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Data.Map&lt;/code&gt;&lt;/a&gt; turned out to be a lifesaver!&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Hillis beta reduction improvements</title>
      <link>http://foldl.me/2012/better-hillis-beta-reduction/</link>
      <pubDate>Sun, 08 Jul 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/better-hillis-beta-reduction/</guid>
      <description>&lt;p&gt;&lt;a href=&quot;/2012/hillis-beta-reduction-in-clojure/&quot;&gt;Last week&lt;/a&gt; I introduced the concept of Hillis beta reduction and provided an example implementation in Clojure. There were a few caveats to this implementation, however, mostly stemming from the fact that I &amp;beta;-reduced with sequences and vectors rather than the native &amp;ldquo;xectors&amp;rdquo; of Hillis&amp;rsquo; system. With the risk of adding even more complexity to the demonstration, I&amp;rsquo;d like to attempt to rectify some of these problems using a few extra tools to transform our data.&lt;/p&gt;

&lt;h2 id=&quot;xectors&quot;&gt;Xectors&lt;/h2&gt;

&lt;p&gt;I won&amp;rsquo;t provide much detail at all on the xector data type, as I will inevitably botch the majority of the facts. If you&amp;rsquo;re at all interested in parallel computing, I recommend checking out Hillis&amp;rsquo; book, &lt;a href=&quot;http://www.amazon.com/gp/product/0262580977/ref=as_li_tf_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0262580977&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;The Connection Machine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For our purposes, we can consider a xector to be equivalent to a Clojure map&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. We can easily redesign our Hillis &amp;beta;-reduction function to take maps as input, but who would want to convert a sequence to a map whenever using the function?&lt;/p&gt;

&lt;h3 id=&quot;the-xector-monad&quot;&gt;The Xector monad&lt;/h3&gt;

&lt;p&gt;For this issue we can design a small &lt;a href=&quot;http://en.wikipedia.org/wiki/Monad_(functional_programming)&quot;&gt;monad&lt;/a&gt; which deliberately breaks the monad laws (cowboy monad?) for demonstration purposes&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. The monad will convert provided seqs into an internal map (xector) representation for use in the &amp;beta;-function and (here&amp;rsquo;s the law-breaking part) leave them as maps when returning results. We could be proper and return the same seq type that was provided, but that would essentially destroy the purpose of the &amp;beta;-reduction in the first place!&lt;/p&gt;

&lt;p&gt;Without further ado:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;&apos;clojure.algo.monads&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;defmonad&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector-m&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;;; Xector a -&amp;gt; a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m-result&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m-result-xector&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;vals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

   &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;;; a -&amp;gt; (Xector b -&amp;gt; Xector c) -&amp;gt; Xector c&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m-bind&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;m-bind-xector&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xec&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sequential?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;into&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;map-indexed&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;vector&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                        &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))])&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Notice the cheating in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;m-result&lt;/code&gt;: we return constant values as expected, but non-constant values (i.e., maps made from seqs) are kept as maps.&lt;/p&gt;

&lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;m-bind&lt;/code&gt;, we convert any type of seq into a map, and keep any other constant value (in our case, we&amp;rsquo;ll use numbers) unmodified&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h2 id=&quot;β-reduction-redux&quot;&gt;&amp;beta;-reduction-redux&lt;/h2&gt;

&lt;p&gt;We define a new multimethod &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xvals&lt;/code&gt; which dispatches on the result of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map?&lt;/code&gt;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;. This aligns with the result of the monad bind we defined earlier: for any &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Xector a&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a&lt;/code&gt; will be either a map or a constant.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defmulti&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xvals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;map?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defmethod&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xvals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;vals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defmethod&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xvals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defn&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;;; (a -&amp;gt; b) -&amp;gt; Xector c -&amp;gt; Xector d&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;;; (a -&amp;gt; b) -&amp;gt; Xector c -&amp;gt; Xector d -&amp;gt; Xector e&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xvals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xvals&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
              &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;or&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;nil?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;nil?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new-val&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;contains?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                           &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
             &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;recur&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;assoc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new-val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))))))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now we can perform &amp;beta;-reduction on seqs by binding them inside our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xector-m&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;domonad&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector-m&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Z&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; {X 1, Z 7}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Traditional folds can now return the expected values without a wrapping map:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;domonad&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector-m&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; 8&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;hillis-arity-function&quot;&gt;Hillis&amp;rsquo; arity function&lt;/h3&gt;

&lt;p&gt;Now that we have a better-ported version of the beta function, I can present a fascinating application also imagined by Hillis later in his paper. It uses both the one- and two-argument forms of the beta function: it simultaneously folds multiple maps into a single map, and then folds that single map to a single value. As always, the code speaks more clearly than I can:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;c1&quot;&gt;;; Return the highest arity of the sequence (i.e., the number of times&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;;; the most often occurring element appears).&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defn&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;arity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;domonad&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector-m&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In the inner &amp;beta;-reduce, we reduce a set of keys to the same constant value of 1. When duplicate keys (duplicate occurrences of a value in the provided seq) are found, the value 1 is combined with another value 1 using the function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt;, forming a count of 2! This process repeats until the entire provided seq has been digested. Here&amp;rsquo;s a look at the inner &amp;beta;-reduction by itself (notice that its output matches that of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;frequencies&lt;/code&gt;!):&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;domonad&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xector-m&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
          &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; {2 4, 3 1, 5 1, 8 2}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;where-from-here&quot;&gt;Where from here?&lt;/h3&gt;

&lt;p&gt;To be frank: not a clue! I am having trouble thinking of names for the process, let alone applications. It will most likely remain nothing more than a &amp;ldquo;thought experiment,&amp;rdquo; as I said in my previous post. Let me know in the comments below if you have any thoughts!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0262580977&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Ignoring all the parallel-processing fun that comes along with xectors, yes.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I still don&amp;rsquo;t fully understand monads, so I may actually be breaking more laws than I intend.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I experimented with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ConstantXector&lt;/code&gt; type and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;:constant&lt;/code&gt; metadata key, but both of these methods proved much less elegant than simply leaving the value alone.&amp;nbsp;&lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Dispatches on &amp;ldquo;mappiness?&amp;rdquo;&amp;nbsp;&lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Hillis beta reduction in Clojure</title>
      <link>http://foldl.me/2012/hillis-beta-reduction-in-clojure/</link>
      <pubDate>Tue, 03 Jul 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/hillis-beta-reduction-in-clojure/</guid>
      <description>&lt;p&gt;Danny Hillis&amp;rsquo; seminal work &lt;a href=&quot;http://www.amazon.com/gp/product/0262580977/ref=as_li_tf_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0262580977&amp;amp;linkCode=as2&amp;amp;tag=blog0cbb-20&quot;&gt;The Connection Machine&lt;/a&gt; introduced, among many other things, the concept of &amp;ldquo;beta reduction&amp;rdquo; on vectors&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; (I dub this &amp;ldquo;Hillis beta reduction&amp;rdquo; so as not to confuse the term with traditional &lt;a href=&quot;http://en.wikipedia.org/wiki/Lambda_calculus#Beta_reduction&quot;&gt;beta reduction&lt;/a&gt; in the lambda calculus). I found this particular idea fascinating and still applicable today, if only as a quick thought experiment.&lt;/p&gt;

&lt;p&gt;Hillis asserted that the everyday &lt;a href=&quot;http://en.wikipedia.org/wiki/Fold_(higher-order_function)&quot;&gt;fold / reduce routines&lt;/a&gt; that we have all come to know and love are merely a subset of a larger scheme of operations that can be performed on ordered data structures. The overarching process is named the &amp;ldquo;beta function,&amp;rdquo; and accepts one function and two vectors as arguments. The result of this function is the combination of the two vectors into a map, using the first vector to form the map&amp;rsquo;s values and the second vector to form the map&amp;rsquo;s keys. When duplicate keys are found, the provided function is used to &amp;ldquo;combine&amp;rdquo; the corresponding values. It&amp;rsquo;s an interesting process that&amp;rsquo;s much easier to understand given an example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Z&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Z&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; {X 1, Z 7}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Using the positions of each element to match keys and values of the map to be formed, the beta function pulls together data like a zip function. When the duplicate key &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Z&lt;/code&gt; is encountered twice, the two values are combined using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+&lt;/code&gt; function we provided, and the final value corresponding to the key &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Z&lt;/code&gt; in the map is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;(+ 2 5)&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;7&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;What is traditional list folding, then? Why, it&amp;rsquo;s just beta reduction with a certain constant second argument:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; {1 8}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;When we provide the beta function with the same key for every value (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt;, in this case), all values are combined to the same key using the provided function. This is reduction in a different form!&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Below is an implementation of Hillis&amp;rsquo; beta function in Clojure. I included a shorthand form of the function in which a two-argument call will give the same result as a call to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reduce&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;; =&amp;gt; 8&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Feel free to play around!&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-clojure&quot; data-lang=&quot;clojure&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;defn&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;beta&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;or&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;nil?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;nil?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new-val&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;contains?&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                         &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;recur&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;assoc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;acc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;e2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new-val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;first&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;rest&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;c2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;img src=&quot;http://www.assoc-amazon.com/e/ir?t=blog0cbb-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0262580977&quot; width=&quot;1&quot; height=&quot;1&quot; border=&quot;0&quot; alt=&quot;&quot; style=&quot;border:none !important; margin:0px !important;&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For simplicity&amp;rsquo;s sake, I deliberately ripped out Hillis&amp;rsquo; concept of beta reduction from its containing system of parallel processing with xectors. References to this particular domain have been shamelessly replaced with Clojure-specific terms.&amp;nbsp;&lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;You may notice that this alternate fold returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{1 8}&lt;/code&gt; rather than a simple &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8&lt;/code&gt;. This is due to my somewhat-haphazard readaptation of Hillis&amp;rsquo; concept for Clojure: the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{1 8}&lt;/code&gt; that is returned is technically correct within Hillis&amp;rsquo; system of xectors, but is not convenient for those of us living in a von Neumann world. I experimented in using a xector monad as a sort of shim to better integrate beta-reduction into Clojure, but did not develop it far enough to make it merit more than a mention in a footnote.&amp;nbsp;&lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
    </item>
    
    
    
    <item>
      <title>Disabling electric indenting in Emacs modes</title>
      <link>http://foldl.me/2012/disabling-electric-indent-mode/</link>
      <pubDate>Mon, 02 Jul 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/disabling-electric-indent-mode/</guid>
      <description>&lt;p&gt;I am just getting settled in with &lt;a href=&quot;http://orgmode.org&quot;&gt;Org Mode&lt;/a&gt; for Emacs and am constantly amazed at its versatility and wide feature set. One problem has been bugging me in Org for quite a while now, though: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;electric-indent-mode&lt;/code&gt;, which I use for auto-indentation when programming, gets in the way by auto-indenting Org headers.&lt;/p&gt;

&lt;p&gt;My annoyance reached a critical point earlier this morning, and so I set off in search of a fix to disable electric indenting &amp;ldquo;mode-locally&amp;rdquo; &amp;mdash; that is, disable the mode in Org buffers but not in buffers of any other mode. The catch with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;electric-indent-mode&lt;/code&gt; is that it is a global minor mode &amp;mdash; something that is enabled once and assumed to be necessary for all buffers.&lt;/p&gt;

&lt;p&gt;After a bit of searching, however, I was glad to find that the author of the mode had left in a backdoor for customizing its functionality. Meet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;electric-indent-functions&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Special hook run to decide whether to auto-indent.
Each function is called with one argument (the inserted char), with point right after that char, and it should return t to cause indentation, `no-indent&amp;rsquo; to prevent indentation or nil to let other functions decide.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Perfect! The default value for this variable (as of Emacs 24.0.92.1) is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nil&lt;/code&gt;, so I made the choice to recklessly overwrite this variable at a &lt;a href=&quot;http://www.gnu.org/software/emacs/manual/html_node/emacs/Locals.html&quot;&gt;buffer-local level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enough technoblabber; here&amp;rsquo;s the fix. Add the following code into an Emacs Lisp file that gets run on initialization:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-cl&quot; data-lang=&quot;cl&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;add-hook&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&apos;org-mode-hook&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;make-local-variable&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&apos;electric-indent-functions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
                 &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;arg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&apos;no-indent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))))&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You can find the latest version of my Org mode config in my &lt;a href=&quot;https://github.com/hans/dotfiles/blob/master/emacs.d/scripts/org.el&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dotfiles&lt;/code&gt; repo&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    
    
    
    <item>
      <title>Post excerpts in Jekyll</title>
      <link>http://foldl.me/2012/jekyll-excerpts/</link>
      <pubDate>Sat, 21 Jan 2012 00:00:00 +0000</pubDate>
      <author>Jon Gauthier</author>
      <guid>http://foldl.me/2012/jekyll-excerpts/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a &lt;a href=&quot;http://www.jacquesf.com/2011/03/creating-excerpts-in-jekyll-with-wordpress-style-more-html-comments/&quot;&gt;fairly simple method&lt;/a&gt; for creating WordPress-like post excerpts in Jekyll using a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;!-- more --&amp;gt;&lt;/code&gt; tag, but unfortunately it requires the installation of a Jekyll plugin, a feature unavailable on a GitHub-hosted Jekyll instance.&lt;/p&gt;

&lt;p&gt;What&amp;rsquo;s a bored geek like me to do? Find another way! &lt;!-- more --&gt; The exact same excerpt functionality linked to earlier can be replicated by composing a few &lt;a href=&quot;https://github.com/Shopify/liquid/wiki/Liquid-for-Designers&quot;&gt;Liquid filters&lt;/a&gt; in the site layout code, like so:&lt;/p&gt;

&lt;pre&gt;&amp;#123;{ post.content | split: &apos;&amp;lt;!-- more --&amp;gt;&apos; | first }}&lt;/pre&gt;

&lt;p&gt;This little bit of code will output the content of a post until it sees a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;!-- more --&amp;gt;&lt;/code&gt; tag inside the post content. Just insert the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;!-- more --&amp;gt;&lt;/code&gt; tag into your posts wherever you&amp;rsquo;d like them to be cut off.&lt;/p&gt;

&lt;p&gt;You can see this snippet in action in my &lt;a href=&quot;/&quot;&gt;site index template&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    
    

  </channel>
</rss>
