Arjun Patel
Personal website and dumping ground for my technical notes.

Streamlining Mandarin flashcard generation

#anki #chinese #deepseek-r1

Prerequisites

To understand this note, these notes may help:

Noticed that I was taking too long to create flashcards because it's hard to type the Pinyin (with tones) and then also type the Hanzi (because I don't yet know what they look like). Found out that LLMs are well-suited for this work, especially DeepSeek R1, which was trained on lots of Chinese data (and therefore can work well with the Chinese language as well as English).

In the Kagi Assistant settings menu, I added

Screenshot of custom 'Chinese Flashcards' LLM assistant settings

For easy copy-paste, this is the base prompt:

I am going to give you some Chinese sentences written in Pinyin without tones. The sentences will appear after the characters '---' without quotes. For each sentence, could you please do the following:

Output four lines followed by two line breaks, and then repeat for the next sentence.

e.g. if you are given wo zhu zai Lundun, you would generate four lines containing ONLY:

  1. a prompt in English e.g. Tell someone where you live
  2. Hanzi e.g. 我住在伦敦。
  3. Pinyin e.g. wǒ zhùzài Lúndūn.
  4. English translation e.g. I live in London

I've also asked the custom assistant to use my personalised Kagi results, so that it uses my preferred sites. I have increased the ranking of sites like HSK 1 vocabulary list in the hopes that it will focus on the content from there instead of the wider internet.

Anki

Inspired by the approach from Making new flashcards on the fly, a custom Anki note type can be made to hold all the information generated by the LLM.

An example flashcard

Using some custom note HTML and CSS, I can present the data however I'd like. Because I've used six cloze deletions, the above data generates six flashcards, each testing different bits of information.

Here is an example of one of the pieces of vocabulary being tested:

A rendered front view of the example flashcard

And here is what is looks like when you reveal the answer:

A rendered answer view of the example flashcard

If I become comfortable enough with Mandarin Chinese reading that I don't want to see the Pinyin, I can just remove the Pinyin field from the flashcard view.

Flashcard

Front

<!-- Only shown if the Tags exist -->
{{#Tags}}
<span style="color:#339922" class="small">{{Tags}}</span>
<br><br>
{{/Tags}}

{{Prompt}}
<br>
<br>
{{cloze:Pinyin}}
<br>
{{cloze:Hanzi}}

Back

<!-- Only shown if the Tags exist -->
{{#Tags}}
<span style="color:#339922" class="small">{{Tags}}</span>
<br><br>
{{/Tags}}

{{Prompt}}
<br>
<br>
{{cloze:Pinyin}}
<br>
{{cloze:Hanzi}}
<br>
<br>
{{#English}}
<hr>
<em>"{{English}}"</em>
{{/English}}

Duplicates the front contents a little bit, but adds the English translation below if one was added to the card. If I become comfortable enough that I don't need the English translations on the cards at all, I can just remove it. Same with anything else, like the prompt or the Pinyin.