Project: Anki flashcards

Published

13 Nov, 2024

We will now attempt to use the tools we’ve learned to create a set of Anki flashcards, using content from our teaching material and an LLM.

Anki is a powerful open-source flashcard program that uses the principles of spaced repetition and active recall to enhance learning and long-term retention. It presents flashcards at optimal intervals, adjusting the frequency of review based on the user’s performance. This is thought to ensure that information is reinforced before it is forgotten.

One of the key strengths of Anki is its flexibility. Users can create their own decks of flashcards tailored to their specific learning needs, or they can download pre-made decks from shared repositories covering a vast array of subjects, from languages and vocabulary to complex medical terminology.

However, Anki requires a lot of manual work to create effective flashcards. In this workshop, we will use an LLM to generate the flashcards for us.

Anki Flashcard Project

The simplest type of Anki flashcard is a pair of text fields: a question and an answer (or a term and a definition).

Anki can import flashcards in a variety of formats, including Anki’s native format, but also from a comma-separated values (CSV) file.

A CSV file is a text file that uses a comma to separate values. Each line of the file is a row, and each row has of one or more columns, separated by commas.

If we have the following list of terms and definitions:

term definition
Metacognition “The ability to think about one’s own thinking processes”
Self-Regulated Learning “The process of taking control of and evaluating one’s own learning”
Executive Functions “Higher-order cognitive processes like working memory and cognitive flexibility”
Scaffolding “Support provided by teachers or peers to help students learn new skills”

we can save these in a CSV file like this:

term,definition
Metacognition,"The ability to think about one's own thinking processes"
Self-Regulated Learning,"The process of taking control of and evaluating one's own learning"
Executive Functions,"Higher-order cognitive processes like working memory and cognitive flexibility"
Scaffolding,"Support provided by teachers or peers to help students learn new skills"

If we save the contents above in a file called anki-flashcards.csv, we can import them into Anki by selecting the `File -> Import… menu item.

Goal

The goal of this project is to create a set of flashcards based on your some teaching material, and to save these in a CSV file that can be imported into Anki.

We will use the following teaching material: four essays about different musical eras (e.g. Baroque, Classical, Romantic, and Modern). These were generated using an LLM, and haven’t been verified for accuracy, but they should give you an idea of what you can do with an LLM.

We will first use an LLM, either GPT-4o or GPT-4o Mini, to extract pairs of questions and answers from the teaching material. Additionally, we can also extract tags for each flashcard, which we can use to categorise the flashcards later.

I recommend using some of the tools we’ve learned in this workshop:

  • creating suitable system and user messages for an LLM
  • create a prompt to extract pairs of questions and answers from the teaching material
  • writing a function to call an LLM with the prompt
  • using structured outputs to control the format of the LLM’s response
    • define a pydantic model to describe the format of the desired response
    • call the LLM with the structured output format

Let’s get started! You can find detailed instructions on the next page.

Back to top

Reuse

Citation

BibTeX citation:
@online{ellis2024,
  author = {Ellis, Andrew},
  title = {Project: {Anki} Flashcards},
  date = {2024-11-13},
  url = {https://virtuelleakademie.github.io/promptly-engineered/workshop/projects/},
  langid = {en}
}
For attribution, please cite this work as:
Ellis, Andrew. 2024. “Project: Anki Flashcards.” November 13, 2024. https://virtuelleakademie.github.io/promptly-engineered/workshop/projects/.