Intermediate level · Module 5: Structured Outputs and Validation · Lesson 3 of 3
Designing Report Schemas with References
Learners design the nested report schema for the level project: summary, findings with supporting references, open questions and confidence, with checks that tie every finding to evidence.
In this lesson you will
- Design nested schemas for reports
- Enforce evidence links for every finding
Key concepts
nested modelslist of findingsreference objects (document ID, passage)validatorsrendering to Markdown
The lesson
A research report schema might contain a summary, a list of findings (each with a statement and one or more references to document IDs and passage numbers), open questions and an overall confidence. Nested Pydantic models express this cleanly.
Add checks that every finding has at least one reference and that every reference points to a passage that was actually retrieved in this task. This is a strong defence against invented evidence.
Render the validated report to Markdown or HTML for people, with references as footnotes, so that readers can check each claim.
Step by step
- Define Report, Finding and Reference models.
- Add a validator that checks references against the retrieved passages.
- Validate three scripted reports, including one with an invented reference.
- Render a valid report to Markdown.
Practice activity
Implement and test the project report schema and renderer.
Expected result: A schema that rejects unsupported findings and a readable rendered report.
Check your understanding
-
How can a schema help prevent invented evidence?
Show answer
By requiring references for every finding and checking that they point to retrieved passages.
-
Why render references as footnotes?
Show answer
So that readers can check each claim against its source.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.