Write an LLM prompt that extracts fields from page text
Writes a reusable extraction prompt and JSON schema that pulls named fields out of page text I am allowed to process.
Task:
Write one reusable prompt, with a JSON schema, that makes a language model pull [list of fields] out of the text of a page.
Context:
The pages are [page type] from [source], and I am allowed to process them for [purpose]. I will send the text from [my script or tool] and read the output with [language]. Here is one sample of the page text in the material.
Rules:
- Make the prompt return only JSON that matches the schema, with null for any field the text does not contain.
- Add a rule that the model must copy values from the text and never infer a missing one.
- Keep personal data out of the schema unless the field list above names it.
- Include one worked example built from the sample, with the expected JSON.
- Mention that I should test the prompt on 10 varied pages and compare the output by hand.
Result:
The prompt in one block, the schema in a second block, and at most 3 lines on how to test it.
Material:
[paste one sample of the page text here]