Separate facts, source text, and generated artifacts
Canonical metadata identifies a work or edition. Source text comes from a licensed file, public-domain text, approved OCR, or a user-provided document. Generated artifacts are summaries, topics, embeddings, answers, and recommendations. Each layer needs its own IDs, permissions, versions, retention, and provenance.
An enrichment record should name the edition, input fingerprint, rights profile, task type, prompt version, retrieval version, model, generated time, evaluation state, and evidence references. Clients can request the current approved artifact without assuming the output is an authoritative publisher statement.
Reference pipeline
Typed operations beat one generic generator
Use explicit resources such as summary-jobs, topic-artifacts, embeddings, and answers. Each operation has different inputs, length limits, evidence requirements, and evaluation. Structured JSON output lets the service validate fields, citation IDs, and warnings before an artifact reaches clients.
Grounded answer
Question, answer, evidence spans, answerability state, confidence band, and policy flags.
Summary artifact
Brief synopsis, key ideas, chapter coverage, source edition, evidence map, and generation version.
Retrieval is part of the contract
Chunks should preserve page or location ranges, heading path, language, OCR quality, and rights. Hybrid keyword and vector retrieval can find both exact names and semantic matches. Reranking must retain references. When evidence is missing, insufficient_evidence is a successful, honest outcome.
Guardrails by input and task
- Reject unsupported rights profiles before model calls.
- Treat document text as untrusted data, including prompt injection.
- Limit long or location-based reproduction requests.
- Keep private libraries and notes tenant-isolated.
- Label generated content and preserve its source edition.
- Use stricter review for sensitive or high-impact subjects.
Evaluation before model replacement
Book-specific tests should cover long works, translations, technical text, fiction, OCR noise, missing chapters, conflicting editions, and adversarial instructions. Evaluate factual consistency, central coverage, citation support, answerability detection, excessive source overlap, schema validity, and usefulness at the requested length.
Track results by model, prompt, retrieval, and input version. A cheaper or newer model should not replace production behavior without a measured quality gate.
Asynchronous jobs and budget controls
Whole-book tasks can require OCR, indexing, several model calls, and review. Return a job ID with stages, progress, warnings, cancellation, and idempotency. Set bounds for chunks, output tokens, retries, tool calls, and total cost. Cache only when edition, rights, tenant, task, and processing versions match.