Inferensys

Prompt

Bill of Materials Extraction Prompt

A practical prompt playbook for using Bill of Materials Extraction Prompt in production AI workflows.
Operations team reviewing AI workflow automation on laptop, workflow builder visible, casual office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, the ideal user, required context, and the boundaries where this prompt should not be applied.

This prompt is designed for manufacturing and integration engineers who need to convert unstructured Bill of Materials (BOM) text into a strict, typed JSON schema. The core job-to-be-done is building a reliable data pipeline that ingests BOMs from spreadsheets, legacy system exports, or technical specification documents and produces records safe for downstream PLM, ERP, or MRP systems. The ideal user is an engineer who understands BOM structure—parent-child assembly hierarchies, phantom assemblies, reference designators, and the distinction between a missing field and a field that is genuinely empty—and needs a prompt that enforces these distinctions programmatically rather than relying on post-processing cleanup.

Use this prompt when you have unstructured or semi-structured BOM text and need a predictable extraction contract. It handles the complexity that breaks naive extraction: a part number that appears in multiple assemblies with different quantities, a reference designator that applies to some instances but not others, a phantom assembly that should be flattened into its parent, and optional fields like revision or unit of measure that may be absent from the source. The prompt is built to produce output that can pass a JSON Schema validator before insertion into a database, with explicit null handling for fields the source does not provide and empty-string handling for fields the source provides but leaves blank. This distinction matters because downstream systems often treat a missing field as an error and an empty field as valid data.

Do not use this prompt for generating new BOMs, suggesting alternative parts, or performing design validation. It is an extraction and normalization tool only—it reads what exists and structures it. It will not catch engineering errors like a part number that does not exist in your master data or a quantity that violates assembly rules. Those checks belong in application-layer validation after extraction. Do not use this prompt when the source text is too ambiguous to resolve without domain expertise; if a human engineer cannot determine the parent-child relationship from the text, the model will guess, and guessing in a manufacturing pipeline creates costly errors. For high-stakes BOMs where an extraction error could cause a production line stoppage, always route low-confidence extractions to a human review queue and log the original source text alongside the extracted record for auditability.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works and where it does not. Use these cards to decide if the Bill of Materials Extraction Prompt is the right tool for your manufacturing data pipeline.

01

Good Fit: Structured BOM Text

Use when: Input is semi-structured BOM text with consistent part number patterns, quantity columns, and reference designators. Guardrail: Validate that the input contains at least two of the required fields before invoking extraction.

02

Bad Fit: Scanned Blueprints

Avoid when: Input is a scanned image, handwritten BOM, or blueprint without OCR preprocessing. Guardrail: Route image-based BOMs through a document intelligence pipeline first; this prompt expects pre-extracted text.

03

Required Inputs

Risk: Missing parent-child hierarchy context causes flat extraction that loses assembly structure. Guardrail: Always provide the full BOM text block including level indicators, indentation, or item numbering that signals hierarchy.

04

Operational Risk: Phantom Assemblies

Risk: Phantom assemblies extracted as physical parts create inventory discrepancies and ordering errors. Guardrail: Include a phantom flag field in the output schema and validate against a known phantom part list before ingestion.

05

Bad Fit: Unstructured Narratives

Avoid when: BOM data is embedded in prose descriptions, emails, or meeting notes without tabular structure. Guardrail: Use a relationship extraction prompt first to isolate part references, then apply this prompt for structured output.

06

Operational Risk: Null Field Confusion

Risk: Missing optional fields like reference designators treated as errors rather than valid nulls. Guardrail: Define explicit null vs. empty vs. not-applicable semantics in the output schema and validate against expected null patterns.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready template for extracting a structured Bill of Materials from unstructured text, ready for adaptation with your specific fields and constraints.

The following prompt template is designed to extract a structured Bill of Materials (BOM) from raw text. It instructs the model to identify parts, their hierarchical relationships, quantities, units of measure, and revision data while explicitly handling null fields for optional attributes like reference designators. The template uses square-bracket placeholders that you must replace with your specific input data, output schema requirements, and operational constraints before use.

text
You are a manufacturing data extraction system. Your task is to parse the provided text and output a structured Bill of Materials (BOM) as a JSON object.

## Input Text
[INPUT]

## Output Schema
Produce a JSON object conforming to this exact structure. Do not include any text outside the JSON object.
{
  "bom_name": "string | null",
  "parts": [
    {
      "part_number": "string",
      "description": "string",
      "quantity": "number",
      "unit_of_measure": "string (e.g., EA, M, KG, L)",
      "revision": "string | null",
      "reference_designators": ["string"] | null,
      "parent_part_number": "string | null",
      "is_phantom_assembly": "boolean"
    }
  ]
}

## Extraction Rules
1.  **Hierarchy:** Use `parent_part_number` to link a child part to its immediate assembly. The top-level assembly should have a `null` parent.
2.  **Phantom Assemblies:** If a sub-assembly is described as transient or not stocked, set `is_phantom_assembly` to `true`. Otherwise, `false`.
3.  **Null Handling:** If a field like `revision` or `reference_designators` is not present in the text, set its value to `null`. Do not hallucinate values.
4.  **Quantity:** Extract the numeric quantity. If a quantity is described as "AR" (As Required), set the value to `-1`.
5.  **Unit Normalization:** Normalize common units to a standard abbreviation (e.g., "pieces" -> "EA", "kilograms" -> "KG").

## Constraints
[CONSTRAINTS]

## Examples
[EXAMPLES]

To adapt this template, replace the placeholders with your concrete data. [INPUT] should be your raw BOM text. [CONSTRAINTS] can be used to add domain-specific rules, such as "Ignore parts with a 'DEPRECATED' flag" or "Map all vendor names to their three-letter codes." The [EXAMPLES] placeholder is critical for teaching the model the desired behavior for edge cases like phantom assemblies or "AR" quantities. Start with 2-3 few-shot examples that pair a text snippet with its correct JSON output.

Before deploying this prompt into a production pipeline, you must add a validation layer. The model's JSON output should be validated against the defined schema to catch missing required fields or type errors. For high-stakes manufacturing data, implement a human review step for any record where a required field like part_number is null or where the quantity is -1, flagging it for manual clarification. This prompt is a starting point; its reliability will depend on the clarity of your input text and the quality of your few-shot examples.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Bill of Materials extraction prompt. Each placeholder must be populated before the prompt is sent to the model. Validation notes describe how to check input quality before execution.

PlaceholderPurposeExampleValidation Notes

[BOM_TEXT]

Raw unstructured bill of materials text to extract fields from

ASSY, BRACKET, SUPPORT DWG NO: 17P2W123 FIND NO 1: .BRACKET, ANGLE QTY: 2 U/M: EA REV: C

Check string length > 0. Reject if empty. Warn if < 50 chars as likely incomplete. Strip null bytes before passing to model.

[OUTPUT_SCHEMA]

JSON schema definition the model must conform to for every extracted record

{"type": "object", "properties": {"part_number": {"type": "string"}, "description": {"type": "string"}, "quantity": {"type": "number"}, "unit_of_measure": {"type": "string"}, "revision": {"type": ["string", "null"]}, "parent_assembly": {"type": ["string", "null"]}, "reference_designator": {"type": ["string", "null"]}, "phantom_flag": {"type": "boolean"}}, "required": ["part_number", "description", "quantity", "unit_of_measure"]}

Validate schema is parseable JSON. Confirm required fields match downstream ingestion contract. Reject if schema allows additionalProperties: true without explicit intent.

[HIERARCHY_DELIMITER]

Character or string that separates assembly levels in the BOM text

"|" or "." or "->"

Must be a non-empty string. Default to period if not provided. Warn if delimiter appears in part numbers as this will cause false splits. Escape regex-special characters before use in parsing.

[NULL_REPRESENTATION]

Token or pattern indicating an intentionally empty field in source text

"N/A" or "—" or "REF"

Provide as string array if multiple tokens used. Check that null tokens do not collide with valid part number prefixes. Log warning if null token appears in a required field position.

[UNIT_NORMALIZATION_MAP]

Mapping from source unit abbreviations to canonical forms for downstream systems

{"EA": "EACH", "FT": "FEET", "IN": "INCHES", "LB": "POUNDS"}

Validate map is valid JSON object. Check for duplicate canonical values. Ensure all expected source units are covered. Reject if map is empty when unit_of_measure is a required output field.

[PHANTOM_ASSEMBLY_INDICATORS]

Keywords or patterns that signal a phantom assembly in the BOM hierarchy

["PHANTOM", "TRANSIENT", "KIT", "—"]

Provide as string array. Case-insensitive matching recommended. Validate no overlap with valid part number prefixes. Log count of matched phantoms for audit trail.

[MAX_HIERARCHY_DEPTH]

Maximum allowed nesting depth for parent-child BOM relationships

10

Must be positive integer. Reject values > 50 to prevent runaway recursion. Default to 10 if not provided. Use to truncate or flag excessively deep BOM structures before extraction.

[REQUIRED_FIELDS_OVERRIDE]

Additional fields to treat as required beyond the base schema for this extraction run

["revision", "reference_designator"]

Must be array of strings matching OUTPUT_SCHEMA property names. Validate no field is in both required and optional lists. Merge with base schema required list before validation. Empty array is valid.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Bill of Materials extraction prompt into a reliable application pipeline with validation, retries, and human review.

The Bill of Materials extraction prompt is designed to sit inside a structured ingestion pipeline, not as a standalone chat interaction. The typical integration pattern is: receive raw BOM text from a file upload, ERP export, or API payload; assemble the prompt with the text inserted into the [BOM_TEXT] placeholder; send the request to the model; validate the returned JSON against the expected schema; and route the output to a downstream system or a human review queue. Because BOM data feeds directly into procurement, inventory, and production planning systems, the extraction pipeline must treat every field as potentially wrong until validated. The prompt itself handles null fields, parent-child hierarchy assembly, and phantom part detection, but the application layer owns schema enforcement, confidence thresholding, and the decision to escalate.

Validation and schema enforcement. Before any extracted record reaches a downstream system, validate the model's output against a strict JSON schema. Required fields such as part_number, description, and quantity must be present and non-null for every line item. Optional fields like reference_designator and revision can be null, but their types must match the expected schema (string or null, not an empty object or a number). Use a JSON Schema validator at the application layer—do not rely on the model to self-correct without a validation gate. If validation fails, capture the specific schema errors and feed them into a repair prompt or a retry loop. For BOM extraction, common validation failures include missing unit_of_measure on child items, malformed parent_part_number references that don't match any item in the extracted list, and quantity fields that are strings instead of numbers. Your validator should also check referential integrity: every parent_part_number value must resolve to a part_number present in the same BOM, and top-level assemblies should have parent_part_number set to null.

Retry and repair strategy. When validation fails, implement a two-stage recovery pattern. First, send the original BOM text plus the validation error messages back to the model with a repair instruction: 'The previous extraction failed schema validation with the following errors. Return a corrected JSON object that satisfies the schema.' This repair prompt should include the full schema definition and the specific field paths that failed. If the repair attempt succeeds validation, proceed. If it fails again, or if the model returns low confidence on critical fields like part_number or quantity, escalate to a human review queue. Do not retry more than twice—beyond two attempts, the failure mode is usually ambiguous source text that requires human judgment, not a better prompt. Log every extraction attempt, validation result, and repair outcome for auditability. For high-volume BOM ingestion, track extraction success rates by supplier or source format to identify patterns that need prompt tuning or preprocessing.

Model choice and performance considerations. This prompt works best with models that have strong JSON mode or structured output capabilities. Use a model that supports guaranteed schema adherence (such as GPT-4 with structured outputs or Claude with tool-use mode) rather than relying on prompt-level format instructions alone. The BOM extraction task benefits from models with large context windows when processing multi-level assemblies with dozens of line items. For cost-sensitive pipelines, consider routing simple flat BOMs (no parent-child hierarchy) to a smaller, faster model and reserving the larger model for deeply nested BOMs with phantom assemblies. Always set temperature to 0 or near-zero for extraction tasks—variability in part numbers or quantities is a defect, not a feature. If your pipeline processes BOMs in batch, implement rate limiting and exponential backoff to handle API throttling without data loss.

Human review integration. Build a review queue for records that fail validation after retries, have low confidence scores on safety-critical fields, or contain phantom assembly references that the model flagged but couldn't fully resolve. The review interface should display the original BOM text alongside the extracted JSON, with validation errors and confidence flags highlighted. Reviewers should be able to correct fields, approve the extraction, or reject the record and flag the source text as unparseable. Track review decisions to build a feedback dataset for future prompt improvements or fine-tuning. For regulated manufacturing environments, require human approval on every BOM before it enters the production system—the prompt and validation pipeline reduce review time, but they don't eliminate the need for sign-off when part errors have safety or compliance consequences.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape, types, and validation rules for the JSON object the model must return. Use this contract to build a downstream parser that rejects malformed or incomplete payloads before they enter your system of record.

Field or ElementType or FormatRequiredValidation Rule

bom_id

string

Must match pattern ^BOM-[A-Z0-9]{6,12}$. Reject if missing or malformed.

bom_name

string

Must be non-empty string with length between 1 and 200 characters. Trim whitespace before validation.

revision

string

Must match pattern ^[A-Z]{1,2}$ or ^[0-9]{1,3}.[0-9]{1,3}$. Reject if revision field is present but empty.

items

array of objects

Must be a non-empty array. Each element must conform to the item schema below. Reject if array is missing or empty.

items[].part_number

string

Must be non-empty string. If the source text contains a part number, it must be extracted exactly as written. Reject if missing.

items[].description

string

Must be non-empty string with length between 1 and 500 characters. Reject if missing or whitespace-only.

items[].quantity

number

Must be a positive number greater than 0. Reject if negative, zero, or non-numeric. Accept integers and decimals.

items[].unit_of_measure

string

Must be a non-empty string. Normalize to uppercase. Reject if missing. Common values: EA, M, KG, L, FT, IN.

items[].revision

string or null

If present, must match ^[A-Z]{1,2}$ or ^[0-9]{1,3}.[0-9]{1,3}$. Set to null only when the source text explicitly states no revision or the field is absent.

items[].reference_designators

array of strings or null

If present, must be an array of non-empty strings. Set to null only for phantom assemblies or when source text has no reference designators. Reject if array contains empty strings.

items[].parent_part_number

string or null

If present, must be a non-empty string matching the part_number of another item in the BOM. Set to null for top-level items. Reject if parent_part_number references a non-existent part_number.

items[].phantom_assembly

boolean

Must be true or false. Default to false if not specified. Set to true only when the source text explicitly identifies the item as a phantom or transient assembly.

extraction_confidence

object

Must contain a field-level confidence map. Each extracted field must have a confidence score between 0.0 and 1.0. Reject if any required field has a confidence below 0.5 without a null_handling note.

extraction_confidence.null_handling

array of strings

If present, each entry must describe why a field was set to null. Format: 'FIELD_NAME: reason for null assignment'. Reject if a null field has no corresponding entry.

PRACTICAL GUARDRAILS

Common Failure Modes

Bill of Materials extraction fails in predictable ways when the model encounters ambiguous part references, implicit hierarchies, or missing optional fields. These cards cover the most common production failure modes and the guardrails that catch them before bad data reaches downstream systems.

01

Phantom Assembly Hallucination

What to watch: The model invents a parent-child relationship or a phantom assembly number that does not exist in the source text. This happens when the BOM text implies a grouping but does not explicitly state it. Guardrail: Require explicit parent reference in the source span for every assembly relationship. Add a validation step that rejects any parent part number not found verbatim in the input text.

02

Reference Designator Collapse

What to watch: Multiple reference designators (e.g., R1, R2, R3) get collapsed into a single line item or a single designator is incorrectly expanded across multiple parts. Guardrail: Enforce a strict one-to-one or one-to-many mapping rule in the output schema. Validate that each designator string is a discrete, parseable value and that the count of designators matches the quantity field when applicable.

03

Unit of Measure Drift

What to watch: The model normalizes units incorrectly—converting 'each' to 'pcs' or 'feet' to 'inches' without explicit instruction—or leaves the UOM field null when the source implies a default. Guardrail: Provide an explicit unit mapping table in the prompt. If the source unit is ambiguous or missing, flag the field with a confidence score of 'low' and route to a human review queue rather than guessing.

04

Revision Field Contamination

What to watch: The model copies the parent assembly revision into every child component, or pulls a revision from a nearby but unrelated part number. Guardrail: Instruct the model to extract revision only when it is unambiguously paired with a specific part number in the source text. Post-extraction, validate that no two distinct part numbers share the same revision unless explicitly stated.

05

Quantity Field Type Coercion

What to watch: The model outputs a string like '2-3' or 'AR' (as required) in a numeric quantity field, or coerces a fractional quantity into an integer. Guardrail: Define the quantity field as a strict numeric type with an optional unitless string fallback for non-numeric expressions. Add a post-extraction type check that rejects any non-numeric value in the primary quantity field and routes it for manual normalization.

06

Implicit Indenture Level Confusion

What to watch: The model misinterprets indentation or numbering in the source text, placing a sub-component at the wrong level of the BOM hierarchy. Guardrail: If the source format uses indentation or numbering for hierarchy, include explicit parsing rules in the prompt. Add a structural validator that checks for orphaned children (components with a parent reference that does not exist in the output) and circular parent-child loops.

IMPLEMENTATION TABLE

Evaluation Rubric

Use this rubric to evaluate the quality of extracted Bill of Materials data before integrating it into downstream manufacturing systems. Each criterion targets a specific failure mode common in BOM extraction.

CriterionPass StandardFailure SignalTest Method

Part Number Presence

Every line item with a non-null [PART_NUMBER] field contains a value matching the source text pattern.

A line item is returned with a null or empty [PART_NUMBER] where the source text clearly contains an identifier.

Parse the output JSON. For each item in the line_items array, assert [PART_NUMBER] is not null when a regex match for [A-Z0-9-]{5,} exists in the corresponding source span.

Quantity Type Safety

All [QUANTITY] fields are strictly numeric (integer or float) and greater than zero.

A [QUANTITY] field contains a string like 'several', 'as required', or a negative number.

Validate the output schema. Assert typeof item[QUANTITY] === 'number' and item[QUANTITY] > 0 for every item. Fail the test if any item fails this check.

Parent-Child Hierarchy Integrity

Every child item's [PARENT_PART_NUMBER] matches the [PART_NUMBER] of another item in the same output, or is explicitly null for top-level items.

An orphaned child item references a [PARENT_PART_NUMBER] that does not exist in the extracted list.

Build a set of all extracted [PART_NUMBER] values. For each item where [PARENT_PART_NUMBER] is not null, assert that the value exists in the set.

Unit of Measure Enum Adherence

All [UNIT_OF_MEASURE] values match a predefined enum: EA, IN, FT, MM, CM, M, KG, G, LB, OZ, L, ML, SET, or null.

A [UNIT_OF_MEASURE] field contains a free-text string like 'a few', 'tube', or 'pack' that is not in the allowed enum.

Validate the output against the JSON Schema enum constraint for [UNIT_OF_MEASURE]. Flag any value not in the allowed list or not null.

Reference Designator Null Handling

The [REFERENCE_DESIGNATORS] field is an array of strings or null. It is never an empty array [].

An item has an empty array [] for [REFERENCE_DESIGNATORS] instead of null, causing downstream ingestion ambiguity.

Assert item[REFERENCE_DESIGNATORS] === null || (Array.isArray(item[REFERENCE_DESIGNATORS]) && item[REFERENCE_DESIGNATORS].length > 0). Fail if an empty array is found.

Revision Format Consistency

All non-null [REVISION] fields match a consistent pattern (e.g., a single uppercase letter or a digit).

A [REVISION] field contains a full date string, a descriptive phrase like 'latest', or mixed formatting across items.

Apply a regex pattern (e.g., ^[A-Z]$|^\d+$) to all non-null [REVISION] fields. Calculate the pass rate; fail if less than 100% of non-null values match.

Phantom Assembly Flag Accuracy

The [IS_PHANTOM] boolean is true only when the source text explicitly describes the item as a transient or non-stocked assembly.

A line item is flagged as true for [IS_PHANTOM] when the source text describes a standard sub-assembly with its own part number.

Manually review a golden dataset of 20 BOMs with known phantom assemblies. Assert the model's [IS_PHANTOM] flag matches the ground truth label with >95% accuracy.

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a frontier model (GPT-4o, Claude 3.5 Sonnet) and minimal post-processing. Focus on getting the schema shape right before adding validation layers. Remove the revision and parent-child hierarchy fields if you only need flat BOM lines. Replace [OUTPUT_SCHEMA] with a simplified JSON structure containing only part_number, description, and quantity.

Watch for

  • The model hallucinating part numbers for vaguely described components
  • Missing unit of measure fields silently defaulting to 'EA' without confidence flags
  • Phantom assembly references appearing when the source text mentions subassemblies but provides no child items
  • Format drift when BOM text uses inconsistent delimiters (tabs vs. spaces vs. commas)
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.