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
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.
Why do form-to-file links break during export?
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.
| Where the link lives | How the source stores it | What a flat export loses | What to capture |
|---|---|---|---|
| CRM files (Salesforce) | A ContentDocumentLink record joins a file to the record it is shared with through LinkedEntityId | Which record or records the file belonged to; one file can be linked to several | Every link row, not only the file and its first parent |
| Email with inline content | HTML parts refer to other body parts in the same message through cid: URLs that map to Content-ID headers | Which image or document a sentence in the body pointed to | Message ID, part Content-ID and the referencing position |
| Healthcare-style document references | A FHIR Attachment carries content type, URL, size, a SHA-1 hash and a creation date | Integrity data and creation time if only the bytes are copied | Hash, size and creation date alongside the file |
| Archives and folders | Files sit inside a zip or directory whose path implies the parent | The parent once files are flattened or renamed | Container ID and relative path, as Croissant's containedIn does |
| Versioned uploads | A replacement file supersedes an earlier one on the same form | Which version the decision used | Version 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.
| Field | Purpose | Illustrative value | Validation rule |
|---|---|---|---|
| file_id | Stable identifier used by every link | F-000731 | Unique; never reused after deletion |
| sha256 and byte_size | Detect changes, duplicates and truncation | 64-character hex digest; 2,481,920 bytes | Recomputed on the delivered file and must match |
| media_type and page_count | Tells the loader how to read it and how many pages to expect | application/pdf; 4 pages | Declared type matches file signature |
| source_system and source_file_ref | Where the file came from | Claims portal; upload record 88231 | Resolves in the source export manifest |
| container_id and relative_path | Archive or folder that held it | batch_2026_03.zip; claims/1043/ | Container exists in the register |
| created_at and uploaded_at | When the file was made and when it reached the system | 2026-03-02 and 2026-03-04 | uploaded_at not before created_at |
| version_of and version_no | Chain of replacements for the same logical document | Supersedes F-000702; version 2 | No cycles; one latest version per chain |
| redaction_state | Whether content was masked and how | Faces and plate numbers masked in image | Set for every file; method recorded |
The link record: one row per form-to-file relationship
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.
| Field | Purpose | Illustrative value | Validation rule |
|---|---|---|---|
| link_id, form_id and field_path | Which form and which field the file belongs to | L-5120; WC-1043; section_3.proof_of_purchase | field_path exists in the form type's definition |
| file_id | The file in the register, or empty when expected but absent | F-000731 | Present in register, or link state set to a missing state |
| relation | What the file does for the form | supports, required_by, supersedes, derived_from, referenced_in_text | From a fixed list |
| required | Whether the form type requires this file | true for proof of purchase | Derived from the form type, not from what arrived |
| link_origin | How the link was established | system_link, filename_match, text_reference, manual_review | Inferred links carry a reviewer and date |
| valid_from and decision_ref | When the link applied and which decision used it | 2026-03-04; adjudication record A-2210 | Decision date falls within the link's validity |
| link_state | Result of the missing file audit | present_verified | One 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?"
The missing file audit: nine states every expected link can be in
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
| Link state | How it is detected | Effect on the example | Action |
|---|---|---|---|
| present_verified | File in register, hash matches, opens, linked by the system | Usable | None |
| hash_mismatch | Delivered bytes differ from the recorded sha256 | Unsafe: content may have changed | Re-pull from source or exclude |
| wrong_parent | Hash or content matches a file linked to another form | Misleading evidence | Fix the link; review any labels built on it |
| expected_not_linked | Form type requires it, no link row exists | Answer may be unsupported | Search source; else mark missing |
| referenced_not_found | Form text or a cid: reference points to a file that is absent | Context gap | Recover or flag with reason |
| unreadable | File present but corrupt, encrypted or zero pages | Evidence unavailable | Re-export or exclude |
| redacted_decisive | Masking removed the region the answer depends on | Answer cannot be checked | Relabel or exclude from evaluation |
| superseded_only | Only an older version present; the decision used a later one | Wrong version | Recover latest; else exclude |
| orphan_file | File in register with no link to any form | Not harmful alone; may hide a broken link | Trace 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.
| Failing item (illustrative) | Check it fails | Why it matters | Fix |
|---|---|---|---|
| WC-1088 links invoice F-000731, already required evidence for WC-1043 | Shared required evidence | Both claims appear supported by one purchase | Trace the real invoice; mark the other link wrong_parent |
| Photo link created by filename match with no reviewer | Inferred link review | Filename collisions are common in batch uploads | Review or downgrade to unverified |
| Decision cites report version 1; version 2 uploaded before the decision | Version at decision date | The label may describe a document the adjuster did not use | Re-anchor to version 2 or exclude |
| Anchor on page 5 of a 4-page file | Anchor opens to a region | The evidence pointer is broken | Recompute 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.