Upload folder using huggingface_hub
Browse files- .gitattributes +18 -0
- assets/.DS_Store +0 -0
- assets/vllm-structured-generation/.DS_Store +0 -0
- assets/vllm-structured-generation/indexes/DSC00168.JPG +2 -2
- assets/vllm-structured-generation/indexes/DSC00169.JPG +2 -2
- assets/vllm-structured-generation/indexes/DSC00170.JPG +2 -2
- assets/vllm-structured-generation/indexes/DSC00172.JPG +2 -2
- assets/vllm-structured-generation/indexes/DSC00173.JPG +2 -2
- index.html +6 -14
- patterns/structured-generation/intro.html +55 -23
- patterns/structured-generation/vlm-structured-generation.html +0 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-11-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-15-output-1.png +2 -2
- patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-16-output-1.png +2 -2
- patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-21-output-1.png +2 -2
- patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-9-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-11-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-12-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-14-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-15-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-16-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-17-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-18-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-19-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-21-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-22-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-24-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-27-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-3-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-4-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-5-output-1.png +3 -0
- patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-9-output-1.png +3 -0
- patterns/what-is-an-ai-pattern.html +41 -16
- search.json +65 -142
- site_libs/quarto-diagram/mermaid-init.js +275 -0
- site_libs/quarto-diagram/mermaid.css +13 -0
- site_libs/quarto-diagram/mermaid.min.js +0 -0
- site_libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css +236 -0
.gitattributes
CHANGED
|
@@ -82,3 +82,21 @@ patterns/structured-generation/advisor-index-cards_files/figure-html/cell-17-out
|
|
| 82 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-17-output-5.png filter=lfs diff=lfs merge=lfs -text
|
| 83 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-17-output-6.png filter=lfs diff=lfs merge=lfs -text
|
| 84 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-3-output-1.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-17-output-5.png filter=lfs diff=lfs merge=lfs -text
|
| 83 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-17-output-6.png filter=lfs diff=lfs merge=lfs -text
|
| 84 |
patterns/structured-generation/advisor-index-cards_files/figure-html/cell-3-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 85 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-11-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 86 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-9-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 87 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-11-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 88 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-12-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 89 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-14-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 90 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-15-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 91 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-16-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 92 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-17-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 93 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-18-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 94 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-19-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 95 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-21-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 96 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-22-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 97 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-24-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 98 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-27-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 99 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-3-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 100 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-4-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 101 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-5-output-1.png filter=lfs diff=lfs merge=lfs -text
|
| 102 |
+
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-9-output-1.png filter=lfs diff=lfs merge=lfs -text
|
assets/.DS_Store
ADDED
|
Binary file (8.2 kB). View file
|
|
|
assets/vllm-structured-generation/.DS_Store
ADDED
|
Binary file (8.2 kB). View file
|
|
|
assets/vllm-structured-generation/indexes/DSC00168.JPG
CHANGED
|
|
Git LFS Details
|
|
|
Git LFS Details
|
assets/vllm-structured-generation/indexes/DSC00169.JPG
CHANGED
|
|
Git LFS Details
|
|
|
Git LFS Details
|
assets/vllm-structured-generation/indexes/DSC00170.JPG
CHANGED
|
|
Git LFS Details
|
|
|
Git LFS Details
|
assets/vllm-structured-generation/indexes/DSC00172.JPG
CHANGED
|
|
Git LFS Details
|
|
|
Git LFS Details
|
assets/vllm-structured-generation/indexes/DSC00173.JPG
CHANGED
|
|
Git LFS Details
|
|
|
Git LFS Details
|
index.html
CHANGED
|
@@ -2,12 +2,12 @@
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.8.
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
| 9 |
<meta name="author" content="Daniel van Strien">
|
| 10 |
-
<meta name="dcterms.date" content="
|
| 11 |
|
| 12 |
<title>AI Design Patterns for GLAM</title>
|
| 13 |
<style>
|
|
@@ -40,7 +40,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 40 |
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 41 |
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 42 |
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 43 |
-
<link href="site_libs/quarto-html/quarto-syntax-highlighting-
|
| 44 |
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 45 |
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 46 |
<link href="site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
@@ -97,9 +97,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 97 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 98 |
<!-- sidebar -->
|
| 99 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 100 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header
|
| 101 |
-
<a href="./index.html" class="sidebar-logo-link">
|
| 102 |
-
</a>
|
| 103 |
<div class="sidebar-title mb-0 py-0">
|
| 104 |
<a href="./">AI Design Patterns for GLAM</a>
|
| 105 |
</div>
|
|
@@ -150,7 +148,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 150 |
<li class="sidebar-item">
|
| 151 |
<div class="sidebar-item-container">
|
| 152 |
<a href="./patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link">
|
| 153 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 154 |
</div>
|
| 155 |
</li>
|
| 156 |
<li class="sidebar-item">
|
|
@@ -158,12 +156,6 @@ ul.task-list li input[type="checkbox"] {
|
|
| 158 |
<a href="./patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 159 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 160 |
</div>
|
| 161 |
-
</li>
|
| 162 |
-
<li class="sidebar-item">
|
| 163 |
-
<div class="sidebar-item-container">
|
| 164 |
-
<a href="./patterns/structured-generation/advisor-index-cards.html" class="sidebar-item-text sidebar-link">
|
| 165 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Practical Application: Advisor Index Card Extraction</span></span></a>
|
| 166 |
-
</div>
|
| 167 |
</li>
|
| 168 |
</ul>
|
| 169 |
</li>
|
|
@@ -213,7 +205,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 213 |
<div>
|
| 214 |
<div class="quarto-title-meta-heading">Published</div>
|
| 215 |
<div class="quarto-title-meta-contents">
|
| 216 |
-
<p class="date">
|
| 217 |
</div>
|
| 218 |
</div>
|
| 219 |
|
|
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
+
<meta name="generator" content="quarto-1.8.27">
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
| 9 |
<meta name="author" content="Daniel van Strien">
|
| 10 |
+
<meta name="dcterms.date" content="2026-02-16">
|
| 11 |
|
| 12 |
<title>AI Design Patterns for GLAM</title>
|
| 13 |
<style>
|
|
|
|
| 40 |
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 41 |
<script src="site_libs/quarto-html/anchor.min.js"></script>
|
| 42 |
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 43 |
+
<link href="site_libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 44 |
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
|
| 45 |
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 46 |
<link href="site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
|
|
| 97 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 98 |
<!-- sidebar -->
|
| 99 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 100 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
|
|
|
|
|
|
| 101 |
<div class="sidebar-title mb-0 py-0">
|
| 102 |
<a href="./">AI Design Patterns for GLAM</a>
|
| 103 |
</div>
|
|
|
|
| 148 |
<li class="sidebar-item">
|
| 149 |
<div class="sidebar-item-container">
|
| 150 |
<a href="./patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link">
|
| 151 |
+
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></span></a>
|
| 152 |
</div>
|
| 153 |
</li>
|
| 154 |
<li class="sidebar-item">
|
|
|
|
| 156 |
<a href="./patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 157 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 158 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
</li>
|
| 160 |
</ul>
|
| 161 |
</li>
|
|
|
|
| 205 |
<div>
|
| 206 |
<div class="quarto-title-meta-heading">Published</div>
|
| 207 |
<div class="quarto-title-meta-contents">
|
| 208 |
+
<p class="date">February 16, 2026</p>
|
| 209 |
</div>
|
| 210 |
</div>
|
| 211 |
|
patterns/structured-generation/intro.html
CHANGED
|
@@ -2,12 +2,12 @@
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.8.
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
| 9 |
|
| 10 |
-
<title>2
|
| 11 |
<style>
|
| 12 |
code{white-space: pre-wrap;}
|
| 13 |
span.smallcaps{font-variant: small-caps;}
|
|
@@ -39,7 +39,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 39 |
<script src="../../site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 40 |
<script src="../../site_libs/quarto-html/anchor.min.js"></script>
|
| 41 |
<link href="../../site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 42 |
-
<link href="../../site_libs/quarto-html/quarto-syntax-highlighting-
|
| 43 |
<script src="../../site_libs/bootstrap/bootstrap.min.js"></script>
|
| 44 |
<link href="../../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 45 |
<link href="../../site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
@@ -70,6 +70,9 @@ ul.task-list li input[type="checkbox"] {
|
|
| 70 |
"search-label": "Search"
|
| 71 |
}
|
| 72 |
}</script>
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
|
| 75 |
</head>
|
|
@@ -83,7 +86,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 83 |
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 84 |
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 85 |
</button>
|
| 86 |
-
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html">Structured Information Extraction</a></li><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 87 |
<a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 88 |
</a>
|
| 89 |
<button type="button" class="btn quarto-search-button" aria-label="Search" onclick="window.quartoOpenSearch();">
|
|
@@ -96,9 +99,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 96 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 97 |
<!-- sidebar -->
|
| 98 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 99 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header
|
| 100 |
-
<a href="../../index.html" class="sidebar-logo-link">
|
| 101 |
-
</a>
|
| 102 |
<div class="sidebar-title mb-0 py-0">
|
| 103 |
<a href="../../">AI Design Patterns for GLAM</a>
|
| 104 |
</div>
|
|
@@ -149,7 +150,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 149 |
<li class="sidebar-item">
|
| 150 |
<div class="sidebar-item-container">
|
| 151 |
<a href="../../patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link active">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 153 |
</div>
|
| 154 |
</li>
|
| 155 |
<li class="sidebar-item">
|
|
@@ -157,12 +158,6 @@ ul.task-list li input[type="checkbox"] {
|
|
| 157 |
<a href="../../patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 158 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 159 |
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="../../patterns/structured-generation/advisor-index-cards.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Practical Application: Advisor Index Card Extraction</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
</li>
|
| 167 |
</ul>
|
| 168 |
</li>
|
|
@@ -180,17 +175,18 @@ ul.task-list li input[type="checkbox"] {
|
|
| 180 |
<li><a href="#dont-we-just-need-ocr" id="toc-dont-we-just-need-ocr" class="nav-link" data-scroll-target="#dont-we-just-need-ocr"><span class="header-section-number">2.2</span> Don’t we just need OCR?</a></li>
|
| 181 |
<li><a href="#solution-overview" id="toc-solution-overview" class="nav-link" data-scroll-target="#solution-overview"><span class="header-section-number">2.3</span> Solution Overview</a>
|
| 182 |
<ul class="collapse">
|
| 183 |
-
<li><a href="#what-this-pattern-looks-like" id="toc-what-this-pattern-looks-like" class="nav-link" data-scroll-target="#what-this-pattern-looks-like"><span class="header-section-number">2.3.1</span> What this pattern looks like
|
| 184 |
</ul></li>
|
|
|
|
| 185 |
</ul>
|
| 186 |
</nav>
|
| 187 |
</div>
|
| 188 |
<!-- main -->
|
| 189 |
<main class="content" id="quarto-document-content">
|
| 190 |
|
| 191 |
-
<header id="title-block-header" class="quarto-title-block default"><nav class="quarto-page-breadcrumbs quarto-title-breadcrumbs d-none d-lg-block" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html">Structured Information Extraction</a></li><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 192 |
<div class="quarto-title">
|
| 193 |
-
<h1 class="title"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 194 |
</div>
|
| 195 |
|
| 196 |
|
|
@@ -209,21 +205,57 @@ ul.task-list li input[type="checkbox"] {
|
|
| 209 |
|
| 210 |
<section id="the-challenge" class="level2" data-number="2.1">
|
| 211 |
<h2 data-number="2.1" class="anchored" data-anchor-id="the-challenge"><span class="header-section-number">2.1</span> The Challenge</h2>
|
| 212 |
-
<p>Many GLAM institutions have vast collections of structured documents
|
|
|
|
| 213 |
</section>
|
| 214 |
<section id="dont-we-just-need-ocr" class="level2" data-number="2.2">
|
| 215 |
<h2 data-number="2.2" class="anchored" data-anchor-id="dont-we-just-need-ocr"><span class="header-section-number">2.2</span> Don’t we just need OCR?</h2>
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
</section>
|
| 218 |
<section id="solution-overview" class="level2" data-number="2.3">
|
| 219 |
<h2 data-number="2.3" class="anchored" data-anchor-id="solution-overview"><span class="header-section-number">2.3</span> Solution Overview</h2>
|
| 220 |
-
<p>
|
|
|
|
|
|
|
|
|
|
| 221 |
<section id="what-this-pattern-looks-like" class="level3" data-number="2.3.1">
|
| 222 |
-
<h3 data-number="2.3.1" class="anchored" data-anchor-id="what-this-pattern-looks-like"><span class="header-section-number">2.3.1</span> What this pattern looks like
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
|
| 226 |
-
</section>
|
| 227 |
</section>
|
| 228 |
|
| 229 |
</main> <!-- /main -->
|
|
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
+
<meta name="generator" content="quarto-1.8.27">
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
| 9 |
|
| 10 |
+
<title>2 Structured Document Processing – AI Design Patterns for GLAM</title>
|
| 11 |
<style>
|
| 12 |
code{white-space: pre-wrap;}
|
| 13 |
span.smallcaps{font-variant: small-caps;}
|
|
|
|
| 39 |
<script src="../../site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 40 |
<script src="../../site_libs/quarto-html/anchor.min.js"></script>
|
| 41 |
<link href="../../site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 42 |
+
<link href="../../site_libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 43 |
<script src="../../site_libs/bootstrap/bootstrap.min.js"></script>
|
| 44 |
<link href="../../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 45 |
<link href="../../site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
|
|
| 70 |
"search-label": "Search"
|
| 71 |
}
|
| 72 |
}</script>
|
| 73 |
+
<script src="../../site_libs/quarto-diagram/mermaid.min.js"></script>
|
| 74 |
+
<script src="../../site_libs/quarto-diagram/mermaid-init.js"></script>
|
| 75 |
+
<link href="../../site_libs/quarto-diagram/mermaid.css" rel="stylesheet">
|
| 76 |
|
| 77 |
|
| 78 |
</head>
|
|
|
|
| 86 |
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 87 |
<i class="bi bi-layout-text-sidebar-reverse"></i>
|
| 88 |
</button>
|
| 89 |
+
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html">Structured Information Extraction</a></li><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></a></li></ol></nav>
|
| 90 |
<a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
|
| 91 |
</a>
|
| 92 |
<button type="button" class="btn quarto-search-button" aria-label="Search" onclick="window.quartoOpenSearch();">
|
|
|
|
| 99 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 100 |
<!-- sidebar -->
|
| 101 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 102 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
|
|
|
|
|
|
| 103 |
<div class="sidebar-title mb-0 py-0">
|
| 104 |
<a href="../../">AI Design Patterns for GLAM</a>
|
| 105 |
</div>
|
|
|
|
| 150 |
<li class="sidebar-item">
|
| 151 |
<div class="sidebar-item-container">
|
| 152 |
<a href="../../patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link active">
|
| 153 |
+
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></span></a>
|
| 154 |
</div>
|
| 155 |
</li>
|
| 156 |
<li class="sidebar-item">
|
|
|
|
| 158 |
<a href="../../patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 159 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 160 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</li>
|
| 162 |
</ul>
|
| 163 |
</li>
|
|
|
|
| 175 |
<li><a href="#dont-we-just-need-ocr" id="toc-dont-we-just-need-ocr" class="nav-link" data-scroll-target="#dont-we-just-need-ocr"><span class="header-section-number">2.2</span> Don’t we just need OCR?</a></li>
|
| 176 |
<li><a href="#solution-overview" id="toc-solution-overview" class="nav-link" data-scroll-target="#solution-overview"><span class="header-section-number">2.3</span> Solution Overview</a>
|
| 177 |
<ul class="collapse">
|
| 178 |
+
<li><a href="#what-this-pattern-looks-like" id="toc-what-this-pattern-looks-like" class="nav-link" data-scroll-target="#what-this-pattern-looks-like"><span class="header-section-number">2.3.1</span> What this pattern looks like</a></li>
|
| 179 |
</ul></li>
|
| 180 |
+
<li><a href="#when-to-use-this-pattern" id="toc-when-to-use-this-pattern" class="nav-link" data-scroll-target="#when-to-use-this-pattern"><span class="header-section-number">2.4</span> When to Use This Pattern</a></li>
|
| 181 |
</ul>
|
| 182 |
</nav>
|
| 183 |
</div>
|
| 184 |
<!-- main -->
|
| 185 |
<main class="content" id="quarto-document-content">
|
| 186 |
|
| 187 |
+
<header id="title-block-header" class="quarto-title-block default"><nav class="quarto-page-breadcrumbs quarto-title-breadcrumbs d-none d-lg-block" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html">Structured Information Extraction</a></li><li class="breadcrumb-item"><a href="../../patterns/structured-generation/intro.html"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></a></li></ol></nav>
|
| 188 |
<div class="quarto-title">
|
| 189 |
+
<h1 class="title"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></h1>
|
| 190 |
</div>
|
| 191 |
|
| 192 |
|
|
|
|
| 205 |
|
| 206 |
<section id="the-challenge" class="level2" data-number="2.1">
|
| 207 |
<h2 data-number="2.1" class="anchored" data-anchor-id="the-challenge"><span class="header-section-number">2.1</span> The Challenge</h2>
|
| 208 |
+
<p>Many GLAM institutions have vast collections of structured documents—index cards, forms, registers—containing valuable information locked in physical or image formats. Manual transcription doesn’t scale, but the structured nature of these documents makes them ideal candidates for AI-powered processing.</p>
|
| 209 |
+
<p>Unlocking this data means better discovery, new research possibilities, and integration with modern cataloguing systems.</p>
|
| 210 |
</section>
|
| 211 |
<section id="dont-we-just-need-ocr" class="level2" data-number="2.2">
|
| 212 |
<h2 data-number="2.2" class="anchored" data-anchor-id="dont-we-just-need-ocr"><span class="header-section-number">2.2</span> Don’t we just need OCR?</h2>
|
| 213 |
+
<p>Traditional OCR extracts text from images, but that’s only half the problem. Consider an index card with a name, date, reference number, and description arranged in specific positions. OCR gives you a block of text—but not which part is the name, which is the date, or how they relate.</p>
|
| 214 |
+
<p>Often, you don’t even need the raw text—you need the <em>information</em> it contains. A catalogue record doesn’t need “Mr. John Smith, 1847” preserved exactly; it needs <code>name: "John Smith"</code> and <code>year: 1847</code> as usable data.</p>
|
| 215 |
+
<p>With OCR alone, you still need someone to parse text into structured fields. For hundreds of documents, that’s manageable. For hundreds of thousands, it’s not.</p>
|
| 216 |
</section>
|
| 217 |
<section id="solution-overview" class="level2" data-number="2.3">
|
| 218 |
<h2 data-number="2.3" class="anchored" data-anchor-id="solution-overview"><span class="header-section-number">2.3</span> Solution Overview</h2>
|
| 219 |
+
<p>Structured extraction is a pattern that works across modalities—text, images, audio transcripts. The core idea is the same: constrain a model to return data in a predefined schema rather than freeform text.</p>
|
| 220 |
+
<p>For document images, we use Vision Language Models (VLMs). Unlike OCR, VLMs understand both visual layout and textual content together. They can see that “1847” appears in the date field position, not just that the characters “1847” exist somewhere on the page.</p>
|
| 221 |
+
<p>Structured output generation constrains the model to return your fields, your format. The result: input in, structured JSON out.</p>
|
| 222 |
+
<p>This section focuses on the image case—extracting from document images—but the same principles apply when working with text or other formats.</p>
|
| 223 |
<section id="what-this-pattern-looks-like" class="level3" data-number="2.3.1">
|
| 224 |
+
<h3 data-number="2.3.1" class="anchored" data-anchor-id="what-this-pattern-looks-like"><span class="header-section-number">2.3.1</span> What this pattern looks like</h3>
|
| 225 |
+
<div class="cell" data-layout-align="default">
|
| 226 |
+
<div class="cell-output-display">
|
| 227 |
+
<div>
|
| 228 |
+
<p></p><figure class="figure"><p></p>
|
| 229 |
+
<div>
|
| 230 |
+
<pre class="mermaid mermaid-js">flowchart LR
|
| 231 |
+
A[Document Image] --> B[VLM + Schema]
|
| 232 |
+
B --> C[Structured JSON]
|
| 233 |
+
C --> D[Catalogue/Database]
|
| 234 |
+
</pre>
|
| 235 |
+
</div>
|
| 236 |
+
<p></p></figure><p></p>
|
| 237 |
+
</div>
|
| 238 |
+
</div>
|
| 239 |
+
</div>
|
| 240 |
+
<p>The following chapters walk through this in detail—starting with basic VLM queries, then building to real extraction workflows with evaluation strategies.</p>
|
| 241 |
+
</section>
|
| 242 |
+
</section>
|
| 243 |
+
<section id="when-to-use-this-pattern" class="level2" data-number="2.4">
|
| 244 |
+
<h2 data-number="2.4" class="anchored" data-anchor-id="when-to-use-this-pattern"><span class="header-section-number">2.4</span> When to Use This Pattern</h2>
|
| 245 |
+
<p><strong>Good fit:</strong></p>
|
| 246 |
+
<ul>
|
| 247 |
+
<li>Forms, index cards, registers with consistent layouts</li>
|
| 248 |
+
<li>Documents where you know what fields you want to extract</li>
|
| 249 |
+
<li>Collections too large for manual transcription</li>
|
| 250 |
+
</ul>
|
| 251 |
+
<p><strong>Less suited:</strong></p>
|
| 252 |
+
<ul>
|
| 253 |
+
<li>Free-form manuscripts with no predictable structure</li>
|
| 254 |
+
<li>Documents requiring deep contextual interpretation</li>
|
| 255 |
+
<li>Cases where verbatim transcription is the goal (use OCR instead)</li>
|
| 256 |
+
</ul>
|
| 257 |
|
| 258 |
|
|
|
|
| 259 |
</section>
|
| 260 |
|
| 261 |
</main> <!-- /main -->
|
patterns/structured-generation/vlm-structured-generation.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-11-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-15-output-1.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-16-output-1.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-21-output-1.png
CHANGED
|
Git LFS Details
|
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-html/cell-9-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-11-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-12-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-14-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-15-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-16-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-17-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-18-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-19-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-21-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-22-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-24-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-27-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-3-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-4-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-5-output-1.png
ADDED
|
Git LFS Details
|
patterns/structured-generation/vlm-structured-generation_files/figure-pdf/cell-9-output-1.png
ADDED
|
Git LFS Details
|
patterns/what-is-an-ai-pattern.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
-
<meta name="generator" content="quarto-1.8.
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
|
@@ -39,7 +39,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 39 |
<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 40 |
<script src="../site_libs/quarto-html/anchor.min.js"></script>
|
| 41 |
<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 42 |
-
<link href="../site_libs/quarto-html/quarto-syntax-highlighting-
|
| 43 |
<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
|
| 44 |
<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 45 |
<link href="../site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
@@ -96,9 +96,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 96 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 97 |
<!-- sidebar -->
|
| 98 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 99 |
-
<div class="pt-lg-2 mt-2 text-left sidebar-header
|
| 100 |
-
<a href="../index.html" class="sidebar-logo-link">
|
| 101 |
-
</a>
|
| 102 |
<div class="sidebar-title mb-0 py-0">
|
| 103 |
<a href="../">AI Design Patterns for GLAM</a>
|
| 104 |
</div>
|
|
@@ -149,7 +147,7 @@ ul.task-list li input[type="checkbox"] {
|
|
| 149 |
<li class="sidebar-item">
|
| 150 |
<div class="sidebar-item-container">
|
| 151 |
<a href="../patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link">
|
| 152 |
-
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 153 |
</div>
|
| 154 |
</li>
|
| 155 |
<li class="sidebar-item">
|
|
@@ -157,12 +155,6 @@ ul.task-list li input[type="checkbox"] {
|
|
| 157 |
<a href="../patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 158 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 159 |
</div>
|
| 160 |
-
</li>
|
| 161 |
-
<li class="sidebar-item">
|
| 162 |
-
<div class="sidebar-item-container">
|
| 163 |
-
<a href="../patterns/structured-generation/advisor-index-cards.html" class="sidebar-item-text sidebar-link">
|
| 164 |
-
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Practical Application: Advisor Index Card Extraction</span></span></a>
|
| 165 |
-
</div>
|
| 166 |
</li>
|
| 167 |
</ul>
|
| 168 |
</li>
|
|
@@ -171,8 +163,16 @@ ul.task-list li input[type="checkbox"] {
|
|
| 171 |
</nav>
|
| 172 |
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
|
| 173 |
<!-- margin-sidebar -->
|
| 174 |
-
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
</div>
|
| 177 |
<!-- main -->
|
| 178 |
<main class="content" id="quarto-document-content">
|
|
@@ -196,8 +196,33 @@ ul.task-list li input[type="checkbox"] {
|
|
| 196 |
</header>
|
| 197 |
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
|
| 200 |
|
|
|
|
| 201 |
|
| 202 |
</main> <!-- /main -->
|
| 203 |
<script id="quarto-html-after-body" type="application/javascript">
|
|
@@ -607,8 +632,8 @@ ul.task-list li input[type="checkbox"] {
|
|
| 607 |
</a>
|
| 608 |
</div>
|
| 609 |
<div class="nav-page nav-page-next">
|
| 610 |
-
<a href="../patterns/structured-generation/intro.html" class="pagination-link" aria-label="
|
| 611 |
-
<span class="nav-page-text"><span class="chapter-number">2</span> <span class="chapter-title">
|
| 612 |
</a>
|
| 613 |
</div>
|
| 614 |
</nav>
|
|
|
|
| 2 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
|
| 3 |
|
| 4 |
<meta charset="utf-8">
|
| 5 |
+
<meta name="generator" content="quarto-1.8.27">
|
| 6 |
|
| 7 |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
| 8 |
|
|
|
|
| 39 |
<script src="../site_libs/quarto-html/tippy.umd.min.js"></script>
|
| 40 |
<script src="../site_libs/quarto-html/anchor.min.js"></script>
|
| 41 |
<link href="../site_libs/quarto-html/tippy.css" rel="stylesheet">
|
| 42 |
+
<link href="../site_libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css" rel="stylesheet" id="quarto-text-highlighting-styles">
|
| 43 |
<script src="../site_libs/bootstrap/bootstrap.min.js"></script>
|
| 44 |
<link href="../site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
|
| 45 |
<link href="../site_libs/bootstrap/bootstrap-27c261d06b905028a18691de25d09dde.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
|
|
|
|
| 96 |
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
|
| 97 |
<!-- sidebar -->
|
| 98 |
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
|
| 99 |
+
<div class="pt-lg-2 mt-2 text-left sidebar-header">
|
|
|
|
|
|
|
| 100 |
<div class="sidebar-title mb-0 py-0">
|
| 101 |
<a href="../">AI Design Patterns for GLAM</a>
|
| 102 |
</div>
|
|
|
|
| 147 |
<li class="sidebar-item">
|
| 148 |
<div class="sidebar-item-container">
|
| 149 |
<a href="../patterns/structured-generation/intro.html" class="sidebar-item-text sidebar-link">
|
| 150 |
+
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></span></a>
|
| 151 |
</div>
|
| 152 |
</li>
|
| 153 |
<li class="sidebar-item">
|
|
|
|
| 155 |
<a href="../patterns/structured-generation/vlm-structured-generation.html" class="sidebar-item-text sidebar-link">
|
| 156 |
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">Structured Information Extraction with Vision Language Models</span></span></a>
|
| 157 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
</li>
|
| 159 |
</ul>
|
| 160 |
</li>
|
|
|
|
| 163 |
</nav>
|
| 164 |
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
|
| 165 |
<!-- margin-sidebar -->
|
| 166 |
+
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
|
| 167 |
+
<nav id="TOC" role="doc-toc" class="toc-active">
|
| 168 |
+
<h2 id="toc-title">Table of contents</h2>
|
| 169 |
+
|
| 170 |
+
<ul>
|
| 171 |
+
<li><a href="#why-patterns" id="toc-why-patterns" class="nav-link active" data-scroll-target="#why-patterns"><span class="header-section-number">1.1</span> Why Patterns?</a></li>
|
| 172 |
+
<li><a href="#anatomy-of-a-pattern" id="toc-anatomy-of-a-pattern" class="nav-link" data-scroll-target="#anatomy-of-a-pattern"><span class="header-section-number">1.2</span> Anatomy of a Pattern</a></li>
|
| 173 |
+
<li><a href="#patterns-in-this-book" id="toc-patterns-in-this-book" class="nav-link" data-scroll-target="#patterns-in-this-book"><span class="header-section-number">1.3</span> Patterns in This Book</a></li>
|
| 174 |
+
</ul>
|
| 175 |
+
</nav>
|
| 176 |
</div>
|
| 177 |
<!-- main -->
|
| 178 |
<main class="content" id="quarto-document-content">
|
|
|
|
| 196 |
</header>
|
| 197 |
|
| 198 |
|
| 199 |
+
<p>A pattern is a reusable solution to a commonly occurring problem. The concept comes from architecture—Christopher Alexander’s work on design patterns—and was later adopted by software engineering. In this book, we apply the same idea to AI implementations in GLAM contexts.</p>
|
| 200 |
+
<section id="why-patterns" class="level2" data-number="1.1">
|
| 201 |
+
<h2 data-number="1.1" class="anchored" data-anchor-id="why-patterns"><span class="header-section-number">1.1</span> Why Patterns?</h2>
|
| 202 |
+
<p>AI and machine learning are evolving rapidly. The models, APIs, and frameworks we use today will be superseded—often within months. But the underlying problems—extracting structured data from historical documents, assessing condition at scale, making collections discoverable—persist.</p>
|
| 203 |
+
<p>Patterns help us in three ways:</p>
|
| 204 |
+
<p><strong>They’re technology-agnostic.</strong> A pattern describes <em>what</em> problem you’re solving and <em>why</em> an approach works, not just <em>which</em> model to use. When better models emerge, the pattern still applies.</p>
|
| 205 |
+
<p><strong>They’re communicable.</strong> Patterns give teams a shared vocabulary. Saying “we’re using a structured extraction pattern” conveys more than listing the specific models and APIs involved.</p>
|
| 206 |
+
<p><strong>They’re adaptable.</strong> The same pattern can be implemented differently depending on your constraints—budget, infrastructure, staff expertise, risk tolerance.</p>
|
| 207 |
+
</section>
|
| 208 |
+
<section id="anatomy-of-a-pattern" class="level2" data-number="1.2">
|
| 209 |
+
<h2 data-number="1.2" class="anchored" data-anchor-id="anatomy-of-a-pattern"><span class="header-section-number">1.2</span> Anatomy of a Pattern</h2>
|
| 210 |
+
<p>Each pattern in this book follows a consistent structure:</p>
|
| 211 |
+
<p><strong>The Challenge</strong> What recurring problem does this pattern address? What makes it difficult or impossible to solve with traditional approaches?</p>
|
| 212 |
+
<p><strong>Solution Overview</strong> The high-level approach. What makes this work? What are the key components?</p>
|
| 213 |
+
<p><strong>Implementation</strong> Technical walkthrough with working code. We use real examples from GLAM collections, not toy datasets.</p>
|
| 214 |
+
<p><strong>Considerations</strong> When should you use this pattern? What are the tradeoffs? What might go wrong?</p>
|
| 215 |
+
</section>
|
| 216 |
+
<section id="patterns-in-this-book" class="level2" data-number="1.3">
|
| 217 |
+
<h2 data-number="1.3" class="anchored" data-anchor-id="patterns-in-this-book"><span class="header-section-number">1.3</span> Patterns in This Book</h2>
|
| 218 |
+
<p>This book currently covers:</p>
|
| 219 |
+
<ul>
|
| 220 |
+
<li><strong>Structured Information Extraction</strong> — Using Vision Language Models to extract structured metadata from document images (index cards, forms, registers)</li>
|
| 221 |
+
</ul>
|
| 222 |
+
<p>Additional patterns will be added as the book develops.</p>
|
| 223 |
|
| 224 |
|
| 225 |
+
</section>
|
| 226 |
|
| 227 |
</main> <!-- /main -->
|
| 228 |
<script id="quarto-html-after-body" type="application/javascript">
|
|
|
|
| 632 |
</a>
|
| 633 |
</div>
|
| 634 |
<div class="nav-page nav-page-next">
|
| 635 |
+
<a href="../patterns/structured-generation/intro.html" class="pagination-link" aria-label="Structured Document Processing">
|
| 636 |
+
<span class="nav-page-text"><span class="chapter-number">2</span> <span class="chapter-title">Structured Document Processing</span></span> <i class="bi bi-arrow-right-short"></i>
|
| 637 |
</a>
|
| 638 |
</div>
|
| 639 |
</nav>
|
search.json
CHANGED
|
@@ -29,37 +29,81 @@
|
|
| 29 |
"Welcome"
|
| 30 |
]
|
| 31 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
{
|
| 33 |
"objectID": "patterns/structured-generation/intro.html",
|
| 34 |
"href": "patterns/structured-generation/intro.html",
|
| 35 |
-
"title": "2
|
| 36 |
"section": "",
|
| 37 |
-
"text": "2.1 The Challenge\nMany GLAM institutions have vast collections of structured documents
|
| 38 |
"crumbs": [
|
| 39 |
"Structured Information Extraction",
|
| 40 |
-
"<span class='chapter-number'>2</span> <span class='chapter-title'>
|
| 41 |
]
|
| 42 |
},
|
| 43 |
{
|
| 44 |
"objectID": "patterns/structured-generation/intro.html#dont-we-just-need-ocr",
|
| 45 |
"href": "patterns/structured-generation/intro.html#dont-we-just-need-ocr",
|
| 46 |
-
"title": "2
|
| 47 |
"section": "2.2 Don’t we just need OCR?",
|
| 48 |
-
"text": "2.2 Don’t we just need OCR
|
| 49 |
"crumbs": [
|
| 50 |
"Structured Information Extraction",
|
| 51 |
-
"<span class='chapter-number'>2</span> <span class='chapter-title'>
|
| 52 |
]
|
| 53 |
},
|
| 54 |
{
|
| 55 |
"objectID": "patterns/structured-generation/intro.html#solution-overview",
|
| 56 |
"href": "patterns/structured-generation/intro.html#solution-overview",
|
| 57 |
-
"title": "2
|
| 58 |
"section": "2.3 Solution Overview",
|
| 59 |
-
"text": "2.3 Solution Overview\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
"crumbs": [
|
| 61 |
"Structured Information Extraction",
|
| 62 |
-
"<span class='chapter-number'>2</span> <span class='chapter-title'>
|
| 63 |
]
|
| 64 |
},
|
| 65 |
{
|
|
@@ -67,7 +111,7 @@
|
|
| 67 |
"href": "patterns/structured-generation/vlm-structured-generation.html",
|
| 68 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 69 |
"section": "",
|
| 70 |
-
"text": "3.1 Introduction\nIn this chapter we’ll start to look at how we can use Visual Language Models (VLMs) to extract structured information from images of documents.\nWe already saw what this looked like at a conceptual level in the previous chapter. In this chapter we’ll get hands on with some code examples to illustrate how this can be done in practice. To start we’ll focus on some
|
| 71 |
"crumbs": [
|
| 72 |
"Structured Information Extraction",
|
| 73 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
@@ -89,7 +133,7 @@
|
|
| 89 |
"href": "patterns/structured-generation/vlm-structured-generation.html#setup",
|
| 90 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 91 |
"section": "3.3 Setup",
|
| 92 |
-
"text": "3.3 Setup\n\n3.3.1 Start LM Studio\n\nWe’ll use LM Studio for this notebook. Since we’ll be using the OpenAI Python client to interact with models run by LM Studio it will be fairly easy to switch to a different model/tool for running the models since many tools have an OpenAI compatible endpoint.\n\n\n\n\n\n\nIf you haven’t already, make sure to install LM Studio by following the instructions on the LM Studio website.\n\n\n\nWhile LM Studio is primarily known as a GUI tool for interacting with local LLMs, it also includes a built-in API server that is compatible with the OpenAI API. This allows us to use the same code we would use for OpenAI hosted models to interact with local models running in LM Studio.\nLM Studio has a command line interface (CLI) that we can use to start the server. We can check that the lms command is available here:\n\n!lms\n\n\n __ __ ___ ______ ___ _______ ____\n\n / / / |/ / / __/ /___ _____/ (_)__ / ___/ / / _/\n\n / /__/ /|_/ / _\\ \\/ __/ // / _ / / _ \\ / /__/ /___/ / \n\n/____/_/ /_/ /___/\\__/\\_,_/\\_,_/_/\\___/ \\___/____/___/ \n\n\n\nlms - LM Studio CLI - v0.0.47\n\nGitHub: https://github.com/lmstudio-ai/lms\n\n\n\nUsage\n\nUsage: lms [options] [command]\n\n\n\nLM Studio CLI\n\n\n\nOptions:\n\n -h, --help display help for command\n\n\n\nManage Models:\n\n get Searching and downloading a model from online.\n\n import Import a model file into LM Studio\n\n ls List all downloaded models\n\n\n\nUse Models:\n\n chat Open an interactive chat with the currently loaded model.\n\n load Load a model\n\n ps List all loaded models\n\n server Commands for managing the local server\n\n unload Unload a model\n\n\n\nDevelop & Publish Artifacts:\n\n clone Clone an artifact from LM Studio Hub to a local folder.\n\n create Create a new project with scaffolding\n\n dev Starts the development server for the plugin in the current folder.\n\n login Authenticate with LM Studio\n\n push Uploads the plugin in the current folder to LM Studio Hub.\n\n\n\nSystem Management:\n\n bootstrap Bootstrap the CLI\n\n flags Set or get experiment flags\n\n log Log operations. Currently only supports streaming logs from LM Studio via `lms log\n\n stream`\n\n runtime Manage runtime engines\n\n status Prints the status of LM Studio\n\n version Prints the version of the CLI\n\n\n\nCommands:\n\n help display help for command\n\n\n\n\nWe can check that LM Studio server is running by using the lms server start command.\n\n!lms server start\n\nSuccess! Server is now running on port 1234\n\n\n\n\n3.3.2 Connect to LM Studio\nWe can use the OpenAI Python client (TODO add link), to connect to LM studio. By default LM studio is running on port 1234 on localhost so we can connect to it here. The default api_key is lm-studio.\n\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"http://localhost:1234/v1\",\n api_key=\"lm-studio\"\n)\n\nWe can use various different methods with the client, for example we can access the models available:\n\nfrom rich import print as rprint\nmodels = client.models.list()\nrprint(f\"Connected. Models: {[m.id for m in models.data]}\")\n\nConnected. Models: ['qwen3-vl-2b-instruct-mlx', 'qwen/qwen2.5-vl-7b', 'qwen/qwen3-vl-8b', 'qwen/qwen3-vl-4b', \n'text-embedding-nomic-embed-text-v1.5', 'qwen3-vl-30b-a3b-instruct', 'qwen3-vl-30b-a3b-thinking@4bit', \n'qwen3-vl-30b-a3b-thinking@3bit', 'qwen/qwen3-4b-thinking-2507', 'google/gemma-3-12b', 'google/gemma-3-4b', \n'qwen2-0.5b-instruct-fingreylit', 'google/gemma-3n-e4b', 'granite-vision-3.3-2b', 'ibm/granite-4-h-tiny', \n'iconclass-vlm', 'mlx-community/qwen2.5-vl-3b-instruct', 'lmstudio-community/qwen2.5-vl-3b-instruct', \n'lfm2-vl-1.6b', 'mimo-vl-7b-rl-2508@q4_k_s', 'mimo-vl-7b-rl-2508@q8_0', 'qwen3-30b-a3b-instruct-2507', \n'qwen3-4b-instruct-2507-mlx', 'openai/gpt-oss-20b', 'mistralai/mistral-small-3.2', \n'qwen3-30b-a3b-instruct-2507-mlx', 'liquid/lfm2-1.2b', 'smollm3-3b-mlx', 'unsloth/smollm3-3b', \n'ggml-org/smollm3-3b', 'mlx-community/smollm3-3b']\n\n\n\n\n\n\n\n\n\n\nNoteAlternative: Using Hugging Face Inference Providers\n\n\n\n\n\nThis is WIP. TODO add an alternative path that doesn’t require any local model hosting using Inference Providers instead. sl\n\nfrom huggingface_hub import list_models\nfrom rich import print as rprint\nvlm_models = list(list_models(filter=\"image-text-to-text\", inference_provider='all', sort='trending_score', expand=['safetensors']))\nrprint(vlm_models[:5])\nvlm_models[0].safetensors.total\n\n[\n ModelInfo(\n id='Qwen/Qwen3-VL-8B-Instruct',\n author=None,\n sha=None,\n created_at=None,\n last_modified=None,\n private=None,\n disabled=None,\n downloads=None,\n downloads_all_time=None,\n gated=None,\n gguf=None,\n inference=None,\n inference_provider_mapping=None,\n likes=None,\n library_name=None,\n tags=None,\n pipeline_tag=None,\n mask_token=None,\n card_data=None,\n widget_data=None,\n model_index=None,\n config=None,\n transformers_info=None,\n trending_score=116,\n siblings=None,\n spaces=None,\n safetensors=SafeTensorsInfo(parameters={'BF16': 8767123696}, total=8767123696),\n security_repo_status=None,\n xet_enabled=None\n ),\n ModelInfo(\n id='Qwen/Qwen3-VL-30B-A3B-Instruct',\n author=None,\n sha=None,\n created_at=None,\n last_modified=None,\n private=None,\n disabled=None,\n downloads=None,\n downloads_all_time=None,\n gated=None,\n gguf=None,\n inference=None,\n inference_provider_mapping=None,\n likes=None,\n library_name=None,\n tags=None,\n pipeline_tag=None,\n mask_token=None,\n card_data=None,\n widget_data=None,\n model_index=None,\n config=None,\n transformers_info=None,\n trending_score=38,\n siblings=None,\n spaces=None,\n safetensors=SafeTensorsInfo(parameters={'BF16': 31070754032}, total=31070754032),\n security_repo_status=None,\n xet_enabled=None\n ),\n ModelInfo(\n id='Qwen/Qwen2.5-VL-7B-Instruct',\n author=None,\n sha=None,\n created_at=None,\n last_modified=None,\n private=None,\n disabled=None,\n downloads=None,\n downloads_all_time=None,\n gated=None,\n gguf=None,\n inference=None,\n inference_provider_mapping=None,\n likes=None,\n library_name=None,\n tags=None,\n pipeline_tag=None,\n mask_token=None,\n card_data=None,\n widget_data=None,\n model_index=None,\n config=None,\n transformers_info=None,\n trending_score=16,\n siblings=None,\n spaces=None,\n safetensors=SafeTensorsInfo(parameters={'BF16': 8292166656}, total=8292166656),\n security_repo_status=None,\n xet_enabled=None\n ),\n ModelInfo(\n id='google/gemma-3-27b-it',\n author=None,\n sha=None,\n created_at=None,\n last_modified=None,\n private=None,\n disabled=None,\n downloads=None,\n downloads_all_time=None,\n gated=None,\n gguf=None,\n inference=None,\n inference_provider_mapping=None,\n likes=None,\n library_name=None,\n tags=None,\n pipeline_tag=None,\n mask_token=None,\n card_data=None,\n widget_data=None,\n model_index=None,\n config=None,\n transformers_info=None,\n trending_score=16,\n siblings=None,\n spaces=None,\n safetensors=SafeTensorsInfo(parameters={'BF16': 27432406640}, total=27432406640),\n security_repo_status=None,\n xet_enabled=None\n ),\n ModelInfo(\n id='Qwen/Qwen3-VL-30B-A3B-Thinking',\n author=None,\n sha=None,\n created_at=None,\n last_modified=None,\n private=None,\n disabled=None,\n downloads=None,\n downloads_all_time=None,\n gated=None,\n gguf=None,\n inference=None,\n inference_provider_mapping=None,\n likes=None,\n library_name=None,\n tags=None,\n pipeline_tag=None,\n mask_token=None,\n card_data=None,\n widget_data=None,\n model_index=None,\n config=None,\n transformers_info=None,\n trending_score=14,\n siblings=None,\n spaces=None,\n safetensors=SafeTensorsInfo(parameters={'BF16': 31070754032}, total=31070754032),\n security_repo_status=None,\n xet_enabled=None\n )\n]\n\n\n\n8767123696\n\n\n\nmax_params = 8767123696 # ~8.7B parameters\nvlm_models = list_models(filter=\"image-text-to-text\", inference_provider='all', sort='trending_score', expand=['safetensors'])\nvlm_models_small = [m for m in vlm_models if m.safetensors and m.safetensors.total <= max_params]\n[m.id for m in vlm_models_small]\n\n['Qwen/Qwen3-VL-8B-Instruct',\n 'Qwen/Qwen2.5-VL-7B-Instruct',\n 'xtuner/llava-llama-3-8b-v1_1',\n 'TheFinAI/StockLLM',\n 'dinalad0/my-LLM_RAG-model']\n\n\n\nimport os\nfrom openai import OpenAI\nfrom dotenv import load_dotenv\nload_dotenv()\n\nhf_client = OpenAI(\n base_url=\"https://router.huggingface.co/v1\",\n api_key=os.environ[\"HF_TOKEN\"],\n)\n\ncompletion = hf_client.chat.completions.create(\n model=\"Qwen/Qwen3-VL-8B-Instruct\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe this image in one sentence.\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg\"\n }\n }\n ]\n }\n ],\n)\n\nprint(completion.choices[0].message)\n\nChatCompletionMessage(content='The Statue of Liberty stands tall on her island in New York Harbor, with the iconic Manhattan skyline rising majestically behind her under a clear blue sky.', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None)",
|
| 93 |
"crumbs": [
|
| 94 |
"Structured Information Extraction",
|
| 95 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
@@ -100,7 +144,7 @@
|
|
| 100 |
"href": "patterns/structured-generation/vlm-structured-generation.html#basic-vlm-query",
|
| 101 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 102 |
"section": "3.4 Basic VLM Query",
|
| 103 |
-
"text": "3.4 Basic VLM Query\nLet’s start by defining a simple function that we can use to query a VLM with an image and a prompt. This function will handle converting the image to base64 and sending the request to the model.\
|
| 104 |
"crumbs": [
|
| 105 |
"Structured Information Extraction",
|
| 106 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
@@ -111,7 +155,7 @@
|
|
| 111 |
"href": "patterns/structured-generation/vlm-structured-generation.html#simple-vlm-query-example",
|
| 112 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 113 |
"section": "3.5 102: Simple VLM Query Example",
|
| 114 |
-
"text": "3.5 102: Simple VLM Query Example\nTo get started let’s do a simple query to describe an image from the dataset.\n\nimage = ds[0][\"image\"]\n\n# Query the VLM to describe the image\ndescription = query_image(image, \"Describe this image.\", model='
|
| 115 |
"crumbs": [
|
| 116 |
"Structured Information Extraction",
|
| 117 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
@@ -122,7 +166,7 @@
|
|
| 122 |
"href": "patterns/structured-generation/vlm-structured-generation.html#classification",
|
| 123 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 124 |
"section": "3.6 Classification",
|
| 125 |
-
"text": "3.6 Classification\n\nWe’ll define a fairly simple prompt that asks the VLM to decide if a page is one of three categories. We describe each of these categopries and then ask the model to only return one of these as the output. We’ll do this for ten examples and we’ll also log how long it’s taking.\n\nimport time\nfrom tqdm.auto import tqdm\n\nsample_size = 10\n\nsample = ds.take(sample_size)\n\nprompt = \"\"\"Classify this image into one of the following categories:\n\n1. **Index/Reference Card**: A library catalog or reference card\n\n2. **Manuscript Page**: A handwritten or historical document page\n\n3. **Other**: Any document that doesn't fit the above categories\n\nExamine the overall structure, layout, and content type to determine the classification. Focus on whether the document is a structured catalog/reference tool (Index Card) or a historical manuscript with continuous text (Manuscript Page).\n\nReturn only the category name: \"Index/Reference Card\", \"Manuscript Page\", or \"Other\"\n\"\"\"\n\nresults = []\n# Time the execution using standard Python\nstart_time = time.time()\nfor row in tqdm(sample):\n image = row['image']\n results.append(query_image(image, prompt))\nelapsed_time = time.time() - start_time\nprint(f\"Execution time: {elapsed_time:.2f} seconds\")\nrprint(results)\n\n\n\n\nExecution time:
|
| 126 |
"crumbs": [
|
| 127 |
"Structured Information Extraction",
|
| 128 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
@@ -133,142 +177,21 @@
|
|
| 133 |
"href": "patterns/structured-generation/vlm-structured-generation.html#beyond-classifying---extracting-structured-information",
|
| 134 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 135 |
"section": "3.7 Beyond classifying - Extracting structured information",
|
| 136 |
-
"text": "3.7 Beyond classifying - Extracting structured information\nSo far we’ve focused on classifying images but what if we want to extract information from the images? Let’s take the first example from the dataset again.\n\nindex_image = ds[0]['image']\nindex_image\n\n\n\n\n\n\n\n\nIf we have an image like this we don’t just want to assign a label from it (we may do this as a first step) we actually want to extract the various fields from the card in a structured way. We can again use a Pydantic model to define the structure of the data we want to extract.\n\nfrom pydantic import BaseModel, Field\nfrom typing import Optional\n\n\nclass BritishLibraryReprographicCard(BaseModel):\n \"\"\"\n Pydantic model for extracting information from British Library Reference Division \n reprographic cards used to document manuscripts and other materials.\n \"\"\"\n \n department: str = Field(\n ..., \n description=\"The division that holds the material (e.g., 'MANUSCRIPTS')\"\n )\n \n shelfmark: str = Field(\n ..., \n description=\"The library's classification/location code (e.g., 'SLOANE 3972.C. (VOL 1)')\"\n )\n \n order: str = Field(\n ..., \n description=\"Order reference, typically starting with 'SCH NO' followed by numbers\"\n )\n \n author: Optional[str] = Field(\n None, \n description=\"Author name if present, null if blank or marked with diagonal line\"\n )\n \n title: str = Field(\n ..., \n description=\"The name of the work or manuscript\"\n )\n \n place_and_date_of_publication: Optional[str] = Field(\n None, \n description=\"Place and date of publication if present, null if blank\"\n )\n \n reduction: int = Field(\n ..., \n description=\"The reduction number shown at the bottom of the card\"\n )\n\nWe’ll now create a function to handle the querying process using this structured schema.\n\ndef query_image_structured(image, prompt, schema, model='
|
| 137 |
"crumbs": [
|
| 138 |
"Structured Information Extraction",
|
| 139 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
| 140 |
]
|
| 141 |
},
|
| 142 |
{
|
| 143 |
-
"objectID": "patterns/structured-generation/
|
| 144 |
-
"href": "patterns/structured-generation/
|
| 145 |
-
"title": "
|
| 146 |
-
"section": "",
|
| 147 |
-
"text": "
|
| 148 |
-
"crumbs": [
|
| 149 |
-
"Structured Information Extraction",
|
| 150 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 151 |
-
]
|
| 152 |
-
},
|
| 153 |
-
{
|
| 154 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#introduction",
|
| 155 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#introduction",
|
| 156 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 157 |
-
"section": "",
|
| 158 |
-
"text": "Designing schemas for real catalog requirements\nRunning extractions at scale\nEvaluating extraction quality - different strategies for assessing accuracy\nHandling edge cases and failures",
|
| 159 |
-
"crumbs": [
|
| 160 |
-
"Structured Information Extraction",
|
| 161 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 162 |
-
]
|
| 163 |
-
},
|
| 164 |
-
{
|
| 165 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#the-task-advisor-index-cards",
|
| 166 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#the-task-advisor-index-cards",
|
| 167 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 168 |
-
"section": "4.2 The Task: Advisor Index Cards",
|
| 169 |
-
"text": "4.2 The Task: Advisor Index Cards\nThe National Library of Scotland has a collection of historical index cards documenting manuscripts and correspondence. Each card follows a fairly consistent format:\n\nSurname: Family name\nForenames: Given names\nEpithet: Role, title, or occupation\nMS no: Manuscript reference number\nDescription: Document type and date\nFolios: Page references\n\nThe goal is to extract this structured information to enable: - Searchable digital catalog - Integration with library management systems - Research access to historical collections\n\n4.2.1 Example Cards\nLet’s look at a few sample cards from the collection:\n\nfrom pathlib import Path\nimport matplotlib.pyplot as plt\n\nimages = list(Path(\"../../assets/vllm-structured-generation/indexes/\").rglob(\"*.JPG\"))\nimages\n\n[PosixPath('../../assets/vllm-structured-generation/indexes/DSC00172.JPG'),\n PosixPath('../../assets/vllm-structured-generation/indexes/DSC00173.JPG'),\n PosixPath('../../assets/vllm-structured-generation/indexes/DSC00171.JPG'),\n PosixPath('../../assets/vllm-structured-generation/indexes/DSC00170.JPG'),\n PosixPath('../../assets/vllm-structured-generation/indexes/DSC00169.JPG'),\n PosixPath('../../assets/vllm-structured-generation/indexes/DSC00168.JPG')]\n\n\n\n# display a grid of images using matplotlib (len of images)\nnumber_of_images = len(images)\ncols = 3\nrows = (number_of_images + cols - 1) // cols\nfig, axs = plt.subplots(rows, cols, figsize=(15, 5 * rows))\nfor i, img_path in enumerate(images):\n img = plt.imread(img_path)\n ax = axs[i // cols, i % cols] if rows > 1 else axs[i % cols]\n ax.imshow(img)\n ax.axis('off')\n ax.set_title(img_path.stem)\nplt.tight_layout()\nplt.show()",
|
| 170 |
-
"crumbs": [
|
| 171 |
-
"Structured Information Extraction",
|
| 172 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 173 |
-
]
|
| 174 |
-
},
|
| 175 |
-
{
|
| 176 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#schema-design",
|
| 177 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#schema-design",
|
| 178 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 179 |
-
"section": "4.3 Schema Design",
|
| 180 |
-
"text": "4.3 Schema Design\nWorking with the library curators, we designed a schema that matches their cataloging requirements. The schema is intentionally simple - complex schemas are harder for VLMs to extract reliably.\nThis schema is something we can iterate on later based on extraction quality but gives us a solid starting point.\n\nfrom pydantic import BaseModel, Field\nfrom typing import Optional\n\nclass IndexCardEntry(BaseModel):\n \"\"\"Schema for index card extraction matching curator specification\"\"\"\n \n surname: str = Field(..., description=\"Family name as written on card\")\n forenames: Optional[str] = Field(None, description=\"Given names\")\n epithet: Optional[str] = Field(None, description=\"Title, occupation, or role\")\n ms_no: str = Field(..., description=\"Manuscript number\")\n description: str = Field(..., description=\"Document description with date\")\n folios: str = Field(..., description=\"Folio reference\")\n \n failed_to_parse: bool = Field(\n False,\n description=\"Set to True if the card cannot be reliably extracted (illegible, damaged, etc.)\"\n )\n notes: Optional[str] = Field(\n None, \n description=\"Optional notes about the card: handwritten annotations, ambiguities, \"\n \"corrections, or reasons for failed parsing.\"\n )\n\n\nLet’s take a look at the schema definition we’ll use for extraction:\n\n# Display the schema\nfrom rich import print\nprint(IndexCardEntry.model_json_schema())\n\n{\n 'description': 'Schema for index card extraction matching curator specification',\n 'properties': {\n 'surname': {'description': 'Family name as written on card', 'title': 'Surname', 'type': 'string'},\n 'forenames': {\n 'anyOf': [{'type': 'string'}, {'type': 'null'}],\n 'default': None,\n 'description': 'Given names',\n 'title': 'Forenames'\n },\n 'epithet': {\n 'anyOf': [{'type': 'string'}, {'type': 'null'}],\n 'default': None,\n 'description': 'Title, occupation, or role',\n 'title': 'Epithet'\n },\n 'ms_no': {'description': 'Manuscript number', 'title': 'Ms No', 'type': 'string'},\n 'description': {\n 'description': 'Document description with date',\n 'title': 'Description',\n 'type': 'string'\n },\n 'folios': {'description': 'Folio reference', 'title': 'Folios', 'type': 'string'},\n 'failed_to_parse': {\n 'default': False,\n 'description': 'Set to True if the card cannot be reliably extracted (illegible, damaged, etc.)',\n 'title': 'Failed To Parse',\n 'type': 'boolean'\n },\n 'notes': {\n 'anyOf': [{'type': 'string'}, {'type': 'null'}],\n 'default': None,\n 'description': 'Optional notes about the card: handwritten annotations, ambiguities, corrections, or \nreasons for failed parsing.',\n 'title': 'Notes'\n }\n },\n 'required': ['surname', 'ms_no', 'description', 'folios'],\n 'title': 'IndexCardEntry',\n 'type': 'object'\n}",
|
| 181 |
-
"crumbs": [
|
| 182 |
-
"Structured Information Extraction",
|
| 183 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 184 |
-
]
|
| 185 |
-
},
|
| 186 |
-
{
|
| 187 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#setup",
|
| 188 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#setup",
|
| 189 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 190 |
-
"section": "4.4 Setup",
|
| 191 |
-
"text": "4.4 Setup\nWe’ll reuse the VLM setup from the previous chapter. If you haven’t already, make sure LM Studio is running with a VLM loaded.\n\nfrom openai import OpenAI\nimport base64\nfrom io import BytesIO\nfrom PIL import Image as PILImage\n\n\nclient = OpenAI(\n base_url=\"http://localhost:1234/v1\",\n api_key=\"lm-studio\"\n)\n\n\nclient.models.list() \n\nSyncPage[Model](data=[Model(id='qwen3-vl-2b-instruct-mlx', created=None, object='model', owned_by='organization_owner'), Model(id='qwen/qwen3-vl-8b', created=None, object='model', owned_by='organization_owner'), Model(id='qwen/qwen3-vl-4b', created=None, object='model', owned_by='organization_owner'), Model(id='text-embedding-nomic-embed-text-v1.5', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-vl-30b-a3b-instruct', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-vl-30b-a3b-thinking@4bit', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-vl-30b-a3b-thinking@3bit', created=None, object='model', owned_by='organization_owner'), Model(id='qwen/qwen3-4b-thinking-2507', created=None, object='model', owned_by='organization_owner'), Model(id='google/gemma-3-12b', created=None, object='model', owned_by='organization_owner'), Model(id='google/gemma-3-4b', created=None, object='model', owned_by='organization_owner'), Model(id='qwen2-0.5b-instruct-fingreylit', created=None, object='model', owned_by='organization_owner'), Model(id='google/gemma-3n-e4b', created=None, object='model', owned_by='organization_owner'), Model(id='granite-vision-3.3-2b', created=None, object='model', owned_by='organization_owner'), Model(id='ibm/granite-4-h-tiny', created=None, object='model', owned_by='organization_owner'), Model(id='iconclass-vlm', created=None, object='model', owned_by='organization_owner'), Model(id='mlx-community/qwen2.5-vl-3b-instruct', created=None, object='model', owned_by='organization_owner'), Model(id='lmstudio-community/qwen2.5-vl-3b-instruct', created=None, object='model', owned_by='organization_owner'), Model(id='lfm2-vl-1.6b', created=None, object='model', owned_by='organization_owner'), Model(id='mimo-vl-7b-rl-2508@q4_k_s', created=None, object='model', owned_by='organization_owner'), Model(id='mimo-vl-7b-rl-2508@q8_0', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-30b-a3b-instruct-2507', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-4b-instruct-2507-mlx', created=None, object='model', owned_by='organization_owner'), Model(id='openai/gpt-oss-20b', created=None, object='model', owned_by='organization_owner'), Model(id='qwen/qwen2.5-vl-7b', created=None, object='model', owned_by='organization_owner'), Model(id='mistralai/mistral-small-3.2', created=None, object='model', owned_by='organization_owner'), Model(id='qwen3-30b-a3b-instruct-2507-mlx', created=None, object='model', owned_by='organization_owner'), Model(id='liquid/lfm2-1.2b', created=None, object='model', owned_by='organization_owner'), Model(id='smollm3-3b-mlx', created=None, object='model', owned_by='organization_owner'), Model(id='unsloth/smollm3-3b', created=None, object='model', owned_by='organization_owner'), Model(id='ggml-org/smollm3-3b', created=None, object='model', owned_by='organization_owner'), Model(id='mlx-community/smollm3-3b', created=None, object='model', owned_by='organization_owner')], object='list')\n\n\n\nfrom typing import Union\ndef query_image_structured(image: Union[PILImage.Image, str], prompt: str, schema: BaseModel, model='qwen/qwen3-vl-4b'):\n \"\"\"\n Query VLM with an image and get structured output based on a Pydantic schema.\n \n Args:\n image: PIL Image or file path to the image\n prompt: Text prompt describing what to extract\n schema: Pydantic model class defining the expected output structure\n model: Model ID to use for the query\n \n Returns:\n Parsed Pydantic model instance with the extracted data\n \"\"\"\n # Convert image to base64\n if isinstance(image, PILImage.Image):\n buffered = BytesIO()\n image.save(buffered, format=\"JPEG\")\n image_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')\n else:\n with open(image, \"rb\") as f:\n image_base64 = base64.b64encode(f.read()).decode('utf-8')\n \n # Query with structured output\n completion = client.beta.chat.completions.parse(\n model=model,\n messages=[{\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"text\", \"text\": prompt},\n {\"type\": \"image_url\", \"image_url\": {\"url\": f\"data:image/jpeg;base64,{image_base64}\"}}\n ]\n }],\n response_format=schema,\n temperature=0.3 # Lower temperature for more consistent extraction\n )\n \n # Return the parsed structured data\n return completion.choices[0].message.parsed",
|
| 192 |
-
"crumbs": [
|
| 193 |
-
"Structured Information Extraction",
|
| 194 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 195 |
-
]
|
| 196 |
-
},
|
| 197 |
-
{
|
| 198 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#extraction-examples",
|
| 199 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#extraction-examples",
|
| 200 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 201 |
-
"section": "4.5 Extraction Examples",
|
| 202 |
-
"text": "4.5 Extraction Examples\nLet’s run extraction on several sample cards to see how the model performs.\n\nprompt = \"\"\"Extract structured information from this historical library index card and return it as JSON.\n\n This is an index card from the National Library of Scotland's Advocate's Library collection. Each card documents a person and associated manuscript references.\n\n Return a JSON object with these exact fields:\n\n {\n \"surname\": \"Family name exactly as typed (e.g., 'ABAD', 'ABARACA Y BOLEA')\",\n \"forenames\": \"Given names (e.g., 'Joseph', 'Thomas') or null if not present\",\n \"epithet\": \"Title, occupation, or role (e.g., 'Captain, Spanish Army') or null if not present\",\n \"ms_no\": \"Manuscript number exactly as written (e.g., '5538', '5529')\",\n \"description\": \"Document description with date (e.g., 'letter of (1783)', 'copy of petition of (ca. 1783)')\",\n \"folios\": \"Folio reference exactly as written (e.g., 'f.11', 'f.169')\",\n \"failed_to_parse\": false (or true if card is illegible/severely damaged),\n \"notes\": \"Optional notes about handwritten corrections, ambiguities, or parsing issues\"\n }\n\n Guidelines:\n - Extract text exactly as it appears - do not correct spelling or expand abbreviations\n - Preserve original punctuation and formatting\n - If a field is unclear but you can make a reasonable inference, extract it and note the ambiguity in \"notes\"\n - Only set \"failed_to_parse\" to true if you genuinely cannot extract the required fields\n - Use null for optional fields (forenames, epithet, notes) if they are not present or marked with a line\"\"\"\n\n\nimage = PILImage.open(images[0])\nimage \n\n\n\n\n\n\n\n\n\nfrom rich import print\nresult = query_image_structured(image, prompt, IndexCardEntry, model='qwen/qwen3-vl-4b')\n \n\n\nprint(result)\n\nIndexCardEntry(\n surname='ABBAATE',\n forenames='Itala',\n epithet='Daughter of the Physician',\n ms_no='2633',\n description='letter of (1878)',\n folios='f. 38',\n failed_to_parse=False,\n notes=\"Handwritten corrections and annotations present: 'Cairo' (instead of 'ABBAATE'), 'Cairo' (instead of \n'ABBAATE'), 'Physician' (instead of 'Physician'), '2633' (instead of '2633'), 'f. 38' (instead of 'f. 38'). Also, \n'Cairo' appears to be a scribbled correction or miswriting of 'ABBAATE'.\"\n)\n\n\n\n\n4.5.1 Comparing Extraction to Ground Truth\nLet’s compare a few extractions to the actual card content:\n\nfrom tqdm.auto import tqdm\n\nresults = []\nfor img_path in tqdm(images):\n image = PILImage.open(img_path)\n result = query_image_structured(image, prompt, IndexCardEntry, model='qwen/qwen3-vl-4b')\n results.append((img_path.stem, result))",
|
| 203 |
-
"crumbs": [
|
| 204 |
-
"Structured Information Extraction",
|
| 205 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 206 |
-
]
|
| 207 |
-
},
|
| 208 |
-
{
|
| 209 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#evaluation-strategies",
|
| 210 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#evaluation-strategies",
|
| 211 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 212 |
-
"section": "4.6 Evaluation Strategies",
|
| 213 |
-
"text": "4.6 Evaluation Strategies\nHow do we know if the extraction is working well? There are several approaches to evaluation, each with different tradeoffs.\n\n4.6.1 Looking at lots of samples\nIt sounds simple, but looking at a large number of random samples can give a good sense of overall quality. You can spot common errors and get a feel for how reliable the extraction is. You can quickly build intuition about what might be going wrong and where to focus improvement efforts. Realistically you will usually spend some time iterating on the prompt and schema at this stage. Looking at more than one example is important to avoid overfitting to a single case but you don’t immediately need to look at hundreds of examples or set up complex metrics or evaluations. This can come later.\n\nfor i, (img_stem, result) in enumerate(results):\n fig, (ax_img, ax_text) = plt.subplots(1, 2, figsize=(16, 6), \n gridspec_kw={'width_ratios': [1, 1]})\n\n # Left: Display image\n img = plt.imread(images[i])\n ax_img.imshow(img)\n ax_img.axis('off')\n ax_img.set_title(f\"Card {i+1}: {img_stem}\", fontsize=14, fontweight='bold')\n\n # Right: Display extracted data as formatted text\n ax_text.axis('off')\n\n # Format the extracted data nicely\n text_lines = [\n \"Extracted Data:\",\n \"\",\n f\"Surname: {result.surname}\",\n f\"Forenames: {result.forenames or 'N/A'}\",\n f\"Epithet: {result.epithet or 'N/A'}\",\n f\"MS No: {result.ms_no}\",\n f\"Description: {result.description}\",\n f\"Folios: {result.folios}\",\n \"\",\n f\"Failed to Parse: {result.failed_to_parse}\",\n ]\n\n # Add notes if present\n if result.notes:\n text_lines.extend((\"\", \"Notes:\"))\n # Wrap long notes\n import textwrap\n wrapped_notes = textwrap.fill(result.notes, width=60)\n text_lines.append(wrapped_notes)\n\n # Join and display\n formatted_text = \"\\n\".join(text_lines)\n ax_text.text(0.05, 0.95, formatted_text, \n transform=ax_text.transAxes,\n fontsize=11,\n verticalalignment='top',\n fontfamily='monospace',\n bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.3))\n\n plt.tight_layout()\n plt.show()\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n4.6.1.1 What we learned from these samples\n\nIt seems that in these examples the notes field isn’t really adding much value and potentially it just adds noise.\nWhile the failed_to_parse flag sounds useful, we may want to rely on other approaches to identify failures since the model may not always set this flag correctly (and in this case we probably have some other ways to identify failures like looking for missing critical fields).\nOverall, we should prioritize extracting the most relevant information and avoid including fields that do not contribute to the understanding of the index card content. The simpler the schema the less for us to have to check and the fewer tokens the model has to generate. When we’re testing with small batches it doesn’t seem so important but when scaling to thousands of cards it can make a bigger difference.\n\n\nfrom pydantic import BaseModel, Field\nfrom typing import Optional\n\nclass IndexCardEntry(BaseModel):\n \"\"\"Schema for index card extraction matching curator specification\"\"\"\n \n surname: str = Field(..., description=\"Family name as written on card\")\n forenames: Optional[str] = Field(None, description=\"Given names\")\n epithet: Optional[str] = Field(None, description=\"Title, occupation, or role\")\n ms_no: str = Field(..., description=\"Manuscript number\")\n description: str = Field(..., description=\"Document description with date\")\n folios: str = Field(..., description=\"Folio reference\")\n \n\nprompt = \"\"\"Extract structured information from this historical library index card and return it as JSON.\n\n This is an index card from the National Library of Scotland's Advocate's Library collection. Each card documents a person and associated manuscript references.\n\n Return a JSON object with these exact fields:\n\n {\n \"surname\": \"Family name exactly as typed (e.g., 'ABAD', 'ABARACA Y BOLEA')\",\n \"forenames\": \"Given names (e.g., 'Joseph', 'Thomas') or null if not present\",\n \"epithet\": \"Title, occupation, or role (e.g., 'Captain, Spanish Army') or null if not present\",\n \"ms_no\": \"Manuscript number exactly as written (e.g., '5538', '5529')\",\n \"description\": \"Document description with date (e.g., 'letter of (1783)', 'copy of petition of (ca. 1783)')\",\n \"folios\": \"Folio reference exactly as written (e.g., 'f.11', 'f.169')\",\n }\n\n Guidelines:\n - Extract text exactly as it appears - do not correct spelling or expand abbreviations\n - Preserve original punctuation and formatting\n - Use null for optional fields (forenames, epithet, notes) if they are not present or marked with a line\"\"\"\n\n\nresults = []\nfor img_path in tqdm(images):\n image = PILImage.open(img_path)\n result = query_image_structured(image, prompt, IndexCardEntry, model='qwen/qwen3-vl-8b')\n results.append((img_path.stem, result))\n\n\n\n\n\n# Display images with extracted data side-by-side\n# Two columns: left = image, right = extracted text\n\nfor i, (img_stem, result) in enumerate(results):\n fig, (ax_img, ax_text) = plt.subplots(1, 2, figsize=(16, 6), \n gridspec_kw={'width_ratios': [1, 1]})\n \n # Left: Display image\n img = plt.imread(images[i])\n ax_img.imshow(img)\n ax_img.axis('off')\n ax_img.set_title(f\"Card {i+1}: {img_stem}\", fontsize=14, fontweight='bold')\n \n # Right: Display extracted data as formatted text\n ax_text.axis('off')\n \n # Format the extracted data nicely\n text_lines = [\n \"Extracted Data:\",\n \"\",\n f\"Surname: {result.surname}\",\n f\"Forenames: {result.forenames or 'N/A'}\",\n f\"Epithet: {result.epithet or 'N/A'}\",\n f\"MS No: {result.ms_no}\",\n f\"Description: {result.description}\",\n f\"Folios: {result.folios}\",\n \"\",\n ]\n # Join and display\n formatted_text = \"\\n\".join(text_lines)\n ax_text.text(0.05, 0.95, formatted_text, \n transform=ax_text.transAxes,\n fontsize=11,\n verticalalignment='top',\n fontfamily='monospace',\n bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.3))\n \n plt.tight_layout()\n plt.show()\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n4.6.2 1. Manual Ground Truth Evaluation\nThe Gold Standard: Manually annotate a sample of cards and compare.\nPros: - Most accurate measure of performance - Catches all types of errors - Builds training data for future improvements\nCons: - Time consuming - Requires expert annotators - Limited sample size\nBest for: Final validation, establishing baselines, understanding failure modes\n\n# TODO: Load manually annotated ground truth\n# Compare predictions to ground truth\n# Calculate field-level accuracy\n\n# Example metrics:\n# - Exact match accuracy per field\n# - Character error rate\n# - Common error patterns\n\n\n\n4.6.3 2. Cross-Model Evaluation (Model-as-Judge)\nThe Pragmatic Approach: Use a stronger/different model to evaluate outputs.\nPros: - Much faster than manual annotation - Can evaluate full dataset - Good for catching obvious errors\nCons: - Requires access to multiple models - May miss subtle errors - Judge model can be wrong too\nBest for: Large-scale quality monitoring, automated testing, identifying problem areas for manual review\n\n# TODO: Implement model-as-judge evaluation\n# - Extract with Model A (e.g., local Qwen)\n# - Show image + extraction to Model B (e.g., Claude/GPT-4)\n# - Ask Model B to rate accuracy and identify errors\n# - Aggregate results\n\n# Example judge prompt:\n# \"\"\"\n# Compare this extracted data to the index card image:\n# [extraction]\n# \n# For each field, rate accuracy:\n# - Correct: Field matches card exactly\n# - Minor error: Small typo or formatting difference\n# - Major error: Wrong information\n# - Missing: Field is on card but not extracted\n# \"\"\"\n\n\n\n4.6.4 3. Internal Consistency Checks\nThe Automated Approach: Use business rules and patterns to identify suspicious outputs.\nExamples: - Manuscript numbers should follow known patterns - Dates should be within expected ranges - Folio references have consistent formats - Certain fields should always be present\nPros: - Completely automated - Fast - can run on full dataset - No additional model costs\nCons: - Only catches specific error types - Requires domain knowledge to design rules - Can miss errors that follow valid patterns\nBest for: Flagging outliers for review, automated quality gates, monitoring production systems\n\n# TODO: Implement consistency checks\n\n# def validate_extraction(entry: IndexCardEntry) -> list[str]:\n# \"\"\"Run validation checks and return list of warnings.\"\"\"\n# warnings = []\n# \n# # Check MS number format\n# if not re.match(r'^\\d+', entry.ms_no):\n# warnings.append(f\"Unusual MS number format: {entry.ms_no}\")\n# \n# # Check for dates in expected range\n# dates = re.findall(r'\\d{4}', entry.description)\n# for date in dates:\n# if not (1500 <= int(date) <= 1950):\n# warnings.append(f\"Date outside expected range: {date}\")\n# \n# # Check folio format\n# if not re.match(r'^f+\\.?\\s*\\d+', entry.folios, re.IGNORECASE):\n# warnings.append(f\"Unusual folio format: {entry.folios}\")\n# \n# return warnings\n\n\n\n4.6.5 4. Confidence Scoring\nMany VLM APIs return confidence scores or logprobs. We can use these to identify uncertain extractions.\nPros: - No additional cost or models needed - Can prioritize review efforts - Helps establish quality thresholds\nCons: - Not all models/APIs provide confidence scores - High confidence doesn’t guarantee correctness - Requires calibration\nBest for: Prioritizing manual review, quality-based routing, understanding model uncertainty\n\n# TODO: If available, extract and analyze confidence scores\n# Plot distribution of confidence scores\n# Correlate confidence with manual evaluation results\n\n\n\n4.6.6 Combining Evaluation Approaches\nIn practice, a robust evaluation strategy uses multiple approaches:\n\nStart with manual ground truth on a small sample (~50-100 cards) to establish baseline accuracy\nUse consistency checks to automatically flag suspicious outputs\nApply model-as-judge on a larger sample to monitor quality\nPrioritize review using confidence scores or validation warnings\nContinuous monitoring as you process the full collection\n\nThis gives you both rigorous accuracy metrics and practical quality assurance at scale.",
|
| 214 |
-
"crumbs": [
|
| 215 |
-
"Structured Information Extraction",
|
| 216 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 217 |
-
]
|
| 218 |
-
},
|
| 219 |
-
{
|
| 220 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#batch-processing",
|
| 221 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#batch-processing",
|
| 222 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 223 |
-
"section": "4.7 Batch Processing",
|
| 224 |
-
"text": "4.7 Batch Processing\nNow let’s process a larger batch of cards and analyze the results.\n\n# TODO: Process all available cards\n# Track timing, failures, warnings\n# Save results to file\n\n\n4.7.1 Results Analysis\n\n# TODO: Analyze batch results\n# - Success rate\n# - Failed to parse rate\n# - Validation warnings distribution\n# - Processing time statistics",
|
| 225 |
-
"crumbs": [
|
| 226 |
-
"Structured Information Extraction",
|
| 227 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 228 |
-
]
|
| 229 |
-
},
|
| 230 |
-
{
|
| 231 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#edge-cases-and-failure-modes",
|
| 232 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#edge-cases-and-failure-modes",
|
| 233 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 234 |
-
"section": "4.8 Edge Cases and Failure Modes",
|
| 235 |
-
"text": "4.8 Edge Cases and Failure Modes\nWhat kinds of cards are hard for the model to process?\n\n# TODO: Examine failed/problematic extractions\n# Common patterns:\n# - Handwritten corrections/additions\n# - Faded or damaged cards\n# - Unusual formats or layouts\n# - Multiple entries per card",
|
| 236 |
-
"crumbs": [
|
| 237 |
-
"Structured Information Extraction",
|
| 238 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 239 |
-
]
|
| 240 |
-
},
|
| 241 |
-
{
|
| 242 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#export-for-cataloging",
|
| 243 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#export-for-cataloging",
|
| 244 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 245 |
-
"section": "4.9 Export for Cataloging",
|
| 246 |
-
"text": "4.9 Export for Cataloging\nConvert the extracted data to formats suitable for library systems.\n\n# TODO: Export to CSV/JSON/XML\n# Consider catalog system requirements (MARC, Dublin Core, etc.)",
|
| 247 |
-
"crumbs": [
|
| 248 |
-
"Structured Information Extraction",
|
| 249 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 250 |
-
]
|
| 251 |
-
},
|
| 252 |
-
{
|
| 253 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#next-steps",
|
| 254 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#next-steps",
|
| 255 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 256 |
-
"section": "4.10 Next Steps",
|
| 257 |
-
"text": "4.10 Next Steps\nThis notebook demonstrates the core extraction and evaluation workflow. For production deployment, you would need:\n\nRobust error handling - retry logic, fallbacks, logging\nQuality assurance workflow - human review interface for flagged items\nBatch processing infrastructure - queue management, progress tracking\nModel optimization - prompt tuning, model selection, cost optimization\n\nThese production considerations are covered in the appendices and separate infrastructure documentation.",
|
| 258 |
-
"crumbs": [
|
| 259 |
-
"Structured Information Extraction",
|
| 260 |
-
"<span class='chapter-number'>4</span> <span class='chapter-title'>Practical Application: Advisor Index Card Extraction</span>"
|
| 261 |
-
]
|
| 262 |
-
},
|
| 263 |
-
{
|
| 264 |
-
"objectID": "patterns/structured-generation/advisor-index-cards.html#key-takeaways",
|
| 265 |
-
"href": "patterns/structured-generation/advisor-index-cards.html#key-takeaways",
|
| 266 |
-
"title": "4 Practical Application: Advisor Index Card Extraction",
|
| 267 |
-
"section": "4.11 Key Takeaways",
|
| 268 |
-
"text": "4.11 Key Takeaways\n\nSimple schemas work better - Don’t over-engineer the structure\nMultiple evaluation strategies - Combine automated and manual approaches\nPlan for failure - Build in quality flags and review workflows\nDomain expertise matters - Work closely with catalogers to define requirements\nIterate based on results - Start small, evaluate, adjust, scale",
|
| 269 |
"crumbs": [
|
| 270 |
"Structured Information Extraction",
|
| 271 |
-
"<span class='chapter-number'>
|
| 272 |
]
|
| 273 |
}
|
| 274 |
]
|
|
|
|
| 29 |
"Welcome"
|
| 30 |
]
|
| 31 |
},
|
| 32 |
+
{
|
| 33 |
+
"objectID": "patterns/what-is-an-ai-pattern.html",
|
| 34 |
+
"href": "patterns/what-is-an-ai-pattern.html",
|
| 35 |
+
"title": "1 What is an AI Pattern?",
|
| 36 |
+
"section": "",
|
| 37 |
+
"text": "1.1 Why Patterns?\nA pattern is a reusable solution to a commonly occurring problem. The concept comes from architecture—Christopher Alexander’s work on design patterns—and was later adopted by software engineering. In this book, we apply the same idea to AI implementations in GLAM contexts.\nAI and machine learning are evolving rapidly. The models, APIs, and frameworks we use today will be superseded—often within months. But the underlying problems—extracting structured data from historical documents, assessing condition at scale, making collections discoverable—persist.\nPatterns help us in three ways:\nThey’re technology-agnostic. A pattern describes what problem you’re solving and why an approach works, not just which model to use. When better models emerge, the pattern still applies.\nThey’re communicable. Patterns give teams a shared vocabulary. Saying “we’re using a structured extraction pattern” conveys more than listing the specific models and APIs involved.\nThey’re adaptable. The same pattern can be implemented differently depending on your constraints—budget, infrastructure, staff expertise, risk tolerance.",
|
| 38 |
+
"crumbs": [
|
| 39 |
+
"Design Patterns",
|
| 40 |
+
"<span class='chapter-number'>1</span> <span class='chapter-title'>What is an AI Pattern?</span>"
|
| 41 |
+
]
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"objectID": "patterns/what-is-an-ai-pattern.html#anatomy-of-a-pattern",
|
| 45 |
+
"href": "patterns/what-is-an-ai-pattern.html#anatomy-of-a-pattern",
|
| 46 |
+
"title": "1 What is an AI Pattern?",
|
| 47 |
+
"section": "1.2 Anatomy of a Pattern",
|
| 48 |
+
"text": "1.2 Anatomy of a Pattern\nEach pattern in this book follows a consistent structure:\nThe Challenge What recurring problem does this pattern address? What makes it difficult or impossible to solve with traditional approaches?\nSolution Overview The high-level approach. What makes this work? What are the key components?\nImplementation Technical walkthrough with working code. We use real examples from GLAM collections, not toy datasets.\nConsiderations When should you use this pattern? What are the tradeoffs? What might go wrong?",
|
| 49 |
+
"crumbs": [
|
| 50 |
+
"Design Patterns",
|
| 51 |
+
"<span class='chapter-number'>1</span> <span class='chapter-title'>What is an AI Pattern?</span>"
|
| 52 |
+
]
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"objectID": "patterns/what-is-an-ai-pattern.html#patterns-in-this-book",
|
| 56 |
+
"href": "patterns/what-is-an-ai-pattern.html#patterns-in-this-book",
|
| 57 |
+
"title": "1 What is an AI Pattern?",
|
| 58 |
+
"section": "1.3 Patterns in This Book",
|
| 59 |
+
"text": "1.3 Patterns in This Book\nThis book currently covers:\n\nStructured Information Extraction — Using Vision Language Models to extract structured metadata from document images (index cards, forms, registers)\n\nAdditional patterns will be added as the book develops.",
|
| 60 |
+
"crumbs": [
|
| 61 |
+
"Design Patterns",
|
| 62 |
+
"<span class='chapter-number'>1</span> <span class='chapter-title'>What is an AI Pattern?</span>"
|
| 63 |
+
]
|
| 64 |
+
},
|
| 65 |
{
|
| 66 |
"objectID": "patterns/structured-generation/intro.html",
|
| 67 |
"href": "patterns/structured-generation/intro.html",
|
| 68 |
+
"title": "2 Structured Document Processing",
|
| 69 |
"section": "",
|
| 70 |
+
"text": "2.1 The Challenge\nMany GLAM institutions have vast collections of structured documents—index cards, forms, registers—containing valuable information locked in physical or image formats. Manual transcription doesn’t scale, but the structured nature of these documents makes them ideal candidates for AI-powered processing.\nUnlocking this data means better discovery, new research possibilities, and integration with modern cataloguing systems.",
|
| 71 |
"crumbs": [
|
| 72 |
"Structured Information Extraction",
|
| 73 |
+
"<span class='chapter-number'>2</span> <span class='chapter-title'>Structured Document Processing</span>"
|
| 74 |
]
|
| 75 |
},
|
| 76 |
{
|
| 77 |
"objectID": "patterns/structured-generation/intro.html#dont-we-just-need-ocr",
|
| 78 |
"href": "patterns/structured-generation/intro.html#dont-we-just-need-ocr",
|
| 79 |
+
"title": "2 Structured Document Processing",
|
| 80 |
"section": "2.2 Don’t we just need OCR?",
|
| 81 |
+
"text": "2.2 Don’t we just need OCR?\nTraditional OCR extracts text from images, but that’s only half the problem. Consider an index card with a name, date, reference number, and description arranged in specific positions. OCR gives you a block of text—but not which part is the name, which is the date, or how they relate.\nOften, you don’t even need the raw text—you need the information it contains. A catalogue record doesn’t need “Mr. John Smith, 1847” preserved exactly; it needs name: \"John Smith\" and year: 1847 as usable data.\nWith OCR alone, you still need someone to parse text into structured fields. For hundreds of documents, that’s manageable. For hundreds of thousands, it’s not.",
|
| 82 |
"crumbs": [
|
| 83 |
"Structured Information Extraction",
|
| 84 |
+
"<span class='chapter-number'>2</span> <span class='chapter-title'>Structured Document Processing</span>"
|
| 85 |
]
|
| 86 |
},
|
| 87 |
{
|
| 88 |
"objectID": "patterns/structured-generation/intro.html#solution-overview",
|
| 89 |
"href": "patterns/structured-generation/intro.html#solution-overview",
|
| 90 |
+
"title": "2 Structured Document Processing",
|
| 91 |
"section": "2.3 Solution Overview",
|
| 92 |
+
"text": "2.3 Solution Overview\nStructured extraction is a pattern that works across modalities—text, images, audio transcripts. The core idea is the same: constrain a model to return data in a predefined schema rather than freeform text.\nFor document images, we use Vision Language Models (VLMs). Unlike OCR, VLMs understand both visual layout and textual content together. They can see that “1847” appears in the date field position, not just that the characters “1847” exist somewhere on the page.\nStructured output generation constrains the model to return your fields, your format. The result: input in, structured JSON out.\nThis section focuses on the image case—extracting from document images—but the same principles apply when working with text or other formats.\n\n2.3.1 What this pattern looks like\n\n\n\n\n\nflowchart LR\n A[Document Image] --> B[VLM + Schema]\n B --> C[Structured JSON]\n C --> D[Catalogue/Database]\n\n\n\n\n\n\nThe following chapters walk through this in detail—starting with basic VLM queries, then building to real extraction workflows with evaluation strategies.",
|
| 93 |
+
"crumbs": [
|
| 94 |
+
"Structured Information Extraction",
|
| 95 |
+
"<span class='chapter-number'>2</span> <span class='chapter-title'>Structured Document Processing</span>"
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"objectID": "patterns/structured-generation/intro.html#when-to-use-this-pattern",
|
| 100 |
+
"href": "patterns/structured-generation/intro.html#when-to-use-this-pattern",
|
| 101 |
+
"title": "2 Structured Document Processing",
|
| 102 |
+
"section": "2.4 When to Use This Pattern",
|
| 103 |
+
"text": "2.4 When to Use This Pattern\nGood fit:\n\nForms, index cards, registers with consistent layouts\nDocuments where you know what fields you want to extract\nCollections too large for manual transcription\n\nLess suited:\n\nFree-form manuscripts with no predictable structure\nDocuments requiring deep contextual interpretation\nCases where verbatim transcription is the goal (use OCR instead)",
|
| 104 |
"crumbs": [
|
| 105 |
"Structured Information Extraction",
|
| 106 |
+
"<span class='chapter-number'>2</span> <span class='chapter-title'>Structured Document Processing</span>"
|
| 107 |
]
|
| 108 |
},
|
| 109 |
{
|
|
|
|
| 111 |
"href": "patterns/structured-generation/vlm-structured-generation.html",
|
| 112 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 113 |
"section": "",
|
| 114 |
+
"text": "3.1 Introduction\nIn this chapter we’ll start to look at how we can use Visual Language Models (VLMs) to extract structured information from images of documents.\nWe already saw what this looked like at a conceptual level in the previous chapter. In this chapter we’ll get hands on with some code examples to illustrate how this can be done in practice. To start we’ll focus on some relatively simple documents and tasks. This allows us to focus on the core concepts without getting bogged down in too many complexities. We’ll use open source models accessed via the Hugging Face Inference API (you can also run them locally — see the appendix).",
|
| 115 |
"crumbs": [
|
| 116 |
"Structured Information Extraction",
|
| 117 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
|
|
| 133 |
"href": "patterns/structured-generation/vlm-structured-generation.html#setup",
|
| 134 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 135 |
"section": "3.3 Setup",
|
| 136 |
+
"text": "3.3 Setup\n\n3.3.1 Connecting to a Vision Language Model\nWe’ll use Hugging Face Inference Providers to access VLMs via an API. This means we don’t need to install or run any models locally — we just need a free Hugging Face account and an API token.\nSince the Hugging Face Inference API is compatible with the OpenAI Python client, all the code in this chapter will also work with local model servers (like LM Studio, Ollama, or vLLM) with just a one-line change to the client setup. See the appendix at the end of this chapter for details.\n\n\n\n\n\n\nTipGetting a Hugging Face Token\n\n\n\n\nCreate a free account at huggingface.co\nGo to Settings → Access Tokens\nCreate a new token with Read access\nSet it as an environment variable: export HF_TOKEN=hf_... or add it to a .env file\n\n\n\n\nimport os\nfrom openai import OpenAI\nfrom rich import print as rprint\nfrom dotenv import load_dotenv\nload_dotenv()\n\nclient = OpenAI(\n base_url=\"https://router.huggingface.co/v1\",\n api_key=os.environ.get(\"HF_TOKEN\"),\n)\n\nWe’ll use Qwen/Qwen3-VL-8B-Instruct throughout this chapter — an 8 billion parameter vision-language model that offers a good balance of quality and speed for document understanding tasks.",
|
| 137 |
"crumbs": [
|
| 138 |
"Structured Information Extraction",
|
| 139 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
|
|
| 144 |
"href": "patterns/structured-generation/vlm-structured-generation.html#basic-vlm-query",
|
| 145 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 146 |
"section": "3.4 Basic VLM Query",
|
| 147 |
+
"text": "3.4 Basic VLM Query\nLet’s start by defining a simple function that we can use to query a VLM with an image and a prompt. This function will handle converting the image to base64 and sending the request to the model.\nWe’ll default to using the Qwen/Qwen3-VL-8B-Instruct model via HF Inference Providers. You could experiment with different models later on — the code works with any OpenAI-compatible VLM endpoint.\n\n\nCode\nimport base64\nfrom PIL.Image import Image as PILImage\nfrom io import BytesIO\n\ndef query_image(image: str | PILImage, prompt: str, model: str='Qwen/Qwen3-VL-8B-Instruct', max_image_size: int=1024, client=client) -> str:\n \"\"\"Query VLM with an image.\"\"\"\n if isinstance(image, PILImage):\n # Convert PIL Image to bytes and encode to base64\n buffered = BytesIO()\n # ensure image is not too big\n if image.size > (max_image_size, max_image_size):\n image.thumbnail((max_image_size, max_image_size)) \n image.save(buffered, format=\"JPEG\")\n image_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')\n else:\n # Assume image is a file path\n with open(image, \"rb\") as f:\n image_base64 = base64.b64encode(f.read()).decode('utf-8')\n #\n # Query\n response = client.chat.completions.create(\n model=model,\n messages=[{\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"text\", \"text\": prompt},\n {\"type\": \"image_url\", \"image_url\": {\"url\": f\"data:image/jpeg;base64,{image_base64}\"}}\n ]\n }]\n )\n return response.choices[0].message.content",
|
| 148 |
"crumbs": [
|
| 149 |
"Structured Information Extraction",
|
| 150 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
|
|
| 155 |
"href": "patterns/structured-generation/vlm-structured-generation.html#simple-vlm-query-example",
|
| 156 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 157 |
"section": "3.5 102: Simple VLM Query Example",
|
| 158 |
+
"text": "3.5 102: Simple VLM Query Example\nTo get started let’s do a simple query to describe an image from the dataset.\n\nimage = ds[0][\"image\"]\n\n# Query the VLM to describe the image\ndescription = query_image(image, \"Describe this image.\", model='Qwen/Qwen3-VL-8B-Instruct')\nrprint(description)\n\nThis is a black-and-white image of a form from The British Library's Reprographic Section, used to request a copy \nof a manuscript or archival material.\n\nHere is a breakdown of the information on the form:\n\n* **Institution:** The British Library, Reference Division, Reprographic Section.\n* **Address:** Great Russell Street, London WC1B 3DG.\n* **Department:** Manuscripts.\n* **Shelfmark:** SLOANE 3972.C. (Vol. 1)\n* **Order Number:** SCH NO 98876\n* **Author:** This field is blank.\n* **Title:** CATALOGUE OF SIR HANS SLOANES LIBRARY\n* **Place and date of publication:** This field is blank.\n* **Scale/Reduction:** The form indicates a reduction of 12, meaning the reproduction will be scaled down to \n1/12th of the original size. A ruler scale is provided for reference in centimetres and inches.\n\nThe form appears to be filled out by hand for a specific item: Volume 1 of the \"Catalogue of Sir Hans Sloane's \nLibrary,\" which is held in the Manuscripts department under the shelfmark SLOANE 3972.C. This catalogue was \ncompiled by Sir Hans Sloane himself and is a significant historical document detailing his extensive collection, \nwhich later formed part of the foundation of the British Museum and now resides at the British Library.\n\n\n\nWe can see we get a fairly useful description of the card. If we compare against the image we can see most of the details it mentions appear to be largely correct.\n\nimage\n\n\n\n\n\n\n\n\nThere are workflows where open ended description like this could be useful but this isn’t usually the kind of format we want if we want to take some action or do something based on the predictions of the model. In these cases it’s usually nice to have some more controlled output, for example, a label.",
|
| 159 |
"crumbs": [
|
| 160 |
"Structured Information Extraction",
|
| 161 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
|
|
| 166 |
"href": "patterns/structured-generation/vlm-structured-generation.html#classification",
|
| 167 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 168 |
"section": "3.6 Classification",
|
| 169 |
+
"text": "3.6 Classification\n\nWe’ll define a fairly simple prompt that asks the VLM to decide if a page is one of three categories. We describe each of these categopries and then ask the model to only return one of these as the output. We’ll do this for ten examples and we’ll also log how long it’s taking.\n\nimport time\nfrom tqdm.auto import tqdm\nfrom rich import print as rprint\n\nsample_size = 10\n\nsample = ds.take(sample_size)\n\nprompt = \"\"\"Classify this image into one of the following categories:\n\n1. **Index/Reference Card**: A library catalog or reference card\n\n2. **Manuscript Page**: A handwritten or historical document page\n\n3. **Other**: Any document that doesn't fit the above categories\n\nExamine the overall structure, layout, and content type to determine the classification. Focus on whether the document is a structured catalog/reference tool (Index Card) or a historical manuscript with continuous text (Manuscript Page).\n\nReturn only the category name: \"Index/Reference Card\", \"Manuscript Page\", or \"Other\"\n\"\"\"\n\nresults = []\n# Time the execution using standard Python\nstart_time = time.time()\nfor row in tqdm(sample):\n image = row['image']\n results.append(query_image(image, prompt, model='Qwen/Qwen3-VL-8B-Instruct'))\nelapsed_time = time.time() - start_time\nprint(f\"Execution time: {elapsed_time:.2f} seconds\")\nrprint(results)\n\n\n\n\nExecution time: 18.31 seconds\n\n\n[\n 'Index/Reference Card',\n 'Other',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page',\n 'Manuscript Page'\n]\n\n\n\nLet’s check the result that was predicted as “index/reference card”\n\nsample[0]['image']\n\n\n\n\n\n\n\n\nWe can extrapolate how long this would take for the full dataset\n\n# Calculate average time per image\navg_time_per_image = elapsed_time / sample_size\n\n# Project time for full dataset\ntotal_images = len(ds)\nprojected_time = avg_time_per_image * total_images\n\nprint(f\"Sample processing time: {elapsed_time:.2f} seconds ({elapsed_time/60:.2f} minutes)\")\nprint(f\"Average time per image: {avg_time_per_image:.2f} seconds\")\nprint(f\"Total images in dataset: {total_images}\")\nprint(f\"Projected time for full dataset: {projected_time/60:.2f} minutes ({projected_time/3600:.2f} hours)\")\n\nSample processing time: 18.31 seconds (0.31 minutes)\nAverage time per image: 1.83 seconds\nTotal images in dataset: 2734\nProjected time for full dataset: 83.45 minutes (1.39 hours)\n\n\n\n3.6.1 Classifying with structured labels\nIn the previous example, we relied on the model to return the label in the correct format. While this often works, it can sometimes lead to inconsistencies in the output. To address this, we can use Pydantic models to define a structured output format. This way, we can ensure that the output adheres to a specific schema.\nIn this example, we’ll define a Pydantic model for our classification task. The model will have a single field category which can take one of three literal values \"Index/Reference Card\", \"Manuscript Page\", or \"other\".\nWhat this means in practice is that the model will only be able to return one of these three values for the category field.\n\nfrom pydantic import BaseModel, Field\nfrom typing import Literal\n\nclass PageCategory(BaseModel):\n category: Literal[\"Index/Reference Card\", \"Manuscript Page\", \"other\"] = Field(\n ..., description=\"The category of the image\"\n )\n\nWhen using the OpenAI client we can specify this Pydantic model as the response_format when making the request. This tells the model to return the output in a format that can be parsed into the Pydantic model (the APIs for this are still evolving so may change slightly over time).\n\nbuffered = BytesIO()\nimage.save(buffered, format=\"JPEG\")\nimage_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')\ncompletion = client.beta.chat.completions.parse(\n model=\"Qwen/Qwen3-VL-8B-Instruct\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": prompt,\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\"url\": f\"data:image/jpeg;base64,{image_base64}\"},\n },\n ],\n },\n ],\n max_tokens=200,\n temperature=0.7,\n response_format=PageCategory,\n)\nrprint(completion)\nrprint(completion.choices[0].message.parsed)\n\nParsedChatCompletion[PageCategory](\n id='47c1a911111046291f6bbec65ebb1ead',\n choices=[\n ParsedChoice[PageCategory](\n finish_reason='stop',\n index=0,\n logprobs=None,\n message=ParsedChatCompletionMessage[PageCategory](\n content='{\\n \"category\": \"Manuscript Page\"\\n}',\n refusal=None,\n role='assistant',\n annotations=None,\n audio=None,\n function_call=None,\n tool_calls=None,\n parsed=PageCategory(category='Manuscript Page')\n )\n )\n ],\n created=1771255803,\n model='qwen/qwen3-vl-8b-instruct',\n object='chat.completion',\n service_tier=None,\n system_fingerprint='',\n usage=CompletionUsage(\n completion_tokens=13,\n prompt_tokens=966,\n total_tokens=979,\n completion_tokens_details=CompletionTokensDetails(\n accepted_prediction_tokens=0,\n audio_tokens=0,\n reasoning_tokens=0,\n rejected_prediction_tokens=0,\n text_tokens=13,\n image_tokens=0,\n video_tokens=0\n ),\n prompt_tokens_details=PromptTokensDetails(\n audio_tokens=0,\n cached_tokens=0,\n cache_creation_input_tokens=0,\n cache_read_input_tokens=0,\n text_tokens=228,\n image_tokens=738,\n video_tokens=0\n )\n )\n)\n\n\n\nPageCategory(category='Manuscript Page')\n\n\n\n\nimage",
|
| 170 |
"crumbs": [
|
| 171 |
"Structured Information Extraction",
|
| 172 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
|
|
|
| 177 |
"href": "patterns/structured-generation/vlm-structured-generation.html#beyond-classifying---extracting-structured-information",
|
| 178 |
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 179 |
"section": "3.7 Beyond classifying - Extracting structured information",
|
| 180 |
+
"text": "3.7 Beyond classifying - Extracting structured information\nSo far we’ve focused on classifying images but what if we want to extract information from the images? Let’s take the first example from the dataset again.\n\nindex_image = ds[0]['image']\nindex_image\n\n\n\n\n\n\n\n\nIf we have an image like this we don’t just want to assign a label from it (we may do this as a first step) we actually want to extract the various fields from the card in a structured way. We can again use a Pydantic model to define the structure of the data we want to extract.\n\nfrom pydantic import BaseModel, Field\nfrom typing import Optional\n\n\nclass BritishLibraryReprographicCard(BaseModel):\n \"\"\"\n Pydantic model for extracting information from British Library Reference Division \n reprographic cards used to document manuscripts and other materials.\n \"\"\"\n \n department: str = Field(\n ..., \n description=\"The division that holds the material (e.g., 'MANUSCRIPTS')\"\n )\n \n shelfmark: str = Field(\n ..., \n description=\"The library's classification/location code (e.g., 'SLOANE 3972.C. (VOL 1)')\"\n )\n \n order: str = Field(\n ..., \n description=\"Order reference, typically starting with 'SCH NO' followed by numbers\"\n )\n \n author: Optional[str] = Field(\n None, \n description=\"Author name if present, null if blank or marked with diagonal line\"\n )\n \n title: str = Field(\n ..., \n description=\"The name of the work or manuscript\"\n )\n \n place_and_date_of_publication: Optional[str] = Field(\n None, \n description=\"Place and date of publication if present, null if blank\"\n )\n \n reduction: int = Field(\n ..., \n description=\"The reduction number shown at the bottom of the card\"\n )\n\nWe’ll now create a function to handle the querying process using this structured schema.\n\ndef query_image_structured(image, prompt, schema, model='Qwen/Qwen3-VL-8B-Instruct'):\n \"\"\"\n Query VLM with an image and get structured output based on a Pydantic schema.\n \n Args:\n image: PIL Image or file path to the image\n prompt: Text prompt describing what to extract\n schema: Pydantic model class defining the expected output structure\n model: Model ID to use for the query\n \n Returns:\n Parsed Pydantic model instance with the extracted data\n \"\"\"\n # Convert image to base64\n if isinstance(image, PILImage):\n buffered = BytesIO()\n image.save(buffered, format=\"JPEG\")\n image_base64 = base64.b64encode(buffered.getvalue()).decode('utf-8')\n else:\n with open(image, \"rb\") as f:\n image_base64 = base64.b64encode(f.read()).decode('utf-8')\n \n # Query with structured output\n completion = client.beta.chat.completions.parse(\n model=model,\n messages=[{\n \"role\": \"user\",\n \"content\": [\n {\"type\": \"text\", \"text\": prompt},\n {\"type\": \"image_url\", \"image_url\": {\"url\": f\"data:image/jpeg;base64,{image_base64}\"}}\n ]\n }],\n response_format=schema,\n temperature=0.3 # Lower temperature for more consistent extraction\n )\n \n # Return the parsed structured data\n return completion.choices[0].message.parsed\n\nWe also need to define a prompt that describes what information we want to extract from the card.\n\n# Example usage\nextraction_prompt = \"\"\"\nExtract the information from this British Library card into structured data (JSON format).\n\nRead each field on the card and extract the following information:\n- department: The division name (e.g., \"MANUSCRIPTS\")\n- shelfmark: The catalog number (e.g., \"SLOANE 3972.C. (VOL 1)\")\n- order: The SCH NO reference number\n- author: The author name, or null if blank\n- title: The full title of the work\n- place_and_date_of_publication: Publication info, or null if blank\n- reduction: The reduction number (as integer) at bottom of card\n\nReturn the exact text as shown on the card. For empty fields with diagonal lines or no text, use null.\n\"\"\"\nresult = query_image_structured(index_image, extraction_prompt, BritishLibraryReprographicCard)\nrprint(result)\n\nBritishLibraryReprographicCard(\n department='MANUSCRIPTS',\n shelfmark='SLOANE 3972.C. (VOL 1)',\n order='SCH NO 98876',\n author=None,\n title='CATALOGUE OF SIR HANS SLOANES LIBRARY',\n place_and_date_of_publication=None,\n reduction=12\n)\n\n\n\n\nrprint(result)\n\nBritishLibraryReprographicCard(\n department='MANUSCRIPTS',\n shelfmark='SLOANE 3972.C. (VOL 1)',\n order='SCH NO 98876',\n author=None,\n title='CATALOGUE OF SIR HANS SLOANES LIBRARY',\n place_and_date_of_publication=None,\n reduction=12\n)\n\n\n\n\nindex_image",
|
| 181 |
"crumbs": [
|
| 182 |
"Structured Information Extraction",
|
| 183 |
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
| 184 |
]
|
| 185 |
},
|
| 186 |
{
|
| 187 |
+
"objectID": "patterns/structured-generation/vlm-structured-generation.html#appendix-using-a-local-model",
|
| 188 |
+
"href": "patterns/structured-generation/vlm-structured-generation.html#appendix-using-a-local-model",
|
| 189 |
+
"title": "3 Structured Information Extraction with Vision Language Models",
|
| 190 |
+
"section": "3.8 Appendix: Using a Local Model",
|
| 191 |
+
"text": "3.8 Appendix: Using a Local Model\nAll the code in this chapter uses the OpenAI-compatible API, which means you can swap in a local model server with a single change to the client setup. Everything else — schemas, prompts, .parse() calls — works identically.\n\n# Replace the HF Inference client with a local server\nfrom openai import OpenAI\n\nclient = OpenAI(\n base_url=\"http://localhost:1234/v1\", # LM Studio default port\n api_key=\"lm-studio\" # Default API key\n)\n\nPopular local options:\n\n\n\nTool\nBest for\nNotes\n\n\n\n\nLM Studio\nGetting started quickly\nGUI-based, MLX acceleration on Mac, built-in model browser\n\n\nOllama\nCLI workflows\nSimple ollama run commands, runs on port 11434\n\n\nvLLM\nProduction & batch processing\nGPU-optimized, highest throughput, best for large-scale extraction\n\n\n\n\n\n\n\n\n\nNote\n\n\n\nSmaller local models (2B-4B parameters) work well for simpler tasks like classification, but for accurate structured extraction you’ll generally want 8B+ parameter models. The trade-off is between running costs/speed (local, smaller models) and extraction quality (API or larger models).",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
"crumbs": [
|
| 193 |
"Structured Information Extraction",
|
| 194 |
+
"<span class='chapter-number'>3</span> <span class='chapter-title'>Structured Information Extraction with Vision Language Models</span>"
|
| 195 |
]
|
| 196 |
}
|
| 197 |
]
|
site_libs/quarto-diagram/mermaid-init.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// mermaid-init.js
|
| 2 |
+
// Initializes the quarto-mermaid JS runtime
|
| 3 |
+
//
|
| 4 |
+
// Copyright (C) 2022 Posit Software, PBC
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* String.prototype.replaceAll() polyfill
|
| 8 |
+
* https://gomakethings.com/how-to-replace-a-section-of-a-string-with-another-one-with-vanilla-js/
|
| 9 |
+
* @author Chris Ferdinandi
|
| 10 |
+
* @license MIT
|
| 11 |
+
*/
|
| 12 |
+
if (!String.prototype.replaceAll) {
|
| 13 |
+
String.prototype.replaceAll = function (str, newStr) {
|
| 14 |
+
// If a regex pattern
|
| 15 |
+
if (
|
| 16 |
+
Object.prototype.toString.call(str).toLowerCase() === "[object regexp]"
|
| 17 |
+
) {
|
| 18 |
+
return this.replace(str, newStr);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
// If a string
|
| 22 |
+
return this.replace(new RegExp(str, "g"), newStr);
|
| 23 |
+
};
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
const mermaidOpts = {
|
| 27 |
+
startOnLoad: false,
|
| 28 |
+
};
|
| 29 |
+
// this CSS is adapted from
|
| 30 |
+
// mkdocs-material
|
| 31 |
+
// Copyright (c) 2016-2022 Martin Donath <martin.donath@squidfunk.com>
|
| 32 |
+
|
| 33 |
+
const defaultCSS =
|
| 34 |
+
".label text{fill:var(--mermaid-fg-color)}.node circle,.node ellipse,.node path,.node polygon,.node rect{fill:var(--mermaid-node-bg-color);stroke:var(--mermaid-node-fg-color)}marker{fill:var(--mermaid-edge-color)!important}.edgeLabel .label rect{fill:#0000}.label{color:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.label foreignObject{line-height:normal;overflow:visible}.label div .edgeLabel{color:var(--mermaid-label-fg-color)}.edgeLabel,.edgeLabel rect,.label div .edgeLabel{background-color:var(--mermaid-label-bg-color)}.edgeLabel,.edgeLabel rect{fill:var(--mermaid-label-bg-color);color:var(--mermaid-edge-color)}.edgePath .path,.flowchart-link{stroke:var(--mermaid-edge-color)}.edgePath .arrowheadPath{fill:var(--mermaid-edge-color);stroke:none}.cluster rect{fill:var(--mermaid-fg-color--lightest);stroke:var(--mermaid-fg-color--lighter)}.cluster span{color:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}defs #flowchart-circleEnd,defs #flowchart-circleStart,defs #flowchart-crossEnd,defs #flowchart-crossStart,defs #flowchart-pointEnd,defs #flowchart-pointStart{stroke:none}g.classGroup line,g.classGroup rect{fill:var(--mermaid-node-bg-color);stroke:var(--mermaid-node-fg-color)}g.classGroup text{fill:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.classLabel .box{fill:var(--mermaid-label-bg-color);background-color:var(--mermaid-label-bg-color);opacity:1}.classLabel .label{fill:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.node .divider{stroke:var(--mermaid-node-fg-color)}.relation{stroke:var(--mermaid-edge-color)}.cardinality{fill:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.cardinality text{fill:inherit!important}defs #classDiagram-compositionEnd,defs #classDiagram-compositionStart,defs #classDiagram-dependencyEnd,defs #classDiagram-dependencyStart,defs #classDiagram-extensionEnd,defs #classDiagram-extensionStart{fill:var(--mermaid-edge-color)!important;stroke:var(--mermaid-edge-color)!important}defs #classDiagram-aggregationEnd,defs #classDiagram-aggregationStart{fill:var(--mermaid-label-bg-color)!important;stroke:var(--mermaid-edge-color)!important}g.stateGroup rect{fill:var(--mermaid-node-bg-color);stroke:var(--mermaid-node-fg-color)}g.stateGroup .state-title{fill:var(--mermaid-label-fg-color)!important;font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}g.stateGroup .composit{fill:var(--mermaid-label-bg-color)}.nodeLabel{color:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.node circle.state-end,.node circle.state-start,.start-state{fill:var(--mermaid-edge-color);stroke:none}.end-state-inner,.end-state-outer{fill:var(--mermaid-edge-color)}.end-state-inner,.node circle.state-end{stroke:var(--mermaid-label-bg-color)}.transition{stroke:var(--mermaid-edge-color)}[id^=state-fork] rect,[id^=state-join] rect{fill:var(--mermaid-edge-color)!important;stroke:none!important}.statediagram-cluster.statediagram-cluster .inner{fill:var(--mermaid-bg-color)}.statediagram-cluster rect{fill:var(--mermaid-node-bg-color);stroke:var(--mermaid-node-fg-color)}.statediagram-state rect.divider{fill:var(--mermaid-fg-color--lightest);stroke:var(--mermaid-fg-color--lighter)}defs #statediagram-barbEnd{stroke:var(--mermaid-edge-color)}.entityBox{fill:var(--mermaid-label-bg-color);stroke:var(--mermaid-node-fg-color)}.entityLabel{fill:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}.relationshipLabelBox{fill:var(--mermaid-label-bg-color);fill-opacity:1;background-color:var(--mermaid-label-bg-color);opacity:1}.relationshipLabel{fill:var(--mermaid-label-fg-color)}.relationshipLine{stroke:var(--mermaid-edge-color)}defs #ONE_OR_MORE_END *,defs #ONE_OR_MORE_START *,defs #ONLY_ONE_END *,defs #ONLY_ONE_START *,defs #ZERO_OR_MORE_END *,defs #ZERO_OR_MORE_START *,defs #ZERO_OR_ONE_END *,defs #ZERO_OR_ONE_START *{stroke:var(--mermaid-edge-color)!important}.actor,defs #ZERO_OR_MORE_END circle,defs #ZERO_OR_MORE_START circle{fill:var(--mermaid-label-bg-color)}.actor{stroke:var(--mermaid-node-fg-color)}text.actor>tspan{fill:var(--mermaid-label-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}line{stroke:var(--mermaid-fg-color--lighter)}.messageLine0,.messageLine1{stroke:var(--mermaid-edge-color)}.loopText>tspan,.messageText,.noteText>tspan{fill:var(--mermaid-edge-color);stroke:none;font-family:var(--mermaid-font-family)!important;font-weight:var(--mermaid-font-weight)!important}.noteText>tspan{fill:#000}#arrowhead path{fill:var(--mermaid-edge-color);stroke:none}.loopLine{stroke:var(--mermaid-node-fg-color)}.labelBox,.loopLine{fill:var(--mermaid-node-bg-color)}.labelBox{stroke:none}.labelText,.labelText>span{fill:var(--mermaid-node-fg-color);font-family:var(--mermaid-font-family);font-weight:var(--mermaid-font-weight)}";
|
| 35 |
+
|
| 36 |
+
const mermaidThemeEl = document.querySelector('meta[name="mermaid-theme"]');
|
| 37 |
+
if (mermaidThemeEl) {
|
| 38 |
+
mermaidOpts.theme = mermaidThemeEl.content;
|
| 39 |
+
} else {
|
| 40 |
+
mermaidOpts.themeCSS = defaultCSS;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
mermaid.initialize(mermaidOpts);
|
| 44 |
+
|
| 45 |
+
const _quartoMermaid = {
|
| 46 |
+
// NB: there's effectively a copy of this function
|
| 47 |
+
// in `core/svg.ts`.
|
| 48 |
+
// if you change something here, you must keep it consistent there as well.
|
| 49 |
+
setSvgSize(svg) {
|
| 50 |
+
const { widthInPoints, heightInPoints, explicitHeight, explicitWidth } =
|
| 51 |
+
this.resolveSize(svg);
|
| 52 |
+
|
| 53 |
+
if (explicitWidth && explicitHeight) {
|
| 54 |
+
svg.setAttribute("width", widthInPoints);
|
| 55 |
+
svg.setAttribute("height", heightInPoints);
|
| 56 |
+
svg.style.maxWidth = null; // remove mermaid's default max-width
|
| 57 |
+
} else {
|
| 58 |
+
if (explicitWidth) {
|
| 59 |
+
svg.style.maxWidth = `${widthInPoints}px`;
|
| 60 |
+
}
|
| 61 |
+
if (explicitHeight) {
|
| 62 |
+
svg.style.maxHeight = `${heightInPoints}px`;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
},
|
| 66 |
+
|
| 67 |
+
// NB: there's effectively a copy of this function
|
| 68 |
+
// in `core/svg.ts`.
|
| 69 |
+
// if you change something here, you must keep it consistent there as well.
|
| 70 |
+
makeResponsive(svg) {
|
| 71 |
+
const width = svg.getAttribute("width");
|
| 72 |
+
if (width === null) {
|
| 73 |
+
throw new Error("Couldn't find SVG width");
|
| 74 |
+
}
|
| 75 |
+
const numWidth = Number(width.slice(0, -2));
|
| 76 |
+
|
| 77 |
+
if (numWidth > 650) {
|
| 78 |
+
changed = true;
|
| 79 |
+
svg.setAttribute("width", "100%");
|
| 80 |
+
svg.removeAttribute("height");
|
| 81 |
+
}
|
| 82 |
+
},
|
| 83 |
+
|
| 84 |
+
// NB: there's effectively a copy of this function
|
| 85 |
+
// in `core/svg.ts`.
|
| 86 |
+
// if you change something here, you must keep it consistent there as well.
|
| 87 |
+
fixupAlignment(svg, align) {
|
| 88 |
+
let style = svg.getAttribute("style") || "";
|
| 89 |
+
|
| 90 |
+
switch (align) {
|
| 91 |
+
case "left":
|
| 92 |
+
style = `${style}; display: block; margin: auto auto auto 0`;
|
| 93 |
+
break;
|
| 94 |
+
case "right":
|
| 95 |
+
style = `${style}; display: block; margin: auto 0 auto auto`;
|
| 96 |
+
break;
|
| 97 |
+
case "center":
|
| 98 |
+
style = `${style}; display: block; margin: auto auto auto auto`;
|
| 99 |
+
break;
|
| 100 |
+
}
|
| 101 |
+
svg.setAttribute("style", style);
|
| 102 |
+
},
|
| 103 |
+
|
| 104 |
+
resolveOptions(svgEl) {
|
| 105 |
+
return svgEl.parentElement.parentElement.parentElement.parentElement
|
| 106 |
+
.dataset;
|
| 107 |
+
},
|
| 108 |
+
|
| 109 |
+
// NB: there's effectively a copy of this function
|
| 110 |
+
// in our mermaid runtime in `core/svg.ts`.
|
| 111 |
+
// if you change something here, you must keep it consistent there as well.
|
| 112 |
+
resolveSize(svgEl) {
|
| 113 |
+
const inInches = (size) => {
|
| 114 |
+
if (size.endsWith("in")) {
|
| 115 |
+
return Number(size.slice(0, -2));
|
| 116 |
+
}
|
| 117 |
+
if (size.endsWith("pt") || size.endsWith("px")) {
|
| 118 |
+
// assume 96 dpi for now
|
| 119 |
+
return Number(size.slice(0, -2)) / 96;
|
| 120 |
+
}
|
| 121 |
+
return Number(size);
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
// these are figWidth and figHeight on purpose,
|
| 125 |
+
// because data attributes are translated to camelCase by the DOM API
|
| 126 |
+
const kFigWidth = "figWidth",
|
| 127 |
+
kFigHeight = "figHeight";
|
| 128 |
+
const options = this.resolveOptions(svgEl);
|
| 129 |
+
let width = svgEl.getAttribute("width");
|
| 130 |
+
let height = svgEl.getAttribute("height");
|
| 131 |
+
const getViewBox = () => {
|
| 132 |
+
const vb = svgEl.attributes.getNamedItem("viewBox").value; // do it the roundabout way so that viewBox isn't dropped by deno_dom and text/html
|
| 133 |
+
if (!vb) return undefined;
|
| 134 |
+
const lst = vb.trim().split(" ").map(Number);
|
| 135 |
+
if (lst.length !== 4) return undefined;
|
| 136 |
+
if (lst.some(isNaN)) return undefined;
|
| 137 |
+
return lst;
|
| 138 |
+
};
|
| 139 |
+
if (!width || !height) {
|
| 140 |
+
// attempt to resolve figure dimensions via viewBox
|
| 141 |
+
const viewBox = getViewBox();
|
| 142 |
+
if (viewBox !== undefined) {
|
| 143 |
+
const [_mx, _my, vbWidth, vbHeight] = viewBox;
|
| 144 |
+
width = `${vbWidth}px`;
|
| 145 |
+
height = `${vbHeight}px`;
|
| 146 |
+
} else {
|
| 147 |
+
throw new Error(
|
| 148 |
+
"Mermaid generated an SVG without a viewbox attribute. Without knowing the diagram dimensions, quarto cannot convert it to a PNG"
|
| 149 |
+
);
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
let svgWidthInInches, svgHeightInInches;
|
| 154 |
+
|
| 155 |
+
if (
|
| 156 |
+
(width.slice(0, -2) === "pt" && height.slice(0, -2) === "pt") ||
|
| 157 |
+
(width.slice(0, -2) === "px" && height.slice(0, -2) === "px") ||
|
| 158 |
+
(!isNaN(Number(width)) && !isNaN(Number(height)))
|
| 159 |
+
) {
|
| 160 |
+
// we assume 96 dpi which is generally what seems to be used.
|
| 161 |
+
svgWidthInInches = Number(width.slice(0, -2)) / 96;
|
| 162 |
+
svgHeightInInches = Number(height.slice(0, -2)) / 96;
|
| 163 |
+
}
|
| 164 |
+
const viewBox = getViewBox();
|
| 165 |
+
if (viewBox !== undefined) {
|
| 166 |
+
// assume width and height come from viewbox.
|
| 167 |
+
const [_mx, _my, vbWidth, vbHeight] = viewBox;
|
| 168 |
+
svgWidthInInches = vbWidth / 96;
|
| 169 |
+
svgHeightInInches = vbHeight / 96;
|
| 170 |
+
} else {
|
| 171 |
+
throw new Error(
|
| 172 |
+
"Internal Error: Couldn't resolve width and height of SVG"
|
| 173 |
+
);
|
| 174 |
+
}
|
| 175 |
+
const svgWidthOverHeight = svgWidthInInches / svgHeightInInches;
|
| 176 |
+
let widthInInches, heightInInches;
|
| 177 |
+
|
| 178 |
+
if (options[kFigWidth] && options[kFigHeight]) {
|
| 179 |
+
// both were prescribed, so just go with them
|
| 180 |
+
widthInInches = inInches(String(options[kFigWidth]));
|
| 181 |
+
heightInInches = inInches(String(options[kFigHeight]));
|
| 182 |
+
} else if (options[kFigWidth]) {
|
| 183 |
+
// we were only given width, use that and adjust height based on aspect ratio;
|
| 184 |
+
widthInInches = inInches(String(options[kFigWidth]));
|
| 185 |
+
heightInInches = widthInInches / svgWidthOverHeight;
|
| 186 |
+
} else if (options[kFigHeight]) {
|
| 187 |
+
// we were only given height, use that and adjust width based on aspect ratio;
|
| 188 |
+
heightInInches = inInches(String(options[kFigHeight]));
|
| 189 |
+
widthInInches = heightInInches * svgWidthOverHeight;
|
| 190 |
+
} else {
|
| 191 |
+
// we were not given either, use svg's prescribed height
|
| 192 |
+
heightInInches = svgHeightInInches;
|
| 193 |
+
widthInInches = svgWidthInInches;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
return {
|
| 197 |
+
widthInInches,
|
| 198 |
+
heightInInches,
|
| 199 |
+
widthInPoints: Math.round(widthInInches * 96),
|
| 200 |
+
heightInPoints: Math.round(heightInInches * 96),
|
| 201 |
+
explicitWidth: options?.[kFigWidth] !== undefined,
|
| 202 |
+
explicitHeight: options?.[kFigHeight] !== undefined,
|
| 203 |
+
};
|
| 204 |
+
},
|
| 205 |
+
|
| 206 |
+
postProcess(svg) {
|
| 207 |
+
const options = this.resolveOptions(svg);
|
| 208 |
+
if (
|
| 209 |
+
options.responsive &&
|
| 210 |
+
options["figWidth"] === undefined &&
|
| 211 |
+
options["figHeight"] === undefined
|
| 212 |
+
) {
|
| 213 |
+
this.makeResponsive(svg);
|
| 214 |
+
} else {
|
| 215 |
+
this.setSvgSize(svg);
|
| 216 |
+
}
|
| 217 |
+
if (options["reveal"]) {
|
| 218 |
+
this.fixupAlignment(svg, options["figAlign"] || "center");
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
// forward align attributes to the correct parent dif
|
| 222 |
+
// so that the svg figure is aligned correctly
|
| 223 |
+
const div = svg.parentElement.parentElement.parentElement;
|
| 224 |
+
const align = div.parentElement.parentElement.dataset.layoutAlign;
|
| 225 |
+
if (align) {
|
| 226 |
+
div.classList.remove("quarto-figure-left");
|
| 227 |
+
div.classList.remove("quarto-figure-center");
|
| 228 |
+
div.classList.remove("quarto-figure-right");
|
| 229 |
+
div.classList.add(`quarto-figure-${align}`);
|
| 230 |
+
}
|
| 231 |
+
},
|
| 232 |
+
};
|
| 233 |
+
|
| 234 |
+
// deno-lint-ignore no-window-prefix
|
| 235 |
+
window.addEventListener(
|
| 236 |
+
"load",
|
| 237 |
+
async function () {
|
| 238 |
+
let i = 0;
|
| 239 |
+
// we need pre because of whitespace preservation
|
| 240 |
+
for (const el of Array.from(document.querySelectorAll("pre.mermaid-js"))) {
|
| 241 |
+
// doesn't appear to be treated as whitespace by mermaid
|
| 242 |
+
// so we replace it with a space.
|
| 243 |
+
const text = el.textContent.replaceAll(" ", " ");
|
| 244 |
+
const { svg: output } = await mermaid.mermaidAPI.render(
|
| 245 |
+
`mermaid-${++i}`,
|
| 246 |
+
text,
|
| 247 |
+
el
|
| 248 |
+
);
|
| 249 |
+
el.innerHTML = output;
|
| 250 |
+
if (el.dataset.label) {
|
| 251 |
+
// patch mermaid's emitted style
|
| 252 |
+
const svg = el.firstChild;
|
| 253 |
+
const style = svg.querySelector("style");
|
| 254 |
+
style.innerHTML = style.innerHTML.replaceAll(
|
| 255 |
+
`#${svg.id}`,
|
| 256 |
+
`#${el.dataset.label}-mermaid`
|
| 257 |
+
);
|
| 258 |
+
svg.id = el.dataset.label + "-mermaid";
|
| 259 |
+
delete el.dataset.label;
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
const svg = el.querySelector("svg");
|
| 263 |
+
const parent = el.parentElement;
|
| 264 |
+
parent.removeChild(el);
|
| 265 |
+
parent.appendChild(svg);
|
| 266 |
+
svg.classList.add("mermaid-js");
|
| 267 |
+
}
|
| 268 |
+
for (const svgEl of Array.from(
|
| 269 |
+
document.querySelectorAll("svg.mermaid-js")
|
| 270 |
+
)) {
|
| 271 |
+
_quartoMermaid.postProcess(svgEl);
|
| 272 |
+
}
|
| 273 |
+
},
|
| 274 |
+
false
|
| 275 |
+
);
|
site_libs/quarto-diagram/mermaid.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.mermaidTooltip {
|
| 2 |
+
position: absolute;
|
| 3 |
+
text-align: center;
|
| 4 |
+
max-width: 200px;
|
| 5 |
+
padding: 2px;
|
| 6 |
+
font-family: "trebuchet ms", verdana, arial;
|
| 7 |
+
font-size: 12px;
|
| 8 |
+
background: #ffffde;
|
| 9 |
+
border: 1px solid #aaaa33;
|
| 10 |
+
border-radius: 2px;
|
| 11 |
+
pointer-events: none;
|
| 12 |
+
z-index: 1000;
|
| 13 |
+
}
|
site_libs/quarto-diagram/mermaid.min.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
site_libs/quarto-html/quarto-syntax-highlighting-ed96de9b727972fe78a7b5d16c58bf87.css
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* quarto syntax highlight colors */
|
| 2 |
+
:root {
|
| 3 |
+
--quarto-hl-ot-color: #003B4F;
|
| 4 |
+
--quarto-hl-at-color: #657422;
|
| 5 |
+
--quarto-hl-ss-color: #20794D;
|
| 6 |
+
--quarto-hl-an-color: #5E5E5E;
|
| 7 |
+
--quarto-hl-fu-color: #4758AB;
|
| 8 |
+
--quarto-hl-st-color: #20794D;
|
| 9 |
+
--quarto-hl-cf-color: #003B4F;
|
| 10 |
+
--quarto-hl-op-color: #5E5E5E;
|
| 11 |
+
--quarto-hl-er-color: #AD0000;
|
| 12 |
+
--quarto-hl-bn-color: #AD0000;
|
| 13 |
+
--quarto-hl-al-color: #AD0000;
|
| 14 |
+
--quarto-hl-va-color: #111111;
|
| 15 |
+
--quarto-hl-bu-color: inherit;
|
| 16 |
+
--quarto-hl-ex-color: inherit;
|
| 17 |
+
--quarto-hl-pp-color: #AD0000;
|
| 18 |
+
--quarto-hl-in-color: #5E5E5E;
|
| 19 |
+
--quarto-hl-vs-color: #20794D;
|
| 20 |
+
--quarto-hl-wa-color: #5E5E5E;
|
| 21 |
+
--quarto-hl-do-color: #5E5E5E;
|
| 22 |
+
--quarto-hl-im-color: #00769E;
|
| 23 |
+
--quarto-hl-ch-color: #20794D;
|
| 24 |
+
--quarto-hl-dt-color: #AD0000;
|
| 25 |
+
--quarto-hl-fl-color: #AD0000;
|
| 26 |
+
--quarto-hl-co-color: #5E5E5E;
|
| 27 |
+
--quarto-hl-cv-color: #5E5E5E;
|
| 28 |
+
--quarto-hl-cn-color: #8f5902;
|
| 29 |
+
--quarto-hl-sc-color: #5E5E5E;
|
| 30 |
+
--quarto-hl-dv-color: #AD0000;
|
| 31 |
+
--quarto-hl-kw-color: #003B4F;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/* other quarto variables */
|
| 35 |
+
:root {
|
| 36 |
+
--quarto-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/* syntax highlight based on Pandoc's rules */
|
| 40 |
+
pre > code.sourceCode > span {
|
| 41 |
+
color: #003B4F;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
code.sourceCode > span {
|
| 45 |
+
color: #003B4F;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
div.sourceCode,
|
| 49 |
+
div.sourceCode pre.sourceCode {
|
| 50 |
+
color: #003B4F;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/* Normal */
|
| 54 |
+
code span {
|
| 55 |
+
color: #003B4F;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/* Alert */
|
| 59 |
+
code span.al {
|
| 60 |
+
color: #AD0000;
|
| 61 |
+
font-style: inherit;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/* Annotation */
|
| 65 |
+
code span.an {
|
| 66 |
+
color: #5E5E5E;
|
| 67 |
+
font-style: inherit;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/* Attribute */
|
| 71 |
+
code span.at {
|
| 72 |
+
color: #657422;
|
| 73 |
+
font-style: inherit;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* BaseN */
|
| 77 |
+
code span.bn {
|
| 78 |
+
color: #AD0000;
|
| 79 |
+
font-style: inherit;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* BuiltIn */
|
| 83 |
+
code span.bu {
|
| 84 |
+
font-style: inherit;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* ControlFlow */
|
| 88 |
+
code span.cf {
|
| 89 |
+
color: #003B4F;
|
| 90 |
+
font-weight: bold;
|
| 91 |
+
font-style: inherit;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/* Char */
|
| 95 |
+
code span.ch {
|
| 96 |
+
color: #20794D;
|
| 97 |
+
font-style: inherit;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
/* Constant */
|
| 101 |
+
code span.cn {
|
| 102 |
+
color: #8f5902;
|
| 103 |
+
font-style: inherit;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* Comment */
|
| 107 |
+
code span.co {
|
| 108 |
+
color: #5E5E5E;
|
| 109 |
+
font-style: inherit;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
/* CommentVar */
|
| 113 |
+
code span.cv {
|
| 114 |
+
color: #5E5E5E;
|
| 115 |
+
font-style: italic;
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
/* Documentation */
|
| 119 |
+
code span.do {
|
| 120 |
+
color: #5E5E5E;
|
| 121 |
+
font-style: italic;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/* DataType */
|
| 125 |
+
code span.dt {
|
| 126 |
+
color: #AD0000;
|
| 127 |
+
font-style: inherit;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/* DecVal */
|
| 131 |
+
code span.dv {
|
| 132 |
+
color: #AD0000;
|
| 133 |
+
font-style: inherit;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
/* Error */
|
| 137 |
+
code span.er {
|
| 138 |
+
color: #AD0000;
|
| 139 |
+
font-style: inherit;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
/* Extension */
|
| 143 |
+
code span.ex {
|
| 144 |
+
font-style: inherit;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/* Float */
|
| 148 |
+
code span.fl {
|
| 149 |
+
color: #AD0000;
|
| 150 |
+
font-style: inherit;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
/* Function */
|
| 154 |
+
code span.fu {
|
| 155 |
+
color: #4758AB;
|
| 156 |
+
font-style: inherit;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
/* Import */
|
| 160 |
+
code span.im {
|
| 161 |
+
color: #00769E;
|
| 162 |
+
font-style: inherit;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/* Information */
|
| 166 |
+
code span.in {
|
| 167 |
+
color: #5E5E5E;
|
| 168 |
+
font-style: inherit;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
/* Keyword */
|
| 172 |
+
code span.kw {
|
| 173 |
+
color: #003B4F;
|
| 174 |
+
font-weight: bold;
|
| 175 |
+
font-style: inherit;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/* Operator */
|
| 179 |
+
code span.op {
|
| 180 |
+
color: #5E5E5E;
|
| 181 |
+
font-style: inherit;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
/* Other */
|
| 185 |
+
code span.ot {
|
| 186 |
+
color: #003B4F;
|
| 187 |
+
font-style: inherit;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/* Preprocessor */
|
| 191 |
+
code span.pp {
|
| 192 |
+
color: #AD0000;
|
| 193 |
+
font-style: inherit;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
/* SpecialChar */
|
| 197 |
+
code span.sc {
|
| 198 |
+
color: #5E5E5E;
|
| 199 |
+
font-style: inherit;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/* SpecialString */
|
| 203 |
+
code span.ss {
|
| 204 |
+
color: #20794D;
|
| 205 |
+
font-style: inherit;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
/* String */
|
| 209 |
+
code span.st {
|
| 210 |
+
color: #20794D;
|
| 211 |
+
font-style: inherit;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/* Variable */
|
| 215 |
+
code span.va {
|
| 216 |
+
color: #111111;
|
| 217 |
+
font-style: inherit;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
/* VerbatimString */
|
| 221 |
+
code span.vs {
|
| 222 |
+
color: #20794D;
|
| 223 |
+
font-style: inherit;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
/* Warning */
|
| 227 |
+
code span.wa {
|
| 228 |
+
color: #5E5E5E;
|
| 229 |
+
font-style: italic;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.prevent-inlining {
|
| 233 |
+
content: "</";
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/*# sourceMappingURL=0920dd6d7437995b8cdf7429764427b1.css.map */
|