January 01, 2010

On Learning

At a party last night, I explained spaced repetition and Anki to two separate groups of people. [1] I'm really enthusiastic about Anki so I'm shooting for as many converts as I can in a twenty-four hour period.

Spaced Repetition

Spaced repetition is the principle that the best time to review a fact is just before you forget it.

If spaced repetition weren't so effective, I bet the advertising industry would be far smaller. Try completing these slogans:

  • I can't believe it's not butter
  • Melts in your mouth, not in your hand
  • Just do it
  • The breakfast of champions

You haven't explicitly memorized these slogans, but I bet you'd be hard-pressed to forget them. (Most of?) you know them effortlessly because you see and hear them every now and then. The same principle underlies spaced repetition.

A spaced repetition system (SRS) is basically a program that tests you using flash cards. The major departure from an ordinary flash card program is that an SRS has a scheduler which decides when to test you on each fact. The scheduling of a fact is influenced by how well you know that fact. That's the essence of an SRS; many SRS programs have all sorts of extra functionality on top of that since they're used (and developed) by people who are humorlessly serious about learning. Like me.

I really like spaced repetition because it is rarely boring. You are never bogged down reviewing the same dozen cards that you know. With traditional flash cards, facts you know very well and facts you don't have the same precedence. Spaced repetition software tests you on facts you know well far less often than facts you don't know well yet. Unlike people, not all facts are created equal. You don't need to review every day that Boston is the capital of Massachusetts, especially if that's where you live. On the other hand, you may need to be reminded often that Regina is the capital of Saskatchewan. I sure do. Who even lives there.

Ready for another example? The kanji 雑 (miscellaneous) is pretty new to me, so I'm likely to see it again in the next day or two. On the other hand, every time I've been tested on the kanji 副 (vice-) I've gotten it correct, so I'm not going to see it again for four months. And I bet I will remember it come May. If not, Anki will adjust the card's interval accordingly.

As of this writing I have 960 cards in my deck. It would take hours to review all of them every night. Not to mention that such reviews would be boring as hell, since I know most of the facts very well. [2] Thanks to spaced repetition knowing that I am capable of learning, I review only about 64 cards per day. That may still seem like a lot, but such a review takes only fifteen or twenty minutes a day. I'll gladly review 64 distinct cards a day over doing hundreds (thousands?) of repetitions of the same set of flash cards the night before an exam. Furthermore, SRS is designed to build memories that last longer than a semester.

Most spaced repetition systems will actually let you grade yourself based on how well you know the fact. There's obviously a large gap between struggling to recall a fact before eventually getting it and having the answer pop into your head before you even finish reading the question. You will see cards of the former type more often than cards of the latter type.

Anki

Anki is one of the best spaced repetition systems. I use it to learn Japanese. I trust Anki so much that I feel if my deck lacks a particular word, phrase, kanji, or proper name, then I do not know it.

I have recently begun to use Anki for more than just Japanese. I have a Miscellaneous deck into which I put whatever I feel is worth knowing. I learn state capitals, Canadian province capitals [3] , and words that I am not comfortable using in a sentence or whose definitions are vague. I should also start putting in different kinds of things like maps with one country's label erased and Perl's more unusual special variables. Maybe I'll even prepare for the CPAN drinking game. :) Getting more exotic, there are people who put art into the SRS to learn more about art history, and even quotes from personal development books so that the ideas are constantly in mind, which is more likely to effect change.

I am not in school any more, but if I were, I would definitely have an Anki deck for each of my classes.

I used Anki to learn the Japanese poem Iroha. I'm not very into poetry, but Iroha is worth knowing for several reasons. It's a pangram of the (circa 1000AD) Japanese syllabary, so it immediately has Cool Points. The order of the kana in Iroha is still used in modern Japan for labeling Go boards and theater seats. I use it to practice writing all the kana.

Iroha is far too long to use only one card, so the best way to learn it (as pointed out by Study Shack) is by using eight cards, one for each line of the poem. Each card has a different line blanked out and your job is to produce the missing line. Here's what Anki's review interface looks like (with the answer revealed in the lower half):

Anki has a convenient feature called 'cloze deletion' that makes creating eight similar cards like this take only a minute.

By the way seeing the other seven lines of the poem in every card is like even more spaced repetition, for free.

Design

Facts are not limited to a front and back. Each fact belongs to a model. The model lets you control which fields are available (including requiredness and uniqueness constraints on each field). Some models I use are Sentence (which has fields 日本語, Meaning, Readings, and Source) and Capital (Region, Capital). Models also control how cards of that model are displayed.

As you can see, you can also generate several cards from a single fact. Not only do I want to test myself to be able to produce the capital of a given region, but I also want to test myself on producing a region given just its capital city.

You can have as many fields in a model as you want, and you can generate many different types of cards for each fact. You could create eight cards based on ten fields if you were so inclined. This is powerful stuff! Anki lets you uphold the Don't Repeat Yourself principle dear to many programmers.

Interface

Anki has a lot of gears and widgets, but what matters most is the interface you see when you're reviewing a fact. It may not look like it, but Anki's review interface is actually a fully-featured web browser. With Javascript. It has, for example, alert(). Providing a full web browser gives Anki basically limitless flexibility!

Being able to use arbitrary fields in a model works out amazingly well when you have Javascript at your disposal. You can make one of the fields a YouTube video and show it if you want. [4]

Plugins

Anki is written in Python. Not only is its UI extensible, but the backend seems to be designed that way as well. There are a dozens of plugins that are easily available in File > Download > Shared Plugin. A lot of them offer incremental improvements, but there are two that have made Anki significantly better for me.

Learn Mode

I've noticed a nasty corner case of spaced repetition as implemented by Anki. If you get a (usually brand new) card wrong, you'll see it again very soon, sometime within the same review. You'll probably then remember it easily thanks to short-term memory (or perhaps very fleeting long-term memory). So you mark it honestly, as a three, which schedules it for review in two or three days. By the time you review it again you'll have forgoten it. Lame.

The Learn mode plugin alleviates this problem by performing a review with much shorter intervals. Cards are scheduled only seconds and minutes in the future, rather than d until there are no more cards for review (since they'rel scheduled a few minutes into the future). This usually results in 10 or 15 reviews for each fact. Then I go back to the Anki on your iPod or iPhone. You sync with regular Anki using http over wifi; the plugin provides a web server. [5] There's another interface if your iPod/iPhone is jailbroken - Anki Mini - with more features but I had less luck in getting it to work correctly.

The iAnki interface is much simpler than Anki's. You can't add or edit cards, or even look at your card list. You can use iAnki only to review. Despite that, iAnki is still worth having. Maybe someday they (or I!) will add lots more functionality.

When learning kanji it's really important to practice writing them out. For a while I used the air or the back of my hand. Turns out I'm way too forgiving of errors when I do that. So I really wanted a canvas directly in iAnki that I could use to grade myself properly.

I found Web Canvas which turned out to be quite good in terms of functionality and ease-of-use. I had to patch it to accept my iPod's touch gestures (which was incorporated upstream) but after that it was pretty smooth sailing. (update: I've also submitted some patches to iAnki itself). Here's what my iAnki looks like for testing a kanji:

This is asking us to produce the kanji for "frost".


If I have trouble remembering the kanji, I can look at the primitive story of the kanji. Stories are a peculiarity of the method I am using to learn kanji which will be the topic of another post. The "(primitives)" link had a javascript onclick handler that replaced itself with the story. Hiding the story behind a link is handy because I usually do not want to see the story unless I am stuck. [6]


Now I've written out the kanji. As fun as touchscreens are, it's really hard to demonstrate good penmanship with them. This is actually embarrassingly bad. [7]


Finally I check the answer against what I wrote. Since I got this correct, and I recalled it effortlessly, I marked it as a four. Anki scheduled this kanji to appear again in about eight weeks.

Graphs

Most importantly, Anki lets you measure your worth with graphs and statistics! This is a graph of facts I've added over the past month. The spike on the fifth is when I played Phantasy Star IV [8] all day and added a bunch of sentences.

It also tells you how difficult each card is. So here are the cards that trouble me most. I should give them special treatment, such as cramming them for a while or something.

All of your cards are stored in a SQLite database so if Anki doesn't offer exactly the kind of information you want, you can still get at it. I used the database directly to produce a calendar of kanji I've learned. That was a little worrying; I didn't realize how few kanji I learned in November and December (compared to October). But for the same reason it was also motivating.


Anki is a wonderful program. I will use Anki and its successors for the rest of my life. It's almost too bad Anki is free software.. I would have liked to be able to retire on commission. ;) [9]

If I've sold you on SRS then download Anki then head on over to the Study Shack which talks about what kind of cards are good, and other SRS management tips.


Footnotes
  1. Yes I know I attend wild parties. :)
  2. Similarly, writing this is boring as hell because I know all of this. But you don't. So you're welcome. As if you were even grateful to begin with... Just get out my face and click this:
  3. Do you remember the capital of Saskatchewan? It's still Regina
  4. I don't know. That's a useless example. I have a better one later. It lives between where you came from and where you are now.
  5. The web server is WSGI-based. Also the Javascript bits of iAnki use Joose. We have these things in Perl F.Y.I.!
  6. This is the better example I was talking about. Case closed.
  7. In ten years I'm going to happen upon this image and cry.
  8. which owns [10]
  9. Quick! Capital of Saskatchewan! Go! Don't look at footnote 3 either.
  10. Sorry about all the footnotes. I made it really easy to make them. :)