liveBook · Manning

Structured extraction

As explained in Data Analysis with LLMs

Information extraction is the task of identifying and structuring specified facts or entities from text.

Structured extraction identifies specified facts in text and arranges them as attributes in a table. It is useful when information scattered across documents—such as internship applicants’ names, GPAs, and degrees—needs to be compared. section 4.3

A simple extraction workflow:

  • Name the attributes to extract and provide the source text. section 4.3.1
  • Specify an output format, including a placeholder for missing values. section 4.3.1
  • Ask a language model for the results, then postprocess its text response into rows and fields. section 4.3.1 section 4.3.3
 #1
Extract the following properties into a table:
name,GPA,Degree
 #2
Text source: My name is Martin, I would love to do a summer 
internship at Banana! A bit about myself: I am currently 
working on a Bachelor of Computer Science at Stanford 
University, my current GPA is 4.0.
 #3
Mark the beginning of the table with <BeginTable> and the end with <EndTable>. Separate rows by newline symbols and separate fields by pipe
symbols (|). Omit the table header and insert values in the attribute 
order from above. Use the placeholder <NA> if the value for an attribute 
is not available.

A reusable prompt specifies the attributes, source text, table delimiters, field order, and missing-value placeholder. section 4.3.1

From emails to an applicant table

For an email describing an applicant, extract the name, GPA, and degree. Repeating the process across emails produces a table for comparison; other examples extract birth cities and dates from biographies, using a placeholder when a fact is absent. section 4.3 section 4.3.5

How Data Analysis with LLMs covers it

How deep it goes
Details prompt components and parsing rows and fields, but does not describe model internals.
Examples
Uses applicant emails to extract names, GPAs, and degrees, and biographies to extract birthplaces and dates.
What you can do after
Build it from scratch by prompting a language model and parsing its response into rows of structured data.
How it connects
Connects text analysis with prompt design, postprocessing, classification, and question answering.

Also explained in

Compare how 4 books explain structured extraction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.