• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdatabase

databricks-unstructured-pdf-generation

プラグイン
databricks
ソース
GitHub で見る ↗
説明

Databricks上でRAG(検索強化生成)や非構造化ドキュメント評価用データセット、デモドキュメント(例:Knowledge Assistant向け)を構築します。 具体的には以下の処理を実行します: - 合成PDFをローカルで生成する - Unity Catalogボリューム(データ保存領域)にアップロードする - 各ドキュメントに対して取得精度を評価するためのテスト質問を組み合わせる

原文を表示

Build RAG / unstructured-document evaluation datasets and demo documents (e.g. for Knowledge Assistant) on Databricks: generate synthetic PDFs locally, upload to Unity Catalog volumes, and pair each document with test questions for retrieval evaluation.

ユースケース
  • 合成PDFをローカルで生成するとき
  • ドキュメントをUnity Catalogボリュームにアップロードするとき
  • RAGシステムの取得精度を評価するとき
  • Knowledge Assistant向けのデモドキュメントを構築するとき
本文(日本語訳)

Databricks向けデモと評価用データセット用の非構造化ドキュメント生成

Databricks上でのデモやRAG(検索機能付き生成AI)、非構造化ドキュメント取得の評価に向けた、合成PDF文書と対応するテスト質問をUnity Catalogに保存するデータセットとして生成するワークフローです。PDF生成には標準的なローカルツール(HTMLからPDFへの変換)を使用しており、Databricks固有の価値はワークフローの構成にあります。すなわち、UCボリューム(ファイル保存領域)のレイアウト、対応する質問ファイル、そして下流のDatabricks検索・ai_extract・ai_parse_document評価ツールとの統合です。

ワークフロー

  1. HTMLファイルを ./raw_data/html/ に作成します(複数ファイルを並列処理で高速化)。本番環境の検索パイプラインが遭遇するドキュメントに合わせた内容にします。

  2. <SKILL_ROOT>/scripts/pdf_generator.py を使用してHTMLからPDFに変換します(並列変換対応、plutoprintをラップしたツール)。

  3. databricks fs cp コマンドでPDFをUnity Catalogボリュームにアップロードします。本番パイプラインが読み込むのと同じボリューム構成を使用します。

  4. ./raw_data/pdf/pdf_eval_questions.json を生成します。各ドキュメントに対応する検索評価用質問を含め、mlflow.genai.evaluate() などの検索品質スコアリングツール用の正解データセットとなります。

Databaksワークフローが不要で単発のPDFだけが必要な場合は、どのHTMLからPDF変換ツール(weasyprint、wkhtmltopdf、playwright pdf、plutoprintなど)でも直接使用できます。このスキルは合成データセットをUC上で一連の流れで生成することを目的としており、汎用PDF生成ツールではありません。

パス規約: 以下の <SKILL_ROOT> は、このSKILL.mdを含むディレクトリを示します。絶対パスに解決してください(例:~/.claude/skills/databricks-unstructured-pdf-generation)。./raw_data/... パスはプロジェクトの作業ディレクトリからの相対パスです。

必要なパッケージ

uv pip install plutoprint

ステップ1:HTMLファイルの作成

mkdir -p ./raw_data/html

HTMLドキュメントを ./raw_data/html/ファイル名.html に保存します。サブディレクトリを使って整理することもできます(フォルダ構成は保持されます)。

ステップ2:PDFへの変換

# フォルダ全体を変換(並列処理:4ワーカー)
python <SKILL_ROOT>/scripts/pdf_generator.py convert --input ./raw_data/html --output ./raw_data/pdf

PDFが既に存在し、かつHTMLより新しい場合はスキップします。すべてのファイルを再変換するには --force を指定します。

ステップ3:ボリュームへのアップロード

databricks fs コマンドはUCボリュームパスであっても dbfs: スキームプレフィックスが必要です。-r オプションはソースディレクトリの内容をコピーします(ソースディレクトリ名は保持されません)。そのため、ボリューム上でPDFを専用フォルダに保つために、明示的にターゲットを raw_data/pdf と指定します。PDFは raw_data/pdf/ 配下に配置されます。つまり dbfs:/Volumes/my_catalog/my_schema/raw_data/pdf/report.pdf のようになるので、ナレッジアシスタント(知識検索AI)または取り込みパイプラインがこの単一フォルダを指すことができます。

databricks fs cp -r --overwrite ./raw_data/pdf dbfs:/Volumes/my_catalog/my_schema/raw_data/pdf

ステップ4:テスト質問の生成

./raw_data/pdf/pdf_eval_questions.json を作成します。ナレッジアシスタント(知識検索AI)またはマルチエージェント監督役(複数のAIを統括するシステム)の評価用質問を含めます。このファイルはPDFと一緒にボリュームにアップロードして問題ありません。下流のエージェントが利用できます:

{
  "api_errors_guide.pdf": {
    "question": "エラーERR-4521の解決方法は何ですか?",
    "expected_fact": "リフレッシュトークンの有効期限切れ前に /api/v2/auth/refresh を refresh_token で呼び出します(デフォルトTTL:3600秒)"
  },
  "installation_manual.pdf": {
    "question": "サービスはデフォルトでどのポートを使用していますか?",
    "expected_fact": "HTTPS用ポート8443。CONFIG_PORT環境変数で変更可能"
  }
}

このJSONはナレッジアシスタントのテストケース構築と検索精度の検証に使用できます。

ドキュメント内容のガイドライン

ナレッジアシスタントのテストやデモ用のドキュメントを生成する場合:

  • 複数ページのドキュメント: 各PDFは数ページで実質的な内容を含みます
  • 具体的なエラーコードと解決方法: 製品固有のエラーコード、原因、解決手順を含めます
  • 技術的詳細: APIエンドポイント、設定パラメータ、バージョン番号、具体的なコマンドなど
  • シンプルなCSS: HTMLの作成を高速に保ち、PDF変換を確実にするためスタイル設定は最小限にします
  • 検索可能な情報: ナレッジアシスタントがドキュメントを読まないと答えられない詳細情報を含めます

良いドキュメント例:

  • トラブルシューティングセクション付き製品ユーザーマニュアル
  • エラーコード、原因、解決方法を含むAPI エラーリファレンスガイド
  • 具体的な手順を含むインストール・設定ガイド
  • バージョン固有の詳細を含む技術仕様書

コンテンツの例: 一般的な「接続失敗」エラーではなく、以下のように具体的に記述します:

  • 「エラーERR-4521:OAuthトークン有効期限切れ。原因:トークンTTLがデフォルトの3600秒を超過。解決方法:有効期限切れ前に /api/v2/auth/refresh をrefresh_tokenで呼び出してください。トークンライフサイクル管理の詳細はセクション4.2を参照してください。」

CLIリファレンス

python <SKILL_ROOT>/scripts/pdf_generator.py convert [オプション]

  --input, -i     入力HTMLファイルまたはフォルダ(必須)
  --output, -o    PDF出力フォルダ(必須)
  --force, -f     再変換を強制(タイムスタンプを無視)
  --workers, -w   並列処理ワーカー数(デフォルト:4)

フォルダ構成

サブフォルダ構成は保持されます:

./raw_data/html/                    ./raw_data/pdf/
├── report.html             →       ├── report.pdf
├── quarterly/                      ├── quarterly/
│   └── q1.html             →       │   └── q1.pdf
└── legal/                          └── legal/
    └── terms.html          →           └── terms.pdf

付属スクリプト

このスキルには1つのヘルパースクリプトが含まれます:

ファイル 説明
scripts/pdf_generator.py HTMLからPDFへの変換ツール(plutoprintをラップ)。タイムスタンプによるスキップ機能付きの並列フォルダ変換に対応。ステップ2とCLIリファレンスで参照されます。

スクリプトは <SKILL_ROOT>/scripts/pdf_generator.py に配置されます。見つからない場合は、CLIリファレンスから再作成してください(--input/--output/--force/--workers を取る convert サブコマンドで、HTMLからPDFへの変換に plutoprint をラップしたツール)。

トラブルシューティング

問題 対処方法
「plutoprint not installed」エラー uv pip install plutoprint を実行
PDFの表示がおかしい HTMLやCSS構文を確認
「ボリュームが存在しない」エラー databricks volumes create カタログ スキーマ ボリューム名 MANAGED(4つの独立した引数。catalog.schema.volume の形式ではなく)
原文(English)を表示

Unstructured-Document for Demos and Eval Datasets on Databricks

Workflow for producing synthetic PDF documents + paired test questions as a Unity Catalog-resident dataset for Demos and RAG / unstructured-document retrieval evaluation on Databricks. The PDF-generation step uses standard local HTML → PDF tooling; the Databricks-specific value is the workflow shape — UC volume layout, paired question files, and integration with downstream Databricks retrieval / ai_extract / ai_parse_document evaluation.

Workflow

  1. Write HTML files to ./raw_data/html/ (write multiple files in parallel for speed) — domain-shaped to match the documents your retrieval pipeline will see in production.
  2. Convert HTML → PDF using <SKILL_ROOT>/scripts/pdf_generator.py (parallel conversion, wraps plutoprint).
  3. Upload PDFs to a Unity Catalog volume via databricks fs cp — same volume shape your production pipeline will read from.
  4. Generate ./raw_data/pdf/pdf_eval_questions.json pairing each document with retrieval-eval questions; this becomes the gold dataset for mlflow.genai.evaluate() or comparable retrieval-quality scorers.

If you only need ad-hoc PDFs (no Databricks workflow), any HTML → PDF tool (weasyprint, wkhtmltopdf, playwright pdf, plutoprint) works directly — this skill exists for the synthetic-dataset-on-UC end-to-end shape, not as a general PDF generator.

Path convention: <SKILL_ROOT> below = the directory containing this SKILL.md. Resolve to the absolute install path (e.g. ~/.claude/skills/databricks-unstructured-pdf-generation). ./raw_data/... paths are relative to your own project cwd.

Dependencies

uv pip install plutoprint

Step 1: Write HTML Files

mkdir -p ./raw_data/html

Write HTML documents to ./raw_data/html/filename.html. Use subdirectories to organize (structure is preserved).

Step 2: Convert to PDF

# Convert entire folder (parallel, 4 workers)
python <SKILL_ROOT>/scripts/pdf_generator.py convert --input ./raw_data/html --output ./raw_data/pdf

Skips files where PDF exists and is newer than HTML. Use --force to reconvert all.

Step 3: Upload to Volume

databricks fs requires the dbfs: scheme prefix even for UC Volume paths. -r copies the contents of the source directory into the target (the source directory name is not preserved), so name the target raw_data/pdf explicitly to keep the PDFs in their own folder on the volume. They land under raw_data/pdf/ — i.e. dbfs:/Volumes/my_catalog/my_schema/raw_data/pdf/report.pdf — so a Knowledge Assistant or ingest pipeline can point at that single folder.

databricks fs cp -r --overwrite ./raw_data/pdf dbfs:/Volumes/my_catalog/my_schema/raw_data/pdf

Step 4: Generate Test Questions

Create ./raw_data/pdf/pdf_eval_questions.json with questions for Knowledge Assistant (KA) or Multi-Agent Supervisor (MAS) evaluation. It's fine for this file to be uploaded to the volume alongside the PDFs — downstream agents can use it:

{
  "api_errors_guide.pdf": {
    "question": "What is the solution for error ERR-4521?",
    "expected_fact": "Call /api/v2/auth/refresh with refresh_token before the 3600s TTL expires"
  },
  "installation_manual.pdf": {
    "question": "What port does the service use by default?",
    "expected_fact": "Port 8443 for HTTPS, configurable via CONFIG_PORT environment variable"
  }
}

This JSON can be used to build KA test cases and validate retrieval accuracy.

Document Content Guidelines

When generating documents for Knowledge Assistant testing or demos:

  • Multi-page documents: Each PDF should be several pages with substantial content
  • Specific error codes and solutions: Include product-specific error codes, causes, and resolution steps
  • Technical details: API endpoints, configuration parameters, version numbers, specific commands
  • Simple CSS: Keep styling minimal for fast HTML creation and reliable PDF conversion
  • Queryable facts: Include details a KA must read the document to answer (not general knowledge)

Good document types:

  • Product user manuals with troubleshooting sections
  • API error reference guides (error codes, causes, solutions)
  • Installation/configuration guides with specific steps
  • Technical specifications with version-specific details

Example content: Instead of generic "Connection failed" errors, write:

  • "Error ERR-4521: OAuth token expired. Cause: Token TTL exceeded 3600s default. Solution: Call /api/v2/auth/refresh with your refresh_token before expiration. See Section 4.2 for token lifecycle management."

CLI Reference

python <SKILL_ROOT>/scripts/pdf_generator.py convert [OPTIONS]

  --input, -i     Input HTML file or folder (required)
  --output, -o    Output folder for PDFs (required)
  --force, -f     Force reconvert (ignore timestamps)
  --workers, -w   Parallel workers (default: 4)

Folder Structure

Subfolder structure is preserved:

./raw_data/html/                    ./raw_data/pdf/
├── report.html             →       ├── report.pdf
├── quarterly/                      ├── quarterly/
│   └── q1.html             →       │   └── q1.pdf
└── legal/                          └── legal/
    └── terms.html          →           └── terms.pdf

Bundled Script

This skill ships one helper script:

File Description
scripts/pdf_generator.py HTML → PDF converter (wraps plutoprint); parallel folder conversion with timestamp-skip. Referenced by Step 2 and the CLI Reference.

The script ships at <SKILL_ROOT>/scripts/pdf_generator.py. If it is absent, recreate it from the CLI Reference above (a convert subcommand taking --input/--output/--force/--workers, wrapping plutoprint for HTML → PDF).

Troubleshooting

Issue Solution
"plutoprint not installed" uv pip install plutoprint
PDF looks wrong Check HTML/CSS syntax
"Volume does not exist" databricks volumes create CATALOG SCHEMA VOLUME_NAME MANAGED (four separate positional args, not catalog.schema.volume)

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。