Datasets:

Modalities:
Image
Text
Formats:
parquet
Languages:
English
License:
bpl-card-catalog / README.md
davanstrien's picture
davanstrien HF Staff
Update README.md
39be0fb verified
metadata
dataset_info:
  features:
    - name: image
      dtype: image
    - name: drawer_id
      dtype: string
    - name: card_number
      dtype: int64
    - name: filename
      dtype: string
    - name: text
      dtype: string
    - name: has_ocr
      dtype: bool
    - name: source
      dtype: string
    - name: source_url
      dtype: string
    - name: ia_collection
      dtype: string
  splits:
    - name: train
      num_bytes: 82657878595
      num_examples: 838023
  download_size: 81240422350
  dataset_size: 82657878595
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*
license: cc0-1.0
language:
  - en
size_categories:
  - 100K<n<1M
tags:
  - ocr
  - handwriting-recognition
  - library-science
  - glam
pretty_name: Boston Public Library Card Catalog

Boston Public Library Rare Books Card Catalog Dataset

Dataset Description

This dataset contains approximately 410,000 digitized catalog cards from the Boston Public Library's Rare Books Department card catalog. The cards represent the main entry catalog (author/title cross-referenced) covering printed materials from various historical periods.

Why This Dataset?

Historical card catalogs are rich sources of:

  • Bibliographic information structured in semi-standardized formats
  • Handwritten and typewritten text from multiple time periods and catalogers
  • Historical cataloging practices including subject classification and cross-referencing
  • Metadata about rare and historically significant materials

This dataset is valuable for training and evaluating AI models on:

  • OCR and handwriting recognition for historical documents
  • Information extraction from semi-structured text
  • Layout analysis of document formats
  • Vision-language model performance on library/archival materials

Dataset Summary

  • Total Cards: ~410,000 individual catalog cards
  • Total Drawers: 386 drawers organized alphabetically
  • Image Format: JPG (converted from JP2)
  • OCR Coverage: ~100% (Tesseract 5.x via Internet Archive)
  • Source: Internet Archive - BPL Rare Books Catalog
  • Original Institution: Boston Public Library Rare Books Department

Dataset Structure

Data Fields

Field Type Description
image Image JPG image of the catalog card (~800-1000px width)
drawer_id string Internet Archive item identifier (e.g., "248-pach-palmas")
card_number int Card position within drawer (0-indexed)
filename string Original filename of the card image
text string OCR-extracted text from the card (Tesseract 5.x)
has_ocr bool Whether OCR text is available for this card
source string Attribution string
source_url string Direct link to source drawer on Internet Archive
ia_collection string Internet Archive collection identifier

Data Splits

This dataset contains a single train split with all catalog cards.

Example

from datasets import load_dataset

dataset = load_dataset("davanstrien/bpl-card-catalog")

# Access a sample
sample = dataset['train'][0]
print(f"Card #{sample['card_number']}")
print(f"OCR Text:\n{sample['text']}")

# Display the card image
sample['image'].show()

Typical Card Contents

Catalog cards typically contain:

  • Author names (surname, forename)
  • Book titles and subtitles
  • Publication information (publisher, place, date)
  • Physical description (pages, illustrations, size)
  • Call numbers and shelfmarks
  • Subject headings and cross-references
  • Notes on condition, provenance, or special features

Dataset Creation

Source Data

The cards were originally created by Boston Public Library catalogers over many decades, representing a historical record of the library's rare books collection. The physical cards were digitized by BPL and uploaded to the Internet Archive with OCR processing.

Collection Process

  1. Digitization: Boston Public Library photographed each drawer of cards
  2. OCR Processing: Internet Archive applied Tesseract OCR to create searchable text
  3. Dataset Creation: Images were extracted from JP2 archives, converted to JPG, and paired with OCR text

Data Processing

  • Original format: JP2 images in ZIP archives on Internet Archive
  • Converted to: JPG at 95% quality for ML compatibility
  • OCR format: HOCR (HTML with bounding boxes) → plain text extraction
  • Organization: Preserved original drawer organization and card order

Uses

Example Use Cases

OCR Model Evaluation

from transformers import TrOCRProcessor, VisionEncoderDecoderModel

processor = TrOCRProcessor.from_pretrained('microsoft/trocr-base-handwritten')
model = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten')

# Evaluate on catalog cards with ground truth OCR
for sample in dataset['train'].select(range(100)):
    pixel_values = processor(sample['image'], return_tensors="pt").pixel_values
    generated_ids = model.generate(pixel_values)
    generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]

    # Compare with ground truth
    print(f"Ground truth: {sample['text'][:100]}")
    print(f"Generated: {generated_text[:100]}")

Information Extraction

# Extract structured bibliographic data
import re

def extract_author(text):
    # Authors typically appear at start, often in "Surname, Forename" format
    lines = text.split('\n')
    if lines:
        return lines[0].strip()
    return None

# Process cards to extract authors
authors = [extract_author(card['text']) for card in dataset['train']]

VLM Evaluation

from transformers import AutoProcessor, AutoModelForVision2Seq

processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b")
model = AutoModelForVision2Seq.from_pretrained("HuggingFaceM4/idefics2-8b")

# Ask questions about catalog cards
messages = [
    {
        "role": "user",
        "content": [
            {"type": "image"},
            {"type": "text", "text": "What is the author and title of this book?"}
        ]
    }
]

for card in dataset['train'].select(range(10)):
    text = processor.apply_chat_template(messages, add_generation_prompt=True)
    inputs = processor(images=[card['image']], text=text, return_tensors="pt")
    outputs = model.generate(**inputs, max_new_tokens=100)
    print(processor.decode(outputs[0], skip_special_tokens=True))

Bias, Risks, and Limitations

Known Biases

  1. Historical Language: Cards use terminology that may be considered offensive by modern standards, reflecting historical cataloging practices and societal biases.

  2. Western Canon Bias: The collection reflects the collecting priorities and interests of a major American library, which historically focused on Western European and American materials.

  3. Cataloger Variation: Cataloging practices evolved over time; older cards may use different standards than newer ones.

OCR Limitations

  • Handwriting Variation: Some cards are handwritten with varying legibility
  • Typewriter Quality: Older typewritten cards may have faded or unclear text
  • Special Characters: Diacritical marks, mathematical symbols, or non-Latin scripts may be incorrectly recognized
  • Layout Complexity: Multi-column layouts, annotations, or crossed-out text may confuse OCR

Additional Information

Dataset Curators

  • Digitization: Boston Public Library Rare Books Department
  • Hosting & OCR: Internet Archive
  • Dataset Creation: Daniel van Strien (@davanstrien)

Licensing Information

The catalog card images are in the public domain as works of the U.S. government or works whose copyright has expired. The dataset is released under CC0 1.0 Universal (Public Domain Dedication).

Acknowledgments

  • Boston Public Library for digitizing this invaluable historical resource and making it publicly accessible
  • Internet Archive for hosting the collection and providing OCR processing
  • The catalogers who created these cards over many decades, preserving knowledge about rare books

Links

Version History

  • v1.0 (2025): Initial release with ~410,000 cards from 386 drawers

Contact

For questions about this dataset, please open an issue in the dataset repository