项目 / thiswillbeyourgithub/AnkiAIUtils
Anki AI Utils 是一组用人工智能辅助完善 [Anki](https://en.wikipedia.org/wiki/Anki_(software)) 卡片的脚本,作者在医学院学习场景中试用过,可按你已有的助记习惯为较难记住的卡片补充说明、助记和配图等字段。工具包括 Illustrator(生成助记图像)、Reformulator(在保留挖空和媒体的前提下改写题面)、助记创建与解释等,并通过 LiteLLM 接入多种模型服务。修改直接写回 Anki 笔记,因此可在各端客户端中使用。目前尚未封装成插件:需自行安装 Python(作者建议 3.12.7 或 3.11),克隆仓库并创建虚拟环境后,再按各脚本说明运行。本页按学习辅助用途介绍。说明见[仓库 README](https://github.com/thiswillbeyourgithub/AnkiAIUtils)。
本站整理,非 GitHub 官方 description。
官方快照(gh_history.db,2026-11-25):总榜 未进 Top50 · 日榜 未进 Top50 · 周榜未满 7 天基线(官方不生成) · 月榜暂无官方口径;下方四卡为站内趋势聚合(周卡按上榜次数,非官方 7 日增量窗)。
以下三段按该项目自己的 GitHub README 章节摘录(可合理截断并标明);README 没有对应章节的留空,不编造。
脚本会为每张答错的卡片自动生成含解释、记忆术和插图的新字段,且保留用户已有记忆术;examples/ 目录提供各工具的训练数据集和示例文件,可作自建数据集的模板。
AnkiAIUtils 用语义相似度动态匹配训练集中的示例来增强卡片,复用自定义助记库,可经 cron 定时自动处理,直接就地修改笔记并兼容各平台 Anki 客户端,支持更换模型提供方。
来自 GitHub 仓库 README / 主页介绍正文,正文较长,已截断:保留前 20000 字符(原始 37,963 字节),完整内容见 GitHub 仓库。
# Anki AI Utils
A powerful suite of AI-powered tools to enhance your [Anki](https://en.wikipedia.org/wiki/Anki_(software)) flashcard learning experience by automatically improving cards you struggle with, tested through medical school. For example think of it like this: every time you fail a card you get a ChatGPT explanation, a Dall-E illustration, mnemonics, etc but supporting your own mnemonics.
**Check out my other Anki and AI related projects on my [GitHub profile](https://github.com/thiswillbeyourgithub)!**
### Simple example
**Those scripts make it so that every failed note will automatically have new fields containing explanations, mnemonics, and illustrations.** This is done in a way that respects **your own mnemonics**, can even use the [major system](https://en.wikipedia.org/wiki/Mnemonic_major_system), and has **many** more features.
An example of the kind of workflow that AnkiIllustrator facilitates, watch [pixorise's youtube channel](https://www.youtube.com/watch?v=QzxHpjryJHg0) which is full of great image mnmemonics, particularly appropriate for mental palace types of learning.
## Developer's note / call for help
This collection of scripts is the culmination of my efforts to contributes the AI features I wish existed when I started medical school. All scripts should be working but I released them hastily after documenting them heavily with the help of [aider](https://aider.chat/). It is possible that some aspects of the documentation is slightly off or imprecise. It is also possible that some of the scripts where slighly broken during the release process. In any case, **by releasing this project made with love and care my hope is to motivate others to package it into addons.** I have too little time to learn how to package those scripts into addons and make the appropriate GUI so any help is absolutely welcome. To that end, please take a look at the TODO list below and open an isue!
## Key Features
- **Adaptive Learning**: Uses [semantic similarity](https://en.wikipedia.org/wiki/Semantic_similarity) to dynamically match your cards with the most relevant examples from your training datasets. The more examples you add, the better it gets!
- **Personalized Memory Hooks**: Reuses consistent mnemonics from your custom collection, building a personalized memory system. Includes a dedicated tool to help create and manage your mnemonic library.
- **Automation Ready**: Run programmatically - for example, use cron to automatically enhance cards you struggled with yesterday, making them easier to remember through images, mnemonics, and explanations.
- **Universal Compatibility**: Modifies Anki notes directly in-place, working seamlessly across all Anki clients (Windows, Mac, Linux, Android, iOS). Extensive logging ensures you can track changes and rollback if needed.
- **Provider Agnostic**: Supports all LLM providers and models through LiteLLM, letting you choose the best option for your needs.
- **Infinitely Extensible**: Add as many examples as you want to your training datasets - the semantic filtering automatically picks the most relevant ones for each card.
## Tools
### Illustrator
Creates custom mnemonic images for your cards using AI image generation. It:
- Analyzes card content to identify key concepts
- Generates creative visual memory hooks
- Preserves a history of generated images
- Supports both DALL-E2, DALL-E3 and Stable Diffusion
- Automatically formats images for optimal display (centered, proper sizing)
- Handles multiple images per card with consistent layout
Perfect for visual learners or complex topics that benefit from imagery.
An example of the kind of workflow that AnkiIllustrator facilitates, watch [pixorise's youtube channel](https://www.youtube.com/watch?v=QzxHpjryJHg0) which is full of great image mnmemonics, particularly appropriate for mental palace types of learning.
<details>
<summary>
Click to see an example
</summary>
For example, I had this French flashcard:

<details>
<summary>Click here if you can't read French</summary>
Here's the note content translated to English:
```
Diagnostic criteria for simple febrile seizures:
- Age greater than 1 year
- Seizure occurring with fever above 38°C (100.4°F)
- Symmetrical motor manifestations lasting less than 15 minutes and without deficit
- Single seizure per febrile episode
- Less than 3 episodes in total
```
</details>
`illustrator.py` generated to me this image:

As well as this text content to understand its thought process: (Note that this part is always in English no matter the original language)
```
Topic: 'Diagnostic criteria for a simple febrile seizure'
Anchors: 'Febrile / Fever: a fireplace (sounds like febrile)'
Phonetic: '1 as T link in thai, tea, tie; 3 as M link in mow, my, meh; 8 as F link in fire, faux, few; 5 as L link in low, lee, lie'
Remarks:
* The criteria are specific and should be presented in a way that is easy to remember.
Step by step decomposition:
* Age over 1 year: a toddler holding a teacup (T for 1)
* Seizure with fever over 38°C: a thermometer with flames around it (F for 8)
* Symmetric motor manifestations lasting less than 15 minutes without deficit: a clock showing 15 minutes with two identical figurines moving symmetrically on either side
* 1 unique seizure per febrile episode: a single lightning bolt striking a fireplace (fireplace for fever)
* Less than 3 episodes in total: three thermometers, but only two showing a high temperature
Imagining:
* A toddler holding a teacup, standing next to a fireplace with a single lightning bolt striking it.
* Above the fireplace, a clock showing 15 minutes with two identical figurines moving symmetrically.
* Next to the toddler, a thermometer surrounded by flames, and three thermometers, two of which show high temperatures.
Subject: 'a toddler holding a teacup next to a fireplace struck by a single lightning bolt, a clock showing 15 minutes with symmetric figurines, a flaming thermometer, and three thermometers with two showing high temperatures'
Description words: 'educational, colorful, engaging, vivid, detailed'
Style: 'illustration'
Realism: 'semi-realistic'
a toddler holding a teacup next to a fireplace struck by a single lightning bolt, a clock showing 15 minutes with symmetric figurines, a flaming thermometer, and three thermometers with two showing high temperatures, educational, colorful, engaging, vivid, detailed, illustration, semi-realistic
[DATE:09/04/2024 VERSION:2.5 LLMMODEL:openai/gpt-4-0125-preview IMAGEMODEL:openai/dall-e-3]
```
</details>
### Reformulator
An intelligent tool that rephrases your flashcards while preserving their core meaning and structure. It helps when:
- Cards are poorly worded or unclear
- You want to vary the phrasing to strengthen recall
- Cards need to be more concise or natural sounding
- Your preferred card format has evolved over time
The tool uses LLMs to reformulate content while carefully preserving cloze deletions and media. This is especially valuable for long-term Anki users - for example, during medical school, your idea of what makes a "perfect" flashcard often evolves after a few semesters. The Reformulator lets you easily update all your older cards to match your current preferred format and style.
<details>
<summary>
Click to see an example
</summary>
For example, given this poorly worded flashcard:
```
bilateral and symmetric alveolar syndrome, perihilar, often with effusion, what to consider?
{{c1::APE}}
```
The reformulator would improve it to:
```
What should be considered in presence of bilateral and symmetric alveolar syndrome, perihilar, often with effusion?
{{c1::In case of bilateral and symmetric alveolar syndrome, perihilar, often with effusion, one should consider APE.}}
```
The reformulator can also make cards more concise when needed. For example, it could reformat the same card as:
```
Key features of bilateral and symmetric alveolar syndrome, perihilar, often with effusion:
- {{c1::Consider APE}}
```
The true power of the reformulator lies in its flexibility - your imagination is the only limit. It can:
- Make questions grammatically complete and clear
- Structure content as proper questions, bullet points, tables, or any format you prefer
- Make answers self-contained by repeating key context when needed
- Adjust verbosity from concise summaries to detailed explanations
- Preserve exact medical terminology while improving clarity
- Maintain cloze deletion format while enhancing content
- Adapt to any formatting style (paragraphs, lists, diagrams, etc.)
- Transform content into mnemonics, analogies, or memory palaces
- Create hierarchical structures for complex topics
- Generate multiple variations to strengthen recall through interleaving
The reformulator is not just a tool for fixing poorly worded cards - it's a creative partner that can help you explore new ways to structure and present information. Whether you want to create visual mind maps, build memory palaces, or develop unique mnemonic systems, the reformulator can help bring your ideas to life while maintaining the integrity of your Anki cards.
</details>
### Mnemonics Creator
Generates memorable mnemonics tailored to your cards by:
- Creating multiple mnemonic options per card
- Using proven memory techniques like the [Major System](https://en.wikipedia.org/wiki/Mnemonic_major_system)
- Incorporating your existing memory anchors
- Preserving context and accuracy
Helps create lasting memory connections, especially for numbers and sequences.
<details>
<summary>
Click to see an example
</summary>
The mnemonics made for the card above about infant fever ended up with this content in the AnkiMnemonics field:
---
1. 'Heureux Hephaistos fébrile tend sa banane unique près du feu'<br>* <b>Heureux </b> Âge supérieur à 1 an <u> Heureux évoque la maturité et donc un âge déjà avancé, supérieur à 1 an </u><br>* <b>Hephaistos fébrile </b> Survenue de la crise avec une fièvre supérieure à 38°C <u> Hephaistos évoque la fièvre du fait de son rôle de forgeron et fébrile réitère ce concept </u><br>* <b>tend sa banane unique </b> 1 unique crise par épisode fébrile donné <u> banane unique évoque une seule occurrence, ici la crise unique par épisode fébrile </u><br>* <b>près du feu </b> Moins de 3 épisodes au total <u> feu évoque la fièvre et sa proximité suggère une limite, ici moins de 3 épisodes en tout </u><br><br>2. 'Un enfant trébuche dans le feu, danse symétriquement, a un seul coup et moins de trois feux'<br>* <b>Un enfant trébuche </b> Âge supérieur à 1 an <u> l'idée d'un enfant qui commence juste à marcher évoque l'âge juste après un an </u><br>* <b>dans le feu, </b> Survenue de la crise avec une fièvre supérieure à 38°C <u> le feu évoque la chaleur, donc la fièvre </u><br>* <b>danse symétriquement, </b> Manifestations motrices symétriques <u> danser évoque le mouvement, et symétriquement évoque les deux côtés du corps bougeant de la même manière </u><br>* <b>a un seul coup </b> 1 unique crise par épisode fébrile donné <u> un seul coup évoque l'unicité de la crise pendant l'épisode fébrile </u><br>* <b>et moins de trois feux </b> Moins de 3 épisodes au total <u> moins de trois feux évoque le nombre total d'épisodes, utilisant l'analogie avec la fièvre comme feu </u><br><br>3. 'Un enfant febrile symetrique forge une unique bulle dans la prairie'<br>* <b>Un enfant </b> Âge supérieur à 1 an <u> enfant indique que le sujet concerne un jeune individu, donc plus d'un an </u><br>* <b>febrile </b> Survenue de la crise avec une fièvre supérieure à 38°C <u> fébrile se lie à la notion de fièvre </u><br>* <b>symetrique </b> Manifestations motrices symétriques <u> directement lié à symétrique </u><br>* <b>forge </b> durant moins de 15 minutes et sans déficit <u> forger évoque une action courte et intense, comme la crise qui dure moins de 15 minutes sans laisser de séquelles </u><br>* <b>une unique </b> 1 unique crise par épisode fébrile donné <u> unique précise le nombre de crises </u><br>* <b>bulle </b> Moins de 3 épisodes au total <u> une bulle évoque quelque chose de rare et limité, semblable à moins de 3 épisodes au total </u><br>* <b>dans la prairie </b> hyperthermique <u> la prairie évoque un espace ouvert et naturel, hyperthermique évoque la chaleur comme celle du soleil sur une prairie </u><br><br>[DATE:09/04/2024 VERSION:2.1 MODEL:openai/gpt-4-0125-preview]<br><br><!--SEPARATOR-->
---
</details>
### Explainer
Provides clear, detailed explanations when you struggle with cards by:
- Breaking down complex concepts
- Highlighting key relationships
- Adding helpful context
- Using analogies and examples
Particularly useful for understanding why you got a card wrong and filling knowledge gaps.
<details>
<summary>
Click to see an example
</summary>
The mnemonics made for the card above about infant fever ended up with this content in the AnkiExplainer field (I translated it french to English for universal documentation):
---
* <b>EXPLANATION</b> A simple febrile seizure is characterized by its uniqueness and brevity during a febrile episode, which helps distinguish it from complex seizures or other neurological disorders.<br>* <b>MECHANISM</b> Fever can lower the seizure threshold in certain children, which explains why an elevation in body temperature can trigger a seizure in predisposed individuals.<br><br>[DATE:09/04/2024 VERSION:1.7 LLMMODEL:openai/gpt-4-0125-preview]<br><br><!--SEPARATOR-->
---
</details>
### Mnemonics Helper
A lightweight interactive CLI tool for quick mnemonic generation that:
- Takes a concept and finds semantically similar existing mnemonics
- Generates multiple new mnemonic options using LLMs
- Lets you choose from generated options with vim-style navigation
- Automatically saves selected mnemonics for future reference
- Works independently of Anki, perfect for brainstorming sessions
Unlike the Mnemonics Creator which processes Anki cards in batch, this tool provides an interactive interface for generating mnemonics one concept at a time. Those new mnemonics can automatically be added to a dataset file that can readily be used by the other tools. This allows rapidly tailoring the scripts to your own imagination.
## FAQ
<details>
<summary>
Click to read more
</summary>
### What are the core benefits of those tools?
Basically if you run these tools each evening on cards you failed that day it will steadily improve your deck quality and learning effectiveness:
- Automatically enhance cards you struggle with
- Save time on manual card improvements
- Create stronger memory connections
- Track improvements with detailed history
- Preserve card structure while enhancing content
### What is the [Major System](https://en.wikipedia.org/wiki/Mnemonic_major_system)?
The Major System is a powerful memory technique that converts numbers into consonant sounds, which can then be turned into memorable words. For example:
- 0 = S sound (as in "sea")
- 1 = T sound (as in "tea")
- 2 = N sound (as in "new")
- etc.
This makes it easier to remember numbers by turning them into words. For example, "92" could become "pen" (P=9, N=2).
You can read more about it [on wikipedia](https://en.wikipedia.org/wiki/Mnemonic_major_system)
### What are Memory Anchors?
Memory anchors are existing associations you already know well that can be used to create new memories. For example, if you already strongly associate "Napoleon" with "France", you can use Napoleon as an anchor when learning new facts about French history.
The tools can use your personal set of memory anchors to generate mnemonics that build on your existing knowledge.
### Which LLM providers are supported?
The tools use [LiteLLM](https://docs.litellm.ai/docs/) which provides a unified interface to virtually any LLM provider including:
- OpenAI
- Anthropic
- Google
- [MiniMax](https://www.minimaxi.com/) (MiniMax-M3 — 512K context, MiniMax-M2.7, MiniMax-M2.7-highspeed — 204K context)
- OpenRouter
- Azure
- AWS Bedrock
- Local models
- And many more
Just specify the model in LiteLLM format (e.g. "openai/gpt-4", "anthropic/claude-3-opus", or "minimax/MiniMax-M3") and it will handle the rest. For MiniMax, place your API key in a file named `MINIMAX` inside the `API_KEYS/` directory (the tools will load it as `MINIMAX_API_KEY`).
### What languages are supported?
The tools work in any language supported by the LLM you choose to use. Since these scripts support virtually all LLM providers through LiteLLM, you can use any model that works well with your language. For example:
- OpenAI's models support 100+ languages
- Anthropic's Claude supports 100+ languages
- You can use local models specifically trained for your language
- etc.
The tools will preserve all language-specific formatting, including:
- Right-to-left text
- Special characters and diacritics
- Language-specific punctuation
- etc.
### How do the Mnemonics Work?
The mnemonics tools use several proven memory techniques:
- [Major System](https://en.wikipedia.org/wiki/Mnemonic_major_system) for numbers
- Vivid imagery and visualization
- Personal memory anchors
- Phonetic similarities
- Humor and absurdity
- Story-based connections
This creates memorable associations that help strengthen recall while preserving accuracy.
### Where can I find example datasets for each tool?
The `examples/` folder contains training datasets and example files for each tool. While these were originally written in French and hastily translated to English, they provide good templates for creating your own datasets. Check the Example Files section below for details on each file.
### What's the future of this project?
This toolkit was developed and battle-tested while studying tens of thousands of Anki cards during medical school. It proved invaluable for maintaining and enhancing a large flashcard collection during intense study periods.
However, as research commitments have grown, I now have limited time to transform these scripts into a more user-friendly package. The tools work well but need:
- Packaging as a proper Anki addon
- Installation via PyPI
- Code deduplication and cleanup
- Better documentation
I'm actively looking for contributors of all skill levels to help make these tools more accessible to the wider Anki community. Whether you're a seasoned developer or just getting started, all contributions are welcome! I can provide guidance and direction based on extensive experience with the codebase, while you help with the technical aspects of packaging and distribution.
Check out the detailed roadmap below to see what needs improving. If you're interested in helping transform these battle-tested scripts into a polished Anki addon, please don't hesitate to reach out - I'm always happy to chat and help you get started!
### Why is there code duplication across the tools?
This project evolved organically alongside my Python skills while solving real needs during medical school. Each tool was developed independently when needed, prioritizing functionality over code elegance. While they all work reliably, there's significant opportunity to unify their codebases around a common API.
I can provide detailed guidance on refactoring and consolidating the code, but lack the time to implement these changes myself. Check the roadmap below if you're interested in helping streamline the codebase while preserving its battle-tested functionality.
### When Should I Use Each Tool?
- **Mnemonics Creator**: Best for memorizing numbers, sequences, lists, and abstract concepts
- **Illustrator**: Ideal for visual learners and complex topics that benefit from imagery
- **Reformulator**: Use when card wording is unclear or you want variety in phrasing. Don't worry about running it on well-formatted cards - the LLM is trained to recognize and preserve cards that already follow best practices, avoiding unnecessary cha