| name | few-shot-examples |
| description | Curated few-shot examples for construction AI tasks: classification, extraction, analysis. Domain-specific examples for improved LLM performance. |
Few-Shot Examples for Construction AI
Overview
Curated few-shot examples for construction industry AI tasks. These examples improve LLM performance by providing domain-specific context for classification, extraction, and analysis tasks.
Few-Shot Framework
Example Manager
from dataclasses import dataclass, field
from typing import List, Dict, Any, Optional
import json
import random
@dataclass
class FewShotExample:
input: str
output: str
explanation: Optional[str] = None
tags: List[str] = field(default_factory=list)
difficulty: str = "medium"
source: str = ""
@dataclass
class ExampleSet:
name: str
description: str
task_type: str
examples: List[FewShotExample]
version: str = "1.0"
def get_examples(self, n: int = 3, difficulty: str = None) -> List[FewShotExample]:
"""Get n examples, optionally filtered by difficulty."""
filtered = self.examples
if difficulty:
filtered = [e for e in self.examples if e.difficulty == difficulty]
return filtered[:n]
def get_random_examples(self, n: int = 3) -> List[FewShotExample]:
"""Get n random examples for variety."""
return random.sample(self.examples, min(n, len(self.examples)))
def format_for_prompt(self, n: int = 3) -> str:
"""Format examples for inclusion in prompt."""
examples = self.get_examples(n)
formatted = []
for i, ex in enumerate(examples, 1):
formatted.append(f"Example {i}:")
formatted.append(f"Input: {ex.input}")
formatted.append(f"Output: {ex.output}")
if ex.explanation:
formatted.append(f"Explanation: {ex.explanation}")
formatted.append("")
return "\n".join(formatted)
class ConstructionExampleLibrary:
"""Library of construction-specific few-shot examples."""
def __init__(self):
self.example_sets: Dict[str, ExampleSet] = {}
self._register_defaults()
def register(self, example_set: ExampleSet):
self.example_sets[example_set.name] = example_set
def get(self, name: str) -> Optional[ExampleSet]:
return self.example_sets.get(name)
def _register_defaults(self):
for example_set in DEFAULT_EXAMPLE_SETS:
self.register(example_set)
CSI Classification Examples
CSI_CLASSIFICATION_EXAMPLES = ExampleSet(
name="csi_classification",
description="Examples for classifying line items to CSI MasterFormat",
task_type="classification",
examples=[
FewShotExample(
input="4000 PSI structural concrete for foundations",
output=json.dumps({
"csi_division": "03",
"csi_section": "03 30 00",
"csi_title": "Cast-in-Place Concrete",
"confidence": "high"
}),
explanation="Structural concrete is Division 03, Cast-in-Place section",
tags=["concrete", "structural"],
difficulty="easy"
),
FewShotExample(
input="Grade 60 #5 reinforcing steel",
output=json.dumps({
"csi_division": "03",
"csi_section": "03 20 00",
"csi_title": "Concrete Reinforcing",
"confidence": "high"
}),
explanation="Rebar is in Division 03 under reinforcing, not Division 05 Metals",
tags=["rebar", "concrete"],
difficulty="medium"
),
FewShotExample(
input="8\" CMU block wall with vertical rebar",
output=json.dumps({
"csi_division": "04",
"csi_section": "04 22 00",
"csi_title": ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: ,
: ,
:
}),
explanation=,
tags=[, ],
difficulty=
)
]
)
RFI Classification Examples
RFI_CLASSIFICATION_EXAMPLES = ExampleSet(
name="rfi_classification",
description="Examples for classifying RFI types and urgency",
task_type="classification",
examples=[
FewShotExample(
input="Drawing A-301 shows a door at grid line 5, but the structural drawing S-102 shows a column at the same location. Please clarify.",
output=json.dumps({
"rfi_type": "conflict_clarification",
"disciplines": ["architectural", "structural"],
"urgency": "high",
"impact_areas": ["design", "schedule"],
"suggested_routing": "architect"
}),
explanation="Drawing conflict between disciplines requires urgent resolution",
tags=["conflict", "multi-discipline"],
difficulty="medium"
),
FewShotExample(
input="Specification section 09 91 00 calls for Benjamin Moore paint, but we would like to submit Sherwin-Williams as an equal. Is this acceptable?",
output=json.dumps({
"rfi_type": "substitution_request",
"disciplines": ["architectural"],
"urgency": "low",
"impact_areas": ["cost"],
"suggested_routing": "architect"
}),
explanation="Substitution request is low urgency, cost-driven",
tags=["substitution", "finishes"],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: [, ],
: ,
: [, , ],
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: [],
: ,
: [],
:
}),
explanation=,
tags=[, ],
difficulty=
),
FewShotExample(
=,
output=json.dumps({
: ,
: [, ],
: ,
: [, ],
:
}),
explanation=,
tags=[, , ],
difficulty=
)
]
)
Cost Analysis Examples
COST_ANALYSIS_EXAMPLES = ExampleSet(
name="cost_analysis",
description="Examples for cost analysis and validation",
task_type="analysis",
examples=[
FewShotExample(
input=json.dumps({
"item": "Cast-in-place concrete",
"unit_cost": 850,
"unit": "CY",
"location": "New York City",
"year": 2026
}),
output=json.dumps({
"assessment": "high",
"typical_range": {"low": 400, "high": 700},
"variance_percent": 21.4,
"likely_causes": ["high local labor rates", "difficult access", "small quantity"],
"recommendation": "Review labor productivity assumptions and access conditions"
}),
explanation="NYC concrete costs are high, but $850/CY exceeds typical range",
tags=["concrete", "unit cost", "validation"],
difficulty="medium"
),
FewShotExample(
input=json.dumps({
"item": "Structural steel erection",
"unit_cost": 1200,
"unit": "TON",
"location": ,
:
}),
output=json.dumps({
: ,
: {: , : },
: ,
: [],
:
}),
explanation=,
tags=[, , ],
difficulty=
),
FewShotExample(
=json.dumps({
: ,
: ,
: ,
: ,
:
}),
output=json.dumps({
: ,
: {: , : },
: -,
: [, , ],
:
}),
explanation=,
tags=[, , ],
difficulty=
)
]
)
Schedule Analysis Examples
SCHEDULE_ANALYSIS_EXAMPLES = ExampleSet(
name="schedule_analysis",
description="Examples for schedule analysis and review",
task_type="analysis",
examples=[
FewShotExample(
input=json.dumps({
"activity": "Foundation concrete pour",
"duration": 45,
"duration_unit": "days",
"quantity": 2500,
"quantity_unit": "CY"
}),
output=json.dumps({
"assessment": "duration_appears_long",
"typical_production": "100-150 CY/day",
"expected_duration_range": {"low": 17, "high": 25},
"possible_reasons": ["phased pours", "complex formwork", "cure time included"],
"recommendation": "Review activity scope - may include formwork and curing"
}),
explanation="45 days for 2500 CY seems long unless multiple activities combined",
tags=["concrete", "duration", "validation"],
difficulty="medium"
),
FewShotExample(
input=json.dumps({
"activity": "Steel erection",
"duration": 60,
"duration_unit": "days",
: ,
: ,
: []
}),
output=json.dumps({
: ,
: ,
: {: , : },
: [],
:
}),
explanation=,
tags=[, , ],
difficulty=
),
FewShotExample(
=json.dumps({
: ,
: ,
: -,
:
}),
output=json.dumps({
: ,
: ,
: ,
: ,
:
}),
explanation=,
tags=[, , ],
difficulty=
)
]
)
BIM Data Examples
BIM_EXTRACTION_EXAMPLES = ExampleSet(
name="bim_extraction",
description="Examples for BIM data extraction and interpretation",
task_type="extraction",
examples=[
FewShotExample(
input=json.dumps({
"element_type": "IfcWall",
"properties": {
"Name": "Interior Partition",
"IsExternal": False,
"FireRating": "1 Hour",
"Pset_WallCommon.Width": 0.165,
"BaseQuantities.GrossArea": 45.5,
"BaseQuantities.NetArea": 42.3
}
}),
output=json.dumps({
"classification": "Interior wall",
"fire_rated": True,
"fire_rating": "1 Hour",
"thickness_mm": 165,
"thickness_in": 6.5,
"gross_area_m2": 45.5,
"gross_area_sf": 490,
"net_area_sf": 455,
"opening_deduction_pct": 7.0
}),
explanation="Extract and convert BIM properties to construction quantities",
tags=["wall", "quantities", "ifc"],
difficulty="medium"
),
FewShotExample(
=json.dumps({
: ,
: {
: ,
: ,
: ,
: ,
: ,
:
}
}),
output=json.dumps({
: ,
: ,
: ,
: ,
: ,
:
}),
explanation=,
tags=[, , ],
difficulty=
),
FewShotExample(
=json.dumps({
: ,
: {
: ,
: ,
: ,
: ,
:
}
}),
output=json.dumps({
: ,
: ,
: ,
: ,
: ,
:
}),
explanation=,
tags=[, , ],
difficulty=
)
]
)
Using Examples in Prompts
library = ConstructionExampleLibrary()
csi_examples = library.get("csi_classification")
examples_text = csi_examples.format_for_prompt(n=3)
prompt = f"""Classify the following line items to CSI MasterFormat.
{examples_text}
Now classify these items:
1. Aluminum storefront framing
2. Acoustic ceiling tiles
3. Elevator cab finishes
"""
easy_examples = csi_examples.get_examples(n=2, difficulty="easy")
random_examples = csi_examples.get_random_examples(n=3)
Adding Custom Examples
my_examples = ExampleSet(
name="my_project_classification",
description="Project-specific classification examples",
task_type="classification",
examples=[
FewShotExample(
input="Your specific input",
output="Expected output",
explanation="Why this classification",
tags=["custom"],
difficulty="medium"
)
]
)
library.register(my_examples)
Best Practices
- Diverse Examples: Include examples across difficulty levels
- Edge Cases: Add examples for ambiguous situations
- Explanations: Include reasoning for complex examples
- Regular Updates: Add new examples as edge cases are discovered
- Balance: Mix easy and hard examples to calibrate model
Resources