arXiv is now an independent nonprofit! Learn more
License: arXiv.org perpetual non-exclusive license
arXiv:2609.11360v1 [cs.CV] 10 Sep 2026
††highlights: Propose R4Tun for label-free adaptation of tunnel lining segmentation pipelines. Integrate memory, state, and knowledge for multi-agent parameter tuning. Achieve mIoU of 0.784–0.796 on near-reference tunnel subsets across different LLMs. Raise overall mIoU from 0.18 to 0.43–0.48 without labels or retraining. Enable controlled cross-LLM adaptation without retraining the expert pipeline.

R4Tun: LLM-guided adaptive segmental tunnel lining segmentation in point clouds

Xinghui Tao    Zehao Ye    Guangming Wang gw462@cam.ac.uk    Jelena Ninić    Brian Sheil organization=Construction Engineering, University of Cambridge, addressline=Trumpington Street, city=Cambridge, postcode=CB2 1PZ, country=United Kingdom organization=Department of Engineering, Durham University, addressline=Stockton Road, city=Durham, postcode=DH1 3LE, country=United Kingdom
September 10, 2026
Abstract

Automated inspection of segmental tunnel linings requires adaptive segmentation from 3D point clouds, yet expert-tuned pipelines often degrade when tunnel conditions vary. This paper presents R4Tun, a large language model (LLM)-driven adaptation framework that extends an expert-designed pipeline (SAM4Tun) with bounded parameter tuning informed by structured context: memory (mm), state (ss), and knowledge (kk). Evaluated on 30 selected Seg2Tunnel subsets (13 regular, 17 complex) across three LLMs, the full m+s+km+s+k design raised mean Intersection-over-Union (mIoU) from 0.18 to 0.43–0.48 and overall accuracy (OA) from 0.42 to 0.59–0.65 relative to the static SAM4Tun baseline, with the near-reference regular (staggered) subsets reaching mIoU 0.784–0.796 across LLMs. Across 270 (30 tunnels ×\times 3 different LLMs ×\times 3 context settings) runs, the LLMs showed similar parameter-adjustment trends (with overlapping 95% CIs on mean gains) and consistently adjusted a shared set of critical parameters. These results support R4Tun as a controlled, label-free, cross-LLM adaptation mechanism in the tested SAM4Tun–Seg2Tunnel setting, demonstrating consistent accuracy gains; we position R4Tun as a mechanism contribution rather than a deployable final-inspection system, in which each bounded parameter change is auditable via logged rationales.

keywords
Segmental tunnel lining ,Point cloud segmentation ,Tunnel inspection ,Large language models ,Parameter adaptation ,Multi-agent systems
††credit: Conceptualization, Methodology, Software, Writing – original draft††credit: Supervision, Writing – review & editing††credit: Supervision, Writing – review & editing††credit: Supervision, Funding acquisition, Project administration††corresponding: Corresponding author

1 Introduction

Automated inspection of segmental tunnel linings is required to support structural health assessment and long-term operational safety, given the scale, frequency, and access constraints of modern tunnel networks [2]. In practice, engineers routinely encounter projects in which tunnel geometry, lining properties, and data acquisition settings vary [46, 53]. Furthermore, although modern laser scanning enables high-fidelity tunnel capture, the resulting measurements often contain mixed structural elements, occlusions, and noise, making direct extraction of lining components challenging [21, 40]. Consequently, segmentation methods need to be adaptive enough to handle this complexity and variability [30, 41].

Refer to caption
Figure 1: Segmentation approaches arranged by their adaptation mechanisms. Expert-guided, LLM-driven methods can extend foundation-model pipelines by adding parameter adaptation with structured context and encoded expert knowledge. In this work, we test one such mechanism (R4Tun) while keeping the underlying SAM4Tun pipeline fixed.

Existing tunnel point-cloud segmentation methods are grouped into three broad categories: feature engineering, deep learning and foundation-model pipelines (see Fig. 1 and Section 2). Feature engineering rules are interpretable but lack robustness under changed conditions [46]. Supervised deep-learning models generalise through data but require large labelled datasets and periodic retraining, while lacking auditability [11, 7, 42]. Foundation-model pipelines bypass annotation by using models pre-trained on large datasets [3, 22], but remain sensitive to expert-tuned processing parameters. Existing tunnel-segmentation approaches have not yet demonstrated, in a single workflow, both robust adaptation to changed conditions and an auditable adaptation process. Among foundation-model pipelines, SAM4Tun [51] combines point-cloud preprocessing with SAM-based prompting [22] and has shown strong performance under expert tuning. However, the pipeline is highly sensitive to its many processing parameters. When tunnel geometry or scanning conditions depart from the tuning reference, performance can degrade, and identifying which parameters need adjustment can require repeated expert intervention.

Given that recent LLMs can follow multi-step instructions over structured inputs, parameter adaptation can be formulated as a diagnostic task in which the model receives context and proposes bounded adjustments. LLMs have been applied to engineering workflows including chemical synthesis planning [4], multi-agent coordination for complex project tasks [37, 19, 8], and manufacturing decision support [16]. However, these studies do not address parameter adaptation in infrastructure inspection pipelines. In this study, we propose R4Tun, an LLM-guided adaptation system that extends the SAM4Tun pipeline by adjusting stage parameters in response to changing tunnel conditions. The framework provides each agent with structured context m+s+km+s+k (memory, state, and knowledge), from which it produces bounded parameter updates via stepwise prompting. We evaluate whether this contextual information improves segmentation adaptability across both regular and complex tunnels, and whether the resulting adaptation behaviour is consistent across LLMs. To isolate the contribution of the LLM beyond deterministic tuning, we also benchmark R4Tun against a rule-based adaptation derived from the same per-stage knowledge documents.

We position R4Tun as a mechanism contribution rather than a deployable final-inspection system: its strength lies in integrating LLM-driven bounded parameter adaptation with an expert-designed pipeline, with each change auditable through logged rationales. Absolute segmentation accuracy remains bounded by the open-source SAM4Tun ceiling and by the single expert reference used here, as discussed in Section 4.6.

This paper makes the following contributions:

  1. 1.

    A framework design in which LLM agents adapt the parameters of the SAM4Tun pipeline using structured context m+s+km+s+k: memory of the reference configuration, state from intermediate pipeline outputs, and a knowledge document of tunnel category-specific configuration shared across all tunnels.

  2. 2.

    A controlled and auditable adaptation mechanism rather than a deployable final-inspection system, in which each bounded parameter update is accompanied by a logged rationale for post-hoc expert review.

  3. 3.

    Empirical evidence from cumulative ablation across 30 tunnels suggesting that intermediate pipeline state is an important contributor to adaptation, while the knowledge component adds a smaller increment concentrated on the complex category.

  4. 4.

    Cross-LLM evidence showing that three different LLMs (Opus-4.6, GPT-5.4, Gemini-3-Flash) produce overlapping effect ranges and adjust a consistent subset of critical parameters under the same prompt structure.

  5. 5.

    Evidence that deterministic, rule-based adaptation explains part, but not all, of the observed mIoU increase, which is consistent with an additional contribution from the LLM-based adaptation process in the tested setting.

The rest of this paper is organised as follows. Section 2 reviews related work. Section 3 presents methodology, including the R4Tun architecture, dataset, experimental design, and evaluation. Section 4 reports results. Section 5 discusses findings, implications, and limitations. Section 6 concludes.

2 Related work

This study situates R4Tun within tunnel point-cloud segmentation by contrasting (i) feature-engineered methods and supervised deep learning, (ii) foundation-model pipelines that reduce annotation but remain parameter-sensitive, and (iii) LLM reasoning as a way to produce auditable, bounded per-tunnel parameter updates.

Refer to caption
Figure 2: The R4Tun multi-agent architecture for tunnel segmentation. Four blue-boxed stage agents (Stage 1: Unfolding, Stage 2: Denoising, Stage 3: Enhancing, and Stage 4: Segmenting) adapt their stage-specific parameters via LLM reasoning, passing intermediate outputs forward to produce the final segmentation. Arrows indicate the workflow direction from the raw point cloud through intermediate representations to 2D segmentation and 3D reprojection.

2.1 Feature engineering versus deep learning

Tunnel point-cloud segmentation has advanced through two generations of methods, which trade off between auditability and adaptability. Feature-engineering approaches encode domain knowledge into deterministic geometric rules: centreline fitting via RANSAC [14], density-based surface clustering [13], and point-sampled surface processing (e.g., simplification and resampling) [35]. Those methods remain widely used in safety-critical inspection because their logic is explicit and auditable [46]. However, each rule embeds assumptions about tunnel geometry and point-cloud characteristics (diameter, ring spacing, joint pattern, point density), and changing any of these requires manual reconfiguration by a domain expert. Supervised deep-learning methods, such as PointNet++ [36], RandLA-Net [20], Mask3D [39], and TD3D [24], learn features directly from annotated point clouds and can generalise across similar conditions present in the training set. Recent work has also extended tunnel and infrastructure understanding with attention mechanisms: for 3D point clouds, UnrollingNet [54] unfolds the cylindrical surface into a structured 2D representation for attention-based semantic segmentation, and SerialFormer [44] uses transformer-style attention to capture long-range context for point-cloud semantic segmentation; for 2D inspection imagery, TransUNet [25] leverages self-attention within a U-Net-style encoder–decoder for tunnel defect segmentation, and ECA-YOLO [26] augments a YOLO detector with efficient channel attention and tiling to improve multi-defect detection. Yet supervised deep-learning models require large labelled tunnel datasets that remain scarce [42], demand retraining for new tunnel conditions, and provide no mechanism for an engineer to trace or override a segmentation decision [7].

Therefore, for inspection operators, deploying to a new tunnel type requires either re-engineering rules, collecting new training data, or accepting degraded performance without a systematic diagnostic mechanism.

2.2 Foundation-model pipelines

To the best of our knowledge, direct 3D point-cloud segmentation of infrastructure at tunnel scene scale remains an open challenge for current foundation models. Existing 3D foundation models target common object recognition on curated datasets and do not transfer to large, noisy tunnel point clouds [5, 28, 18, 49]. As a result, practical tunnel pipelines often project 3D data into 2D representations to use mature vision foundation models pre-trained on large-scale image datasets, thereby bypassing the annotation bottleneck [6, 15]. SAM [22] performs class-agnostic segmentation from spatial prompts without task-specific training, and extensions such as SAM2 [38] for temporal consistency and SEEM [57] for natural-language-guided segmentation are broadening prompt-based segmentation further. These models have been adopted in infrastructure contexts including crack detection [17, 52] and Scan-to-BIM workflows [43, 34, 50].

For tunnel linings, SAM4Tun [51] combines geometric preprocessing (unfolding, denoising, enhancing) with foundation-model 2D segmentation, achieving strong segmentation without training data. However, this pipeline depends on numerous stage-specific parameters that encode assumptions about the reference tunnel’s diameter, ring length, point density, and joint patterns. When a new tunnel departs from the reference, these parameters become misspecified and the pipeline can degrade without indicating which parameters fail or why. This sensitivity is not unique to SAM4Tun: most multi-stage pipelines that chain domain-specific preprocessing with a foundation model tend to inherit it. While foundation models have reduced reliance on labelled data, they have made the pipeline’s dependence on hand-tuned parameters more explicit, without removing the need for expert parameter tuning.

2.3 LLM reasoning

Recent LLM advances have introduced explicit reasoning capabilities relevant to the parameter-adaptation problem. Reasoning-oriented training [33, 10, 9, 47, 31, 32] produces models capable of decomposing complex problems and performing prompted consistency checks. Chain-of-thought (CoT) reasoning [45, 23] enables step-by-step logical traces. Multi-agent architectures coordinate specialised roles through shared context [19, 37, 8, 56, 55], and context engineering influences reasoning quality through the careful design of information provided to models [48, 29, 1].

In tunnelling segmentation, however, no prior work has applied LLM-based reasoning to a challenge in expert-designed pipelines: re-tuning a parameter-sensitive system to new conditions while preserving the engineer’s ability to inspect and override each decision. We therefore introduce an LLM-based reasoning framework that retunes parameter-sensitive pipelines per tunnel using expert-guided context and a logged rationale for each proposed change. Meanwhile, whether LLM reasoning produces gains beyond what hand-coded rules can deliver from the same knowledge text remains an open question. Our experimental design therefore tests this directly by including a deterministic rule-based adaptation of those documents as a non-LLM control.

3 Methodology

Our methodology defines the tunnel-lining segmentation task, summarises the fixed SAM4Tun pipeline, and specifies the R4Tun adaptation layer (structured context m+s+km+s+k and bounded parameter updates), followed by the dataset, baselines, ablations, metrics, and sensitivity analysis.

3.1 Task definition

The task is semantic segmentation of segmental tunnel linings from terrestrial laser scanning (TLS) point clouds. Given a raw point cloud of a tunnel section, the goal is to assign each point a structural label: background, key segment (K), adjacent segments (B), and standard segments (A), with an additional A4 class for 7-segment complex tunnels. The unit of analysis is a tunnel subset spanning multiple rings selected from the Seg2Tunnel benchmark.

A key limitation is that the fixed configuration of the open-source SAM4Tun achieves an mIoU of 0.27 on regular tunnels, but only 0.04 on complex tunnels whose geometry departs from the tuning reference. As noted above, the pipeline provides no built-in signal indicating which parameters become misspecified.

3.2 R4Tun

Refer to caption
Figure 3: Stage 1: Unfolding. Left: fitted tunnel cross-section used to determine the reference centre and radius for cylindrical unfolding. Centre: 2D panoramic depth map derived from the 3D point cloud. Right: zoomed region of the unfolded map showing radial-distance encoding.

R4Tun supplements the SAM4Tun pipeline [51] with an LLM-guided adaptation layer that adjusts parameters per tunnel without modifying the underlying algorithms (Fig. 2). Given a new tunnel point cloud, a characteriser first extracts raw geometric properties (diameter, density, coordinate ranges; full field list in Appendix 2). Each stage (Stage 1: Unfolding, Stage 2: Denoising, Stage 3: Enhancing, and Stage 4: Segmenting) has a dedicated LLM agent that adapts its parameters. In Stage 4, the adapted prompts are passed to SAM, and the resulting 2D masks are reprojected onto the 3D point cloud without further LLM intervention.

Stage 1: Unfolding (Fig. 3) establishes a cylindrical coordinate system for the tunnel. Similar cylindrical unfolding ideas have been explored for tunnel point-cloud semantic segmentation (e.g., UnrollingNet [54]). It slices the point cloud at regular longitudinal intervals, fits an ellipse to each cross-section via RANSAC [14], and selects the model with the highest inlier support. The per-slice ellipse centres are interpolated into a smooth centreline that defines the cylindrical frame (r,θ,h)(r,\theta,h). The 3D tunnel surface is then projected into a 2D panoramic image in which each pixel encodes the radial distance to the centreline, producing a stable depth representation for downstream filtering and segmentation.

Refer to caption
Figure 4: Stage 2: Denoising. Left: radial-distance distribution used to filter points outside the expected tunnel lining surface. Centre: unfolded 2D depth map after filtering, showing the cleaned point distribution. Right: zoomed region of the denoised map.

Stage 2: Denoising (Fig. 4) removes non-structural artefacts (rails, cables, and scattered points) that would otherwise interfere with segmentation. The algorithm applies grid-based radial-density filtering inspired by the DBSCAN clustering principle [13], grouping points by local density in cylindrical coordinates. Dense, connected regions are retained as tunnel surfaces while isolated points are rejected as noise. A pair of radial masks (RlowR_{\mathrm{low}}, RhighR_{\mathrm{high}}) constrains filtering to the expected tunnel radius, preserving joint boundaries and ring edges while discarding outliers beyond the lining surface. The result is a clean, continuous surface representation suitable for curvature analysis and interpolation in the next stage.

Refer to caption
Figure 5: Stage 3: Enhancing. Left: curvature-guided surface and boundary interpolation along the tunnel lining, showing original sampling, curvature-guided insertion, and progressive three-stage upsampling (shown as three sequential upsampling steps). Centre: unfolded 2D depth map after enhancement, where inserted points improve geometric continuity; the red box highlights a local region of interest. Right: zoomed views of the highlighted region, showing added points and pixel-level interpolation.

Stage 3: Enhancing (Fig. 5) improves geometric continuity and surface completeness before projection into the 2D depth map. Local curvature is estimated on neighbourhood points to guide point insertion: new points are placed between neighbours whose curvature difference is small (smooth panel regions), while high-curvature areas (joint boundaries and ring edges) are preserved intact. A three-stage progressive upsampling scheme inserts additional points at progressively finer resolutions to maintain surface continuity without blurring structural boundaries. Pixel-level interpolation then refines outlier points at joint locations. The enhanced surface is projected into a panoramic depth map that balances smooth panel regions with sharply defined joint boundaries.

Refer to caption
Figure 6: Stage 4: Segmenting. The segmenting stage applies Hough-transform line detection [12] to identify ring boundaries, then constructs template-based prompts and feeds them to SAM [22]. SAM produces 2D segment masks that are reprojected into 3D. K denotes the key segment, B denotes adjacent segments, and A denotes standard segments around the ring.

Stage 4: Segmenting (Fig. 6) combines boundary detection and SAM segmentation into a single workflow. First, a Hough-transform-based detector [12] extracts linear features from the enhanced depth map that correspond to ring joint boundaries. Detected lines are filtered by orientation (oblique, horizontal, vertical) with separate Hough thresholds and merged when closer than a distance tolerance. The confirmed boundaries are then used to construct template-based prompts for key, adjacent, and standard segments, which are passed to SAM [22]. SAM produces 2D segment masks on the panoramic image, which are reprojected into 3D point labels via the stored pixel-to-point mapping from Stage 1.

The pipeline contains 81 tunable processing parameters, spanning geometric defaults, filtering and interpolation settings, and boundary-detection thresholds. All parameters were expert-tuned on a reference tunnel (mIoU = 0.88); full parameter tables are provided in Appendix 1. In this study, the underlying pipeline stages remain fixed across all conditions; only the parameter values change. The SAM4Tun baseline applies this single expert-tuned configuration uniformly to all 30 tunnels without per-tunnel adaptation, serving as the static baseline against which LLM-guided adaptation is measured.

3.3 Agent design

Refer to caption
Figure 7: The left column (a) shows R4Tun stage agent architecture. Each agent maintains a shared and cumulative context that informs an LLM analyst component performing CoT reasoning. The right column (b) shows the five CoT phases: (1) Referencing, (2) Diagnostic inspection, (3) Parameter adaptation, (4) Validation, and (5) JSON output.

Each of the four stage agents is a self-contained unit comprising (i) a context (Section 3.3.1; Fig. 7a) and (ii) a Python analyst that constructs the full LLM prompt and parses the returned JSON. For each agent-driven stage, the analyst assembles a prompt from the current context level, calls one of the selected LLM APIs (Opus-4.6, GPT-5.4, or Gemini-3-Flash) to follow a five-step CoT protocol (Section 3.3.2; Fig. 7b): referencing, diagnostic inspection, parameter adaptation, validation, and JSON output. Each agent returns a single schema-conformant parameter JSON, which the corresponding pipeline stage executes unchanged. A characteriser plugin then extracts statistics from the stage output, updating the cumulative state available to subsequent stages. Each stage’s parameters are adapted from the expert-tuned reference configuration together with this cumulative state; the stage scripts and evaluation code are identical across all ablation conditions, with only the parameter JSONs changing. Because every parameter change is logged alongside a generated textual rationale, engineers can review and, where necessary, override adaptation decisions. A worked example is provided in Appendix 5. After the final segmentation, per-point labels are evaluated against ground truth using mean Intersection over Union (mIoU) as the primary metric.

3.3.1 Context design

Each stage agent receives structured context comprising three components: memory, state and knowledge (Fig. 7a). A worked example of the three components for the denoising agent is given in Appendix 4.

Memory (Appendix 4.1) stores the reference tunnel’s characteristics (a JSON file containing geometry, point density, coordinate ranges, nearest-neighbour distances) alongside the expert-tuned reference parameters. The agent compares the current tunnel’s characteristics against this reference to quantify deviation and adjust its parameters via CoT reasoning (Section 3.3.2). Memory is static: it does not change between stages.

State (Appendix 4.2) captures cumulative geometric and statistical properties after each pipeline stage executes. These JSON summaries are injected into subsequent agents’ prompts, and the state grows as stages execute. Importantly, state alone does not prescribe parameter changes: the numeric summaries of the actual point distribution after upstream processing must be interpreted in the context of parameter semantics and tunnel conditions before they can inform parameter updates.

Knowledge (Appendix 4.3) supplies domain-specific guidance in human-readable markdown documents. Each stage has its own knowledge document covering three types of guidance: (i) cross-tunnel variation, which describes common lining layouts and structural conditions; (ii) parameter notes, which define each tunable parameter, its empirically validated range, and proven defaults; and (iii) diagnostic rules, which provide constrained guidelines for recommended parameter adjustments. Knowledge is authored once and shared across all tunnels.

3.3.2 CoT design

CoT reasoning provides the analytical structure for each agent’s decision-making (Fig. 7b). The agent is prompted to follow a five-step protocol (Algorithm 1). A worked example of the full five-step trace is provided in Appendix 5.

  1. 1.

    Referencing: The agent compares the current tunnel’s characteristics against the stored reference to quantify deviation (e.g., +39%+39\% diameter increase).

  2. 2.

    Diagnostic inspection: The agent attributes the deviation to a plausible cause and identifies which specific tunable parameters are implicated. If signals conflict, the agent is instructed to prioritise State over Memory, as State summarises geometry after upstream processing.

  3. 3.

    Parameter adaptation: The agent proposes updates for the implicated parameters. These updates are instructed to stay within the empirical ranges defined in the Knowledge component.

  4. 4.

    Validation: A self-correction step performs a consistency check to confirm that the proposed values satisfy logical constraints (e.g. a radius lower bound must be smaller than the corresponding upper bound). If a constraint is violated, the value is prompted to move toward to the nearest valid bound. This check-and-correction is executed as an LLM reasoning step, rather than a deterministic software routine, and therefore does not guarantee constraint satisfaction.

  5. 5.

    JSON output: The selected parameters and their reasoning trace are packaged into a single schema-conformant JSON object.

Each stage agent reads the tunnel characteristics and the latest pipeline state to identify deviations and decide which parameters to adjust. Starting from the expert reference value, it computes an updated setting from the post-stage statistics and clips it to the empirically observed range in the knowledge document when needed. This differs from the deterministic rule baseline (Appendix 3), which assigns each tunnel to a discrete category based on raw characteristics and then applies one fixed parameter value per family. By contrast, the LLM diagnoses parameters on the fly, resolves conflicts between live state and static memory, and adapts values continuously from the observed statistics.

Notation for Algorithm 1. CtargetC_{\text{target}} denotes the raw characteristics of the current tunnel, while MM stores the reference configuration (Cref,Pref)(C_{\text{ref}},P_{\text{ref}}). SS is the cumulative pipeline state, and ScurrentS_{\text{current}} is its most recent summary. KK is a shared knowledge document that encodes parameter semantics, per-parameter admissible bounds BB, and cross-parameter constraints RR. The adaptation procedure computes a geometric deviation descriptor Δgeom\Delta_{\text{geom}}, selects an implicated parameter subset PimplicatedP_{\text{implicated}}, proposes an updated parameter map PproposedP_{\text{proposed}} (indexed as Pproposed​[p]P_{\text{proposed}}[p]), and finally returns the schema-formatted JSON object PadaptedP_{\text{adapted}}.

Algorithm 1 LLM-driven Parameter Adaptation via CoT
1: Target tunnel raw characteristics CtargetC_{\text{target}}
2: Memory MM (reference characteristics CrefC_{\text{ref}}, reference parameters PrefP_{\text{ref}})
3: State SS (cumulative pipeline outputs / intermediate summaries)
4: Knowledge KK (parameter semantics, tunable bounds BB, and cross-parameter constraints RR)
5: Adapted stage parameter JSON PadaptedP_{\text{adapted}}
6: Phase 1: Referencing
7: Δgeom←Compare​(Ctarget,Cref)\Delta_{\text{geom}}\leftarrow\text{Compare}(C_{\text{target}},C_{\text{ref}}) ⊳\triangleright Quantify deviation from reference
8: Phase 2: Diagnostic inspection
9: Scurrent←ExtractLatest​(S)S_{\text{current}}\leftarrow\text{ExtractLatest}(S) ⊳\triangleright Most recent stage statistics
10: Reconciliation: If ScurrentS_{\text{current}} conflicts with MM, prioritise ScurrentS_{\text{current}}
11: Pimplicated←IdentifyParameters​(Δgeom,Scurrent,K)P_{\text{implicated}}\leftarrow\text{IdentifyParameters}(\Delta_{\text{geom}},S_{\text{current}},K) ⊳\triangleright Select parameters relevant to observed deviations
12: Phase 3: Parameter adaptation
13: Pproposed←∅P_{\text{proposed}}\leftarrow\emptyset
14: for each parameter p∈Pimplicatedp\in P_{\text{implicated}} do
15:   Pproposed​[p]←Adjust​(p,Δgeom,Scurrent,K)P_{\text{proposed}}[p]\leftarrow\text{Adjust}(p,\Delta_{\text{geom}},S_{\text{current}},K) ⊳\triangleright Propose new value within BB guided by KK
16: end for
17: Phase 4: Validation
18: for each parameter p∈Pproposedp\in P_{\text{proposed}} do
19:   Pproposed​[p]←SelfValidate​(Pproposed​[p],p,K)P_{\text{proposed}}[p]\leftarrow\text{SelfValidate}\big(P_{\text{proposed}}[p],\,p,\,K\big) ⊳\triangleright Execute an LLM internal reasoning step conditioned on KK (semantics, bounds spec BB, constraints RR).
20: end for
21: Phase 5: JSON output
22: Padapted←FormatAsJSON​(Pproposed)P_{\text{adapted}}\leftarrow\text{FormatAsJSON}(P_{\text{proposed}})
23: return PadaptedP_{\text{adapted}}

3.4 Experimental setup

3.4.1 Dataset

We selected 30 tunnel subsets from the Seg2Tunnel benchmark (Table 1). These subsets cover the main variations in segmental tunnel geometry (diameter, ring length, segment count, key-segment layout, and point-density distribution), providing a controlled basis for evaluating adaptation across tunnel categories.

As shown in Fig. 8, staggered and continuous tunnels are grouped as “regular” (n=13n=13): they share the 5.60 m nominal diameter, 1.2 m ring spacing, six segments per ring, and, most importantly, regular patterns of key-segment positions similar to the reference. Complex tunnels (n=17n=17) depart from that reference in multiple coupled ways: nominal inner diameter increases by 34% (5.60 m →\rightarrow 7.50 m), ring length by 50% (1.2 m →\rightarrow 1.8 m), and each ring adds a seventh segment with an interleaved key-segment arrangement that does not repeat ring-to-ring. In addition, off-axis scanning yields non-uniform sampling, partial circumferential coverage, and angle-dependent range and incidence. Together, these differences alter both the geometry visible in the point cloud and the semantic targets the pipeline must recover. Consequently, a fixed parameter set cannot be assumed to transfer from the regular reference; these conditions constitute the primary stress test for whether R4Tun can adapt the same algorithmic pipeline to off-design tunnel conditions. Ground-truth labels are per-point structural class annotations provided by the Seg2Tunnel benchmark; they are used for evaluation only and are not provided to the LLM or pipeline during adaptation.

Refer to caption
Figure 8: Tunnel lining pattern categories. From left to right: regular (staggered) tunnels exhibit a repeating ring-to-ring pattern; regular (continuous) tunnels maintain a fixed segment order around each ring; complex tunnels show no consistent repeating pattern.
Table 1: Dataset properties.
Regular (T1, T2, T3) Complex (T4, T5)
Property Staggered (T1, T2) Continuous (T3)
Inner diameter 5.5 m 5.9 m 7.5 m
Ring length 1.2 m 1.2 m 1.8 m
Segments/ring 6 6 7
Joint type Staggered Continuous Complex interleaved
Key-segment position A ring-to-ring repeating pattern A fixed ring-wise order No repeating pattern
Scanning Single-station Multi-station Single-station, offset
Eval. schema 6-class 6-class 7-class
Count 10 subsets 3 subsets 17 subsets

3.4.2 Experimental design

The experiment follows a cumulative ablation design with four conditions, each adding one context component (Table 2). This design isolates the cumulative contribution of each component while maintaining a controlled comparison. Level 0 (SAM4Tun) is the fixed expert-tuned baseline with no LLM involvement. Levels 1–3 progressively provide the LLM with richer context, enabling the cumulative ablation to attribute improvements to specific components. A separate Non-LLM condition (level 0a in Table 2) is included as the Non-LLM adaptive control, allowing the LLMs’ contribution to be read directly from the gap between the Non-LLM column and the LLM columns of Table 5. We codified the per-stage knowledge documents into a deterministic Python rule table as a non-LLM baseline. It maps characterisation fields (e.g., diameter, ring length, segments-per-ring, joint type, point density, and station configuration) to the 18 critical parameters adjusted by the LLMs (Table 9) using explicit “if … then …” rules. The table and script are fixed for all 30 tunnels (regular and complex), with no evaluation-set tuning or subset-specific settings, isolating the value of LLM per-tunnel reasoning. The complete rule specification is provided in Appendix 3.

Table 2: Ablation conditions.
Level Code Condition What the LLM sees
0 SAM4Tun Baseline Default parameters
0a Non-LLM Rule table 18 parameters set by lookup
1 m Memory Reference characteristics + parameters
2 m+s Memory+State + intermediate pipeline outputs
3 m+s+k
Memory + State +
Knowledge
+ domain knowledge

To assess whether adaptation behaviour depends on a specific LLM, each condition was run with three different LLMs (Opus-4.6, GPT-5.4, and Gemini-3-Flash) under identical prompts. Across models, the pipeline code, evaluation scripts, and prompt structure were held constant, while the context content varied by ablation level. Other than setting temperature to 0 to minimise stochasticity (Table 3), all other API settings used vendor defaults. This corresponds to 270 unique LLM-adaptation configurations: 3030 tunnels ×\times 33 LLMs ×\times 33 context settings (m, m+s, m+s+k). Each configuration was executed a second time for repeatability checking, yielding 270×2=540270\times 2=540 pipeline executions, plus 30 baseline runs with fixed parameters. Headline analyses (e.g., Table 5) use the first execution only. All three LLMs were accessed via their respective commercial APIs (Table 3). No model-specific prompt tuning was performed.

Table 3: LLM configuration.
Setting Value
Models Opus-4.6, GPT-5.4, Gemini-3-Flash
Max tokens 16,384
Temperature 0 (override to minimise stochasticity)
Timeout 300 s per call
Prompt format Markdown with JSON code
Failure handling JSON extraction failure

Pipeline execution used a single NVIDIA RTX 5060 GPU. Adapted parameter files and CoT reasoning traces were logged for all runs, enabling post-hoc sensitivity analysis (Section 3.4.4).

3.4.3 Evaluation metrics

Segmentation quality is measured primarily by mean Intersection-over-Union (mIoU). For class cc,

IoUc=TPcTPc+FPc+FNc,mIoU=1C​∑c=1CIoUc,\text{IoU}_{c}=\frac{\text{TP}_{c}}{\text{TP}_{c}+\text{FP}_{c}+\text{FN}_{c}},\qquad\text{mIoU}=\frac{1}{C}\sum_{c=1}^{C}\text{IoU}_{c}, (1)

where CC is the number of segmental segments (classes) within one ring (C=6C=6 for regular tunnels; C=7C=7 for complex tunnels). Equation (1) defines the per-tunnel mIoU (the mean IoU over the CC classes of a single tunnel); unless stated otherwise, mIoU values reported for a group of tunnels are the arithmetic mean of these per-tunnel scores across the relevant subsets. As a complementary global metric we also report overall accuracy (OA),

OA=∑c=1CTPcN,\text{OA}=\frac{\sum_{c=1}^{C}\text{TP}_{c}}{N}, (2)

where NN is the total number of points. Because OA can be dominated by majority classes, we treat mIoU as the primary score. We also report per-class IoU to assess whether improvements are broad or concentrated in specific structural classes.

For each condition and LLM, we computed paired per-tunnel improvements as Δi=mIoUcondition,i−mIoUbaseline,i\Delta_{i}=\mathrm{mIoU}_{\text{condition},i}-\mathrm{mIoU}_{\text{baseline},i}, with n=13n=13 for regular tunnels, n=17n=17 for complex tunnels, and n=30n=30 overall. We summarise these paired improvements using three standard statistics: (i) two-sided paired tt-test pp-values (α=0.05\alpha=0.05) for statistical significance, (ii) paired Cohen’s dd for effect size, and (iii) bootstrap 95% confidence intervals (CIs) for the mean improvement.

3.4.4 Sensitivity analysis

To assess the robustness of adapted parameters, for each parameter, we report the coefficient of variation (CV):

CV=s|v¯|,\text{CV}=\frac{s}{\lvert\bar{v}\rvert}, (3)

where v¯=1N​∑i=1Nvi\bar{v}=\frac{1}{N}\sum_{i=1}^{N}v_{i} and s=1N−1​∑i=1N(vi−v¯)2s=\sqrt{\frac{1}{N-1}\sum_{i=1}^{N}(v_{i}-\bar{v})^{2}} are the mean and standard deviation of the adapted values {vi}i=1N\{v_{i}\}_{i=1}^{N} across N=30N=30 tunnels. CV measures how much a parameter changes from tunnel to tunnel: (i) a high CV (≥0.06\geq 0.06) identifies parameters that are tunnel-responsive; (ii) CV≈0\text{CV}\approx 0 indicates baseline corrections that take the same improved value on every tunnel regardless of geometry. We further examine cross-LLM consistency: for parameters that always trigger adaptation, we compare the adapted values, tunnel counts, and tunnel categories produced by each LLM independently.

4 Results

By comparing segmentation performance against the static SAM4Tun baseline and a deterministic non-LLM control, we quantify the contributions of memory (m), state (s), and knowledge (k) across LLMs, identify consistently adapted parameters, and analyse residual errors and runtime trade-offs.

4.1 Overall performance

Refer to caption
Figure 9: Point-cloud visualisation for the tunnels with the largest mIoU gain in each category: regular (staggered; 2-1), regular (continuous; 3-3-1), and complex (5-1)

. Top (a): SAM4Tun baseline; bottom (b): LLM-adapted pipeline (m+s+k, Opus-4.6). Colours indicate classes; red denotes error; mIoU is shown per example.

Before assessing adaptation across the 30 diverse subsets, we verified the corrected SAM4Tun implementation on the single curated tuning tunnel. Under the expert-tuned configuration, it reaches mIoU ≈\approx 0.88 (Table 4); under the same m+s+km+s+k adaptation, all three LLMs match or slightly surpass this expert anchor.

Table 4: Segmentation performance on the reference tunnel: expert configuration versus LLM-adapted (m+s+km+s+k).
Metric Expert GPT-5.4 Opus-4.6 Gemini-3-Flash
OA 0.9369 0.9390 0.9419 0.9354
F1 0.9361 0.9389 0.9431 0.9362
mIoU 0.8801 0.8852 0.8926 0.8805

Table 5 summarises mIoU across conditions and LLMs. Under the full m+s+k design, overall mIoU rises from 0.18 (baseline) to 0.43–0.48 across the three LLMs (p<0.0001p<0.0001, paired Cohen’s dd = 1.51–1.95); overall OA rises from 0.42 to 0.59–0.65. The improvement holds across both tunnel categories (Fig. 10). Regular tunnels improve from 0.27 to 0.68–0.71 (paired Cohen’s dd = 1.4–2.2). Within the regular category, the near-reference staggered subsets (T1, T2), which match the reference tunnel in diameter, ring spacing, and key-segment layout, reach mIoU 0.784–0.796 across LLMs, whereas the continuous subset (T3), which departs from the reference in key-segment ordering, reaches only mIoU 0.270–0.309 and remains the main source of the lower combined regular figure. Complex tunnels, where the baseline drops to mIoU = 0.04 because several pipeline assumptions no longer match the tunnel conditions, improve to 0.15–0.20 (paired Cohen’s dd = 1.2–2.5); complex-tunnel OA rises from 0.30 to 0.33–0.42 (Fig. 9).

Wall-clock runtime, API-call counts, and per-tunnel input/output token usage with the corresponding indicative USD cost for each LLM under m+s+k are reported in Appendix 6 (Table 19). Per-class IoU analysis (Appendix 8) supports broad improvement across structural classes for regular tunnels and progressive recovery from near-zero baselines for complex tunnels. The full performance distribution is summarised in Appendix 9.

Comparison against the non-LLM adaptation. The rule-based adaptation (Table 5, Non-LLM) increases overall mIoU from 0.18 to 0.25, which shows some gains are deterministic.

On complex tunnels, the rules raise mIoU from 0.04 to 0.15 by applying the large-tunnel specification (diameter, ring spacing, segment count, key-segment layout). The LLM then adds a smaller lift to 0.15–0.20 (10/17 improved). The largest gap is on regular tunnels, where the LLM improve the mIoU from 0.27 to 0.68–0.71. Both non-LLM and LLM approaches remain low in absolute terms on complex tunnels under the single-reference setup.

Refer to caption
Figure 10: Step-wise adaptation results split by tunnel categories.Bars left to right: SAM4Tun (static baseline), Non-LLM (rule-based adaptation), m, m+s, m+s+k. The rule baseline closes part of the gap on complex tunnels but stays flat on regular tunnels; LLM (m+s+k) is highest in both categories. Error bars are bootstrap 95% CIs.
Table 5: Overall segmentation results (n=30n=30): mIoU and paired Δ\DeltamIoU vs. baseline with pp-values, effect sizes, and bootstrap 95% CIs. Δ\Delta is paired against SAM4Tun. OA is reported as a secondary metric, shown as the first line in each condition segment.
Condition Statistic Non-LLM Opus-4.6 GPT-5.4 Gemini-3-Flash
Baseline (SAM4Tun) Mean OA 0.42 0.42 0.42 0.42
mIoU 0.18 0.18 0.18 0.18
Non-LLM Mean OA 0.48 — — —
mIoU 0.25 — — —
Mean Δ\DeltamIoU +0.08+0.08 — — —
pp-value 0.0035 — — —
paired Cohen’s dd 0.58 — — —
std (Δ\Delta) 0.13 — — —
95% CI [0.028, 0.128][0.028,\;0.128] — — —
m Mean OA — 0.46 0.48 0.43
mIoU — 0.22 0.25 0.22
Mean Δ\DeltamIoU — +0.05+0.05 +0.07+0.07 +0.04+0.04
pp-value — 0.558 0.028 0.056
paired Cohen’s dd — 0.11 0.42 0.36
95% CI — [−0.113, 0.207][-0.113,\;0.207] [0.008, 0.134][0.008,\;0.134] [−0.002, 0.090][-0.002,\;0.090]
m+s Mean OA — 0.60 0.58 0.63
mIoU — 0.42 0.40 0.47
Mean Δ\DeltamIoU — +0.25+0.25 +0.23+0.23 +0.29+0.29
pp-value — <0.0001<0.0001 <0.0001<0.0001 <0.0001<0.0001
paired Cohen’s dd — 1.77 1.32 1.46
95% CI — [0.196, 0.300][0.196,\;0.300] [0.163, 0.291][0.163,\;0.291] [0.215, 0.363][0.215,\;0.363]
m+s+k Mean OA — 0.59 0.62 0.65
mIoU — 0.43 0.45 0.48
Mean Δ\DeltamIoU — +0.25+0.25 +0.27+0.27 +0.30+0.30
pp-value — <0.0001<0.0001 <0.0001<0.0001 <0.0001<0.0001
paired Cohen’s dd — 1.95 1.95 1.51
95% CI — [0.205, 0.301][0.205,\;0.301] [0.222, 0.327][0.222,\;0.327] [0.228, 0.378][0.228,\;0.378]

4.2 Ablation analysis

To isolate each context component’s contribution, Table 6 reports cumulative mIoU gains at each ablation step. Fig. 10 visualises the step-wise progression for regular and complex categories across all three LLMs.

Table 6: Cumulative mIoU contribution (mean Δ\Delta vs. previous level).
Transition Opus-4.6 GPT-5.4 Gemini-3-Flash
Baseline →\rightarrow Non-LLM +0.08+0.08 +0.08+0.08 +0.08+0.08
Baseline →\rightarrow m +0.05+0.05 +0.07+0.07 +0.04+0.04
m →\rightarrow m+s +0.20\mathbf{+0.20} +0.16\mathbf{+0.16} +0.25\mathbf{+0.25}
m+s →\rightarrow m+s+k +0.00+0.00 +0.05+0.05 +0.01+0.01

Memory alone provides an initial reference but is insufficient. On regular tunnels, especially the staggered subsets, memory alone changes mIoU by 0.04–0.07 across the three LLMs (Table 6); all three LLMs show small positive averages. Without intermediate feedback, the agent can propose parameter updates but cannot verify whether they improve or degrade the pipeline outputs.

State accounts for the largest observed increment in the ablation study. The m+s condition yields the strongest gain relative to baseline across all three LLMs (all p<0.0001p<0.0001; paired Cohen’s dd = 1.32–1.77), while the memory-only effect is small or inconsistent, indicating that state is the main contributor to the observed improvement. State provides the agent with explicit quantitative evidence of how each stage has transformed the data: radial percentiles for mask bounds, retention rates for denoising aggressiveness, coverage uniformity for upsampling targets. Without state, the agent has only pre-pipeline statistics that may not reflect conditions after unfolding, denoising, or enhancing. The same conclusion holds when the comparator is the Non-LLM baseline rather than the static SAM4Tun: state alone (m+s) lifts overall mIoU by 0.16–0.25 above the rule-based adaptation.

One plausible explanation is that the gain associated with state depends on how the model maps raw numeric summaries (percentiles, counts, ratios) to parameter values in light of parameter semantics. We did not test alternative mapping strategies (e.g., regression models); however, the continuous, multidimensional nature of the characteristic space and the non-trivial parameter interactions suggest that capturing this mapping through static rules alone would require considerable manual engineering effort per tunnel category.

Knowledge provides a small additional gain, concentrated in the complex category. On top of m+s, knowledge raises mIoU by up to 0.05 across the three LLMs. The mean increments are small, but the per-tunnel direction is nevertheless positive. The increment is concentrated where the knowledge document supplies specific tuning guidance that neither memory nor state can reliably infer from numerical summaries alone (e.g., a larger-diameter tunnel often uses wider rings).

4.3 Cross-model consistency and repeatability

To assess whether the adaptation behaviour is model-dependent under a fixed prompt and input structure, Table 7 compares the three LLMs on the full m+s+k condition. The three models show similar effect ranges under the full m+s+k condition, although overlapping 95% confidence intervals do not by themselves rule out between-model differences. A repeatability check under the full m+s+k setting indicates low but non-zero stochastic drift. Across 30 tunnels, each LLM was inferred twice: on average, 90.9% of the 18 critical parameters remain unchanged, and the mean absolute inter-run Δ\DeltamIoU is 0.029 (median 0.000), as reported in Table 20 (Appendix 7).

Table 7: Cross-model summary (m+s+k vs baseline, overall).
LLM Mean Δ\DeltamIoU 95% CI dd
Opus-4.6 +0.25+0.25 [0.21, 0.30][0.21,\;0.30] 1.95
GPT-5.4 +0.27+0.27 [0.22, 0.33][0.22,\;0.33] 1.95
Gemini-3-Flash +0.30+0.30 [0.23, 0.38][0.23,\;0.38] 1.51

4.4 Runtime trade-off

R4Tun trades additional API latency for bounded, logged parameter decisions. In this implementation, the SAM4Tun processing takes approximately 235 s per tunnel, and the LLM adaptation under m+s+k adds 96–307 s depending on the LLM, for total times of roughly 331–542 s per tunnel (Table 8). The added runtime is therefore not negligible, but it is modest relative to the cost of annotating data or retraining a supervised model.

Table 8: Runtime trade-off of the tested R4Tun m+s+k setting.
LLM Extra time Total time Mean Δ\DeltamIoU
Gemini-3-Flash +96+96 s (0.4×0.4\times) ∼\sim331 s +0.30+0.30
Opus-4.6 +140+140 s (0.6×0.6\times) ∼\sim375 s +0.25+0.25
GPT-5.4 +307+307 s (1.3×1.3\times) ∼\sim542 s +0.27+0.27

4.5 Parameter sensitivity

This analysis separates parameters that vary across tunnels from those that remain constant, clarifying which aspects of the adaptation respond to specific tunnel conditions.

Analysis of 270 adapted parameter runs identified 18 parameters that all three LLMs consistently adjust (Table 9). Of these, 11 are tunnel-responsive (CV≥0.06\text{CV}\geq 0.06), in that their adapted values vary with tunnel geometry, clustering by tunnel category. The remaining 7 parameters behave as baseline corrections (CV≈0\text{CV}\approx 0), with near-identical values across tunnels, indicating a shared correction trend relative to the SAM4Tun defaults.

Table 9: Critical parameters identified across all three LLMs (18 total). Tunnel-responsive parameters (CV≥0.06\text{CV}\geq 0.06) vary with tunnel geometry; baseline corrections (CV≈0\text{CV}\approx 0) take near-identical values across tunnels. The meaning/control column briefly explains what each parameter does in the SAM4Tun pipeline.
Stage Parameter Meaning/Control Behaviour Tunnels CV Adapted range / correction
Unfolding diameter Cylindrical scale. Responsive 27/30 0.072 [5.31, 7.6]
Denoising mask_r_low Inner radial gate. Responsive 30/30 0.082 [2.09, 3.75]
Denoising mask_r_high Outer radial gate. Responsive 30/30 0.147 [2.78, 4.38]
Denoising default_cutoff_z Fallback radial cutoff (low density). Responsive 29/30 0.142 [2.65, 6.27]
Denoising z_step Radial histogram bin width. Responsive 30/30 0.181 [0.003, 0.005]
Denoising smooth_win Cutoff-curve smoothing window. Correction 30/30 ≈\approx0 3 →\rightarrow 5
Denoising smooth_offset Post-smoothing cutoff bias. Correction 30/30 ≈\approx0 −-0.003 →\rightarrow −-0.002
Denoising grad_thresh Outer-edge gradient threshold. Correction 30/30 ≈\approx0 0.2 →\rightarrow 0.15
Denoising y_step Angular bin width (density filtering). Correction 30/30 ≈\approx0 0.5 →\rightarrow 0.4
Enhancing inter_radius Interpolation neighbour radius. Responsive 30/30 0.130 [0.03, 0.08]
Enhancing upsampling_stage1 Stage-1 upsampling spacing. Responsive 30/30 0.064 [0.055, 0.11]
Enhancing curv_thresh Panel–joint curvature threshold. Correction 30/30 ≈\approx0 0.0005 →\rightarrow 0.005
Enhancing depth_low Lower interpolation depth tolerance. Correction 30/30 ≈\approx0 0.003 →\rightarrow 0.005
Enhancing depth_high Upper interpolation depth tolerance. Correction 30/30 ≈\approx0 0.008 →\rightarrow 0.015
Segmenting hough_thresh_obliq Oblique joint-line vote threshold. Responsive 30/30 0.188 [20, 83]
Segmenting hough_thresh_horiz Horizontal joint-line vote threshold. Responsive 30/30 0.204 [20, 83]
Segmenting hough_thresh_vert Vertical ring-boundary vote threshold. Responsive 28/30 0.219 [320, 980]
Segmenting processing.padding Segment-crop horizontal padding. Responsive 29/30 0.265 [160, 419]

4.6 Error analysis

Refer to caption
Figure 11: Structural constraints of the fixed SAM4Tun labelling rule. (a) Labelling rule: after K is detected, B segments are placed one step either side of K and A segments at successive multiples of the same fixed offset, in a fixed order, so the template mislabels rings whose segment widths or count differ from the reference. (b) Ground-truth K position versus ring index for one regular (blue, 2-1) and one complex (red, 5-1) tunnel: K jumps from ring to ring, much more on the complex tunnel, which the current one-configuration-per-tunnel setting does not address.

To understand why the absolute metrics stay low, we sorted every predicted point into four outcomes against the ground truth: correct; false negative (a segment point left as background, i.e. under-segmentation); false positive (a background point pulled into a segment, i.e. over-segmentation, rare here); and class swap (a correctly located segment point assigned to the wrong segment type).

Table 10: Error composition as a fraction of ground-truth points (Opus-4.6 m+s+km+s+k versus SAM4Tun baseline; 13 regular, 17 complex tunnels). FN: segment predicted as background; FP: background predicted as segment; Swap: segment predicted as the wrong segment class. Adaptation reduces false negatives; on complex tunnels the residual error is dominated by class swaps.
Category Method Correct FN FP Swap
Regular SAM4Tun 55% 22% 3% 20%
m+s+km+s+k 83% 6% 4% 7%
Complex SAM4Tun 30% 70% 0% 0%
m+s+km+s+k 41% 21% 5% 32%

Regular and complex tunnels fail differently (Table 10). On regular tunnels, adaptation reduces under-segmentation, lowering FN from 22% to 6% of ground-truth points, and reduces class swaps from 20% to 7%. On complex tunnels, the baseline predicts almost all points as background; adaptation recovers the blocks (FN 70%→\rightarrow21%). However, the fixed segment-offset template (anchored at K) turns a per-ring angular shift into systematic adjacent-class swaps (0%→\rightarrow32%). Fig. 12 shows this spatially: after adaptation, swaps dominate the residual error on complex tunnels.

Refer to caption
Figure 12: Per-point error maps for a representative regular tunnel (a, regular tunnel 2-1) and complex tunnel (b, complex tunnel 5-1) under m+s+km+s+k (Opus-4.6), drawn on the unfolded surface (x: ring index; y: circumferential angle). Left column—detection outcomes: correct (grey), false negatives (blue, segment→\rightarrowbackground) and false positives (orange, background→\rightarrowsegment), with the ground-truth K (green) and predicted K (red) overlaid per ring; titles give FN, FP, and mIoU. Right column—class swaps (red) among otherwise correctly located points. On the regular tunnel the predicted K stays on the GT K and swaps remain low (10%). On the complex tunnel the predicted K is nearly constant and drifts away from the GT K, which jumps ring-to-ring; each affected ring’s labels then rotate together and swaps rise to 42%. The maps localise the two constraints: the K mismatch (left) drives the moving-anchor errors, and the resulting label rotation (right) is the dominant residual error.

The failure modes trace back to a mismatch between how the current open-source SAM4Tun pipeline is parameterised and how segmental rings actually vary. The pipeline applies one parameter set per tunnel and labels each ring by first detecting the key segment (K) and then placing every other segment at a fixed angular offset from K, in a fixed order. Neither of these two structural constraints can be removed by tunnel-level parameter tuning.

  1. 1.

    Per-ring density variation under tunnel-level parameterisation. R4Tun adapts one configuration per tunnel, but point density is far from uniform within a tunnel: the per-ring point count varies by up to 19-fold (regular) and 38-fold (complex) between the dense central rings and the sparse end rings. A single tunnel-level setting cannot keep both ends of this range inside the detector’s working band, so the sparse rings systematically lose ring-boundary and K detection no matter how the tunnel-level parameters are chosen. This is a limitation of the adaptation scope (one configuration per tunnel), not of any individual parameter value, and it can only be lifted by moving from tunnel-level to ring-level adaptation.

  2. 2.

    Fixed segment-offset template. Once K is located, the rule places the B segments one step on either side of K and the A segments at successive multiples of that same fixed step, in a fixed order (Fig. 11a). The step size and the segment order are hard-coded, so when the true geometry departs from the reference the fixed steps no longer line up with the real joints and correctly detected points are still given the wrong label. This is the single largest source of class swaps, visible as the red bands in the right column of Fig. 12, which grow from 10% (regular) to 42% (complex) even where points are correctly located.

Lifting these limits is future work rather than a parameter change, because they are baked into SAM4Tun’s one-configuration-per-tunnel, detect-K-then-fixed-template logic. The clearest direction is ring-level adaptation: density-adaptive preprocessing and per-ring K re-anchoring would address the density and K-detection problems above; a variable-length segment template and handedness inference would relax the fixed labelling rule. Implementing this requires rewriting the open-source pipeline and lies outside the bounded-parameter adaptation studied here. These directions extend SAM4Tun and R4Tun rather than invalidate them: structured context already enables LLM adaptation within fixed bounds, and pinpoints which structural parts must change next to lift the absolute ceiling.

5 Discussion

Taken together, the results support a mechanism-level claim rather than a deployment-level one. With the SAM4Tun pipeline and the expert reference held fixed, structured context improves bounded parameter adaptation across three LLMs. In practical terms, m+s+km+s+k can guide a reviewable parameter update without labelled retraining; however, at current accuracy it supports assisted analysis, not autonomous inspection.

5.1 Key findings

The experimental evaluation yields two primary findings. First, as noted in the ablation study (Section 4.2), the ablation results suggest that the context design improves adaptation across models and tunnel categories, with state providing the main gains (+0.16+0.16 to +0.25+0.25 mIoU on top of memory). Second, the LLM (m+s+k) gain over the non-LLM rule-based adaptation is concentrated on the regular category, where the rule table cannot improve over the static baseline (Section 4.1). This concentration is consistent with the single-reference design: both comparators start from a configuration tuned on a tunnel that is similar to the regular category. Near the reference, the LLM has more informative context to condition on, and its advantage over deterministic lookup becomes visible; far from the reference (the complex category), neither approach has a matching anchor and the two converge toward similarly low absolute performance, with the LLMs retaining a small mean advantage. As reported in Section 4.1, the regular category gap occurs where the deterministic control does not improve over the static baseline, whereas the complex category convergence more likely reflects a shared ceiling than a specific failure of LLM reasoning (Section 5.3).

In practice, a domain expert calibrates the pipeline on a single reference tunnel, encodes the tuning rationale into structured documents, and deploys R4Tun for subsequent tunnels. Under this single-reference setup, the framework is best suited to targets that remain close to the calibrated reference, and it can also flag when the fixed pipeline begins to fail. The framework supports post-hoc review by logging a rationale alongside each parameter change, and requires no model retraining or labelled domain data. Experts must still define the reference configuration and bounds, review rationales, and judge whether low-confidence outputs are acceptable. Within this scope, R4Tun does not yet support autonomous final inspection or downstream tasks (e.g. structural health monitoring or Scan-to-BIM) without human verification.

5.2 Comparison with state-of-the-art

We position R4Tun against established tunnel-segmentation paradigms in Table 11. The comparison is presented as an operating-point and setup-cost comparison rather than a direct accuracy ranking, because the methods are not evaluated under comparable conditions. Supervised 3D deep-learning models on Seg2Tunnel (LiningNet, SparseUNet, SCF-Net, FA-ResNet) report mIoU 0.83–0.90 [27], but are evaluated in-distribution and require per-point labels and GPU retraining. Geometric feature-engineering methods avoid training but depend on manually tuned thresholds and typically report cross-section fitting error rather than per-segment mIoU, so they are not directly comparable at the component level. Expert-tuned SAM4Tun reaches mIoU above 0.90, but only on curated, per-case-tuned test rings [51]; under our protocol (30 diverse subsets, single fixed reference, no per-case tuning) the corrected open-source pipeline reaches mIoU 0.88 on its own reference tunnel but only 0.18 when that same fixed configuration is applied static across all subsets.

The only directly comparable pair (same evaluation protocol, with no labels, no training, and no per-case tuning) is R4Tun (0.43–0.48) versus static SAM4Tun (0.18); R4Tun improves the directly comparable baseline. With the corrected implementation and anchor, R4Tun also reaches mIoU 0.784–0.796 across LLMs on near-reference (regular-staggered) tunnels. Supervised and expert-tuned figures come from more favourable settings and bound the remaining gap, not direct competitors. Deterministic, non-LLM rule baseline (Section 4.1) reaches only 0.25, and every higher figure in Table 11 requires labels, training, or per-case expert tuning.

Table 11: Positioning R4Tun against representative tunnel-segmentation paradigms. The comparison is on setup cost as well as accuracy: ✓ indicates the requirement (or capability) applies, “–” that it does not. mIoU figures are not measured under comparable settings (see the “setting” column): supervised and expert-tuned figures are taken from [27] and [51] under their original, more favourable protocols, whereas the static-SAM4Tun, non-LLM, and R4Tun figures are from this study under a single fixed reference across 30 diverse subsets. R4Tun is the only approach that is simultaneously label-free, training-free, and expert-tuning-free while still adapting per tunnel.
Method Labels Training
Per-case
expert tuning
Per-tunnel
adaptation
mIoU (setting)
LiningNet/SparseUNet/SCF-Net/FA-ResNet ✓ ✓ – – 0.83–0.90 (in-distribution)
Expert-tuned SAM4Tun – – ✓ – above 0.90 (curated rings)
Static SAM4Tun (this protocol) – – – – 0.18
Non-LLM rules (this study) – – – ✓ 0.25
R4Tun (near-reference) – – – ✓ 0.784–0.796 (across LLMs)
R4Tun (all tunnels) – – – ✓ 0.43–0.48

5.3 Limitations

The limitations of this work are driven by the fixed SAM4Tun operator design and by the single-reference adaptation protocol. In particular, R4Tun inherits SAM4Tun’s assumptions and failure modes, so the LLM can only re-parameterise the pipeline rather than replace it. All parameter adaptation is anchored to a single expert-tuned configuration, which creates a low ceiling for both the LLM-guided and the rule-based methods. When no contextual anchor resembles the target tunnel, neither approach has sufficient information to recover strong performance. Expanding R4Tun to encode multiple expert-tuned reference configurations (e.g., one per tunnel category) may further narrow the absolute gap.

Our study was evaluated exclusively on the SAM4Tun pipeline and the Seg2Tunnel dataset; potentially, its transferability is most plausible when four conditions hold: (i) each stage exposes bounded, tunable parameters (i.e., adaptation is a re-parameterisation problem rather than a redesign); (ii) expert reference configurations exist whose target characterisation is comparable to the new deployment setting; (iii) each stage admits a compact, summarised intermediate state that can be passed between agents; and (iv) stage-specific knowledge can be encoded (e.g., as bounds, rules, and failure signatures) for use during adaptation.

6 Conclusions

In this paper, we presented R4Tun, positioned as a mechanism contribution rather than a deployable final-inspection system, a multi-agent framework that extends a fixed, expert-designed tunnel-lining segmentation pipeline (SAM4Tun) with LLM-guided bounded parameter adaptation. Rather than replacing the underlying geometric operators, each stage agent compares a new tunnel against the reference configuration, reads compact summaries of intermediate pipeline outputs, and proposes bounded parameter updates accompanied by a logged rationale, preserving the deterministic pipeline structure while supporting post-hoc expert review. We validated R4Tun on 30 Seg2Tunnel subsets (13 regular, 17 complex) across three different LLMs. The main findings of this study are:

  • •

    Structured context improves bounded adaptation across LLMs. The full m+s+km+s+k design raised mIoU from 0.18 to 0.43–0.48 and OA from 0.42 to 0.59–0.65; on the near-reference regular (staggered) subsets it reached mIoU 0.784–0.796, approaching the expert anchor (0.88).

  • •

    Intermediate pipeline state is the dominant contributor. Adding state increased mIoU by 0.16–0.25 over memory alone, whereas memory or knowledge in isolation produced only small increments.

  • •

    The adaptation behaviour is consistent across models. The three LLMs produced overlapping effect ranges, adjusted a shared set of 18 critical parameters under identical prompts, and showed limited run-to-run drift (90.9% of critical parameters unchanged across repeats).

  • •

    The framework is label-free and auditable. R4Tun shifts expert effort from repeated per-tunnel intervention toward an upfront authoring step (reference calibration plus per-stage knowledge documents), runs on commercial LLM APIs without labelled retraining, logs a rationale for each parameter change, and adds only modest runtime (96–307 s per tunnel).

These results also reveal limitations that are inherent to the present design. First, all adaptation is anchored to a single expert-tuned reference, which sets a low ceiling away from that anchor: the regular-continuous (T3) and complex subsets differ from the reference in segment arrangement, segment count, and diameter, and remain challenging (mIoU 0.15–0.31), so at current accuracy R4Tun supports assisted, expert-verified parameter re-configuration for near-reference tunnels rather than autonomous final inspection or unverified downstream use such as structural health monitoring or Scan-to-BIM. Second, R4Tun adapts but does not replace SAM4Tun’s operators; in particular, its one-configuration-per-tunnel parameterisation and fixed offset-and-order labelling template turn per-ring geometric variation into systematic class swaps that persist regardless of parameter choice (Section 4.6). Finally, all evidence is confined to the SAM4Tun–Seg2Tunnel setting, and transferability to other parameter-controllable pipelines is argued conceptually (Section 5.3) but not yet empirically validated.

In the future, encoding multiple expert-tuned reference anchors (for example, one per tunnel category) would narrow the single-anchor gap for off-reference tunnels. Replacing the fixed-template labelling logic with dynamic, ring-level adaptatio would lift the structural ceiling identified in the error analysis. Validating the m+s+km+s+k strategy on other parameter-controllable backbones would test its expected backbone-agnostic behaviour, and broader validation across tunnel typologies and acquisition conditions, together with human-in-the-loop integration into downstream inspection tasks, would strengthen generalisability and move the framework toward verified deployment.

Data availability

The source code, adapted parameters, and evaluation scripts are available at https://github.com/Tao-Robominds/R4Tun. The Seg2Tunnel dataset is publicly available.

Declaration of competing interest

The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

Declaration of generative AI use

During this study, the authors evaluated large language models (Opus-4.6, GPT-5.4, and Gemini-3-Flash) as the main experimental systems. The LLMs were also used for language editing and for improving manuscript structure. The authors reviewed and edited all content and take full responsibility for the content of the publication.

References

  • [1] Anthropic (2025) Effective context engineering for AI agents. Note: Accessed: 2025-12-01https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents Cited by: §2.3.
  • [2] L. Attard, C. J. Debono, G. Valentino, and M. D. Castro (2018) Tunnel inspection using photogrammetric techniques and image processing: a review. ISPRS Journal of Photogrammetry and Remote Sensing 144, pp. 180–188. External Links: Document Cited by: §1.
  • [3] R. Bommasani, D. A. Hudson, E. Adeli, R. Altman, S. Arora, S. von Arx, et al. (2021) On the opportunities and risks of Foundation Models. External Links: Document, 2108.07258 Cited by: §1.
  • [4] A. M. Bran, S. Cox, O. Schilter, C. Baldassari, A. D. White, and P. Schwaller (2024) Augmenting large language models with chemistry tools. Nature Machine Intelligence 6 (5), pp. 525–535. External Links: Document Cited by: §1.
  • [5] E. Camuffo, D. Mari, and S. Milani (2022) Recent advancements in learning algorithms for point clouds: an updated overview. Sensors 22 (4), pp. 1357. External Links: Document Cited by: §2.2.
  • [6] M. Caron, H. Touvron, I. Misra, H. Jégou, J. Mairal, P. Bojanowski, et al. (2021) Emerging properties in self-supervised vision transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 9650–9660. External Links: Document Cited by: §2.2.
  • [7] Y. Cha, R. Ali, J. Lewis, and O. Büyüköztürk (2024) Deep learning-based structural health monitoring. Automation in Construction 161, pp. 105328. External Links: Document Cited by: §1, §2.1.
  • [8] P. Chen, B. Han, and S. Zhang (2024) CoMM: collaborative multi-agent, multi-reasoning-path prompting for complex problem solving. External Links: Document, 2404.17729 Cited by: §1, §2.3.
  • [9] J. Chua and O. Evans (2025) Are DeepSeek R1 and other reasoning models more faithful?. External Links: Document, 2501.08156 Cited by: §2.3.
  • [10] DeepSeek-AI (2025) DeepSeek-R1: incentivizing reasoning capability in LLMs via reinforcement learning. External Links: Document, 2501.12948 Cited by: §2.3.
  • [11] Y. Duan, S. Qiu, W. Jin, T. Lu, and X. Li (2023) High-speed rail tunnel panoramic inspection image recognition technology based on improved YOLOv5. Sensors 23 (13), pp. 5986. External Links: Document Cited by: §1.
  • [12] R. O. Duda and P. E. Hart (1972) Use of the Hough transformation to detect lines and curves in pictures. Communications of the ACM 15 (1), pp. 11–15. External Links: Document Cited by: Figure 6, §3.2.
  • [13] M. Ester, H. Kriegel, J. Sander, and X. Xu (1996) A density-based algorithm for discovering clusters in large spatial databases with noise. In Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96), pp. 226–231. External Links: Document, ISBN 1-57735-004-9 Cited by: §2.1, §3.2.
  • [14] M. A. Fischler and R. C. Bolles (1981) Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography. Communications of the ACM 24 (6), pp. 381–395. External Links: Document Cited by: §2.1, §3.2.
  • [15] G. Franceschelli, C. Cevenini, and M. Musolesi (2024) Training Foundation Models as data compression: on information, model weights and copyright law. External Links: Document, 2407.13493 Cited by: §2.2.
  • [16] C. I. Garcia, M. A. DiBattista, T. A. Letelier, H. D. Halloran, and J. A. Camelio (2024) Framework for LLM applications in manufacturing. Manufacturing Letters 41, pp. 253–263. External Links: Document Cited by: §1.
  • [17] K. Ge, C. Wang, Y. Guo, Y. Tang, Z. Hu, and H. Chen (2024) Fine-tuning vision foundation model for crack segmentation in civil infrastructures. Construction and Building Materials 431, pp. 136573. External Links: Document Cited by: §2.2.
  • [18] Z. Guo, R. Zhang, X. Zhu, Y. Tang, X. Ma, J. Han, et al. (2023) Point-Bind & Point-LLM: aligning point cloud with multi-modality for 3D understanding, generation, and instruction following. External Links: Document, 2309.00615 Cited by: §2.2.
  • [19] S. Hong, M. Zhuge, J. Chen, X. Zheng, Y. Cheng, C. Zhang, et al. (2024) MetaGPT: meta programming for a multi-agent collaborative framework. External Links: Document, 2308.00352 Cited by: §1, §2.3.
  • [20] Q. Hu, B. Yang, L. Xie, S. Rosa, Y. Guo, Z. Wang, et al. (2020) RandLA-Net: efficient semantic segmentation of large-scale point clouds. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pp. 11105–11114. External Links: Document Cited by: §2.1.
  • [21] M. Q. Huang, J. Ninić, and Q. B. Zhang (2021) BIM, machine learning and computer vision techniques in underground construction: current status and future perspectives. Tunnelling and Underground Space Technology 108, pp. 103677. External Links: Document Cited by: §1.
  • [22] A. Kirillov, E. Mintun, N. Ravi, H. Mao, C. Rolland, L. Gustafson, et al. (2023) Segment anything. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), pp. 4015–4026. External Links: Document Cited by: §1, §2.2, Figure 6, §3.2.
  • [23] T. Kojima, S. S. Gu, M. Reid, Y. Matsuo, and Y. Iwasawa (2022) Large language models are zero-shot reasoners. In Advances in Neural Information Processing Systems 35 (NeurIPS 2022), pp. 22199–22213. External Links: Document, 2205.11916 Cited by: §2.3.
  • [24] M. Kolodiazhnyi, A. Vorontsova, A. Konushin, and D. Rukhovich (2024) Top-down beats bottom-up in 3D instance segmentation. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 3566–3574. External Links: Document Cited by: §2.1.
  • [25] X. Li, Y. Zhang, J. Wang, et al. (2026) Tunnel surface defect segmentation using TransUNet with self-attention for complex underground environments. PLOS ONE 21 (10), pp. e0322859. External Links: Document Cited by: §2.1.
  • [26] H. Y. Liang, S. L. Shen, and A. Zhou (2026) ECA-enhanced YOLO integrated with SAHI for multi-defect inspection of tunnel linings. Tunnelling and Underground Space Technology 174, pp. 107705. External Links: Document Cited by: §2.1.
  • [27] W. Lin, B. Sheil, P. Zhang, B. Zhou, C. Wang, and X. Xie (2024) Seg2Tunnel: a hierarchical point cloud dataset and benchmarks for segmentation of segmental tunnel linings. Tunnelling and Underground Space Technology 147, pp. 105735. External Links: Document Cited by: §5.2, Table 11.
  • [28] M. Liu, R. Shi, K. Kuang, Y. Zhu, X. Li, S. Han, et al. (2023) OpenShape: scaling up 3D shape representation towards open-world understanding. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023), pp. 44860–44879. External Links: Document Cited by: §2.2.
  • [29] L. Mei, J. Yao, Y. Ge, Y. Wang, B. Bi, Y. Cai, et al. (2025) A survey of context engineering for large language models. External Links: Document, 2507.13334 Cited by: §2.3.
  • [30] R. Montero, J. G. Victores, S. Martínez, A. Jardón, and C. Balaguer (2015) Past, present and future of robotic tunnel inspection. Automation in Construction 59, pp. 99–112. External Links: Document Cited by: §1.
  • [31] OpenAI (2025) OpenAI o3 and o4-mini system card. External Links: Link Cited by: §2.3.
  • [32] OpenAI (2025) Reasoning best practices. Note: Accessed: 2025-12-01https://platform.openai.com/docs/guides/reasoning-best-practices Cited by: §2.3.
  • [33] L. Ouyang, J. Wu, X. Jiang, D. Almeida, C. L. Wainwright, P. Mishkin, et al. (2022) Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems 35 (NeurIPS 2022), pp. 27730–27744. External Links: Document, 2203.02155 Cited by: §2.3.
  • [34] F. Pan, S. Jeon, B. Wang, F. McKenna, and S. X. Yu (2024) Zero-shot building attribute extraction from large-scale vision and language models. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV), pp. 8647–8656. External Links: Document Cited by: §2.2.
  • [35] M. Pauly, M. Gross, and L. P. Kobbelt (2002) Efficient simplification of point-sampled surfaces. In Proceedings of the IEEE Visualization Conference (VIS 2002), pp. 163–170. External Links: Document Cited by: §2.1.
  • [36] C. R. Qi, L. Yi, H. Su, and L. J. Guibas (2017) PointNet++: deep hierarchical feature learning on point sets in a metric space. In Advances in Neural Information Processing Systems 30 (NeurIPS 2017), pp. 5105–5114. External Links: Document, 1706.02413 Cited by: §2.1.
  • [37] C. Qian, W. Liu, H. Liu, N. Chen, Y. Dang, J. Li, et al. (2024) ChatDev: communicative agents for software development. External Links: Document, 2307.07924 Cited by: §1, §2.3.
  • [38] N. Ravi, V. Gabeur, Y. Hu, R. Hu, C. Ryali, T. Ma, et al. (2025) SAM 2: segment anything in images and videos. Note: International Conference on Learning Representations (ICLR) External Links: Link Cited by: §2.2.
  • [39] J. Schult, F. Engelmann, A. Hermans, O. Litany, S. Tang, and B. Leibe (2023) Mask3D: mask transformer for 3D semantic instance segmentation. In Proceedings of the IEEE International Conference on Robotics and Automation (ICRA), pp. 8216–8223. External Links: Document Cited by: §2.1.
  • [40] A. Sjölander, V. Belloni, A. Ansell, and E. Nordström (2023) Towards automated inspections of tunnels: a review of optical inspections and autonomous assessment of concrete tunnel linings. Sensors 23 (6), pp. 3189. External Links: Document Cited by: §1.
  • [41] A. Strauss, J. Bien, H. Neuner, C. Harmening, C. Seywald, M. Österreicher, et al. (2020) Sensing and monitoring in tunnels: testing and monitoring methods for the assessment of tunnels. Structural Concrete 21 (4), pp. 1356–1376. External Links: Document Cited by: §1.
  • [42] C. Su, Q. Hu, Z. Yang, and R. Huo (2024) A review of deep learning applications in tunneling and underground engineering in china. Applied Sciences 14 (5), pp. 1720. External Links: Document Cited by: §1, §2.1.
  • [43] B. Wang, Z. Chen, M. Li, Q. Wang, C. Yin, and J. C. P. Cheng (2024) Omni-Scan2BIM: a ready-to-use Scan2BIM approach based on vision foundation models for MEP scenes. Automation in Construction 162, pp. 105384. External Links: Document Cited by: §2.2.
  • [44] Q. Wang, W. Ding, F. Li, Y. Qiao, K. Khoshelham, F. Zhang, et al. (2026) Serialized point cloud segmentation with dilated patchwise attention for generating geometric twins of shield metro tunnels. Automation in Construction 187, pp. 106908. External Links: Document Cited by: §2.1.
  • [45] J. Wei, X. Wang, D. Schuurmans, M. Bosma, B. Ichter, F. Xia, et al. (2022) Chain-of-thought prompting elicits reasoning in large language models. In Advances in Neural Information Processing Systems 35 (NeurIPS 2022), pp. 24824–24837. External Links: Document Cited by: §2.3.
  • [46] L. Weidner and G. Walton (2024) Generalized extraction of bolts, mesh, and rock in tunnel point clouds: a critical comparison of geometric feature-based methods using random forest and neural networks. Remote Sensing 16 (23), pp. 4466. External Links: Document Cited by: §1, §1, §2.1.
  • [47] V. Xiang, C. Snell, K. Gandhi, A. Albalak, A. Singh, C. Blagden, et al. (2025) Towards System 2 reasoning in LLMs: learning how to think with meta chain-of-thought. External Links: Document, 2501.04682 Cited by: §2.3.
  • [48] P. Xu, W. Ping, X. Wu, L. McAfee, C. Zhu, Z. Liu, et al. (2024) Retrieval meets long-context large language models. External Links: Document, 2310.03025 Cited by: §2.3.
  • [49] R. Xu, X. Wang, T. Wang, Y. Chen, J. Pang, and D. Lin (2024) PointLLM: empowering large language models to understand point clouds. In Computer Vision – ECCV 2024, pp. 131–147. External Links: Document Cited by: §2.2.
  • [50] Z. Ye, Q. Li, G. Desiderio, M. Huang, W. Liu, V. Villa, and J. Ninić (2026) Maintenance-oriented tunnel digital model generation via panoptic segmentation of ultra-high-resolution images. Computer-Aided Civil and Infrastructure Engineering, pp. 100032. External Links: Document Cited by: §2.2.
  • [51] Z. Ye, W. Lin, A. Faramarzi, X. Xie, and J. Ninić (2025) SAM4Tun: no-training model for tunnel lining point cloud component segmentation. Tunnelling and Underground Space Technology 158, pp. 106401. External Links: Document Cited by: §1, §2.2, §3.2, §5.2, Table 11.
  • [52] Z. Ye, L. Lovell, A. Faramarzi, and J. Ninić (2024) Sam-based instance segmentation models for the automation of structural damage detection. Advanced Engineering Informatics 62, pp. 102826. External Links: Document Cited by: §2.2.
  • [53] Y. Yue, S. Zhang, H. Liu, F. Hong, C. Liu, J. Cui, et al. (2024) Damage mechanism of a shield tunnel with cavities behind the concrete lining: an insight from a scaled model test. Tunnelling and Underground Space Technology 153, pp. 105998. External Links: Document Cited by: §1.
  • [54] [. a. l. Zhang (2022) UnrollingNet: [verify title]. Automation in Construction. External Links: Document Cited by: §2.1, §3.2.
  • [55] Y. Zhang, R. Sun, Y. Chen, T. Pfister, R. Zhang, and S. Ö. Arik (2024) Chain of agents: large language models collaborating on long-context tasks. External Links: Document, 2406.02818 Cited by: §2.3.
  • [56] Z. Zhang, Y. Yao, A. Zhang, X. Tang, X. Ma, Z. He, et al. (2023) Igniting language intelligence: the hitchhikerś guide from chain-of-thought reasoning to language agents. External Links: Document, 2311.11797 Cited by: §2.3.
  • [57] X. Zou, J. Yang, H. Zhang, F. Li, L. Li, J. Wang, et al. (2023) Segment everything everywhere all at once. Note: Advances in Neural Information Processing Systems (NeurIPS 2023) External Links: Link Cited by: §2.2.

1 Baseline parameter tables

Tables 12–15 report the SAM4Tun baseline parameter values used as the reference configuration for all adaptation experiments.

Table 12: Stage 1 — Unfolding parameters (sam4tun baseline).
Parameter Value
delta 0.005
slice_spacing_factor 1.2
vertical_filter_window 4.5
ransac_threshold 1
ransac_probability 0.9
ransac_inlier_ratio 0.75
ransac_sample_size 5
polynomial_degree 3
num_samples_factor 1210
diameter 5.60
Table 13: Stage 2 — Denoising parameters (sam4tun baseline).
Parameter Value
mask_r_low 2.7
mask_r_high 2.8
y_step 0.5
z_step 0.001
grad_threshold 0.2
smoothing_window_size 3
smoothing_offset −0.003-0.003
default_cutoff_z 2.7
Table 14: Stage 3 — Enhancing parameters (sam4tun baseline).
Parameter Value
upsamp_stage1_target_dist 0.08
upsamp_stage2_target_dist 0.04
upsamp_stage3_target_dist 0.02
curvature_threshold 0.0005
depth_threshold_low 0.003
depth_threshold_high 0.01
inter_radius 0.06
duplicate_threshold 0.02
num_neighbors 20
num_interpolations 2
resolution 0.005
window_size 9
Table 15: Stage 4 — Segmenting parameters (sam4tun baseline). *
Parameter Value
Boundary detection
binary_threshold 127
morph_kernel_size [3, 3]
dilation_iterations 1
hough_thresh_oblique 50
minLineLength_oblique 100
maxLineGap_oblique 40
hough_thresh_horiz 50
minLineLength_horiz 100
maxLineGap_horiz 10
hough_thresh_vert 500
angle_range_obliq_pos [6, 9]
angle_range_obliq_neg [−9-9, −6-6]
merge_distance 3
ring_spacing_constant 1.2
resolution 0.005
SAM template
segment_per_ring 6
segment_order [K, B1, A1, A2, A3, B2]
segment_width 1200
K_height 1079.92
AB_height 3239.77
angle 7.52
processing.padding 150
processing.y_bounds [4200, 13100]
processing.crop_margin 50

2 Characteriser fields

Table 16 summarises the characteriser fields used to describe each tunnel and to populate the per-stage state provided to the agents.

Table 16: Characteriser fields by stage. Raw fields are available to all stages; each subsequent group becomes available after the corresponding stage completes.
Source Fields
Raw estimated diameter, tunnel length, tunnel height
zz-range (min, max)
mean / median / min nearest-neighbour distance
Unfolded rr-percentiles (p10p_{10}, p99p_{99}), hh-span, θ\theta-span, θ\theta-range
median / std nearest-neighbour distance
intensity median, intensity min
Denoised mean / median / std nearest-neighbour distance
estimated diameter, tunnel length, surface completeness
surface regularity, average curvature, section curvatures
Enhanced total points, median / mean nearest-neighbour distance
coverage uniformity
template spacing suitability, current median spacing

3 Non-LLM rule-based pseudocode

The non-LLM baseline reads the same per-stage knowledge documents the LLM agents read, transcribed into a deterministic Python lookup. The parameter-selection logic for the denoising stage is reproduced below. Other stages follow the same pattern.

def select_denoising(chars):
    diameter = chars["estimated_diameter"]
    density  = chars["density"]
    p10      = chars["unfolded_p10"]
    p99      = chars["unfolded_p99"]

    if diameter > 6.5:
        family = "large"
    elif chars["joint_type"] == "continuous":
        family = "continuous"
    else:
        family = "base"

    params = REFERENCE_DENOISING.copy()

    if family == "large":
        params["mask_r_low"]       = p10
        params["mask_r_high"]      = p99 + 0.05
        params["smooth_win"]       = 5
    elif family == "continuous":
        params["mask_r_high"]      = max(p99, 2.85)
        params["smooth_win"]       = 6
    return params

4 Context components: denoising agent example

This appendix reproduces the three context components (memory, state, knowledge) that the agent receives as input.

4.1 Memory: reference vs target raw characteristics

Memory pairs the reference tunnel’s raw characteristics with those of the target tunnel using an identical schema, so the agent can compute deviations field-by-field (Table 17).

Table 17: Memory excerpt (raw characteristics). Reference is the expert-tuned tunnel; target is tunnel 4-1.
Field Reference Target (4-1) Δ\Delta
Total points 1,109,768 1,872,537 +69%+69\%
Estimated diameter (m) 5.32 7.41 +39%+39\%
Tunnel length (m) 12.16 18.10 +49%+49\%
Tunnel height (m) 5.08 7.72 +52%+52\%
Mean NN distance (m) 0.0082 0.0081 −1%-1\%
Median NN distance (m) 0.0065 0.0065 ≈0%\approx 0\%

Memory also bundles the SAM4Tun reference parameters for the stage (Table 13), so the agent always has a known-good baseline to deviate from.

4.2 State: cumulative outputs of upstream stages

State grows as the pipeline executes. For the denoising agent, state consists of the unfolded characteristics produced by the preceding unfolding stage, supplied as a reference/target pair (Table 18).

Table 18: State excerpt (unfolded characteristics, after the unfolding stage).
Field Reference Target (4-1)
rr-percentile p10p_{10} (m) 2.30 2.38
rr-percentile p99p_{99} (m) 2.77 3.93
hh-span (m) 12.08 18.86
θ\theta-span (rad) 17.28 23.28
Median NN distance (m) 0.047 0.066

4.3 Knowledge: parameter semantics, ranges, and constraints

Knowledge is a stage-specific Markdown document, authored once and shared across all tunnels. It enumerates each parameter together with its empirically validated range, defaults, and inter-parameter constraints. The denoising knowledge document is reproduced below.

Cross-tunnel variation. Tunnel lining datasets commonly vary along several axes: tunnel scale, from smaller metro-scale tunnels to larger-diameter tunnels; ring geometry, including shorter or longer ring lengths; segment layout, including different numbers and ordering of lining segments per ring; joint assembly, such as staggered, continuous, or interleaved joint arrangements; and scanning configuration, including single-station scans, multi-station registration, or uneven scanner placement.

Tunable parameters. mask_r_low (m), inner radial gate before depth histogramming, range [2.09,3.75][2.09,3.75] (baseline 2.7); mask_r_high (m), outer radial gate, range [2.78,4.38][2.78,4.38] (baseline 2.8); default_cutoff_z (m), fallback radial cutoff when a θ\theta-bin lacks reliable counts, range [2.65,6.27][2.65,6.27] (baseline 2.7); z_step (m), radial bin width per histogram column, range [0.003,0.005][0.003,0.005] (baseline 0.001).

Proven defaults.

smoothing_window_size = 5,

smoothing_offset = −0.002-0.002,

grad_threshold = 0.15,

y_step = 0.4.

Diagnostic rules. mask_r_low << mask_r_high; default_cutoff_z should stay coherent with the upstream unfolding diameter (order of magnitude ≈\approx diameter/2, with diameter in metres).

The three other stages (unfolding, enhancing, segmenting) follow the same four-block template; the per-stage knowledge documents are released in the project’s code repository.

5 Worked CoT trace

The following trace continues the worked example from Appendix 4: the denoising agent receives the memory, state, and knowledge inputs above, executes the five-step CoT protocol (Section 3.3.2), and emits a single schema-conformant JSON object that the denoising stage consumes unchanged.

Step 1 — Referencing.

Estimated diameter is 7.417.41 m vs reference 5.325.32 m (+39%+39\%). Unfolded rr-percentiles are p10=2.38p_{10}=2.38, p99=3.93p_{99}=3.93, vs reference p10=2.30p_{10}=2.30, p99=2.77p_{99}=2.77. Median nearest-neighbour distance after unfolding is 0.0660.066 m vs reference 0.0470.047 m (+41%+41\%), indicating lower areal density on the tunnel wall.

Step 2 — Diagnostic inspection.

Large-diameter, moderate-sparse target. The reference mask_r_low/mask_r_high (2.7/2.82.7/2.8) would clip all wall points beyond r=2.8r=2.8 m, which is below the target p10=2.38p_{10}=2.38 and well below p99=3.93p_{99}=3.93; the radial gate must widen substantially. default_cutoff_z (2.7) is below the target p99p_{99} (3.93) and would force the fallback path to discard valid wall points; it must rise. Lower density (+41%+41\% NN distance) requires z_step to relax from 0.0010.001 so each radial bin retains enough samples for the gradient test.

Step 3 — Parameter adaptation.

Set mask_r_low =2.37=2.37 (just below target p10=2.38p_{10}=2.38); mask_r_high =3.80=3.80 (just below target p99=3.93p_{99}=3.93, retaining ≥99%\geq 99\% of wall points while staying within the empirical range [2.78,4.38][2.78,4.38]); default_cutoff_z =3.7=3.7 (close to mask_r_high and order ≈\approx diameter/2 =3.71=3.71); z_step =0.005=0.005 (proven default for sparse scans). All other parameters take the proven defaults from the knowledge block.

Step 4 — Validation.

mask_r_low (2.37) << mask_r_high (3.80); both lie within their empirical ranges. default_cutoff_z (3.7) is consistent with the unfolding diameter (7.41 m, half-diameter 3.713.71 m). z_step (0.005) lies in [0.003,0.005][0.003,0.005]. All keys present, all types match Table 13.

Step 5 — JSON output.
    {
      "mask_r_low": 2.37,
      "mask_r_high": 3.80,
      "y_step": 0.4,
      "z_step": 0.005,
      "grad_threshold": 0.15,
      "smoothing_window_size": 5,
      "smoothing_offset": -0.002,
      "default_cutoff_z": 3.7
    }

The same parameter keys are adapted by GPT-5.4 and Gemini 3 Flash in qualitatively the same direction for this tunnel.

6 Runtime, API calls, and cost

Table 19 reports the compute setup and, for one m+s+k run, the per-tunnel input/output token counts and indicative USD cost for each LLM (averaged over the 30 tunnels, four stage calls per tunnel).

Table 19: Runtime, API calls, and per-tunnel API cost. Token counts are as reported by each vendor API; USD figures use vendor list prices at submission and are indicative.
Metric Value
LLM API calls per tunnel 4 (one per adapted stage agent)
Total API calls (full ablation) 120 per condition per LLM
GPU Single NVIDIA RTX 5060
Retraining required None
Labelled data required None (GT for evaluation only)
Per-tunnel tokens and cost (m+s+k, mean over 30 tunnels)
Opus 4.6 64,854 in / 6,599 out, $1.47
GPT-5.4 64,414 in / 35,263 out, $0.43
Gemini 3 Flash 83,658 in / 3,058 out, $0.03

7 Repeatability analysis

Table 20 reports a basic repeatability check for the full m+s+k condition (temperature 0). Each tunnel was re-inferred twice per LLM and the resulting adapted parameters and mIoU were compared between run 1 and run 2.

Table 20: Repeatability under m+s+k (temperature 0). Metrics are computed over 30 tunnels, with two runs per tunnel per LLM.
Metric Value
Mean critical parameters unchanged (18 total) 90.9%
Mean |Δ​mIoU|\lvert\Delta\mathrm{mIoU}\rvert (run 1 vs run 2) 0.029
Median |Δ​mIoU|\lvert\Delta\mathrm{mIoU}\rvert (run 1 vs run 2) 0.000

8 Per-class IoU breakdown

Tables 21 and 22 report per-class IoU for Opus 4.6 (representative; other LLMs show the same pattern) alongside the rules baseline. For regular tunnels, rules achieve per-class IoU comparable to sam4tun while all LLM conditions improve roughly uniformly. For complex tunnels (rules n=17n=17 including 3 failed tunnels scored as zero), rules recover segment structure from near-zero for most classes but not K-block; the LLM conditions achieve further improvement on regular tunnels. B2-block remains the hardest class, requiring the 7-segment layout guidance from the knowledge component.

Table 21: Per-class IoU—Regular tunnels (n=13n=13, 6-class, Opus 4.6).
Class sam4tun rules memory m+s m+s+k
Background 0.511 0.639 0.576 0.671 0.698
K-block 0.151 0.295 0.372 0.599 0.558
B1-block 0.217 0.256 0.338 0.643 0.613
A1-block 0.268 0.234 0.317 0.681 0.651
A2-block 0.198 0.159 0.180 0.403 0.398
A3-block 0.302 0.272 0.320 0.667 0.679
B2-block 0.229 0.412 0.317 0.710 0.723
Table 22: Per-class IoU—Complex tunnels (n=17n=17, 7-class, Opus 4.6). Rules include 3 failed tunnels scored as zero.
Class sam4tun rules memory m+s m+s+k
Background 0.337 0.534 0.358 0.513 0.520
K-block 0.000 0.000 0.034 0.183 0.159
B1-block 0.000 0.041 0.001 0.084 0.135
A1-block 0.000 0.072 0.005 0.128 0.155
A2-block 0.000 0.083 0.006 0.143 0.116
A3-block 0.000 0.149 0.017 0.092 0.119
A4-block 0.000 0.116 0.019 0.100 0.104
B2-block 0.000 0.099 0.000 0.000 0.043

9 Performance distribution

Table 23 summarises the distribution of mIoU across tunnels (reported as the mean across the three LLMs for each condition).

Table 23: Performance distribution (mean across 3 LLMs).
Metric sam4tun rules memory m+s m+s+k
Mean mIoU 0.176 0.254 0.230 0.430 0.452
Std 0.173 0.165 0.135 0.304 0.282
Min 0.037 0.119 0.068 0.099 0.156
Max 0.451 0.562 0.397 0.829 0.791