Chapter 5

LLMs & Transformers

The attention revolution — from sequence models to large language models that read building codes, draft reports, and assist design review

10
Sections
8
Interactive Demos
~45 min
Read Time
6
CE Applications

Civil Engineering Focus

LLMs are transforming how civil engineers work — from auto-generating inspection reports and parsing building codes to answering geotechnical queries and reviewing structural calculations. This chapter teaches the fundamentals through real CE applications.

Report Generation Code Compliance Design Review Hydrology Analysis Document Search Sensor Data Narration

Real CE Applications You'll Build Understanding Of

Inspection Report Drafting

LLMs parse inspection photos + sensor data to draft bridge condition reports in FHWA format, saving 60% of documentation time.

Building Code Q&A

RAG over ACI 318, ASCE 7, and IBC allows instant retrieval of relevant code clauses with exact section references.

Hydrology Log Analysis

Sequence models on gauge station time series predict flood peaks, baseflow separation, and aquifer recharge patterns.

Specification Review

BERT-based models flag inconsistencies in structural specs: mismatched rebar sizes, conflicting load cases, missing code references.

Site Communication

GPT generates RFI (Request for Information) drafts, meeting minutes from voice notes, and daily progress reports from field entries.

Geotechnical Data Narration

Transform boring logs, SPT values, and lab results into narrative soil reports with classification per USCS and bearing capacity assessments.

5.1
Sequence Models & RNNs
Sequential data in CE — time-series from sensors, water level gauges, and why order matters for structural monitoring.
RNNLSTMtime-series
5.2
The Attention Mechanism
Learning what to focus on — like an engineer prioritizing the critical load path or the weakest structural element.
attentionQKVweights
5.3
Transformer Architecture
"Attention Is All You Need" — multi-head attention, positional encoding, and the encoder-decoder that powers modern AI.
transformermulti-headencoder-decoder
5.4
BERT & Encoder Models
Bidirectional understanding — classify CE documents, extract entities from specs, understand context in both directions.
BERTclassificationNER
5.5
GPT & Decoder Models
Text generation — how GPT predicts the next word to draft reports, RFIs, and technical summaries for engineers.
GPTgenerationautoregressive
5.6
Tokenization & Embeddings
How text becomes numbers — breaking "prestressed concrete beam" into tokens and mapping them to meaningful vectors.
tokensembeddingsBPE
5.7
Prompt Engineering
Getting the best from LLMs — zero-shot, few-shot, chain-of-thought prompts for soil classification, load calcs, and specs.
promptsfew-shotCoT
5.8
RAG & Knowledge Retrieval
Grounding LLMs in facts — Retrieval Augmented Generation over building codes, geotech manuals, and design standards.
RAGretrievalcodes
5.9
LLM Limitations & Hallucinations
Why you can't blindly trust AI — hallucinated rebar sizes, invented code sections, and critical safety risks in CE.
safetyhallucinationbias
5.10
CE Case Study: AI-Assisted Design Review
Full pipeline — LLM + RAG reviewing a structural design package against ACI 318, flagging non-compliances automatically.
case studydesign reviewACI