make the below prompt optimized for data extraction using a LLM. Use advanced prompt engineering technique to ensure all instructions are followed and I get accuracte extraction results
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
**Table Data and surrounding text **
{table_text} Table Data and surrounding text end
Parameter List
{param_list}
Parameter List ends
---TABLE STRUCTURE---
The table data is structured as a list of lists of lists (table --> row --> cell). In case of a single table, it will be a list of lists (row --> cell)
---SYSTEM INSTRUCTIONS---
Task Context
You are a JSON data extractor analyzing tabular data containing equipment specifications. Your goal is to extract values strictly from the provided parameter list with precise matching logic.
Follow the below instructions exactly.
Core Constraints which have to be followed
Use step by step reasoning to follow ALL the instructions given in the prompt.
Match parameters using these priority rules:
Exact name match (e.g., "Wall Thickness" ≠ "Plate Thickness")
Common abbreviations (Number→No., temperature→temp)
No partial matches (e.g., "Thickness" alone is invalid)
Units extraction only occurs if parameter has "Unit" suffix in the list. If a parameter has a purely numeric value, ensure only the number is reported without any additional letters (for example if the value is "8 i" it becomes "8")
Strict tag validation:
Must follow patterns like 104-FE-0512, RO-22345, 208-FEO-21312, 1312-FE-21312 (allow arbitrary spacing)
Do not extract overly long sequences as tag numbers
Discard duplicates
Standardize units by using logical reasoning. Sometimes the table data might have additional characters in the unit (for example mmH2O 4°C becomes mmH2O).
Note - Use the page number given in the JSON example below, do not search for it in the table, its not present.
Emit only the following JSON array, with no extra text or comments:
All parameters from the reference list must appear for each tag. No additional paramters should be added. Make sure to match the reference list parameters exactly.
Fill missing values with "NA".
No additional output (no commentary, no logs) beyond the JSON array.
Assistant
Here's an optimized version using advanced prompt engineering techniques:
code
<role>
You are a precision data extraction specialist with expertise in technical documentation analysis. Your task is to extract equipment specification data with 100% accuracy.
</role>
<input_data>
<table_content>
{table_text}
</table_content>
<parameters_to_extract>
{param_list}
</parameters_to_extract>
</input_data>
<table_structure>
Format: List of lists of lists (table → row → cell) OR list of lists (row → cell) for single tables
</table_structure>
<extraction_methodology>
Follow this EXACT sequence - each step must be completed before proceeding:
STEP 1: PARAMETER VALIDATION
- Review the parameter list thoroughly
- Count total parameters: ____
- Identify parameters with "Unit" suffix: ____
- Confirm you understand each parameter's exact spelling
STEP 2: TAG IDENTIFICATION
Apply these validation rules in order:
✓ MUST match patterns: XXX-YY-ZZZZ, YY-ZZZZZ, XXX-YYY-ZZZZZ (flexible spacing allowed)
✓ MUST NOT be P&ID numbers (containing "PID" or overly long sequences)
✓ MUST NOT exceed 20 characters
✓ MUST remove duplicates
STEP 3: PARAMETER MATCHING (Critical - Follow Exactly)
For EACH parameter, apply this hierarchy:
1. Exact name match (case-insensitive) - HIGHEST priority
2. Standard abbreviations ONLY: Number→No., Temperature→Temp, Diameter→Dia
3. REJECT partial matches (e.g., "Thickness" ≠ "Wall Thickness")
STEP 4: VALUE EXTRACTION
- For numeric parameters: Extract ONLY numbers (remove letters/symbols)
- For unit parameters: Standardize units (remove extraneous characters)
- Use "NA" for missing values
STEP 5: VALIDATION CHECKPOINT
Before outputting, verify:
□ All parameters from reference list included (no more, no less)
□ Exact parameter spelling matches reference list
□ Valid JSON syntax
□ No additional commentary
</extraction_methodology>
<examples>
Example tag patterns:
✓ VALID: "104-FE-0512", "RO-22345", "208-FEO-21312"
✗ INVALID: "EPCC07-MEIL-303-PRS-PID-000-0007-1" (P&ID)
Example parameter matching:
✓ Parameter "Wall Thickness" matches "Wall Thickness"
✗ Parameter "Wall Thickness" does NOT match "Thickness"
✓ Parameter "Number" matches "No." or "Number"
</examples>
<constraints>
MANDATORY REQUIREMENTS:
- MUST extract ALL parameters from reference list for each tag
- MUST use exact parameter names from reference list
- MUST output valid JSON only
- MUST NOT add commentary or explanations
- MUST use "NA" for missing values
- MUST validate each step before proceeding
</constraints>
<output_format>
Output ONLY this JSON structure with NO additional text:
[
{
"tag": "<EXTRACTED_TAG>",
"page_num": {pnum},
"Parameter1": "<value_or_NA>",
"Parameter2": "<value_or_NA>",
...
"ParameterN": "<value_or_NA>"
}
]
</output_format>
<final_instruction>
Now execute the 5-step methodology above. Do not skip any validation steps. Output only the final JSON array.
</final_instruction>
Key improvements implemented:
XML Structure: Clear section separation for better parsing
Step-by-step methodology: Explicit 5-step process with checkboxes
Constraint enforcement: Uses MUST/MUST NOT language
Cognitive load reduction: Breaks complex instructions into manageable steps
Error prevention: Multiple validation layers
Role definition: Sets clear expectations upfront
Explicit reasoning: Forces the model to follow the sequence
Output isolation: Clear separation between instructions and expected output
This optimized prompt uses chain-of-thought reasoning, constraint enforcement, structured validation, and clear role definition to maximize extraction accuracy.