Extraction of Zurich death register entries using VLM + LLM post-processing.
Project Background This project operationalizes the workflow described in the poster "Informationsextraktion serieller Quellen: Die Zürcher Sterberegister (1876–1925)". The goal is to convert scanned serial sources (e.g., civil and church registers) into structured tables without much manual correction by combining layout analysis, automatic text recognition (ATR), and large language models (LLMs). The project evaluates closed (Transkribus, OpenAI) and open (YOLO, TrOCR, Qwen) toolchains to deliver a reproducible pipeline for historical sources.
Poster Workflow Summary
- Visual Language Model QWEN3 is used to perform text-region detection and ATR.
- LLM-based reconstruction and extraction to normalize order and identify fields via keyword windows.
- Validation and correction to quantify errors and improve models or apply rule-based fixes.
Poster Figures (From Project Documentation)
Figure 1: Document with layout regions marked (Transkribus screenshot, Fields model, Zurich 1876 register).
Figure 2: Layout/line segmentation + OCR output showing disrupted line order (Transkribus screenshot).
Figure 3: CSV output after segmentation, OCR, extraction, and post-processing (VSC screenshot).
What This Repo Does This repo contains several standalone scripts that form a loose pipeline for:
- Detecting text-regions and performing ATR with a VLM
- Converting OCR output into PAGE-XML for downstream tools.
- Extracting structured fields from PAGE-XML and/or raw CSV via LLMs.
The scripts are currently configured with hardcoded local paths and hardcoded API keys. You will need to change those constants before running.
Scripts Overview
-
qwen3_approach_PDFtoText_V3.py
Resizes original image, automatically crops the image and sends it to an API that runs a qwen-model Inputs: Images/PDFs ininputOutputs: Page-XML with detexted text inoutputand alogs.txtfile containing the terminal outputs The page-XML contains two seperated cases which contain plain detected text -
keywordextraxtion_qwen.py
Takes the Page-XML, sends it with an attached prompt to an API that runs a qwen-model, cleans and files the returned text into a CSV Inputs: Page_XML inoutputOutputs: CSV with extracted text inextraction_outputCSV-Layout: Filename,XML_Block_Index,time_of_death,place_of_death and reason_for_death,"name/occupation/father,mother/civil_status/place_of_origin/hometown/confession",place_of_residence/birthdate The CSV-Laout depends entirely on the structure of the original data and the prompt used to extract the information -
LEO_csv_gpt-oss_V6.py
Takes the CSV-file and performs a deeper extraction by using the LLM "gpt-oss-120b" Inputs: CSV inextraction_outputOutputs: CSV with further extracted and filed data inllm_outputThe script used performs a deeper analysis of the already extracted data and categorizes that data into smaller sections
Pipeline (Typical Usage)
- Run
qwen3_approach_PDFtoText_V3.pyto generate a PAGE-XML containing two sections with recognized texts - Run
keywordextraxtion_qwen.pyto extract core content of the text in the PAGE-XML - Run
LEO_csv_gpt-oss_V6.pyto perform a deeper and more precise filing of the already extracted data
Configuration You Must Edit
qwen3_approach_PDFtoText_V3.pyinput,output,logsPromptAPI-Key,base_url,modelvertical_seperator,horizontal_seperator
keywordextraxtion_qwen.pyinput,outputPromptAPI-Key,base_url,model
LEO_csv_gpt-oss_V6.pyinput,outputPromptAPI-Key,base_url,modelevaluate_df
Dependencies Install the Python packages used by each script:
- Core:
pandas,tqdm,openai,requests - PDF rendering:
pymupdf(imported asfitz) - XML:
lxml
Notes / Caveats
- The VLM and the extraction_scripts can make errors, manuall checks are still needed
- Most paths are Windows-style and must be updated to your local environment.