ArtificialGuyBR

Home / Blog / Fixing things

BookWorm AI: hierarchical book summaries for long-form reading

A Python tool that summarizes EPUB, PDF, MOBI and TXT books into Markdown, JSON, HTML, PDF or EPUB with chapter cards, cross-chapter synthesis and any OpenAI…

2 sources cited Fixing things

BookWorm AI: hierarchical book summaries for long-form reading

TL;DR

  • It summarizes EPUB, PDF, MOBI/AZW and TXT books and exports to Markdown, JSON, HTML, PDF or EPUB with any OpenAI-compatible model.
  • The hard problem it solves is length: a book does not fit in a context window, so it processes in chapter cards, section synthesis, a global book memory and a final integration.
  • Genre is detected automatically with explicit theme overrides, and the prompts are English contracts with Portuguese user-facing output by default.
  • It is source code and tests only — no book files, no summaries, no credentials committed.

What it is and who it is for

BookWorm AI is a production-ready summarization pipeline for books. The README frames it around the constraint most summarizers ignore: a book is not an article, so a single prompt with a truncated chapter gives you a summary of the last twenty pages that happened to fit.

It is for the person who wants to know what a book argues before deciding to read it, for the reader who already read it and wants a structured record, and for the one building a library of summaries where each one has to match the book's structure rather than a generic shape.

How it handles a book that does not fit

Hierarchical processing is the core: books larger than the model context window go through chapter cards, then section synthesis, then a global book memory, then final integration. Oversized chapters are split into bounded overlapping chunks, so a chapter longer than the window is still summarized with its boundary intact.

Genre detection is automatic, with explicit theme overrides when the guess is wrong, and the output contract depends on it — which is why a memoir and a technical manual do not get the same summary shape.

There is an optional deep editorial review with coverage, coherence, fidelity and issue reporting. That review is the honest counterpart to generation: a generated summary can be fluent, complete and wrong, and the review is what catches the missing chapter.

Reliability details worth knowing

The pipeline uses strict JSON-object responses with required-key validation and one repair attempt when the model returns something malformed. It also has streaming, retries, bounded concurrency and checkpointed resume, which matters because a two-hundred-chapter book is a long run and a crash at chapter 180 should not start over.

PDF output is Unicode-safe and searchable, with a dedicated contextual appendix. Providers cover OpenAI, Anthropic, Google, OpenRouter and arbitrary OpenAI-compatible gateways.

Install and configure

Python 3.10–3.13, an API key for an OpenAI-compatible chat-completions endpoint, and a Unicode font available to ReportLab for PDF output — BookWorm detects common system fonts automatically.

uv sync --extra dev
# or
pip install -e ".[dev]"

Configuration comes from environment variables, and nothing is hardcoded for a private deployment:

export BOOKWORM_API_KEY="your-api-key"
export BOOKWORM_BASE_URL="https://your-gateway.example/v1"

When to use it, when not to

Use it when you want a structured summary of a book you have not read, when you need the same shape of summary across a shelf of books, or when you want a summary you can export as a readable document rather than a chat reply.

Do not use it for a quick abstract of one article — a chapter-level pipeline is more machinery than one page needs. And do not expect the summary to be automatically faithful: the README ships an optional editorial review precisely because coverage and fidelity are things to check, not things to assume.

Sources

  1. BookWorm AI — repository — features, requirements, configuration and output notes quoted above.
  2. README.md — installation, configuration, feature list.

Project page: BookWorm AI

The repository contains source code and tests only. On the reading side of the same problem, see the Hugging Face learn PDF and ebooks project.

FAQ

Which formats does it accept? EPUB, PDF, MOBI/AZW and plain text.

Which output formats does it write? Markdown, JSON, HTML, PDF and EPUB.

How does it summarize a book longer than the context window? With hierarchical processing: chapter cards, section synthesis, a global book memory and final integration, plus bounded overlapping chunks for oversized chapters.

Which models can it use? Any OpenAI-compatible chat-completions endpoint, plus provider support for OpenAI, Anthropic, Google and OpenRouter.