IDLEARN is an open-source educational tool that helps students and researchers learn more efficiently from long-form documents like PDFs and EPUBs. It automatically extracts content and images, generates comprehensive summaries using multimodal LLMs, creates question-answer pairs, and builds Anki flashcard decks β so you can focus on learning instead of manual note-taking.
All processing can happen locally on your machine using Ollama, meaning your documents never leave your computer. You can also connect to OpenAI-compatible cloud APIs if you prefer.
- Extracts text and images from PDF and EPUB files, using the document's Table of Contents (ToC) to structure content into sections. Filters out watermarks, footnotes, title pages, and running headers/footers. Extracts relevant figures for multimodal summarization.
- Generates comprehensive summaries using a multimodal LLM that can process both text and images. Summaries capture all nuances, key concepts, and figure descriptions β not just brief bullet points.
- Creates question-answer pairs (5 per section) for active recall practice.
- Builds Anki decks (
.apkgfiles) with both Basic and Cloze card models, choosing the appropriate type based on whether the answer contains quantitative data. - Exports Obsidian notes focused on the summary digest with figure references, saved to
~/Documents/obsidian/by default. - Caches results so that previously processed sections are not re-generated, saving time and API calls.
- Knowledge graph (planned) β Extracts concepts and their relationships from summaries into a structured graph exportable to Mermaid, Obsidian Canvas, and GraphML.
IDLEARN is built around a modular pipeline (app/pipeline.py):
| Step | Module | Description |
|---|---|---|
| Text Extraction | app/text_extractor.py |
Uses PyMuPDF to extract structured text from PDFs/EPUBs, guided by the ToC. Filters out watermarks, footnotes, title pages, and running headers/footers. |
| Image Extraction | app/text_extractor.py |
Extracts relevant images from PDF pages for each section, filtering out watermarks, logos, and tiny decorative images. |
| ToC Extraction | app/toc_extractor.py |
Extracts or infers the Table of Contents from PDFs and EPUBs. Falls back to font-analysis heuristics when no built-in ToC exists. |
| Tokenization | app/tokenizer.py |
A SmartTokenizer splits long texts at semantic boundaries (paragraphs, sentence ends) rather than arbitrary character limits, preserving context. |
| Multimodal Summarization | app/pipeline.py β recursive_summarize() |
Texts exceeding ~3 000 tokens are segmented, summarized individually, and recursively combined. Extracted images are included for multimodal models. |
| LLM Integration | app/llmmodel.py |
Interfaces with multimodal LLMs via Ollama (local or cloud) or any OpenAI-compatible API. Supports vision models (e.g., gemma3:4b, llava). |
| Card Generation | app/cg.py |
Uses genanki to create Anki decks, automatically choosing between Basic and Cloze card models. |
| Output Formatting | app/utils.py |
Writes structured Markdown files with summaries, key concepts, figures, and Q&A. |
| Caching | app/utils.py β IdlearnCache |
Persists summaries and Q&A to .cache/cache.json so they survive restarts. |
- Python 3.10+
- Ollama (for local LLM inference): Download and install Ollama, then pull a multimodal model:
For better quality (at the cost of more resources), you can use
ollama pull gemma3:4b
gemma3:12borllava:13b. - Conda (recommended): Miniconda or Anaconda
-
Clone the repository:
git clone https://github.com/diomir0/idlearn.git cd idlearn -
Create and activate the Conda environment:
conda env create -f environment.yml conda activate idlearn
Or, if you prefer
pip:pip install -r requirements.txt
IDLEARN offers two interfaces:
python main.pyA dark-themed window will open. Here's how to use it:
- Choose file β Click the button and select a PDF or EPUB file.
- Choose destination folder β Select where the output files will be saved.
- Select sections β The "File Metadata" pane on the right shows the document's Table of Contents. Check the boxes next to the sections you want to process.
- Toggle options:
- Summarize (on by default) β Enables LLM-based summarization and Q&A generation. Turn it off if you only want the full-text Markdown export.
- Anki cards β When enabled, an
.apkgdeck is generated alongside the Markdown output.
- Click Run β Processing runs in a background thread so the GUI stays responsive. Results are saved to your chosen output folder.
streamlit run web_app.pyThis opens a browser-based interface where you can:
- Upload a PDF or EPUB via the sidebar.
- Set the output folder path.
- Choose LLM provider β Ollama (local/cloud) or OpenAI-compatible API, and configure the model name, host URL, and optional API key.
- Toggle summarization and Anki card generation.
- Select sections from the dynamically generated ToC checkboxes.
- Click "Start Processing" β Summaries and Q&A appear in the main panel; files are saved to the output folder.
IDLEARN supports two LLM backends:
| Provider | Default Model | Default URL | Notes |
|---|---|---|---|
| Ollama | gemma3:4b |
http://localhost:11434 |
Runs locally. No API key needed for local instances. Supports multimodal (vision) models for figure-aware summarization. |
| OpenAI | gpt-4o |
https://api.openai.com/v1 |
Requires an API key. Supports vision models for multimodal summarization. Compatible with any OpenAI-style endpoint (e.g., Azure OpenAI, Together AI). |
In the GUI, these are configured when creating the Pipeline object (the model defaults to Ollama with gemma3:4b, a multimodal model).
In the Web app, you can select the provider and enter credentials directly in the sidebar.
idlearn/
βββ main.py # Desktop GUI entry point
βββ web_app.py # Streamlit web interface
βββ environment.yml # Conda environment specification
βββ requirements.txt # pip dependencies
βββ README.md
βββ app/
β βββ __init__.py # Version info
β βββ config.py # Global configuration (deck_id)
β βββ pipeline.py # Main processing pipeline
β βββ text_extractor.py # Structured text extraction from PDFs/EPUBs
β βββ toc_extractor.py # Automatic ToC extraction & inference
β βββ tokenizer.py # SmartTokenizer, TokenEstimator, HierarchicalSegmenter
β βββ formatter.py # TextFormatter for Markdown output
β βββ llmmodel.py # LLM interface (Ollama + OpenAI)
β βββ cg.py # Anki card generation
β βββ gui.py # customtkinter GUI
β βββ knowledge_graph.py # Knowledge graph data structures and stubs (planned)
β βββ utils.py # Caching, ToC helpers, Markdown writers
β βββ logger.py # Logging configuration
β βββ obsidize/ # Obsidian export add-on (template engine)
β βββ __init__.py # Public API
β βββ engine.py # clip_pdf(), compile_template(), load_template()
β βββ types.py # Dataclasses (Template, PdfContent, etc.)
β βββ tokenizer.py # Template string β Token stream
β βββ parser.py # Token stream β AST
β βββ renderer.py # AST β rendered string
β βββ resolver.py # Variable resolution
β βββ shared.py # Frontmatter, variable building, sanitization
β βββ filters/ # 51 template filters
β βββ templates/ # Built-in Obsidian templates
βββ templates/ # User Obsidian templates (optional, for custom templates)
βββ old/ # Archived prototype scripts and notebooks
βββ cache/ # Runtime cache (auto-created)
βββ logs/ # Log files (auto-created)
IDLEARN includes Obsidize, a built-in Obsidian export engine that converts extracted PDF content into structured Obsidian notes using templates compatible with the Obsidian Web Clipper format.
from app.pipeline import Pipeline
p = Pipeline("paper.pdf", "./output", cards=False)
result = p.run(p.text_extractor.toc, summarize=True)
# Export the summary digest to Obsidian (default template: idlearn-summary)
obs_result = p.export_obsidian(template="idlearn-summary")
print(obs_result.full_content) # Comprehensive digest with figures| Template | ID | Description |
|---|---|---|
| Summary Digest (IDLEARN) | idlearn-summary |
Comprehensive summary digest with key concepts, figures, and Q&A. Best for multimodal summarization. (Default) |
| Study Notes (IDLEARN) | idlearn-study-notes |
Full study notes with sections, summaries, and Q&A from idlearn processing |
| Flashcard Review (IDLEARN) | idlearn-flashcard-review |
Compact review with summary tips and Q&A callouts for self-testing |
| Academic Paper (IDLEARN) | idlearn-academic |
Academic paper with structured idlearn content extraction |
| Academic Paper | academic |
Academic paper with metadata callout and full content |
| Default PDF Note | default |
Simple note with title and content |
Tip: The
idlearn-summarytemplate is the recommended default for exporting multimodal summaries. It focuses on the comprehensive digest rather than the full extracted text, and includes figure references from extracted images.
Tip: Templates with (IDLEARN) in the name use the
{{sections}},{{summaries}}, and{{qa_pairs}}variables, and produce the richest output when summarization is enabled.
In addition to standard variables ({{title}}, {{author}}, {{content}}, etc.), the export provides:
| Variable | Type | Description |
|---|---|---|
{{sections}} |
JSON array | Extracted sections: [{title, content, index}] |
{{summaries}} |
JSON array | LLM summaries: [{title, summary, index}] |
{{qa_pairs}} |
JSON array | Q\u0026A pairs: [{title, qa, index}] |
Use these in templates with {% for section in sections %} loops.
Place .json template files in either:
~/.config/idlearn/templates/./templates/(in the project root)
Templates use the Obsidian Web Clipper format with full filter support (51 filters including date, split, join, callout, wikilink, etc.).
You can also add a "description" field to your template JSON to show a short description in the UI template selector.
Both the desktop GUI and Streamlit web app support saving exported notes directly into an Obsidian vault:
- Desktop GUI: Check "Export to Obsidian", then use the "Vault" field (type or browse) to set your vault folder path.
- Streamlit: Enter your vault path in the "Obsidian Vault Path" field in the sidebar.
When a vault path is set, the exported .md file is written there instead of the default output folder.
In the Streamlit web app:
- Template Preview: Expand the \U0001f50d Template Preview section to see the template's properties and content format before exporting.
- Upload Custom Template: Upload a
.jsontemplate file directly from the sidebar. The uploaded template is used for the current session only.
from app.obsidize import compile_template, clip_pdf, load_template, PdfContent, PdfMetadata
# Compile a template string
result = compile_template('Hello {{name|upper}}!', {'{{name}}': 'world'})
# β "Hello WORLD!"
# Load a template and clip PDF content
template = load_template('academic')
pdf = PdfContent(text='...', metadata=PdfMetadata(title='My Paper', author='Author'), ...)
result = clip_pdf(pdf, template)- ToC dependency: Text extraction relies on the document's Table of Contents to identify sections. While IDLEARN can automatically infer a ToC from heading patterns and font sizes when none is embedded, the results may be imperfect for documents with unusual formatting.
- PDF layout sensitivity: Complex multi-column layouts, interleaved tables, or unusual font arrangements can cause fragmented or out-of-order text extraction.
- EPUB support: EPUB extraction parses the navigation file (NCX/NAV) or falls back to HTML heading analysis. Not all EPUBs use well-structured navigation markup.
- Hardware requirements: Local LLM inference with Ollama requires sufficient RAM and, ideally, a GPU. Models like
mistral:7B-instructneed roughly 5β8 GB of memory. Performance will be slow on CPU-only systems. - Processing time: Nested summarization means long sections may require multiple LLM passes. A 20-page section can take several minutes on consumer hardware.
- LLM output quality: Summaries and Q&A quality depend on the model used. Smaller models may produce less accurate or less concise results.
- Anki Cloze cards: When a Q&A pair is classified as quantitative, the card is created with
genanki.CLOZE_MODEL, but the Cloze deletion fields are currently left as[None, None]. This means Cloze cards will need manual editing in Anki to be useful. Future versions will improve automatic Cloze generation. - No progress indicator in GUI: The desktop GUI does not currently show a progress bar during processing β only console logs indicate progress.
Open-source. Feel free to contribute!