elements-and-metadata
Understand and manipulate Unstructured Element classes, metadata, coordinates, data-source metadata, staging conversions, and bundled inspection helpers. Use when inspecting partition output JSON, preserving table metadata or coordinates, or converting element JSON to JSON, NDJSON, Markdown, text, or HTML; route raw document partitioning to partitioning and chunk composition to chunking.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- elements-and-metadata
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Understand and manipulate Unstructured Element classes, metadata, coordinates, data-source metadata, staging conversions, and bundled inspection helpers. Use when inspecting partition output JSON, preserving table metadata or coordinates, or converting element JSON to JSON, NDJSON, Markdown, text, or HTML; route raw document partitioning to partitioning and chunk composition to chunking.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/element-schema.md5.5 KB
- 参考文档references/staging-formats.md5.0 KB
- 参考文档references/troubleshooting.md5.2 KB
- 脚本scripts/convert_elements_json.py6.2 KB
- 脚本scripts/render_elements_html.py1.9 KB
03 SKILL.md 正文
Elements and Metadata
Use this sub-skill when a task starts from already-partitioned Unstructured elements or element JSON and needs schema inspection, metadata debugging, coordinate reasoning, or format conversion. Do not use it to partition source documents or compose chunks.
Core Model
- Elements are instances of
unstructured.documents.elements.Elementsubclasses such asTitle,NarrativeText,ListItem,Table,TableChunk,Image,Formula,CheckBox,CompositeElement,Header,Footer, andText. - Serialized element dictionaries generally use
type,element_id,text, andmetadata;CheckBoxalso useschecked, while text elements may includeembeddings. ElementMetadatais sparse: unset fields are omitted fromto_dict()and JSON output. Unknown ad-hoc metadata can exist, but known fields should be preferred for portable workflows.CoordinatesMetadatarequires bothpointsandsystem; one without the other is invalid. Coordinate dictionaries includepoints,system,layout_width, andlayout_height.DataSourceMetadatalives undermetadata.data_sourceand supports source-level fields such asurl,version,record_locator, dates, and permissions.
See references/element-schema.md for concrete JSON examples and metadata field guidance.
Staging and Conversion
For in-process conversion, prefer unstructured.staging.base:
from unstructured.staging.base import elements_from_json, elements_to_json, elements_to_md
elements = elements_from_json(filename="elements.json")
markdown = elements_to_md(elements, exclude_binary_image_data=True)
json_text = elements_to_json(elements, indent=2)
For command-line use, use the bundled helpers:
python sub-skills/elements-and-metadata/scripts/convert_elements_json.py elements.json --format markdown --output out.md
python sub-skills/elements-and-metadata/scripts/convert_elements_json.py elements.json --format ndjson --output out.ndjson
python sub-skills/elements-and-metadata/scripts/render_elements_html.py elements.json --output rendered.html
See references/staging-formats.md for JSON, NDJSON, Markdown, text, and HTML behavior.
Table Fidelity
- Preserve
metadata.text_as_htmlwhenever table structure matters; Markdown and HTML conversion can use it for richer table output than plainelement.text. - Preserve
metadata.table_as_cells,table_id,chunk_index, andnum_carried_over_header_rowswhen reconstructing or validating split tables. - Compact table HTML normalizes whitespace and strips cosmetic attributes, while preserving structural
rowspanandcolspan. - When converting or filtering element JSON, check that
TableandTableChunkelements retain both text and structural metadata.
Coordinates
RelativeCoordinateSystemuses width and height1;PixelSpaceis screen-oriented with origin at the upper-left;PointSpaceis Cartesian with origin at the lower-left.- Conversion between coordinate systems may invert the y-axis depending on orientation. Use
element.convert_coordinates_to_new_system(new_system, in_place=False)to inspect without mutation. - JSON round-trips should preserve all four coordinate fields. Missing
layout_widthorlayout_heightcan prevent rehydrating concrete coordinate systems.
Debugging Flow
- Load JSON with
elements_from_json()orscripts/convert_elements_json.py --inspectto catch malformed JSON early. - Confirm each element has a supported
type; unknown text-like types may be dropped byelements_from_dicts()if they are not mapped. - Inspect
metadatasparsely: missing keys often mean unset fields, not failed serialization. - For coordinates, verify
pointsandsystemare both present and thatlayout_width/layout_heightmatch the originating page or image. - For tables, compare
text,metadata.text_as_html, andmetadata.table_as_cellsbefore and after conversion. - For oversized
orig_elements, image payloads, or compressed metadata, watch base64/gzip limits and preferexclude_binary_image_data=Truewhen rendering.
See references/troubleshooting.md for failure modes and fixes.
Boundaries
- Raw document partitioning belongs to the
partitioningsub-skill. - Chunking,
CompositeElement,TableChunkcomposition, and chunk metadata consolidation belong to thechunkingsub-skill unless the task is only inspecting existing chunk JSON. - Review/test artifacts should not be added to this runtime subtree.
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).