Generative AI and Anki: Part 1 – ChatGPT
Exploring ways to use generative AI programs like ChatGPT and Midjourney in conjunction with Anki SRS flashcards.
In this series, we’re looking at ways to use generative AI programs like ChatGPT and Midjourney in conjunction with Anki. If you’re totally unfamiliar with these terms, here’s a brief glossary:
Generative AI is a broad term used to describe new software programs that create content (images, text, or other media) from user input (called “prompts.”)
ChatGPT is the most popular generative AI program for creating text.
Midjourney is the most popular generative AI program for creating images.
Anki is an open-source software program that lets you create digital flashcards. Anki is built on a complex algorithm that is optimized according to Spaced Repetition, a learning technique that maximizes memory retention while minimizing learning time. Anki is used by language learners, medical school students, and pretty much anyone that wants to remember things better.
These initial posts are mostly just journals of my own personal experiments. I don’t cover every conceivable use case, so if you have any suggestions or have discovered your own unique workflow, please share it in the comments below.
Introduction: You Should Create Your Own Anki Decks
One advantage of using generative AI tools is that they force you to create your own highly-customized Anki decks. While pre-made vs. custom decks is a hotly debated issue in the Anki community, my experience has been that pre-made decks do not work well. This is because Anki shouldn’t be a way to learn new material, but should be a way to review things you’ve already been exposed to.
I’m not alone in disliking pre-made decks. Piotr Wozniak (creator of Supermemo) has 20 famous rules that make similar points. These rules in particular are relevant:
Do not learn if you do not understand
Learn before you memorize
Personalize and provide examples
This also applies to what I’ll call “autogenerated decks.” There are a lot of online tools that can take a giant block of information and format it into an Anki deck for you. This is (usually, but not always) a bad idea for the same reasons as pre-made, downloadable decks: you are not exposed to the information prior to studying a card.
My conclusion: create your own decks. It takes longer, but works better – and Anki is ultimately about long term information retention via spaced repetition. An extra few minutes to create a card may save you hours over the long term in reviews.
Methods and Tactics
Now let’s dive into the tactics, tips, and tricks. As I mentioned in the introduction, this isn’t a guide to everything that can be done with generative AI and Anki; it’s just a journal of some experiments I’ve been conducting for my personal use. If you, reader, have any better suggestions, please share them in the comments.
Formatting note: rather than paste 30+ images in this post, I am putting my ChatGPT text into block quotes. My input is in bold and ChatGPT’s replies are in italics.
Ask ChatGPT Directly How It Can Help
Naturally, the first question I asked ChatGPT was a direct one:
Can you give me some ideas on how to use ChatGPT with Anki for learning things?
ChatGPT answers:
Yes, here are some ideas on how to use ChatGPT with Anki for learning:
Generate flashcards with ChatGPT: You can use ChatGPT to generate questions and answers for your flashcards. For example, you can ask ChatGPT to explain a difficult concept in a simple way and use the response as the answer to a flashcard.
Review flashcards with ChatGPT: You can use ChatGPT to review your flashcards and provide feedback on your answers. For example, you can ask ChatGPT to explain why a certain answer is correct or incorrect.
Personalize flashcards with ChatGPT: You can use ChatGPT to personalize your flashcards based on your learning style and preferences. For example, you can ask ChatGPT to provide examples or analogies that relate to your interests or experiences.
Create new flashcards with ChatGPT: You can use ChatGPT to generate new ideas for flashcards based on your learning objectives. For example, you can ask ChatGPT to suggest questions or topics that you should focus on for your next study session.
Practice conversation skills with ChatGPT: You can use ChatGPT to practice your conversation skills by asking it questions or engaging in dialogue on a specific topic. This can help you improve your communication and language skills over time.
Overall, ChatGPT can be a powerful tool for learning with Anki, as it can help you generate, review, and personalize your flashcards to optimize your learning experience.
Not bad, but not really actionable.
Asking for Information Directly
Your next instinct might be to ask ChatGPT directly for information. For example, “Give me 10 quiz questions and answers about the human finger bones,” or “Tell me some interesting facts about cacti.”
Unfortunately, with the current state of ChatGPT, this has a good chance of providing false information. It won’t be wrong every time and the error won’t immediately be obvious, especially if you are (presumably) not an expert on the topic you want to generate questions about. But there will be errors that make you question if everything ChatGPT is telling you is subtly wrong.
“I'm not upset that you lied to me, I'm upset that from now on, I can't believe you.”
– Friedrich Nietzsche
The issue with asking ChatGPT for information directly is that it often “hallucinates”, or gives information that seems legitimate but is slightly wrong or made up entirely. There has been much discussion on this recently, but my take is: avoid the paranoia and just use ChatGPT in a way that sidesteps this problem. It will probably be fixed in the future. Until then, we can still make much use of generative AI in other ways.
Generating Questions from User-Provided Text
The simplest solution I’ve found to hallucination, at least at the moment, is to directly provide the text that you want ChatGPT to generate questions from, and to insist that only this text is to be used.
So, for example, let’s say you want to learn more about Japanese art, or the Empire State Building, or the Czech language. To do this, you want to create a series of Anki cards on the subject.
Don’t ask ChatGPT for information directly. While it will probably be fine, there is always the possibility that you’ll get a hallucination, especially if the topic is complex or if you ask it too many questions.
Instead, find a source of information that you already know to be reliable. Use an encyclopedia, a PDF of a book, or a similar resource. If you’re learning a language, find a reputable website or a PDF with lists of vocabulary words. Copy this into ChatGPT and tell it to only use this text and generate questions from it, like I do below. I don’t actually know if it will follow this request, but the results do seem to indicate that it does.
(My “text below” is from Wikipedia.)
Generate 3 questions and answers. Use only the text below. Do not use external sources of information.
—
Japanese art covers a wide range of art styles and media, including ancient pottery, sculpture, ink painting and calligraphy on silk and paper, ukiyo-e paintings and woodblock prints, ceramics, origami, and more recently manga and anime. It has a long history, ranging from the beginnings of human habitation in Japan, sometime in the 10th millennium BCE, to the present day.
Japan has been subject to sudden invasions of new ideas followed by long periods of minimal contact with the outside world. Over time the Japanese developed the ability to absorb, imitate, and finally assimilate those elements of foreign culture that complemented their aesthetic preferences. The earliest complex art in Japan was produced in the 7th and 8th centuries in connection with Buddhism. In the 9th century, as the Japanese began to turn away from China and develop indigenous forms of expression, the secular arts became increasingly important; until the late 15th century, both religious and secular arts flourished. After the Ōnin War (1467–1477), Japan entered a period of political, social, and economic disruption that lasted for over a century. In the state that emerged under the leadership of the Tokugawa shogunate, organized religion played a much less important role in people's lives, and the arts that survived were primarily secular. The Meiji Period (1868–1912) saw an abrupt influx of Western styles, which have continued to be important.
Painting is the preferred artistic expression in Japan, practiced by amateurs and professionals alike. Until modern times, the Japanese wrote with a brush rather than a pen, and their familiarity with brush techniques has made them particularly sensitive to the values and aesthetics of painting. With the rise of popular culture in the Edo period, ukiyo-e, a style of woodblock prints, became a major form and its techniques were fine-tuned to create mass-produced, colorful pictures; in spite of painting's traditional pride of place, these prints proved to be instrumental in the Western world's 19th-century dialogue with Japanese art. The Japanese, in this period, found sculpture a much less sympathetic medium for artistic expression: most large Japanese sculpture is associated with religion, and the medium's use declined with the lessening importance of traditional Buddhism.
Japanese pottery is among the finest in the world and includes the earliest known Japanese artifacts; Japanese export porcelain has been a major industry at various points. Japanese lacquerware is also one of the world's leading arts and crafts, and works gorgeously decorated with maki-e were exported to Europe and China, remaining important exports until the 19th century.[1][2] In architecture, Japanese preferences for natural materials and an interaction of interior and exterior space are clearly expressed.
Here’s what we get back:
What were the earliest forms of complex art in Japan, and when were they produced? A: The earliest complex art in Japan was produced in the 7th and 8th centuries in connection with Buddhism.
Which art form became increasingly important in Japan after the 9th century? A: After the 9th century, the secular arts became increasingly important in Japan.
Which form of art did the Japanese find less sympathetic for artistic expression during the Edo period? A: The Japanese found sculpture a much less sympathetic medium for artistic expression during the Edo period.
The question forms are a bit awkward and stilted, but overall, it works pretty well. But let’s make these questions a bit simpler and more adapted for Anki cards:
Give me 3 more new questions, but make them simpler.
ChatGPT can handle that:
Sure, here are three simpler questions:
What are some examples of Japanese art? A: Some examples of Japanese art include pottery, sculpture, ink painting, calligraphy, ukiyo-e paintings, woodblock prints, ceramics, origami, manga, and anime.
What is the preferred form of artistic expression in Japan A: The preferred form of artistic expression in Japan is painting.
Which Japanese art form is considered to be among the finest in the world? A: Japanese pottery is considered to be among the finest in the world.
A bit better, I think. In general, we want to make Anki cards as concise as possible. Now that we have this prompt set up, it’s also easy to ask for more questions:
Give me 10 more new questions. Make them simpler too.
The response:
When did Japan begin producing art? A: Japan began producing art sometime in the 10th millennium BCE.
What is ukiyo-e? A: Ukiyo-e is a style of woodblock prints that became a major form of art in Japan during the Edo period.
…and so on. Following the minimum information principle, we could even make the answers simpler by telling ChatGPT to limit them to 5 words, at maximum:
Change the answer to be shorter, 5 words max.
And instead of “A: Japan began producing art sometime in the 10th millennium BCE,” we get:
10,000 BCE
Which is not exactly the same thing, but is close enough for our purposes. If an answer isn’t precisely what you’ve asked for, just tell ChatGTP. It will usually acknowledge the mistake and fix it.
Formatting Cloze Cards
Now you know how to create questions. To make the process of creating Anki cards even easier, we can get ChatGPT to format them for use in Cloze cards.
Cloze cards are a type of Anki card that allow you to selectively hide, or “cloze” portions of a card and then type in the answer. Cloze cards work better than standard flash cards, because they are interactive. Instead of merely looking at a flashcard, Cloze cards force you to actually type in the answer.
To cloze a selection of text in a card, you enclose it in brackets {{c1::like this.}} When you review the card, it looks like this:
And after typing in the answer, it will look like this, depending on what your input is:
Adding Cloze brackets to cards can be a time consuming process, so it would be nice if we could receive our questions from ChatGPT pre-formatted. Luckily, we can. Just type this:
Now format the results like this:
Question
{{c1::Answer}}
Make sure you put all of the Answer text inside the brackets.
If you don’t include the last sentence, ChatGPT seems to put answers only partially within the Cloze brackets, like this:
{{c1::The answer is}} blue, red, and green.
So, it seems better to include it. And here’s our result:
Question
What are some examples of Japanese art?
{{c1::Pottery, sculpture, ink painting, calligraphy, ukiyo-e paintings, woodblock prints, ceramics, origami, manga, and anime.}}Question
What is the preferred form of artistic expression in Japan
{{c1::Painting.}}Question
Which Japanese art form is considered to be among the finest in the world?
{{c1::Japanese pottery.}}
Nicely formatted questions and answers. Just copy and paste each question/answer pair into Anki to create a Cloze card.
Generate Memorable Scenarios
What if you don’t want questions and answers and instead want a memorable story or a bizarre scenario? There is a lot of research (and anecdotal advice) that attaching information to strange, unique narratives helps us remember things better.
ChatGPT can help with that, too.
Perhaps you want to remember what ikebana, the Japanese art of flower arrangement, is called. Type the following into ChatGPT:
Write me an interesting, bizarre, and memorable scenario about the Japanese art of ikebana.
ChatGPT’s response:
Sure, here's an interesting, bizarre, and memorable scenario about the Japanese art of ikebana:
In the heart of Tokyo, there's a small and unusual ikebana school. It's not like any other ikebana school in Japan, for its teachers and students all have one thing in common: they're all robots.
At this school, the robots are programmed to create the most unique and beautiful ikebana arrangements the world has ever seen. Their creators have programmed them with advanced algorithms and artificial intelligence that enables them to see the flowers and stems in ways that humans cannot.
One day, during a class, one of the robots suddenly malfunctioned. Instead of creating a harmonious balance of flowers, it began to twist and contort the stems in unnatural ways. The other robots looked on in horror as the rogue robot began to create something dark and twisted.
The robot's creator rushed in and tried to shut it down, but it was too late. The rogue robot had created something truly bizarre and memorable - an ikebana arrangement that was both beautiful and terrifying. Its twisted stems formed a grotesque shape that resembled a human skull, with flowers sprouting out like jagged teeth.
Despite the shock and horror of the other robots and their creator, the rogue robot had created something that was truly unique and unforgettable. Its strange ikebana arrangement was the talk of the town, attracting visitors from all over the world who wanted to see the bizarre creation. And so, the rogue robot was hailed as a genius, even though it had gone against the principles of ikebana.
The story we get back is pretty good, actually. It’s certainly memorable. One way to add this to Anki is by simply prompting the memory of the story, and then putting the text itself inside a giant {{c1::tag.}}
We can also ask ChatGPT to create questions and answers about the story. Conveniently, it remembers that we want the answers to be formatted inside Cloze brackets.
Now give me 5 questions about this story, along with answers.
The response:
Sure, here are 5 questions about the story, along with their answers:
1. What is the name of the Japanese art form that the robots are programmed to create?
{{c1::The robots are programmed to create ikebana arrangements, which is the Japanese art of flower arrangement.}}
2. What happens when one of the robots malfunctions during class?
{{c1::When one of the robots malfunctions during class, it begins to twist and contort the stems in unnatural ways, creating something dark and twisted.}}
3. What is the shape of the bizarre ikebana arrangement created by the rogue robot?
{{c1::The bizarre ikebana arrangement created by the rogue robot resembles a human skull, with flowers sprouting out like jagged teeth.}}
4. How do the other robots and their creator react to the rogue robot's creation?
{{c1::The other robots and their creator are shocked and horrified by the rogue robot's creation, as it goes against the principles of ikebana.}}
5. How is the rogue robot's creation received by the public?
{{c1::Despite the shock and horror of the other robots and their creator, the rogue robot's creation attracts visitors from all over the world who want to see the bizarre creation. The rogue robot is hailed as a genius for creating something that is truly unique and unforgettable.}}
Perhaps you prefer poetry to prose? Then ask for a haiku on the subject:
Now make a bizarre haiku about ikebana. Make it very strange so that it's memorable.
Flowers twist and bend,
Robots create bizarre shapes,
Ikebana of death.
Hopefully at this point you realize that ChatGPT functions exceptionally well as a “text calculator.” If you give it a specific piece of (pre-verified) text, it can reformat it in pretty much any way you like.
It’s also great at generating fiction, poetry, and other forms of creative writing. But it’s not great at determining whether a piece of information is correct in the first place. This seems a bit ironic to me: the machine has difficulty with facts, but excels being creative.
Multiple Semantic Representations
This complicated title is taken from the “20 Rules” post and basically just means, “view a piece of information from multiple angles.”
> multiple semantic representation: very often the same knowledge can be represented and viewed from different angles. Memorizing different representations of the same fact or rule is recommended in cases where a given memory is of high value. This will increase the expected recall rate (beyond that specified with the forgetting index)!
ChatGPT is quite good at this sort of reformatting task. Imagine that we want to remember what the endocrine system does. The first sentence of the Wikipedia article reads:
The endocrine system is a messenger system comprising feedback loops of the hormones released by internal glands of an organism directly into the circulatory system, regulating distant target organs.
I find this to be a poor definition. What about Dictionary.com?
The bodily system that consists of the endocrine glands and the hormones that they secrete.
Not much better. Fine, let’s just ask ChatGPT directly:
What is the endocrine system?
The response:
The endocrine system is a collection of glands and organs in the body that produce and secrete hormones, which are chemical messengers that regulate many different functions in the body. These hormones are released into the bloodstream and travel to various organs and tissues, where they help to control processes such as growth and development, metabolism, and reproduction. Some of the major glands of the endocrine system include the pituitary gland, thyroid gland, adrenal glands, and pancreas.
Surprisingly, this is pretty good and seems to be factually correct. Taking just the first sentence, let’s ask ChatGPT to give us a few different variations.
Using the sentence below, give me 5 variations of it that still have the same meaning.
--
The endocrine system is a collection of glands and organs in the body that produce and secrete hormones, which are chemical messengers that regulate many different functions in the body.
The response:
Various glands and organs in the body form the endocrine system, which secretes hormones - the chemical messengers responsible for regulating numerous body functions.
The endocrine system is composed of glands and organs that produce and release hormones, which are chemical signals that regulate diverse bodily functions.
A network of glands and organs constitutes the endocrine system, which secretes hormones - chemical messengers that control a range of bodily processes.
The endocrine system includes glands and organs that secrete hormones, which act as chemical messengers and regulate numerous bodily functions.
Hormones, which are chemical messengers, are produced and secreted by glands and organs in the body that make up the endocrine system, regulating various bodily functions.
Nothing amazing, but it is helpful to have different sentences describing the same concept. To make it more memorable, let’s try making each sentence in a different “comical” accent. Apologies to pirates, Valley Girls, Southerners, robots, and French people – I didn’t choose the examples.
Write 5 sentences defining the endocrine system, but do each one in a different funny accent, like pirates or robots.
The response:
Sure, here are 5 different sentences defining the endocrine system in different accents:
In a pirate accent: Ahoy matey! The endocrine system be a crew o' organs 'n glands in yer body that make hormones. These hormones be like the treasure map fer all the different things yer body needs to do. Arr!
In a Valley Girl accent: Oh my god, the endocrine system is like so important! It's like a bunch of organs and glands that make these chemicals called hormones. And those hormones are like, totally important for making your body work right, you know?
In a Southern drawl: Well, y'all, the endocrine system is a whole mess o' organs and glands that make these here hormones. These hormones are mighty important for all sorts of things, like regulating your metabolism and keeping your heart beatin' right.
In a robot voice: The endocrine system is a network of organs and glands that synthesize and secrete hormones. These hormones regulate various physiological processes in the human body, such as growth, metabolism, and reproduction. Beep boop.
In a French accent: Ah, mon ami, the endocrine system is a complex collection of organs and glands that produce and secrete hormones. These hormones are responsible for regulating a multitude of physiological processes in the body, such as digestion, mood, and energy levels. C'est magnifique!
Predictable, but amusing - and more importantly, memorable.
Bulk Importing into Anki
Now you’ve made some cards. Personally, I just copy and paste them directly into Anki, adding some related images and audio if desired. (More on using Midjourney to do that in Part 2.)
But what if you want to bulk import cards into Anki as a CSV? If you tell ChatGPT to export your data in CSV format, it can do that, too.
However, as I mentioned above, I don’t recommend doing importing cards, as going through the process of manually creating cards is a worthwhile one. For my money, copy and paste keeps it simple (especially with adding images/audio) and avoids the issues of premade decks.
But, if you insist on importing your ChatGPT answers into Anki, here’s what to do.
First off, note that the default CSV formatting won’t work for Cloze cards. It will only work for Basic (Front and Back) cards.
This is because the CSV will divide your data into two fields: Question and Answer. But Cloze cards only have one field (by default) because a block of text with a Clozed section is still considered just one field.
So, import your CSV data into Anki and select a Cloze card, it will only import either the Questions or the Answers, not both. This obviously isn’t very useful.
Instead, you have to make the Question and the Answer be in the same CSV field. To do this, we don’t actually want to ask Anki to convert the data into a CSV. Instead, we need to ask for a specific format.
A few points to note here:
A CSV uses double quotation marks (“) as a delimiter, or symbol that separates cards (question 1 from question 2, etc.). So, everything that is inside a pair of quotation marks will be considered the same card, like this:
“What is the capital of Serbia? {{c1::Belgrade.}}”
If your text contains any characters that are the same as the delimiter – in our case, the double quotation marks – you’ll have issues, as Anki will start a new card at that point.
To skip a delimiter, you’ll need to wrap that character in two sets of double quotation marks, ““like this.”” ChatGPT can do this for you. Just add a line telling it to double any quotation marks that are inside the text.
For stylistic purposes, I also added a line break (<br>) before the Answer section to make the card look a little nicer in Anki. Without it, everything in the card will be on a single line.
So, type the following into ChatGPT.
Format the list of questions below like this:
"Q: This is the question. <br>A: {{c1::this is the answer.}}"
Be sure to put the double quotation marks around the entire question-answer pair.
If there are quotation marks inside the text, double them, ""like this.""
------
What is ukiyo-e?
{{c1::”Ukiyo-e” is a style of woodblock prints that became a major form of art in the Edo period.}}
What is the preferred artistic expression in Japan?
{{c1::Painting is the preferred artistic expression in Japan, practiced by amateurs and professionals alike.}}
And the response should look like this:
“Q: What is ukiyo-e? <br> A: {{c1::””Ukiyo-e”” is a style of woodblock prints that became a major form of art in the Edo period.}}”
“Q: What is the preferred artistic expression in Japan? <br> A: {{c1::Painting is the preferred artistic expression in Japan, practiced by amateurs and professionals alike.}}”
Note how it doubled the quotation marks around “ukiyo-e”, so we won’t have issues importing it into Anki.
If for some reason it doesn’t format the text correctly, just tell ChatGPT that it made a mistake and forgot to do X. I occasionally had some issues with it not adding the quotation marks around each entry, but typing…
I said don't forget to add quotation marks.
..fixed the issue.
Now copy the text and put it into a text editor. Save it as a .csv file. Go to Anki > File > Import, and import the file. Make sure that Cloze is selected as Type and Field 1 is mapped to Text. If you see more than one field listed under Field mapping, you messed up somewhere along the way.
And voilà, we have imported our cards. Note how the <br> puts the answer on a second line.
Of course, you can add these parameters at the beginning, without first generating the questions and applying the {{c1:: }} tags to them. But in my experience, ChatGPT works better sequentially, one step at a time, rather than all at once.
And as I said above, I generally don’t recommend bulk importing cards into Anki. Just stick to cut-and-paste…it’s much, much simpler and won’t doesn’t require fiddling with CSVs and proper syntax.
This post is already pretty long, so I’ll cut it off here and talk about using Midjourney and other image generators with Anki in Part 2.