AnkiCardProducer is an intelligent, high-performance tool designed to convert deep learning textbooks (PDF or Markdown) into high-quality Anki flashcards. It leverages modern LLMs (like Gemini/OpenAI) to generate rigorous, bilingual (Chinese/English) Q&A pairs, preserving technical terminology and mathematical formatting.
- Multimodal Input:
- PDF Parsing: Robustly converts PDF textbooks to Markdown, preserving structure, tables, and extracting images.
- Markdown Support: Directly processes existing Markdown files.
- LLM-Driven Generation:
- Uses advanced models (Gemini 1.5/2.0, GPT-4) for context-aware flashcard generation.
- Generates Chinese explanations while strictly referencing English technical terms.
- High Performance:
- Parallel Processing: Multi-threaded LLM requests for rapid generation.
- Resume Capability: Tracks progress at the section level. If interrupted (API limits, network issues), simply re-run to resume exactly where you left off.
- Smart Image Handling:
- Extracts figures from PDFs.
- Uploads to Cloudflare R2 (optional) or handles local references.
- Filters out small decorative icons.
- Python 3.8+
- An LLM API Key (Google Gemini or OpenAI compatible)
- (Optional) Cloudflare R2 credentials for image hosting.
-
Clone the repository:
git clone https://github.com/gaivrt/AnkiCardProducer.git cd AnkiCardProducer -
Install dependencies:
pip install -r requirements.txt
-
Configuration: Copy
.env.exampleto.envand configure your keys:# LLM Settings OPENAI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/ OPENAI_API_KEY=your_api_key_here MODEL_NAME=openai:gemini-1.5-pro # R2 / S3 Settings (Optional) R2_ENDPOINT_URL=https://... R2_ACCESS_KEY_ID=... R2_SECRET_ACCESS_KEY=... R2_BUCKET_NAME=... R2_PUBLIC_URL=...
If you already have a Markdown version of your book:
python src/main.py --mode md --files "path/to/book.md" --prompt src/prompts/deep_learning.txt --output output/dl_cards.csvThis will first convert the PDF to Markdown (extracting images) and then generate cards:
python src/main.py --mode pdf --files "path/to/book.pdf" --prompt src/prompts/deep_learning.txt --output output/dl_cards.csvThe tool generates a CSV file in output/ ready for import into Anki (or further processing).
- Format:
Front, Back, Image, Tag
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.