Extraction
This is a member-only chapter. Log in with your Signal Over Noise membership email to continue.
Log in to readModule 3 · Section 5 of 6
Extraction
Extraction is: given unstructured text, pull out specific fields.
Example: a contact form allows free-text input. You want to extract the sender’s company name, the product they’re asking about, and whether they mentioned a deadline.
System prompt approach:
Extract the following fields from the message and return them as JSON:
- company_name (string or null)
- product_mentioned (string or null)
- has_deadline (boolean)
Return only the JSON object. No explanation.
Tell the model to return JSON and nothing else. After the LLM Chain node, add a Code node with a JSON.parse call to convert the output string to an object:
const text = $input.first().json.text;
return [{ json: JSON.parse(text) }];
Then use the extracted fields in downstream nodes — write them to a database, route based on has_deadline, include them in a notification.
Extraction is less reliable than classification because the output structure depends on the model following your format instructions. Test with representative examples. If the model keeps including explanation text, add “Return ONLY the JSON object with no surrounding text” to the prompt. If it keeps using slightly different field names, enumerate the exact keys you expect.