unstructured
Use the Unstructured Python package to partition documents into elements, inspect element metadata, chunk outputs for RAG, clean/stage data, add embeddings, evaluate extraction quality, and diagnose optional dependency readiness.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- unstructured
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use the Unstructured Python package to partition documents into elements, inspect element metadata, chunk outputs for RAG, clean/stage data, add embeddings, evaluate extraction quality, and diagnose optional dependency readiness.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/repo-provenance.md2.6 KB
- 参考文档references/repo-routing-metadata.json418 B
- 参考文档references/troubleshooting.md3.9 KB
- 脚本scripts/inspect_unstructured_environment.py2.9 KB
03 SKILL.md 正文
Unstructured
Use this repo skill when a task involves the unstructured Python package for preparing raw documents for downstream ML, RAG, annotation, enrichment, or evaluation workflows.
Start Here
- Identify the workflow: partition documents, inspect elements, chunk for RAG, clean/stage outputs, add embeddings, evaluate quality, or debug installation.
- Install only the extras needed for the requested formats or providers; do not default to
all-docsoringestunless the user explicitly needs broad coverage. - Run
unstructured doctororpython -m unstructured.cli doctorwhen a format fails because many capabilities depend on optional Python packages and system tools. - Keep source documents, generated output JSON, metrics, credentials, and temporary work outside this skill tree.
Common Install Patterns
pip install unstructured
pip install "unstructured[docx,pptx,xlsx]"
pip install "unstructured[pdf,image]"
pip install "unstructured[csv,md,rtf,epub]"
Base install is enough for text, HTML, XML, JSON/NDJSON, email, and core APIs. Optional extras add document families, OCR/PDF/image support, audio transcription, token chunking, provider embeddings, and external ingest connectors.
Common system tools:
libmagicimproves MIME detection throughpython-magic.tesseractandpoppler-utilsare commonly needed for OCR/PDF/image workflows.sofficefrom LibreOffice is needed for legacy.docand.pptconversion.pandocis needed by pypandoc-backed formats when the bundled binary is unavailable.ffmpegis needed for audio decoding.
Route by Task
- Use
sub-skills/partitioning/SKILL.mdto turn files, streams, URLs, text, HTML, PDFs/images, Office documents, tabular data, email, JSON, XML, markup, books, or audio intoElementobjects. - Use
sub-skills/elements-and-metadata/SKILL.mdto inspectElementsubclasses, metadata, coordinates, data-source metadata, table HTML/cells, JSON/NDJSON, Markdown, text, or HTML staging. - Use
sub-skills/chunking/SKILL.mdto configurechunk_elements(),chunk_by_title(), integrated partition chunking, token/character limits, overlap, table behavior, andorig_elementsretention. - Use
sub-skills/data-preparation/SKILL.mdto clean extracted text, stage annotation outputs, use lightweight NLP helpers, or prepare local outputs for downstream systems. - Use
sub-skills/embeddings/SKILL.mdto add embeddings to elements with OpenAI, OctoAI, Mixedbread, VoyageAI, VertexAI, Bedrock, or Hugging Face providers while keeping credentials safe. - Use
sub-skills/evaluation/SKILL.mdto compare predicted and gold outputs with text extraction, element type, table, and optional object detection metrics.
Diagnostic Workflow
python -m unstructured.cli doctor
python -m unstructured.cli doctor --for pdf
python -m unstructured.cli doctor --file report.pdf
If the console script is installed, unstructured doctor is equivalent. The doctor command reports Python dependency readiness per file type and checks common system tools. Use it before installing broad extras or debugging a partitioning error by trial and error.
For a reusable local diagnostic wrapper, use sub-skills/partitioning/scripts/partition_diagnostics.py. For package-level environment snapshots, use scripts/inspect_unstructured_environment.py.
End-to-End Patterns
Partition, Chunk, and Serialize
from unstructured.partition.auto import partition
from unstructured.staging.base import elements_to_json
chunks = partition(
filename="report.pdf",
strategy="auto",
chunking_strategy="by_title",
max_characters=1200,
new_after_n_chars=900,
include_orig_elements=False,
)
json_text = elements_to_json(chunks, indent=2)
Use partitioning for format-specific options, chunking for sizing/table/orig-elements decisions, and elements-and-metadata for JSON/output details.
Inspect Tables After Partitioning
python sub-skills/partitioning/scripts/inspect_tables.py elements.json --out-dir tables --index
Use this after exporting elements to JSON when table structure or metadata.text_as_html must be validated.
Compare Output to Gold
python sub-skills/evaluation/scripts/evaluate_elements_pair.py \
--prediction predicted.json \
--gold gold.json
Use the evaluation sub-skill before running large metric batches so shape and obvious mismatches are caught locally.
Safety and Boundaries
- Do not store API keys, tokens, provider credentials, or private endpoints in scripts, examples, or logs.
- Do not run network/API, provider embedding, external ingest, OCR/model download, Docker, or benchmark workflows without explicit user approval.
- Do not assume PDF/image/audio/Office extras or system tools are installed; run diagnostics and install the minimum necessary set.
- Do not write review artifacts, native test outputs, or temporary metrics inside this runtime skill directory.
References
- Read
references/troubleshooting.mdfor cross-cutting install/import, optional dependency, system tool, and CLI/API failure modes. - Read
references/repo-provenance.mdbefore refreshing this skill against a newer checkout. - Use
scripts/inspect_unstructured_environment.pyfor a credential-safe environment and capability summary.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).