fix(ingestion): bound the summary written by the model #85

Merged
crapougnax merged 1 commit from fix/79-summary-bound into develop 2026-11-30 08:53:08 +00:00
Owner

Closes #79

In the end-to-end run of 2026-11-29, the summary of a 549-character text was longer than the text and took its facts sentence by sentence. For a document whose rights are unknown, that is close to a paraphrase of the whole text (#52).

Change (document-analysis.ts)

  • summaryBound(length): a quarter of the text, between 240 and 1,500 characters.
  • Prompt: "a short synthesis … at most N characters: its purpose and main ideas, not every fact, never a paraphrase sentence by sentence".
  • boundSummary(summary, source, bound), applied to every answer:
    • a sentence sharing 8 words in a row with the document (without case, accents, punctuation) is dropped as a copy;
    • whole sentences are kept within the bound, paragraphs preserved;
    • a first sentence longer than the bound is cut at a word, with an ellipsis;
    • nothing left → no summary (bare record body).
  • Docs (EN, FR), section 10.

Checks

Tests: bound values, copy removal, cut at the bound, paragraphs, a summary that is only copies; analyseDocument returns a bounded summary without the copied sentence. yarn test 263/263.

🤖 Generated with Claude Code

Closes #79 In the end-to-end run of 2026-11-29, the summary of a 549-character text was longer than the text and took its facts sentence by sentence. For a document whose rights are `unknown`, that is close to a paraphrase of the whole text (#52). ## Change (`document-analysis.ts`) - `summaryBound(length)`: a quarter of the text, between 240 and 1,500 characters. - Prompt: "a short synthesis … at most N characters: its purpose and main ideas, not every fact, never a paraphrase sentence by sentence". - `boundSummary(summary, source, bound)`, applied to every answer: - a sentence sharing **8 words in a row** with the document (without case, accents, punctuation) is dropped as a copy; - whole sentences are kept within the bound, paragraphs preserved; - a first sentence longer than the bound is cut at a word, with an ellipsis; - nothing left → no summary (bare record body). - Docs (EN, FR), section 10. ## Checks Tests: bound values, copy removal, cut at the bound, paragraphs, a summary that is only copies; `analyseDocument` returns a bounded summary without the copied sentence. `yarn test` 263/263. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(ingestion): bound the summary written by the model (#79)
All checks were successful
Build and Publish OCI Image / Build & Push ARM64 OCI Image (pull_request) Successful in 54s
82a0260210
The model is asked for a short synthesis of at most a quarter of the text
(240 to 1,500 characters), its main ideas rather than every fact. What it
answers is then checked: a sentence sharing eight words in a row with the
document is dropped as a copy, whole sentences are kept within the bound,
and a first sentence longer than the bound is cut at a word.

Closes #79

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crapougnax merged commit 722c6f242b into develop 2026-11-30 08:53:08 +00:00
crapougnax deleted branch fix/79-summary-bound 2026-11-30 08:53:09 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
modaka/studio!85
No description provided.