Skip to content

Privacy and preparation

Document attachment relationship datasets: keep each form tied to its files

By SourceX Editorial · Updated

10 sections

Short answer

Store files and relationships as separate records. Register each attachment once with a stable ID and SHA-256 hash, keep one link row per form-to-file relationship naming the form field, relation type and whether the file was required, anchor answers to the exact page or region, and audit every expected link from the form side so missing, mismatched or misattached files are found before delivery.

Document stack

Document attachment

This page covers document attachment relationship datasets: keep each form tied to its files.Illustrative

Key takeaways

  • Register each attachment once by stable ID and SHA-256 hash, separate from the forms that use it.
  • Store every form-to-file relationship as its own link row with field, relation type, required flag and origin.
  • Anchor answers to a page, region or table cell with its headers, not just to a file.
  • Audit links from the form side into nine states, so misattached and superseded files are caught as well as missing ones.
  • Show the attachment mattered by labeling each item's minimum evidence set and testing form-only answers.

How do you preserve relationships between forms and their attachments in training data?

Keep files and relationships as separate, explicit records. Register every attachment once with a stable ID and a content hash, store each form-to-file relationship as its own link row naming the form field, the relation type and whether the file was required, anchor answers to the exact page or region that holds the evidence, and audit every expected link for a present, verified file before the dataset ships.

The usual failure is quieter than a missing folder. An export produces a forms table and a directory of files, the join depends on filenames or folder order, and somewhere between redaction, deduplication and repackaging a damage photo ends up attached to the wrong claim or to none. The model then learns to answer from the form alone, or worse, from the wrong file.

The asset on this page is an attachment linkage schema in three parts (file register, link records, evidence anchors) plus a missing file audit with nine states. Together they let a buyer check that a document attachment relationship dataset actually preserves the relationships it claims to, and let a supplier prove it.

Links break because source systems store them in places a flat export does not carry: junction objects, message structure, archive paths and version chains. Knowing where each system keeps the link tells you what to capture before files are pulled out.

Why do form-to-file links break during export?
Where the link livesHow the source stores itWhat a flat export losesWhat to capture
CRM files (Salesforce)A ContentDocumentLink record joins a file to the record it is shared with through LinkedEntityIdWhich record or records the file belonged to; one file can be linked to severalEvery link row, not only the file and its first parent
Email with inline contentHTML parts refer to other body parts in the same message through cid: URLs that map to Content-ID headersWhich image or document a sentence in the body pointed toMessage ID, part Content-ID and the referencing position
Healthcare-style document referencesA FHIR Attachment carries content type, URL, size, a SHA-1 hash and a creation dateIntegrity data and creation time if only the bytes are copiedHash, size and creation date alongside the file
Archives and foldersFiles sit inside a zip or directory whose path implies the parentThe parent once files are flattened or renamedContainer ID and relative path, as Croissant's containedIn does
Versioned uploadsA replacement file supersedes an earlier one on the same formWhich version the decision usedVersion number, upload time and the superseded file ID

The file register: one row per physical attachment

The file register lists each physical file exactly once, independent of how many forms use it, so deduplication and integrity checks happen in one place. Croissant, the MLCommons dataset metadata format, takes the same approach: each FileObject may carry a sha256 checksum, and a file extracted from an archive points to its container with containedIn. FIPS 180-4 defines SHA-256 and states that digests are used to detect whether a message has changed since the digest was generated.

The file register: one row per physical attachment
FieldPurposeIllustrative valueValidation rule
file_idStable identifier used by every linkF-000731Unique; never reused after deletion
sha256 and byte_sizeDetect changes, duplicates and truncation64-character hex digest; 2,481,920 bytesRecomputed on the delivered file and must match
media_type and page_countTells the loader how to read it and how many pages to expectapplication/pdf; 4 pagesDeclared type matches file signature
source_system and source_file_refWhere the file came fromClaims portal; upload record 88231Resolves in the source export manifest
container_id and relative_pathArchive or folder that held itbatch_2026_03.zip; claims/1043/Container exists in the register
created_at and uploaded_atWhen the file was made and when it reached the system2026-03-02 and 2026-03-04uploaded_at not before created_at
version_of and version_noChain of replacements for the same logical documentSupersedes F-000702; version 2No cycles; one latest version per chain
redaction_stateWhether content was masked and howFaces and plate numbers masked in imageSet for every file; method recorded

A link record states one relationship between a form (or a specific form field) and one file, with its type and provenance. Keeping relationships as rows rather than as a file path inside the form lets one file serve several forms, lets a form expect files that never arrived, and makes the audit below possible.

The link record: one row per form-to-file relationship
FieldPurposeIllustrative valueValidation rule
link_id, form_id and field_pathWhich form and which field the file belongs toL-5120; WC-1043; section_3.proof_of_purchasefield_path exists in the form type's definition
file_idThe file in the register, or empty when expected but absentF-000731Present in register, or link state set to a missing state
relationWhat the file does for the formsupports, required_by, supersedes, derived_from, referenced_in_textFrom a fixed list
requiredWhether the form type requires this filetrue for proof of purchaseDerived from the form type, not from what arrived
link_originHow the link was establishedsystem_link, filename_match, text_reference, manual_reviewInferred links carry a reviewer and date
valid_from and decision_refWhen the link applied and which decision used it2026-03-04; adjudication record A-2210Decision date falls within the link's validity
link_stateResult of the missing file auditpresent_verifiedOne of the nine audit states

Which page, region or table holds the evidence the answer needs?

Name the page and region, not just the file. A model that is told the answer is somewhere in a twelve-page PDF learns little about where evidence sits; an anchor to page 3, a rectangle and a table cell teaches the relationship the dataset is for. The W3C Web Annotation Data Model gives a standard way to write such anchors: a FragmentSelector carries a fragment value and a conformsTo link to the specification that defines its syntax, such as page=10&viewrect=50,50,640,480 for PDF under RFC 3778 or xywh=100,100,300,300 for an image region.

At a glance

Which page, region or table holds the evidence the answer needs

Each evidence anchor row should carry the following, so a reviewer can open the file and see the same thing the label claims:

  • anchor_id, link_id and the question or label it supports.
  • Selector type and value, for example a PDF page and view rectangle, an image xywh box, or a text character range.
  • Content kind: form field, table cell, footnote, stamp, signature block, photo region or handwritten note.
  • For tables: the header cells that give the value its meaning, because a number without its column header is not evidence.
  • Extracted text and its OCR confidence where text was machine-read, plus the OCR engine and version.
  • Cross-file links when the answer depends on two files, for example an invoice line that must match a serial number in a photo.

Worked example (illustrative): a warranty claim with three expected files

Consider an illustrative equipment warranty claim; the form type, IDs and counts below are invented to show the shape of the records. Form type WC requires three files: proof of purchase, a photo of the failed part and a technician report. Claim WC-1043 was approved in part.

In the valid record, the register holds four files: the purchase invoice (F-000731), two photos (F-000745 and F-000746, the second a closer retake) and the technician report (F-000760). The link table has four rows: the invoice links to section_3.proof_of_purchase with relation required_by; both photos link to section_4.damage_photo, with F-000746 marked supersedes F-000745; the report links to section_5.technician_report.

Evidence anchors connect the decision to the files. The partial approval cites the report's page 2 table, row "labor hours", with its column header, and a region of photo F-000746 showing the cracked housing. A cross-file anchor ties the serial number printed on the invoice line to the serial plate visible in F-000745, which is why the superseded photo stays in the dataset: it is still evidence, just not the latest image.

Every expected link resolves to a present, verified file, every anchor opens to the cited region, and the decision date falls after every upload. That record is fit for training or evaluation on the question "which attachment justified the partial approval?"

Audit from the form side, not the file side. Start from what each form type requires and what each form's text references, then record the state of every expected link. Counting files in a folder only tells you how many exist, not whether the right ones are attached to the right forms.

At a glance

The missing file audit: nine states every expected link can be in

The missing file audit: nine states every expected link can be in
Link stateHow it is detectedEffect on the exampleAction
present_verifiedFile in register, hash matches, opens, linked by the systemUsableNone
hash_mismatchDelivered bytes differ from the recorded sha256Unsafe: content may have changedRe-pull from source or exclude
wrong_parentHash or content matches a file linked to another formMisleading evidenceFix the link; review any labels built on it
expected_not_linkedForm type requires it, no link row existsAnswer may be unsupportedSearch source; else mark missing
referenced_not_foundForm text or a cid: reference points to a file that is absentContext gapRecover or flag with reason
unreadableFile present but corrupt, encrypted or zero pagesEvidence unavailableRe-export or exclude
redacted_decisiveMasking removed the region the answer depends onAnswer cannot be checkedRelabel or exclude from evaluation
superseded_onlyOnly an older version present; the decision used a later oneWrong versionRecover latest; else exclude
orphan_fileFile in register with no link to any formNot harmful alone; may hide a broken linkTrace to a parent or drop

Validator checks, and an example that should fail them

Run these checks on the full delivery, not a sample, because link errors cluster around specific batches, migrations and form versions:

  • Every required field_path for each form type has a link row; the count of expected_not_linked rows is reported by form type.
  • Every file_id in a link resolves to the register, and every register sha256 matches the delivered bytes.
  • No file is linked as required evidence to two forms unless the source system itself linked it to both.
  • Every inferred link (filename_match or text_reference) has a reviewer and a review date.
  • Each version chain has exactly one latest file, and each decision_ref points to the version that existed on the decision date.
  • Every evidence anchor's selector opens to a non-empty region, and table anchors include their header cells.
  • No anchor points into a region recorded as redacted unless the label says the evidence was masked.
Validator checks, and an example that should fail them
Failing item (illustrative)Check it failsWhy it mattersFix
WC-1088 links invoice F-000731, already required evidence for WC-1043Shared required evidenceBoth claims appear supported by one purchaseTrace the real invoice; mark the other link wrong_parent
Photo link created by filename match with no reviewerInferred link reviewFilename collisions are common in batch uploadsReview or downgrade to unverified
Decision cites report version 1; version 2 uploaded before the decisionVersion at decision dateThe label may describe a document the adjuster did not useRe-anchor to version 2 or exclude
Anchor on page 5 of a 4-page fileAnchor opens to a regionThe evidence pointer is brokenRecompute anchors after any repagination

Proving the attachment mattered: questions that need the file

A relationship dataset should show that the attachment was needed, not just present. The simplest test is an ablation: for each question, record whether it can be answered from the form fields alone, from the form plus one named file, or only by combining files. Items answerable from the form alone are useful controls but should not be counted as multimodal reasoning examples.

Label each item with the minimum evidence set: the anchors without which the answer cannot be reached. That gives buyers a way to measure whether a model looks at the right file and region, and it turns the missing file audit into something measurable, because an item whose minimum evidence set includes a missing or redacted region drops out automatically.

Keep the question wording neutral about which file holds the answer. If the question says "according to the technician report", the model is told where to look and the relationship is no longer being tested.

Supplying form and attachment histories for AI work

Real form and attachment histories, with the decisions made on them, come from claims portals, procurement and onboarding systems, warranty desks and CRMs. Their value depends on the links surviving export, which is why the register, link rows and audit belong in the delivery itself rather than in a later cleanup.

A buyer who needs forms with their files intact can ask SourceX, which looks for a U.S. business holding them for that one request instead of selling from inventory; the request should spell out the linkage schema alongside scope, volume, format, timing and licensing needs. Nothing moves until the business holding the forms has approved scope and terms and signed, and attachment archives too big to transfer can remain in its own storage or ship on encrypted drives, since SourceX does not host multi-terabyte sets. Attached documents often come from third parties, so their rights need a check of their own, separate from the forms.

Frequently asked questions

What is a document attachment relationship dataset?

It is a dataset in which forms, their attached files and the links between them are delivered as explicit records, so a model can be trained or evaluated on which file supports which answer. It usually contains a file register, link records with relation types and evidence anchors pointing to pages or regions.

Why not just put the attachment path in the form record?

A single path cannot express that one file supports several forms, that a form expected a file that never arrived, or that a newer version replaced an older one. Separate link rows handle all three and make a missing file audit possible.

How should duplicate attachments be handled?

Register the file once by content hash and keep every link that the source system created. Remove a duplicate link only when it was produced by the export rather than by the source system, and record why it was removed.

Should forms with missing attachments be dropped from the dataset?

Not automatically. Drop or relabel items whose minimum evidence set includes the missing file, keep the rest with the link state recorded, and report counts by form type so buyers can see where gaps cluster.

What should an evidence anchor point to?

It should point to the smallest region a reviewer needs to confirm the answer: a page and rectangle, an image box, a text range or a table cell with its header. Standard selector syntax, such as the W3C Web Annotation FragmentSelector, makes anchors portable between tools.

Sources

  • Salesforce's ContentDocumentLink object represents the link between a file and where it is shared, identified by LinkedEntityId. Source
  • RFC 2392 defines cid: URLs that let one body part of a message refer to another body part through its Content-ID. Source
  • The FHIR Attachment datatype carries contentType, url, size, a base64 SHA-1 hash, title and creation date. Source
  • Croissant FileObjects may carry a sha256 checksum, and containedIn points a file to the archive or file set that contains it. Source
  • FIPS 180-4 specifies SHA-256 and states that digests are used to detect whether messages have changed since the digest was generated. Source
  • The W3C Web Annotation Data Model's FragmentSelector uses a fragment value plus conformsTo, with examples such as PDF page and view rectangle and image xywh regions. Source

Tell us what data you need

Share scope, volume, format, timing and licensing needs. Datasets are sourced on request.

See if your company qualifies