Inspiration
As a medical student, I spend a lot of time inside dense PDF textbooks. General AI assistants can explain a concept quickly, but I kept running into two practical problems: I could not reliably trace an answer back to the exact page, and every new chat started with no understanding of what I had already studied.
A fluent answer is useful only if a student can verify it. Personalization is useful only if the system distinguishes curiosity from actual weakness. Asking a question should not lower a mastery score. Getting a practice question wrong should.
I built Prism Library around those two ideas: evidence first, then adaptation.
What it does
Prism Library turns a learner's own PDF materials into a traceable study system.
A student selects a book and asks a question. Prism retrieves relevant passages, produces a concise answer, and attaches page-level citations to the claims it can support. Each citation opens the exact source page, so the learner can inspect the original context instead of trusting the wording of the model.
The Study Coach then uses the same evidence to create a learning path. It remembers which concepts the learner asked about, which questions they attempted, whether they answered correctly, and how many hints they needed. A first wrong answer unlocks a directional hint. A second mistake gives a more specific conceptual hint. The full explanation and cited source remain available after the scaffolded attempt.
The learner profile updates after every assessable interaction. Questions are stored as attention signals, not failures. Only quiz outcomes affect mastery.
How I built it
Prism Library is a local-first macOS application with a Python backend and an HTML, CSS, and JavaScript interface running through pywebview. Books, chunks, citations, settings, and learning events are stored in SQLite on the user's device.
The document pipeline normalizes different PDF parsers into a shared Markdown representation with heading hierarchy and physical page markers. Text and section titles are indexed with SQLite FTS5. For Chinese materials, Jieba segmentation makes section-level retrieval practical without relying on a hardcoded medical vocabulary. Text-layer PDFs can be parsed locally with PDFium; scanned documents can use MinerU or a configured OCR provider.
The answer pipeline is:
retrieve passages
→ extract evidence
→ generate an answer
→ validate citation numbers and coverage
→ remove unused references
→ render page-linked claims
Citation reliability is enforced in code rather than left as a prompt instruction. Out-of-range citations are rejected. If the final answer contains no valid reference, the system fails closed instead of labeling it as textbook-grounded.
The learning agent uses a stable concept identifier derived from the source and normalized heading path, so a concept does not depend on temporary database row IDs. It stores an append-only event history for questions, quiz attempts, outcomes, and hints.
For a concept (c), mastery is estimated with a Beta posterior:
$$ \hat{m}c = \frac{\alpha_0 + w{\text{correct}}} {\alpha_0 + \beta_0 + w_{\text{correct}} + w_{\text{wrong}}} $$
The current prior is (\alpha_0 = \beta_0 = 1). A correct answer without help has weight (1); a correct answer after hints has weight (0.5). This keeps the score interpretable while recognizing that scaffolded success is still progress.
AI-generated quizzes also pass deterministic checks before they reach the learner. Each question must contain four unique options, a valid answer, evidence references, a cited explanation, and two hints that do not reveal the correct option.
Challenges
PDF structure was the first hard problem. Different parsers disagree about headings, page numbering, and reading order. A page number shown in an AI answer is useless if it points to a printed page label while the viewer expects a physical PDF page. I built a normalized intermediate format and kept the viewer's page semantics consistent across parsing engines.
Retrieval was another challenge, especially for Chinese textbooks. Indexing body text alone missed sections where the query appeared only in the heading. Indexing every character created noise. The working approach combines segmented body text, section titles, weighted FTS5 ranking, and a broader candidate pool, with regression cases to catch ranking failures.
The hardest design problem was trust. Language models are good at producing plausible citation syntax. That does not make a citation real. I moved citation range checks, evidence coverage, quiz validation, and fallback behavior out of prompts and into deterministic code.
Personalization also required careful semantics. Early designs could have treated every question as evidence that the learner was weak. That would punish curiosity. The event model now separates attention from assessment, and the learning path prioritizes concepts using actual practice outcomes.
For the public demo, I created an isolated library with an original five-page epidemiology note. The recording contains no private textbook, personal learning history, or API credential. The model response was prepared through the product's real cache layer so the demo remained reproducible without depending on network latency during recording.
What I learned
The most important part of an AI learning product is not the prompt. It is the system around the model: evidence boundaries, validation, event semantics, and tests that make incorrect behavior visible.
I also learned that retrieval quality cannot be judged by a few results that look right. I built repeatable evaluation cases and found failures caused by stale vectors, title hierarchy, tokenization, and ranking behavior. Several "improvements" were reverted because they made the measured results worse.
Finally, adaptive learning needs restraint. A system should know the difference between observing a learner and judging one. That distinction changed how Prism records questions, computes mastery, and decides what to recommend next.
What's next
Next I want to expand the retrieval and learning evaluations across more subjects, add more practice formats, and test longer-term path adaptation with real study sessions. I am also preparing a review-safe web demo and a packaged macOS beta while keeping the local-first privacy model intact.
Built With
- context
- css3
- fts5
- html5
- httpx
- javascript
- jieba
- language
- learning
- machine
- mineru
- model
- natural
- openai
- pdf.js
- processing
- protocol
- pyinstaller
- pypdfium2
- python
- pywebview
- sqlite
- vercel
Log in or sign up for Devpost to join the conversation.