tk-yasuno/damage_vlm_finetune

An end-to-end pipeline for automated analysis of bridge structural damage (rebar exposure, cracks, corrosion) using LLaVA (Large Language and Vision Assistant). The system generates expert-level damage descriptions from images and produces structured prioritization scores for repair planning.

Python

1

18 commits

updated Jun 3, 2026

See the code

README

Bridge Damage VLM Fine-Tuning: Automated Assessment System v1.0.0

Progressive Fine-Tuning of LLaVA-1.5-7B with Quality Guard Agent for Bridge Damage Analysis and Repair Priority Scoring

Python PyTorch CUDA License

๐ŸŒ ๆ—ฅๆœฌ่ชž็‰ˆใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆ (Japanese Documentation)

๐Ÿ“‹ Table of Contents


Overview

An end-to-end pipeline for automated analysis of bridge structural damage (rebar exposure, cracks, corrosion) using LLaVA (Large Language and Vision Assistant). The system generates expert-level damage descriptions from images and produces structured prioritization scores for repair planning.

Key Features

  • Multi-Modal Vision Analysis: Leverages LLaVA-1.5-7B for accurate damage assessment
  • Automated Structuring: Converts natural language descriptions to structured JSON using Swallow-8B (Japanese LLM)
  • Intelligent Scoring: Rule-based prioritization system (1-5 scale)
  • Production-Ready: 100% success rate on 10-image test batch
  • GPU-Optimized: Full GPU acceleration with quantized GGUF models (4GB)

Pipeline Architecture

High-Level Flow

graph TB
    A[Input Images<br/>254 Bridge Damage Photos] --> B[Preprocessing<br/>Denoise/Resize/Contrast]
    B --> C[Vision Analysis<br/>LLaVA-1.5-7B GGUF]
    C --> D[JSON Structuring<br/>Swallow-8B]
    D --> E[Priority Scoring<br/>Rule-Based Engine]
    E --> F[Output<br/>CSV/JSON Reports]
  
    style A fill:#e1f5ff
    style C fill:#fff4e1
    style E fill:#ffe1e1
    style F fill:#e1ffe1

Detailed Pipeline Components

flowchart LR
    subgraph Input["๐Ÿ“ Input Stage"]
        A1[Raw Images<br/>PNG/JPG]
    end
  
    subgraph Preprocess["๐Ÿ”ง Preprocessing"]
        B1[Noise Reduction<br/>NL-Means]
        B2[Resize<br/>Max 1024x1024]
        B3[Contrast<br/>CLAHE]
    end
  
    subgraph Vision["๐Ÿ‘๏ธ Vision Analysis"]
        C1[Image Encoding<br/>CLIP Vision]
        C2[LLaVA Inference<br/>Q4_K_M Quantized]
        C3[Damage Description<br/>Japanese Text]
    end
  
    subgraph Structure["๐Ÿ“Š Structuring"]
        D1[Swallow-8B LLM<br/>via Ollama]
        D2[JSON Parsing<br/>Multi-Pattern]
        D3[Structured Data<br/>Type/Severity/Location]
    end
  
    subgraph Score["๐ŸŽฏ Scoring"]
        E1[Rule Evaluation<br/>40% Severity<br/>35% Type<br/>15% Location<br/>10% Risk]
        E2[Priority Calculation<br/>0.0-1.0 Score]
        E3[Level Assignment<br/>1-5 Priority]
    end
  
    subgraph Output["๐Ÿ’พ Output"]
        F1[CSV Export<br/>Batch Results]
        F2[JSON Export<br/>Detailed Records]
    end
  
    A1 --> B1 --> B2 --> B3
    B3 --> C1 --> C2 --> C3
    C3 --> D1 --> D2 --> D3
    D3 --> E1 --> E2 --> E3
    E3 --> F1
    E3 --> F2
  
    style Input fill:#e1f5ff
    style Vision fill:#fff4e1
    style Score fill:#ffe1e1
    style Output fill:#e1ffe1

Component Details

StageModulePurposeTechnology
Preprocessingimage_preprocessor.pyImage quality enhancementOpenCV 4.12
Vision Analysisllama_cpp_vision.pyDamage description generationLLaVA-1.5-7B Q4_K_M (4GB)
Structuringjson_structurer.pyNatural language โ†’ JSONSwallow-8B (Ollama)
Scoringpriority_scorer.pyRepair priority calculationRule-based (YAML)
Pipelineend_to_end.pyOrchestrationPython 3.12

Processing Time Breakdown (per image):

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Preprocessing:     ~2s  (4%)            โ”‚
โ”‚ Vision Analysis:  ~42s  (81%)           โ”‚
โ”‚ JSON Structuring:  ~5s  (10%)           โ”‚
โ”‚ Scoring:          <1s   (2%)            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total: ~51.6 seconds/image              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

v0.1 Achievements

โœ… Completed Features

  • 3 Vision Modes Implemented

    • llama-cpp-python + GGUF (Recommended): Lightweight, fast, full GPU utilization
    • HuggingFace Transformers: Stable, high accuracy
    • Ollama Integration: Easy setup (Note: CPU-only, slower)
  • Complete Pipeline

    • Preprocessing module (OpenCV)
    • Vision analysis (LLaVA-1.5-7B)
    • JSON structuring (Swallow-8B via Ollama)
    • Priority scoring (Rule-based)
  • Validation Tests

    • โœ… Single image: 42s/image
    • โœ… 10-image batch: 51.6s/image avg, 100% success rate
    • Priority distribution: Critical (Level 5) 60%, Moderate (Level 3) 40%
  • Windows Encoding Issues Resolved

    • PowerShell cp932 support
    • llama.cpp C++ log suppression
    • UTF-8 encoding standardization

๐Ÿ“Š Validation Data

  • Dataset: 254 images of rebar exposure damage
  • GPU: NVIDIA GeForce RTX 4060 Ti (16GB VRAM)
  • OS: Windows 11
  • Environment: Python 3.12.10 + CUDA 12.4

๐Ÿ”ฌ v0.2: Quantization Comparison Study

Objective

Comprehensive evaluation of LLaVA-1.5-7B quantization levels (Q4_K_M, Q5_K_M, Q8_0) to determine the optimal balance between accuracy, speed, and model size for bridge damage assessment.

Experimental Setup

  • Test Dataset: 254 rebar exposure images (full dataset)
  • Models Tested:
    • Q4_K_M: 4.1GB (4-bit quantization, medium)
    • Q5_K_M: 4.8GB (5-bit quantization, medium)
    • Q8_0: 7.2GB (8-bit quantization, baseline)
  • Hardware: NVIDIA RTX 4060 Ti 16GB, CUDA 12.4
  • Software: llama-cpp-python 0.2.90 (GPU-enabled)

Quality Evaluation Framework

Developed a 5-point quality scoring system (v0.2 design) to assess damage description completeness:

ComponentMax PointsCriteria
Damage Types2.0Recognition of crack, rebar exposure, corrosion, spalling, section loss
Severity Level1.0Minor, moderate, severe classification
Location Info1.0Spatial information (top, bottom, left, right, etc.)
Extent Info1.0Coverage description (local, widespread, partial, etc.)
Total5.0Comprehensive damage assessment score

Results Summary

QuantizationModel SizeInit TimeAvg InferenceQuality ScoreText LengthSuccess Rate
Q4_K_M4.1GB3.6s5.43s2.93 ยฑ 1.53168 ยฑ 41254/254 (100%)
Q5_K_M โญ4.8GB4.5s5.67s3.18 ยฑ 1.35160 ยฑ 37254/254 (100%)
Q8_07.2GB5.9s7.63s3.27 ยฑ 1.39162 ยฑ 39254/254 (100%)

Performance Comparison:

  • Q5_K_M vs Q4_K_M: +17.1% size, +4.5% slower, +8.5% quality โฌ†๏ธ
  • Q8_0 vs Q5_K_M: +50.0% size, +34.6% slower, +3.0% quality (not significant, p=0.16)

Visualization

Basic Comparison Results

LLaVA Quantization Comparison

Figure 1: Performance metrics across quantization levels (N=254). Shows average inference time, model size vs total time, quality score comparison, and summary statistics.

๐Ÿ“Š English Version | Japanese Version

Statistical Analysis

Statistical Analysis

Figure 2: Comprehensive statistical analysis including violin plots (quality, text length, inference time), box plots, scatter plots (quality vs text length/inference time), and detailed statistics table.

Key Findings

1. Quality Score Distribution

Violin Plot Analysis:

  • Q4_K_M: Bimodal distribution (46 images at 0-1 score, 46 at 5.0) โ†’ High variance
  • Q5_K_M: Concentrated at 3-4 points (75 images) โ†’ Stable mid-high quality
  • Q8_0: Similar to Q5_K_M (81 images at 3-4 points) โ†’ Stable but slower

Statistical Significance (Mann-Whitney U Test):

  • Q5_K_M vs Q4_K_M: U=34822.5, p=0.0591 (marginal significance)
  • Q8_0 vs Q5_K_M: U=33870.0, p=0.1627 (not significant)
  • Q8_0 vs Q4_K_M: U=36289.5, p=0.0069 โœ“ (significant, p<0.01)

2. Text Length vs Quality Correlation

QuantizationCorrelation CoefficientInterpretation
Q4_K_M-0.559Moderate negative (longer โ†’ lower quality)
Q5_K_M-0.148Weak negative (stable across lengths)
Q8_0-0.393Moderate negative

Insight: Q5_K_M maintains consistent quality regardless of description length, indicating robust performance.

3. Inference Time Analysis

  • Q4_K_M: Fastest (5.43s ยฑ 1.07s), but quality variance is high
  • Q5_K_M: Slightly slower (5.67s ยฑ 1.14s), best quality-speed balance
  • Q8_0: Slowest (7.63s ยฑ 1.42s), minimal quality improvement over Q5_K_M

Speed-Quality Efficiency:

Q4_K_M: 0.54 quality/sec (2.93 / 5.43)
Q5_K_M: 0.56 quality/sec (3.18 / 5.67) โ† BEST โญ
Q8_0:   0.43 quality/sec (3.27 / 7.63)

Discussion

Why Q5_K_M is Optimal

  1. Best Quality-Speed Balance

    • Only 4.5% slower than Q4_K_M
    • 8.5% higher quality than Q4_K_M (approaching statistical significance)
    • Statistically equivalent quality to Q8_0 (p=0.16)
  2. Stable Performance

    • Lowest text-length correlation (-0.148) โ†’ consistent output
    • Tight standard deviation (1.35 vs 1.53 for Q4_K_M)
    • Predictable inference time (5.67s ยฑ 1.14s)
  3. Resource Efficiency

    • 33% smaller than Q8_0 (4.8GB vs 7.2GB)
    • 25% faster than Q8_0 (34.6% speed advantage)
    • Fits comfortably in 8GB VRAM GPUs

Q8_0 Limitations

  • Diminishing Returns: Only 3% quality improvement over Q5_K_M
  • Slower: 34.6% longer inference time without significant quality gain
  • Larger: 50% more disk space and VRAM usage
  • Not Cost-Effective: Poor quality/sec efficiency (0.43 vs 0.56 for Q5_K_M)

Q4_K_M Use Cases

  • Rapid Prototyping: Fastest iteration for development
  • Resource-Constrained Environments: When speed is critical
  • Not Recommended for Production: High quality variance (SD=1.53) creates inconsistent results

Recommendations

PriorityQuantizationUse Case
๐Ÿฅ‡RecommendedQ5_K_MProduction deployment (best balance)
๐Ÿฅˆ AlternativeQ8_0High-accuracy applications (if speed is not critical)
๐Ÿฅ‰ DevelopmentQ4_K_MFast prototyping only

For Bridge Damage Assessment:

  • Deploy Q5_K_M for operational use (254 images in ~24 minutes)
  • Avoid Q8_0 unless accuracy requirements justify 35% slower processing
  • Use Q4_K_M only for development/testing

Lessons Learned (v0.2)

  1. Quantization is Not Free

    • Q4_K_M's speed advantage comes at the cost of quality variance
    • Bimodal distribution (0-1 or 5 points) indicates unstable outputs
  2. Sweet Spot Exists

    • Q5_K_M achieves 97% of Q8_0's quality with 25% speed improvement
    • Middle-ground quantization often optimal for production
  3. Statistical Validation is Essential

    • Correlation analysis revealed Q5_K_M's consistency advantage
    • Mann-Whitney U test confirmed Q8_0 vs Q5_K_M differences are not significant
  4. GPU Compatibility Matters

    • llama-cpp-python 0.2.90 required for GPU support on Windows
    • Newer versions (0.3.x) have Visual Studio CUDA integration issues
  5. Quality Metrics Enable Optimization

    • 5-point scoring framework made quantization trade-offs measurable
    • Violin plots revealed distribution differences invisible in averages

๐ŸŽฏ v0.3: Dataset Preparation & Progressive Fine-Tuning

Objective

Prepare high-quality training datasets from n=10,789 bridge damage images for progressive QLoRA fine-tuning of LLaVA-1.5-7B to improve damage description quality from 3.18/5.0 โ†’ 4.5+/5.0.

Status: โœ… Phase 1 Complete (Dataset Preparation)

Completion Date: 2026-05-22

Dataset Overview

  • Source: 10,789 bridge damage images with Japanese ground truth annotations
  • Master File: Rank_c_image_text_n10789.xlsx
  • Quality Filtering: Applied to ensure high-quality training data
  • Stratified Sampling: Maintains balanced distribution across damage scenarios
  • Progressive Scaling: 1k โ†’ 2k โ†’ 3k โ†’ 4k training sets for systematic evaluation

Data Preparation Pipeline

1. Quality Filtering Criteria

Text Length: 15-500 characters
Excluded Patterns:
  - Empty or whitespace only
  - Question marks only ("???")
  - "ใชใ—" (none), "่ฉฒๅฝ“ใชใ—" (not applicable)
Required Keywords (at least one):
  Damage Types: ใฒใณๅ‰ฒใ‚Œ, ใ‚ฏใƒฉใƒƒใ‚ฏ, ้‰„็ญ‹, ่…้ฃŸ, ๅ‰ฅ้›ข, ๅŠฃๅŒ–
  Components: ๆก, ๅบŠ็‰ˆ, ๆ”ฏๆ‰ฟ, ๆฉ‹่„š, ใ‚ณใƒณใ‚ฏใƒชใƒผใƒˆ
  Severity: ่‘—ใ—ใ„, ้ก•่‘—, ้€ฒ่กŒ, ่ปฝๅพฎ

Expected Retention Rate: ~70-80% (7,600-8,600 images passing filters)

2. Stratified Sampling Strategy

Purpose: Maintain representative distribution of component types and damage types across all datasets.

Methodology:

  • Strata Definition: Joint distribution of component_type ร— damage_type
  • Proportional Allocation: Each stratum represented according to its frequency
  • Fixed Random Seed: seed=42 for reproducibility

Benefits:

  • โœ… Prevents model bias toward frequent categories
  • โœ… Ensures test set covers all damage scenarios
  • โœ… Enables fair comparison across training scales (1k/2k/3k/4k)

3. Dataset Splits

SplitSizeSeedPurpose
Test Set80042Fixed evaluation set (never used in training)
Train 1k1,00042+1000Initial fine-tuning baseline
Train 2k2,00042+2000Scaling experiment (2x data)
Train 3k3,00042+3000Scaling experiment (3x data)
Train 4k4,00042+4000Maximum scale experiment

Note: Each training set is independently sampled (not cumulative) to measure pure dataset size effects.

Implementation

Script: prepare_v03_dataset.py

Features:

  • Loads Excel master data (10,789 rows)
  • Applies 4-stage quality filtering
  • Merges v0.2 metadata for stratification (if available)
  • Creates fixed test set (800 samples)
  • Generates progressive training sets (1k/2k/3k/4k)
  • Produces comprehensive statistics report

Usage:

# Activate virtual environment (training)
.\.venv-train\Scripts\Activate.ps1

# Run dataset preparation
python prepare_v03_dataset.py

Output Files:

data/v03_fine_tuning/
โ”œโ”€โ”€ test_set_n800.csv              # Fixed test set
โ”œโ”€โ”€ train_1k.csv                    # 1,000 training samples
โ”œโ”€โ”€ train_2k.csv                    # 2,000 training samples
โ”œโ”€โ”€ train_3k.csv                    # 3,000 training samples
โ”œโ”€โ”€ train_4k.csv                    # 4,000 training samples
โ””โ”€โ”€ dataset_preparation_report.md   # Statistics & distribution analysis

CSV Format:

ใƒ•ใ‚กใ‚คใƒซใƒ‘ใ‚น,ๆ‰€่ฆ‹,component_type,damage_type,text_length
rank_c_images_n10789/IMG_0001.jpg,"ๅบŠ็‰ˆไธ‹้ขใซ้ก•่‘—ใชใฒใณๅ‰ฒใ‚Œ...",ๅบŠ็‰ˆ,ใฒใณๅ‰ฒใ‚Œ,85

Why Progressive Training (1kโ†’2kโ†’3kโ†’4k)?

Rationale

  1. Measure Dataset Size Impact

    • Compare model performance at different data scales
    • Identify diminishing returns threshold
    • Determine optimal dataset size for cost-benefit
  2. Detect Overfitting Threshold

    • Monitor when additional data stops improving quality
    • Observe if validation scores plateau or decline
    • Adjust regularization if needed
  3. Resource Planning

    • Estimate training time per 1k samples (~2-4 hours)
    • Total time: ~20-40 hours across all 4 stages
    • Budget GPU hours for future scaling
  4. Ablation Study

    • Isolate effect of data quantity vs quality
    • Validate that improvements are from data, not hyperparameters
    • Support academic publication (arXiv paper)

v0.4-v0.6 Roadmap (Next Phases)


๐ŸŽ“ v0.4: QLoRA Progressive Training

Status: โœ… Complete

Completion Date: 2026-05-23
Training Period: 2026-05-22 01:59 - 2026-05-23 00:17 (Total: ~15 hours)

Objective

Execute progressive QLoRA fine-tuning of LLaVA-1.5-7B across four dataset scales (1k, 2k, 3k, 4k samples) to measure dataset size impact on model performance and identify the optimal training data volume.

Training Results Summary

StageDatasetTraining TimeTrain/Val SamplesFinal Val LossBest CheckpointLoss Improvement
v0.4.11k1:22:57799 / 2003.135checkpoint-100- (baseline)
v0.4.22k2:55:371,599 / 4003.073checkpoint-300โ†“ 1.98%
v0.4.33k4:31:442,398 / 6003.073checkpoint-400โ†” 0.00%
v0.4.44k6:19:103,196 / 7993.067checkpoint-600โ†“ 0.20%

Key Findings

  1. Performance Plateau at 2k-3k Range

    • Significant improvement from 1kโ†’2k (+1.98%)
    • Plateau at 2kโ†’3k (0% improvement)
    • Marginal improvement at 3kโ†’4k (+0.20%)
  2. Optimal Model: 2k Samples (v0.4.2)

    • Best cost-benefit ratio: 2.2x faster than 4k for only 0.2% worse loss
    • Stable training with minimal overfitting
    • Validation loss: 3.073 (vs 3.067 for 4k)
  3. Diminishing Returns

    • Loss convergence confirms limited benefit beyond 2k samples
    • Training time scales approximately linearly with data size
    • Resource efficiency decreases significantly after 2k

Training Configuration

Base Model: llava-hf/llava-1.5-7b-hf
Quantization: 4-bit NF4 with double quantization

LoRA Parameters:
  rank: 32
  alpha: 64
  dropout: 0.05
  target_modules: [q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj]

Training Hyperparameters:
  batch_size: 4
  gradient_accumulation_steps: 4  # Effective batch size: 16
  learning_rate: 2e-4
  num_epochs: 3
  warmup_steps: 50
  max_grad_norm: 1.0
  weight_decay: 0.01
  optimizer: AdamW
  lr_scheduler: cosine
  mixed_precision: fp16

Hardware:
  GPU: NVIDIA GeForce RTX 4060 Ti 16GB
  CUDA: 12.4
  PyTorch: 2.6.0

Loss Convergence Visualization

Validation Loss
3.14 โ”ค
     โ”‚ 1k โ—
3.12 โ”ค     โ•ฒ
     โ”‚      โ•ฒ
3.10 โ”ค       โ•ฒ 2k โ—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ—โ”โ”โ”โ”โ— (plateau)
     โ”‚              3k            4k
3.08 โ”ค
     โ”‚
3.06 โ”ค                              โ—
     โ”‚                             4k
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      1k    2k    3k    4k

Model Artifacts

models/
โ”œโ”€โ”€ llava_v03_qlora_1k/    # 134.5 MB (v0.4.1) โœ…
โ”œโ”€โ”€ llava_v03_qlora_2k/    # 134.5 MB (v0.4.2) โœ… Recommended
โ”œโ”€โ”€ llava_v03_qlora_3k/    # 134.5 MB (v0.4.3) โœ…
โ””โ”€โ”€ llava_v03_qlora_4k/    # 134.5 MB (v0.4.4) โœ…

Detailed Analysis

See Result_QLoRA_Scale.md for:

  • Detailed loss curves for all 4 stages
  • Cost-benefit analysis
  • Training time scaling analysis
  • Validation loss stability comparison
  • Recommendations for production deployment

Documentation


๐Ÿ“Š v0.5.1: Model Evaluation & Visualization

Status: โœ… Complete

Completion Date: 2026-05-24
Evaluation Period: 2026-05-23 - 2026-05-24

Objective

Comprehensive evaluation of all 4 QLoRA fine-tuned models (1k/2k/3k/4k) using semantic similarity metrics and creation of publication-quality visualizations for ACVR 2026 paper submission.

Evaluation Framework

Semantic Similarity Metric (Sentence-BERT)

Replaced simple quality scoring with Japanese Sentence-BERT cosine similarity:

  • Model: sonoisa/sentence-bert-base-ja-mean-tokens-v2
  • Metric: Cosine similarity between model predictions and ground truth
  • Range: 0.0 (completely different) โ†’ 1.0 (identical)
  • Test Set: 800 samples (fixed from v0.3)

Quality Tier Classification

TierSimilarity RangeInterpretation
Excellentฯ โ‰ฅ 0.85Near-perfect match
Good0.75 โ‰ค ฯ < 0.85High quality, minor differences
Acceptable0.65 โ‰ค ฯ < 0.75Adequate, usable
Poor0.50 โ‰ค ฯ < 0.65Significant gaps
Very Poorฯ < 0.50Unacceptable quality

Evaluation Results

Cosine Similarity Performance

ModelMean ยฑ StdMedianMinMaxTier
1k0.6491 ยฑ 0.08750.65360.08090.8462Acceptable
2k0.6850 ยฑ 0.08140.69330.08090.8526Acceptable
3k0.6909 ยฑ 0.07840.70810.08090.8540Acceptable+
4k0.6739 ยฑ 0.07950.68080.08090.8492Acceptable

Quality Tier Distribution

ModelExcellentGoodAcceptablePoorVery Poor
1k0.0%11.9%40.0%42.9%5.2%
2k0.1%20.8%50.6%26.2%2.2%
3k0.0%21.0%48.9%27.6%2.5%
4k0.0%15.9%51.9%32.1%0.1%

Key Findings: Inverted-U Relationship

1. Performance Trajectory

Cosine Similarity
0.70 โ”ค           โ•ญโ”€โ”€โ— 3k (Peak)
     โ”‚          โ•ฑ    โ•ฒ
0.68 โ”ค        โ—        โ•ฒโ— 4k (Degradation)
     โ”‚      โ•ฑ  2k       โ•ฒ
0.66 โ”ค    โ•ฑ              โ•ฒ
     โ”‚  โ—                 โ•ฒ
0.64 โ”ค 1k
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      1k    2k    3k    4k

Observation: Semantic similarity improves from 1kโ†’2k (+5.5%) โ†’ 3k (+0.9%), but degrades at 4k (-2.5%).

2. Optimal Model: 3k Samples

  • Highest Mean: 0.6909 (closest to "Good" tier boundary of 0.70)
  • Highest Median: 0.7081 (actually reaches "Good" tier)
  • Best Good+ Ratio: 21.0% (vs 20.8% for 2k, 15.9% for 4k)
  • Lowest Standard Deviation: 0.0784 (most consistent)

3. Cost-Benefit Winner: 2k Samples

  • Near-Optimal Performance: 0.6850 (only -0.9% below 3k)
  • Best Good+ Distribution: 20.8% Good + 0.1% Excellent
  • Lowest Very Poor Rate: 2.2% (vs 5.2% for 1k)
  • Training Efficiency: 2.9 hours (vs 4.5 hours for 3k, 6.3 hours for 4k)
  • Recommended for Production: Best quality/time ratio

4. Overfitting at 4k

Evidence:

  • 2.5% performance drop from 3k despite 33% more data
  • Good tier collapses from 21.0% (3k) โ†’ 15.9% (4k)
  • Poor tier expands from 27.6% (3k) โ†’ 32.1% (4k)
  • Validation loss: 3.073 (2k/3k) vs 3.067 (4k) โ€” lower loss but worse test performance

Hypothesis: Additional data introduces label noise or vocabulary saturation.

Visualizations (Publication Quality)

Created 5 comprehensive figures for ACVR 2026 paper:

Figure 3: Similarity Comparison

Similarity Comparison

Bar chart comparing mean cosine similarity across all 4 models with error bars (ยฑ1ฯƒ).

Figure 4: Tier Distribution (Stacked)

Tier Stacked

100% stacked bar chart showing quality tier proportions per model.

Figure 5: Tier Distribution (Grouped)

Tier Grouped

Grouped bar chart enabling direct comparison within each quality tier.

Figure 6: Violin Plots

Violin Plots

Distribution visualization showing density concentration (2k/3k near Good/Acceptable boundaries).

Figure 7: Summary Table

Summary Table

Comprehensive statistical summary with mean/std/min/max/median and tier percentages.

Paper Integration

Submitted to: ACVR 2026 (Asian Conference on Computer Vision and Robotics)
Paper: methodology.tex
Total Pages: 16 pages
Figures: 7 figures (including Validation Loss curve)

Key Sections

  1. Results (ยง4): Quantitative evaluation with all 5 visualization figures
  2. Discussion (ยง5):
    • ยง5.1: The 3k Peak and 4k Degradation (inverted-U analysis)
    • ยง5.2: Validation Loss interpretation (train-test discrepancy)
    • ยง5.3: Inference speed optimization (warm-up hypothesis)

Critical Insights for Paper

  1. Loss-Based Early Stopping Limitation
    4k model achieves lowest validation loss (3.067) but worst test performance (0.6739) โ€” highlights need for domain-specific metrics beyond perplexity.

  2. Mid-Scale Training Advantage
    2k-3k range achieves optimal quality-cost balance, challenging "more data = better" assumption in specialized domains.

  3. Overfitting in Low-Resource Domains
    Vocabulary saturation and label noise become dominant factors beyond ~3k samples for Japanese bridge damage terminology.

Scripts & Tools

Next Steps (v0.6)

  1. ACVR 2026 Submission: Complete camera-ready version with reviewer feedback
  2. Production Deployment: Deploy 2k model for operational bridge inspection
  3. Ablation Studies:
    • Test alternative PEFT methods (IAยณ, Prompt Tuning)
    • Experiment with different base models (LLaVA-v1.6, Qwen-VL)
  4. Expand Test Coverage: Evaluate on different damage types (cracks, corrosion without rebar exposure)

v0.5-v0.6 Roadmap (Next Phases)

Phase 2: v0.4 QLoRA Fine-Tuning (โณ Pending)

Script: train_v03_qlora.py

QLoRA Configuration:

Base Model: llava-hf/llava-1.5-7b-hf
Quantization: 4-bit NF4 with double quantization
LoRA Parameters:
  rank: 32
  alpha: 64
  dropout: 0.05
  target_modules: [q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj]
Training Hyperparameters:
  batch_size: 4
  gradient_accumulation_steps: 4  # Effective batch size: 16
  learning_rate: 2e-4
  num_epochs: 3
  optimizer: AdamW
  lr_scheduler: cosine with warmup (50 steps)
  mixed_precision: fp16

Training Stages:

# Stage 1: 1k samples (~2-4 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_1k.csv --output-dir models/llava_v03_qlora_1k

# Stage 2: 2k samples (~4-8 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_2k.csv --output-dir models/llava_v03_qlora_2k

# Stage 3: 3k samples (~6-12 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_3k.csv --output-dir models/llava_v03_qlora_3k

# Stage 4: 4k samples (~8-16 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_4k.csv --output-dir models/llava_v03_qlora_4k

Expected Output:

  • LoRA adapter weights (adapter_model.safetensors)
  • Training configuration (adapter_config.json)
  • Training logs (TensorBoard format)
  • Training summary (JSON with loss curves, timing)

Phase 3: v0.5 Vector Similarity Evaluation (โณ Pending)

Script: src/evaluation/vector_similarity_evaluator.py

Evaluation Method:

  • Model: Sentence-BERT Japanese (sonoisa/sentence-bert-base-ja-mean-tokens-v2)
  • Metric: Cosine similarity between ground truth and predictions
  • Test Set: Fixed 800 images (test_set_n800.csv)

Quality Thresholds:

Excellent:   โ‰ฅ0.85
Good:        โ‰ฅ0.75
Acceptable:  โ‰ฅ0.65
Poor:        โ‰ฅ0.50
Very Poor:   <0.50

Usage:

# Evaluate single model
python -m src.evaluation.vector_similarity_evaluator \
  --csv inference_1k_results.csv \
  --gt-col "ๆ‰€่ฆ‹" \
  --pred-col "prediction" \
  --output data/v03_fine_tuning/evaluations/evaluation_train_1k.json

# Generate progressive training report
python create_progressive_training_report.py \
  --eval-dir data/v03_fine_tuning/evaluations \
  --output-dir data/v03_fine_tuning/reports

Expected Improvements:

Metricv0.2 (Q5_K_M)v0.3 TargetImprovement
Mean Cosine Similarity0.68-0.720.78-0.85+15-20%
Quality Distribution (โ‰ฅ0.75)~45%70-80%+55-78%
Standard Deviation0.18-0.220.12-0.16Better consistency

Phase 4: v0.6 Academic Paper (โณ Pending)

Target: arXiv preprint submission

Paper Structure:

  1. Abstract: Progressive fine-tuning approach for bridge damage VLM
  2. Introduction: Motivation, challenges in civil engineering AI
  3. Methodology:
    • Dataset construction (10,789 images โ†’ filtered โ†’ stratified)
    • QLoRA configuration (4-bit, rank=32)
    • Progressive training strategy (1kโ†’4k)
    • Vector similarity evaluation
  4. Results:
    • Quantization comparison (v0.2)
    • Fine-tuning performance scaling (v0.3-v0.5)
    • Ablation studies
  5. Discussion: Optimal dataset size, cost-benefit analysis
  6. Conclusion: Recommendations for domain-specific VLM deployment

LaTeX Source: paper_damage_vlm/0_Format_arXiv_pdfLaTex/bridge_damage_vlm_quantization_2026.tex

Current Status Summary

PhaseStatusCompletion Date
v0.1: Baseline Pipelineโœ… Complete2025-12
v0.2: Quantization Studyโœ… Complete2026-03
v0.3: Dataset Preparationโœ… Complete2026-05-22
v0.4: QLoRA Trainingโœ… Complete2026-05-23
v0.5.1: Evaluation & Visualizationโœ… Complete2026-05-24
v0.6.3: Quality Guard + Full Pipelineโœ… Complete2026-05-25
v0.7.1: Image Size Optimizationโœ… Complete2026-05-26
v0.7.2: pairdata_v2 Progressive Retrainingโœ… Complete2026-05-27
v0.7.3: Quality Guard Recalibration & Full Pipelineโœ… Complete2026-05-28
v0.7.4: 2048-Dimensional Composite Embedding Evaluationโœ… Complete2026-05-29
v0.7.5: 2k Pipeline Evaluation & Supplementary Paper Updateโœ… Complete2026-05-29
v0.8: pairdata_v3 QLoRA Rank Ablation (r=16/32/64)โœ… Complete2026-05-30
v0.8.1: DoRA vs. LoRA Comparison (r=64)โœ… Complete2026-05-30
v0.8.2: Embedding Eval + QG Assessment โ†’ LoRA r=32 Adoptedโœ… Complete2026-05-31
v0.8.3: U.7 Qualitative Analysis Full Update (pairdata v3)โœ… Complete2026-05-31
v0.8.4: DoRA Rank Ablation Study (r=16/32 vs LoRA r=32)โœ… Complete2026-06-01
v0.8.5: DoRA r=24 Final Rank Ablation & v1.0.0 Model Selectionโœ… Complete2026-06-02

Documentation


๐Ÿ›ก๏ธ v0.6.3: Quality Guard Agent & Full Pipeline Evaluation

Status: โœ… Complete

Completion Date: 2026-05-25
Evaluation: Full n=800 test set (v0.6.3 pipeline, 3k model)

Overview

v0.6.3 introduces a two-stage Quality Guard Agent that filters low-quality VLM outputs before priority scoring, completing the end-to-end production pipeline:

Image โ†’ LLaVA-1.5-7B (3k QLoRA) โ†’ Quality Guard (Stage 1 + 2) โ†’ Priority Scorer โ†’ Report

Quality Guard Agent Architecture

Stage 1: Rule-Based Filter (CPU, ~0.01 s/row)

RuleThresholdReject Code
Token count below minimumฮธ_low = 98 (5th percentile)short_description
Token count above maximumฮธ_high = 202 (95th percentile)dirty_or_noisy
Excessive repetition (โ‰ฅ 3 repeated n-grams)โ€”dirty_or_noisy
No damage keyword presentโ€”dirty_or_noisy
Image file missingโ€”no_such_file

Token counting uses CJK + ASCII tokenization to correctly handle Japanese text.

Stage 2: SLM Judge (Swallow-8B NF4, GPU, Unsloth)

Applies natural-language judgement to Stage 1 PASS outputs as a second verification layer. Empirical result: Stage 2 produced 0 additional rejections for the 3k model โ€” the rule-based Stage 1 alone was sufficient.

n=800 Evaluation Results

MetricValue%
Total images800100.0%
PASS (High Quality)72790.9%
FAIL โ€” Dirty or Noisy364.5%
FAIL โ€” Short description354.4%
FAIL โ€” No such file20.2%
Stage 2 additional rejections0โ€”
End-to-end throughput8.97 s/rowโ€”
Total elapsed7,178 s (โ‰ˆ 2.0 h)โ€”

Priority Scoring Results (PASS n=727)

MetricValue
Priority LevelAll Level 3 (100%)
Priority Score0.54 (uniform)
Cosine Similarity (median)0.705 (Good tier boundary)
Token Count (median)120 tokens

Finding โ€” Output Mode Collapse: The 3k model generates near-identical descriptions for all PASS images. Main Girder is mentioned in 100% of predictions; Rebar Exposure in 99.6%; Spalling in 98.6%. This stereotyped output pattern causes uniform priority scores (Level 3 saturation). See paper_damage_vlm/1_Methodology/methodology.tex for full analysis.

Quality Metric Distributions

MetricPASS (n=727)FAIL (n=73)
Cosine similarity (median)0.7050.659
Token count (median)12097 โ‰ˆ ฮธ_low

The Quality Guard preferentially retains predictions with higher semantic alignment โ€” even though the filter is defined only on output-text properties, it acts as a proxy for semantic quality.

Key Findings

  1. Stage 1 sufficiency: The lightweight CPU rule filter achieves the same classification as the full two-stage pipeline for the 3k model and this corpus.
  2. Output mode collapse: Fine-tuning on a skewed training corpus causes the model to default to a dominant memberโ€“damage template. Requires data balancing or constrained-generation prompts.
  3. Priority scoring calibration gap: All 727 PASS samples receive Priority Level 3, indicating the YAML rules need recalibration or VLM prompts need explicit severity keywords.
  4. Throughput: 8.97 s/row (batch_size=8, torch.compile()) enables processing of 800 images in ~2 hours on RTX 4060 Ti 16GB.

Generated Figures

FigureDescription
figures_vlm/10_priority_score_violin.pngPriority score saturation + PASS vs FAIL cosine similarity + token count violin
figures_vlm/10_member_damage_analysis.pngMember/damage frequency bars + co-occurrence heatmap

Scripts

  • Pipeline: pipeline_v063.py โ€” Full end-to-end v0.6.3 pipeline
  • Figure generation: create_figures_10.py โ€” Analysis figures for n=800 results
  • Output CSV: data/v03_fine_tuning/evaluations/v063_scoring_results.csv (800 rows, 22 columns)

Paper Status

The academic paper (paper_damage_vlm/1_Methodology/methodology.tex) is complete with all v0.6.3 results:

  • Quality Guard Agent methodology section (TikZ algorithm flow diagram)
  • n=800 results tables (tab:qg_final)
  • Output mode collapse analysis (fig:member_damage)
  • Priority scoring distribution (fig:priority_violin)
  • Discussion: Quality Guard efficacy, mode collapse, calibration
  • 25 pages, 10 figures โ€” compiled with pdflatex (no errors)

๐Ÿ–ผ๏ธ v0.7.1: Image Size Optimization for QLoRA Fine-Tuning

Status: โœ… Complete

Completion Date: 2026-05-25
Experiment: Controlled comparison of 3 input image datasets at 1k scale

Background

LLaVA-1.5-7B uses a CLIP ViT-L/14-336 vision encoder pretrained at 336ร—336 px. Feeding images at arbitrary sizes forces internal rescaling and introduces resampling artifacts into the patch embeddings, potentially degrading fine-tuning quality. This experiment quantifies the impact of pre-standardising training images to the model's native resolution.

Image Preprocessing Pipeline

StepDescriptionOutput
1Long-side resize to 1024 px (aspect-ratio preserved)data/inspect_images_v2/ โ€” 10,789 images
2Manual removal of blueprints / blank / corrupted images10,668 images remain (121 removed)
3aCenter-crop to square โ†’ resize to 336ร—336data/inspect_images_336/ โ€” 10,668 images, ~0.034 MB avg
3bCenter-crop to square โ†’ resize to 448ร—448data/inspect_images_448/ โ€” 10,668 images, ~0.060 MB avg

Center-crop (rather than pad-and-resize) was chosen because bridge damage photos are mixed portrait/landscape. Padding introduces black borders that divert the vision encoder's attention from damage regions.

Comparative Training Results (1k Scale, 3 Epochs)

DatasetImage SourceImage SizeTraining Timeeval_losseval Token Accuracy
pairdata_v2-1rank_c_images_n10789Variable (original)1:34:533.18989.5%
pairdata_v2-2inspect_images_336336ร—336 px1:21:463.19490.1%
pairdata_v2-3inspect_images_448448ร—448 px1:21:573.20289.9%

All runs: train_v07_qlora.py, LoRA r=32/ฮฑ=64, LR=2e-4, batch_size=4, BF16, RTX 4060 Ti 16GB

Key Finding

336ร—336 px is the optimal input size for LLaVA-1.5-7B fine-tuning on bridge damage images:

  • +0.6 pt token accuracy vs. variable-size originals
  • 14% shorter training time (1:34:53 โ†’ 1:21:46) due to uniform tensor shapes enabling better GPU batching
  • 448ร—448 px shows no accuracy gain over 336ร—336 px, despite 76% larger file size โ€” the CLIP encoder's 336 px pretraining is the binding constraint

Configuration Update

config.yaml and train_v07_qlora.py now default to data/inspect_images_336/:

# config.yaml โ€” v0.7.1
v03_dataset:
  image_dir: "data/inspect_images_336"   # 336ร—336 center-crop (LLaVA-1.5 native)
  # image_dir: "data/inspect_images_448"  # 448ร—448 alternative
  # image_dir: "data/inspect_images_v2"   # max 1024px long side (original)

Scripts

  • resize_images_v2.py โ€” Step 1: long-side 1024 px resize
  • crop_resize_images.py โ€” Steps 3a/3b: center-crop + resize to 336 and 448
  • train_v07_qlora.py โ€” Added --image-base-dir CLI option for dataset switching

Further Reading


๐Ÿ“ˆ v0.7.2: pairdata_v2 Progressive Retraining (1k-4k)

Status: โœ… Complete

Completion Date: 2026-05-27
Scope: Full progressive QLoRA retraining on denoised pairdata_v2 with inspect_images_336

What Was Completed

  • Completed all four scales (1k, 2k, 3k, 4k) under a fixed training recipe
  • Updated supplementary section S.4 in methodology with final tables and observations
  • Added S.4 figure using the same plotting style as Figure 9:
    • paper_damage_vlm/1_Methodology/figures_vlm/11_s4_validation_loss_pairdata_v2.png
    • plotted from raw eval checkpoints (no interpolation) for fair comparison

Final Progressive Results (pairdata_v2)

ScaleTrainValSkipDurationFinal eval_lossFinal eval Token Accuracy
1k792198101h 21m3.19490.1%
2k1579395262h 56m3.15198.7%
3k2374594324h 24m3.13599.0%
4k3168792405h 55m3.12599.2%

Key Findings

  • Strongest gain is 1k -> 2k (-0.043 nats eval loss, +8.6 pp token accuracy)
  • Clear diminishing returns beyond 2k:
    • 2k -> 3k: -0.016 nats, +0.3 pp
    • 3k -> 4k: -0.010 nats, +0.2 pp
  • In 4k run, minimum eval loss appears at epoch 2 (3.124), then slightly increases at epoch 3 (3.125), suggesting near-convergence

Semantic Similarity Evaluation on Denoised Test Set (S.6)

Test set: n=800, pairdata-v2 ground truth
Evaluator: paraphrase-multilingual-MiniLM-L12-v2 (cosine similarity)
Tier thresholds: Excellent โ‰ฅ 0.85 ยท Good โ‰ฅ 0.70 ยท Acceptable โ‰ฅ 0.55 ยท Poor โ‰ฅ 0.40 ยท Very Poor < 0.40

ScaleMean ฯฯƒMedianGood+ (%)V.Poor (%)
1k0.56570.15730.591635.232.9
2k0.60110.13670.613740.621.9
3k โœ…0.60130.14370.621339.821.5
4k0.57420.13980.601433.828.2

All four models fall in the Acceptable tier under pairdata-v2 thresholds.
Absolute values are ~0.08โ€“0.09 lower than pairdata-v1 results, reflecting the harder matching task of shorter denoised ground-truth texts.

Key findings:

  • 1k โ†’ 2k: +6.3% mean gain (largest improvement)
  • 2k โ‰ˆ 3k: ฮ”ฯ = 0.0002 (saturation)
  • 4k: โˆ’4.5% from 3k (overfitting: VPoor rises 21.5% โ†’ 28.2%)

Model selected: 3k
Rationale: peak mean (0.6013) + highest median (0.6213) + lowest Very Poor rate (21.5%).
Result is consistent with pairdata-v1 finding where 3k also achieved peak performance (ฯ = 0.6909).

Figures generated:

  • paper_damage_vlm/1_Methodology/figures_vlm/12_v072_similarity_by_scale.png
  • paper_damage_vlm/1_Methodology/figures_vlm/13_v072_tier_distribution.png
  • paper_damage_vlm/1_Methodology/figures_vlm/14_v072_cosine_violin.png

Repro Commands

.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 1k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 2k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 3k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 4k

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology.tex (ๆœฌ็ทจใฎใฟใ€Supplementaryๅˆ†้›ขๆธˆใฟ)
  • paper_damage_vlm/1_Methodology/methodology_supp.tex (Supplementary ็‹ฌ็ซ‹ใƒ•ใ‚กใ‚คใƒซใ€S.6็ต่ซ–ๅซใ‚€)
  • paper_damage_vlm/1_Methodology/methodology.pdf (23 pages, recompiled)
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf (7 pages, recompiled)

๐Ÿ”ฌ v0.8: pairdata_v3 QLoRA Rank Ablation

Status: โœ… Complete

Completion Date: 2026-05-30
Scope: pairdata_v3 denoising; LoRA rank ablation r=16/32/64 at 2,500-sample scale; Supplementary 2 full documentation

LoRA Rank Ablation Results (pairdata_v3, 2,500 samples)

Runreval_loss (best)token_acc (best)train_lossDuration
v0.8-r16163.13898.73%3.5673h24m
v0.8-r32323.13398.83%3.4895h36m
v0.8-r64643.12298.90%3.4193h27m

All best checkpoints at epoch 2.421 of 3.

Key Finding

r=64 selected as optimal: 168.8M trainable parameters (4.56% of 7B backbone) provide sufficient representation space to learn the fine-grained correspondence between complex damage imagery and structured recognition text (member type ร— damage category). r=16/32 (42M/84M) leave a residual alignment gap. Critically, r=64 adds no measurable GPU cost over r=16 (3h24m vs 3h27m on RTX 4060 Ti 16GB).

Supplementary 2 Documentation

  • U.1: Motivation (pairdata_v3 noise removal rationale)
  • U.2: Extended noise pattern definition
  • U.3: Pairdata v2 vs v3 statistics comparison
  • U.4: QLoRA training at 2,500-sample scale โ€” rank ablation table + Figure 21 + analysis
  • U.5โ€“U.7: Semantic similarity, Quality Guard, Qualitative analysis (pending v0.8 inference)
  • U.8: DoRA vs. LoRA comparison (filled in v0.8.1)

๐Ÿ”ฌ v0.8.1: DoRA vs. LoRA Comparison (r=64)

Status: โœ… Complete

Completion Date: 2026-05-30
Scope: DoRA fine-tuning (use_dora=True, r=64) on pairdata_v3 2,500 samples; U.8 Supplementary 2 fully documented

DoRA vs. LoRA Results (pairdata_v3, 2,500 samples, r=64)

RunAdaptereval_loss (best)token_acc (best)train_lossDurationฮ”eval
v0.8-r64LoRA3.12298.90%3.4193h27mโ€”
v0.9-r64DoRA3.11998.92%3.4176h51mโˆ’0.003

Best checkpoints at epoch 2.421; final-epoch: LoRA 3.132/98.93%, DoRA 3.132/98.95%.

Research Questions Answered

#QuestionResult
(i)DoRA lower eval_loss than LoRA at same r?โœ… 3.119 < 3.122 (ฮ”=โˆ’0.003)
(ii)Cosine similarity improvement?๐Ÿ”„ Pending inference on n=800 test set
(iii)Hallucination reduction?๐Ÿ”„ Pending inference on n=800 test set

Supplementary 2 Updates (U.8)

  • Configuration table: r=32/alpha=64 โ†’ r=64/alpha=128
  • Training Results table: TBD values filled with actual DoRA results
  • Motivation rewritten: r=64 basis from U.4 ablation; 3 research questions
  • Adapter capacity analysis: 168.8M params at 4.56% provides bridge-domain bandwidth
  • Repro Commands: updated to train_v09_dora.py --lora-r 64

Reproduce

# DoRA training
.venv-train\Scripts\Activate.ps1
python -u train_v09_dora.py --lora-r 64 *> v09_dora_r64_log.txt
# Output: models/llava_v09_dora_r64_2500

# Recompile Supplementary 2
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.2: Embedding Evaluation + Quality Guard Assessment

Status: โœ… Complete

Completion Date: 2026-05-31
Scope: 2048-dim Sentence-BERT evaluation of all 4 adapters on n=800 test set; Quality Guard + Priority Scoring for LoRA r=32 and DoRA r=64; Structural Member & Damage Type analysis; final model selection

Sentence-BERT Evaluation Results (2048-dim composite, n=800)

ModelAdapterMean CosineMedian CosineGood+ RateExcellent Rate
v0.8-r16LoRA r=160.64640.648018.9%0.0%
v0.8-r32LoRA r=320.67000.668932.9%0.0%
v0.8-r64LoRA r=640.65710.660628.4%0.0%
v0.9-r64DoRA r=640.68460.683541.0%0.0%

Embedding model: hotchpotch/static-embedding-japanese (1024-dim) โŠ• intfloat/multilingual-e5-large (1024-dim), L2-normalized concatenation.

Quality Guard + Priority Scoring Results (n=800)

ModelPASSFAILToken MeanToken ฯƒLevel 3Level 4Level 5
LoRA r=32 (v0.8)798 (99.8%)2 (0.2%)89.518.98.0%79.2%12.8%
DoRA r=64 (v0.9)798 (99.8%)2 (0.2%)84.34.50.0%100%0.0%

ฮธ_low=30, ฮธ_high=200 (retained from v0.7.3).

Key Findings

#FindingDetail
(i)DoRA r=64: highest embedding scoreMean cosine 0.6846, Good+ 41.0% โ€” best among all adapters
(ii)DoRA r=64: output-level mode collapseToken ฯƒ=4.5 (vs LoRA 18.9); all 798 PASS โ†’ Level 4 (100%)
(iii)DoRA r=64: structural member/damage collapseMain Girder+Deck Slab 100%, Crack/Rebar/Spalling 100% โ€” stereotyped template
(iv)LoRA r=32: balanced severity distributionLevel 3โ†‘ (8.0% vs v0.7.3-3k 2.7%); Level 3/4/5 distribution improves fairness
(v)DoRA r=64 fine-tuning failedr=64 likely excessive for DoRA; fine-tuning protocol to be established as future work
(vi)LoRA r=32 (v0.8) adopted as final modelBest balance of embedding quality and output diversity

Structural Member & Damage Type Analysis (U.6.1)

ModelMain GirderCurbDeck SlabCrackRebar Exp.SpallingLime Effl.
LoRA r=32100%60.0%9.9%100%88.1%99.0%73.9%
DoRA r=64100%0%100%100%100%100%0%

DoRA r=64 assigns exactly 3 damage types to exactly 2 members across all 798 predictions: clear evidence of fine-tuning failure.

Supplementary 2 Updates (U.5โ€“U.6.1)

  • U.5: Sentence-BERT results table filled (TBDโ†’actual); Figures 22/23/24 inserted; Analysis paragraph added
  • U.6: Quality Guard table (2-model comparison); Priority table; Analysis rewritten with v0.7.3-3k comparison and DoRA failure conclusion
  • U.6.1: New subsection โ€” Structural Member & Damage Type (Figure 28, same style as S.7.1)
  • U.5 conclusion: Revised from "DoRA adopted" to "both forwarded to QG for evaluation"
  • Final conclusion: LoRA r=32 (v0.8) adopted; DoRA finetuning left as future work
  • methodology_supp2.pdf: 21 pages

Figures Generated

FigureFileContent
Fig. 2222_v08_similarity_by_adapter.pngMean/Median cosine similarity by adapter
Fig. 2323_v08_tier_distribution.pngTier distribution stacked bar
Fig. 2424_v08_cosine_violin.pngCosine similarity violin plots
Fig. 2525_v08_token_distribution.pngToken count histograms (LoRA r=32 vs DoRA r=64)
Fig. 2626_v08_guard_breakdown.pngPASS/FAIL + reason code breakdown
Fig. 2727_v08_priority_distribution.pngPriority level distribution
Fig. 2828_v08_member_damage_r32_dora.pngStructural member ร— damage co-occurrence (S.7.1 style)

Reproduce

# Sentence-BERT evaluation (4 models)
.venv-eval\Scripts\Activate.ps1
python -u evaluate_v08_sbert.py

# Quality Guard + Priority Scoring
python -u pipeline_v08.py

# Generate Figures 22-24 (U.5)
python -u create_u8_figures.py

# Generate Figures 25-27 (U.6)
python -u create_u6_figures.py

# Generate Figure 28 (U.6.1, S.7.1 style)
python -u create_u61_figures.py

# Recompile Supplementary 2 (21 pages)
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.3: U.7 Qualitative Analysis Full Update (pairdata v3)

Status: โœ… Complete

Completion Date: 2026-05-31
Scope: U.7 qualitative analysis section fully rebuilt on pairdata v3 (inference_r32.csv); 12 representative PASS images re-selected with member ร— damage diversity; caption simplified and enriched; shared keyword highlighting added

Changes

ItemDescription
Image selection12 images re-selected from inference_r32.csv (pairdata v3 test set) using greedy member ร— damage diversity
Caption structureSimplified to 3 items: Quality Metrics / GT / Pred
Quality MetricsSim(emb) (2048-dim cosine) + Priority Score (0โ€“1) + Level (priority tier 3/4/5)
Keyword highlightKeywords appearing in both GT and Pred rendered in gothic font (\CJKfamily{ipxg}) for visual emphasis
s8 folderAll 12 JPEGs replaced (figures_vlm/s8/s8_01_*.jpg โ€“ s8_12_*.jpg)
PDFmethodology_supp2.pdf rebuilt โ†’ 19 pages

Selected Images (12 panels, member ร— damage)

#MemberDamageSim(emb)PriorityLevel
01girdercracking0.8401.005
02girderrebar_exposure0.8080.814
03girderspalling0.7740.814
04girdercorrosion0.7130.814
05girdersettlement0.5720.814
06girderother0.5850.814
07slabcracking0.8061.005
08slabrebar_exposure0.7780.814
09slabcorrosion0.7410.814
10abutmentcracking0.7981.005
11abutmentrebar_exposure0.7970.814
12abutmentspalling0.6690.814

Reproduce

.venv-eval\Scripts\Activate.ps1
python create_u7_figures.py

cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.4: DoRA Rank Ablation Study

Status: โœ… Complete

Completion Date: 2026-06-01
Scope: DoRA fine-tuning at r=16 (full pipeline: train โ†’ merge โ†’ inference โ†’ SBERT โ†’ quality guard โ†’ figures); 3-way rank ablation (LoRA r=32 vs. DoRA r=32 vs. DoRA r=16) with Figures 35โ€“41 and U.7.2 discussion update

Overview

v0.8.4 extends the DoRA investigation with a lower-rank variant (r=16) and performs a full 3-way comparison against the LoRA r=32 baseline and DoRA r=32. The ablation reveals a non-monotone relationship between DoRA rank and output quality: r=16 achieves the most balanced priority distribution despite having the smallest trainable capacity.

DoRA r=16 Training Details

ItemValue
Scripttrain_v09_dora.py --lora-r 16
AdapterDoRA (use_dora=True), r=16, alpha=32, dropout=0.05
Datasetpairdata-v3, 2,500 samples (80/20 split)
eval_loss (best, ep 2.421)3.135
eval_loss (final, ep 3.0)3.138
Training duration6h 48m 26s
Merged modelmodels/llava_v09_dora_r16_merged/ (85 shards, max_shard_size=200MB)

3-Way Ablation Results (n=800)

SBERT Cosine Similarity (2048-dim composite evaluator)

ModelMeanStdMedianGood+ (โ‰ฅ0.70)
LoRA r=32 (v0.8 baseline)0.67000.06570.685432.9%
DoRA r=32 (v0.9)0.65640.06820.669125.0%
DoRA r=16 (v0.9)0.67170.06390.681136.0%

Quality Guard & Priority Distribution (n=800)

ModelPASSFAILL3L4L5Token mean
LoRA r=32798 (99.8%)26463210289.5
DoRA r=32798 (99.8%)265726788.0
DoRA r=16797 (99.6%)3617053174.5
DoRA r=64 (ref)798 (99.8%)20798084.3

Key finding: DoRA r=64 undergoes complete mode collapse (all Level 4). DoRA r=16 achieves the most balanced Level 3/4/5 distribution among DoRA variants.

Figures Generated

FigureFileContent
3535_u72_similarity.pngMean/median cosine similarity (3-way bar)
3636_u72_tier.pngQuality tier distribution
3737_u72_violin.pngCosine similarity violin plots
3838_u72_token.pngToken count histograms
3939_u72_priority.pngPriority level distribution
4040_u72_member_damage.pngMember ร— damage co-occurrence analysis
4141_u7_dora_rank_training_loss.pngValidation loss trajectories (3 models)

Supplementary Paper Updates

SectionChange
U.7.1Figure 41 (validation loss) + "Training dynamics" analysis paragraph added
U.7.2Title updated to "DoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16"
U.7.2Figures 35โ€“40 inserted (3-way 6-panel comparison)
U.7.2 DiscussionDoRA r=64 gradient collapse, r=16 balanced output, r=24 proposed as future work
PDFmethodology_supp2.pdf rebuilt โ†’ 5648 KB

Discussion Summary

  • DoRA r=64: Directionโ€“magnitude decomposition exceeded model capacity at 2500-sample scale โ†’ priority output collapsed to Level 4 (100%), losing member/damage diversity
  • DoRA r=32: Approached LoRA r=32 in similarity but skewed to Level 4 (91%), Level 5 nearly absent
  • DoRA r=16: Smallest capacity but most equitable priority distribution (L3: 7.7%, L4: 88.5%, L5: 3.9%); best Good+ rate (36.0%) among DoRA variants
  • Next step: DoRA r=24 proposed to explore the non-monotone rankโ€“quality tradeoff

Reproduce

# Phase 1: Training (requires .venv-train)
.\.venv-train\Scripts\python.exe train_v09_dora.py --lora-r 16

# Phase 2: Merge (requires .venv-dora)
.\.venv-dora\Scripts\python.exe merge_dora.py

# Phase 3: Inference (requires .venv-dora, NOT .venv-eval)
.\.venv-dora\Scripts\python.exe inference_v082_lora_dora.py --models r16_dora

# Phase 4: SBERT evaluation
.\.venv-eval\Scripts\python.exe evaluate_v08_sbert.py

# Phase 5: Quality Guard + Priority Scoring
.\.venv-eval\Scripts\python.exe pipeline_v08.py

# Phase 6: Figures 35-40 + U.7.2 update
.\.venv-eval\Scripts\python.exe create_u72_dora_ablation.py

# PDF recompile
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

๐ŸŽ‰ v0.8.5: DoRA r=24 Final Rank Ablation & v1.0.0 Model Selection

Status: โœ… Complete

Completion Date: 2026-06-02
Scope: DoRA r=24 full pipeline; 4-way rank ablation (LoRA r=32 + DoRA r=32/16/24); Figure 15 & Figures 35โ€“40 updated to 4-model comparison; U.7.2 Discussion extended; U.7.3 Qualitative Analysis added; DoRA r=24 selected as v1.0.0 final model

Overview

v0.8.5 completes the DoRA rank ablation study by adding DoRA r=24 โ€” the midpoint proposed in v0.8.4 to resolve the non-monotone rankโ€“quality tradeoff. The experiment confirms that DoRA r=24 achieves the best overall balance among all tested variants, leading to its adoption as the production model for v1.0.0.

DoRA r=24 Training Details

ItemValue
Scripttrain_v09_dora.py --lora-r 24
AdapterDoRA (use_dora=True), r=24, alpha=48, dropout=0.05
Datasetpairdata-v3, 2,500 samples (80/20 split)
eval_loss (best, ep 2.421)3.137
Training duration~6h 50m
Merged modelmodels/llava_v09_dora_r24_merged/

4-Way Ablation Results (n=800)

SBERT Cosine Similarity (2048-dim composite evaluator)

ModelMeanStdMedianGood+ (โ‰ฅ0.70)
LoRA r=32 (v0.8 baseline)0.67000.06670.668932.9%
DoRA r=32 (v0.9)0.65640.06300.660225.0%
DoRA r=16 (v0.9)0.67170.06390.681136.0%
DoRA r=24 (v0.9)0.67910.06350.683437.8%

Quality Guard & Priority Distribution (n=800)

ModelPASSFAILL3L4L5Token mean
LoRA r=32798 (99.8%)26463210289.5
DoRA r=32798 (99.8%)265726788.0
DoRA r=16797 (99.6%)3617053174.5
DoRA r=24798 (99.8%)2486747890.6

Key finding: DoRA r=24 achieves the highest SBERT similarity (mean=0.6791, Good+=37.8%) while maintaining a balanced priority distribution (L3/L4/L5 = 6.0%/84.5%/9.8%). This non-monotone optimum confirms DoRA r=24 as the sweet spot for LLaVA-1.5-7B on this structural damage domain.

Paper Updates

SectionChange
Figure 15Updated to "four models"; DoRA r=24 (eval_loss=3.137) added as 4th curve
Training dynamics paragraphDoRA r=24 convergence behaviour added
U.7.2 titleโ†’ "DoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16/24"
U.7.2 Figures 35โ€“40Regenerated as 4-model comparison (added DoRA r=24 column)
U.7.2 DiscussionExpanded to 6 paragraphs: rankโ€“quality relationship; figure-level evidence for each of Figs 35โ€“40; final model selection
U.7.3New subsection: Qualitative Analysis: Finetuned Model Predictions DoRA r=24 (12 panels, Figure 12โ€“14 style)
PDFmethodology_supp2.pdf rebuilt, no errors

Final Model Selection: DoRA r=24

DoRA r=24 (v0.9) is adopted as the v1.0.0 production model based on:

  1. Highest SBERT similarity: mean=0.6791, Good+=37.8% (best across all 7 tested adapters)
  2. Balanced priority distribution: L5 rate 9.8% โ€” higher than DoRA r=16 (3.9%) and DoRA r=32 (0.9%), more discriminative than LoRA r=32 (12.8%)
  3. Non-collapse output: token ฯƒโ‰ˆ6 (stable), no mode collapse to single level
  4. Optimal adapter capacity: 126M trainable parameters โ€” sufficient for bridge-domain fine-grained semantics without over-parameterisation (r=64โ†’collapse; r=16โ†’lower similarity)

v1.0.0 Full Inference (โœ… Complete)

ItemValue
Scriptinference_v10_full.py
ModelDoRA r=24 merged (models/llava_v09_dora_r24_merged/)
InputRank_c_image_text_n10789.xlsx (10,903 rows)
PipelineVLM inference + Quality Guard + Priority Scoring (single pass)
Checkpointevery 2,000 rows โ†’ data/v10_full/checkpoint_{n:06d}.xlsx
Speed3.5 s/image (batch_size=4, RTX 4060 Ti 16GB)
Total time10.55 h (37,968 s)
Outputdata/v10_full/v10_full_r24_dora.xlsx

Figures Generated

FigureFileContent
1515_training_dynamics.pngValidation loss curves โ€” 4 models
3535_u72_similarity.pngMean/median cosine similarity (4-model bar)
3636_u72_tier.pngQuality tier distribution (4 models)
3737_u72_violin.pngCosine similarity violin plots (4 models)
3838_u72_token.pngToken count histograms (4 panels)
3939_u72_priority.pngPriority level distribution (4 models)
4040_u72_member_damage.pngMember ร— damage co-occurrence (4 columns)
U.7.3 Figss9/s9_01โ€“s9_12.jpgDoRA r=24 qualitative panels

Reproduce

# Phase 1: Training (requires .venv-train)
.\.venv-train\Scripts\python.exe train_v09_dora.py --lora-r 24

# Phase 2: Merge (requires .venv-dora)
.\.venv-dora\Scripts\python.exe merge_dora.py --rank 24

# Phase 3: Inference n=800 (requires .venv-dora)
.\.venv-dora\Scripts\python.exe inference_v082_lora_dora.py --models r24_dora

# Phase 4: SBERT evaluation
.\.venv-eval\Scripts\python.exe evaluate_v08_sbert.py

# Phase 5: Quality Guard + Priority Scoring
.\.venv-eval\Scripts\python.exe pipeline_v08.py

# Phase 6: Figures 35-40 (4-way) + U.7.2 Discussion update
.\.venv-eval\Scripts\python.exe create_u72_dora_4way.py

# Phase 7: U.7.3 Qualitative Analysis
.\.venv-eval\Scripts\python.exe create_u73_qualitative.py

# Phase 8: PDF recompile
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

# Phase 9: v1.0.0 full inference โ†’ see v1.0.0 section below
chcp 65001 | Out-Null; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
.\.venv-dora\Scripts\python.exe -u inference_v10_full.py --checkpoint-every 2000 2>&1 | Tee-Object -FilePath "v10_full_r24_dora_log.txt"

๐Ÿš€ v1.0.0: Production Full Inference (n=10,903)

Status: โœ… Complete โ€” ๐ŸŽ‰ Latest Release

Execution period: 2026-06-02 20:20 โ†’ 2026-06-03 06:53 JST
Scope: Full-dataset deployment of DoRA r=24 model over all 10,903 records; Quality Guard + Priority Scoring end-to-end; member ร— damage analysis; Supplementary 2 U.7.4 added to paper

Inference Results

MetricCountRatio (%)
Total records10,903100.0
Quality Guard PASS10,66897.8
Quality Guard FAIL00.0
Missing (no image)2352.2
Priority Level 34544.3
Priority Level 49,18586.1
Priority Level 51,0299.6
Total processing time10.55 h (37,968 s)โ€”
Mean speed (batch=4)3.5 s/imageโ€”

Key finding: PASS rate 97.8% at production scale (n=10,903) is consistent with the validation-set rate. Zero FAIL outputs confirm robust generalisation across the full field dataset. Batch-size-4 processing delivers a 50% speed improvement over single-image inference.

Structural Member & Damage Type Analysis (PASS n=10,668)

Member Frequency

MemberCount% of PASS
Main Girder8,29377.7%
Deck Slab4,13938.8%
Curb3,40431.9%
Railing/Parapet2,86226.8%
Abutment2,18020.4%
Expansion Joint5325.0%
Drainage1381.3%
Bearing780.7%

Damage Type Frequency

Damage TypeCount% of PASS
Crack10,666100.0%
Rebar Exposure9,83792.2%
Spalling4,27740.1%
Lime Efflorescence3,69734.7%
Corrosion3,64534.2%
Deformation2,94327.6%
Delamination6756.3%
Deterioration4684.4%

Key Co-occurrence Findings

MemberMost Associated DamageCo-occ. Rate
Main GirderCrack100.0%
Main GirderRebar Exposure92.4%
Deck SlabCrack + Rebar Exposure100.0%
CurbCorrosion81.5%
Railing/ParapetDeformation99.9%
AbutmentRebar Exposure99.4%

Paper Update

SectionChange
U.7.4 (new)"Damage VLM Apps v1.0.0 Test Prediction: n=10,903" โ€” inference config table, results table, memberร—damage figure & discussion
Figure (fig:u74_member_damage)3-panel: member frequency / damage type frequency / memberร—damage heatmap for PASS n=10,668
PDFmethodology_supp2.pdf rebuilt, no errors

Output Files

FileDescription
data/v10_full/v10_full_r24_dora.xlsxFinal predictions (10,903 rows)
data/v10_full/checkpoint_{002000โ€ฆ010903}.xlsxCheckpoints every 2,000 rows
paper_damage_vlm/1_Methodology/figures_vlm/u74_member_damage_analysis.pngMemberร—damage analysis figure

Reproduce

# Full inference (10,903 rows, batch_size=4, ~10.5 h on RTX 4060 Ti 16GB)
chcp 65001 | Out-Null; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
.\.venv-dora\Scripts\python.exe -u inference_v10_full.py --checkpoint-every 2000 2>&1 | Tee-Object -FilePath "v10_full_r24_dora_log.txt"

# Member ร— Damage analysis figure (U.7.4)
.\.venv-eval\Scripts\python.exe create_figures_u74.py

# Recompile paper (run twice for cross-references)
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

Performance Metrics

v0.1 Test Results

Test ScaleProcessing TimeSuccess RateAvg Time/Image
Single Image42s100%42s
10-Image Batch8m 35s100%51.6s
50-Image (Est.)~43m-~52s
254-Image (Est.)~3.6h-~51s

Priority Distribution (10-Image Test)

  • Priority 5 (Immediate Repair Required): 6 images (60%)
  • Priority 3 (Planned Maintenance): 4 images (40%)

Resource Utilization

  • GPU Usage: 100% (all layers on GPU)
  • VRAM: ~8GB / 16GB
  • Model Size: 4.08GB (quantized GGUF)
  • Processing Speed: ~51.6s/image

Setup

1. System Requirements

  • OS: Windows 10/11, Linux, or macOS
  • GPU: NVIDIA GPU with 8GB+ VRAM (16GB recommended)
  • Python: 3.10 or higher
  • CUDA: 12.1 or higher
  • Storage: 20GB+ free space

2. Clone Repository

git clone https://github.com/your-username/damage_text_score.git
cd damage_text_score

3. Create Virtual Environment

# Windows PowerShell
python -m venv .venv
.venv\Scripts\Activate.ps1

# Linux/macOS
python -m venv .venv
source .venv/bin/activate

4. Install Dependencies

# PyTorch (CUDA 12.4)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

# llama-cpp-python (GPU version)
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124

# Other dependencies
pip install -r requirements.txt

5. Download Models

# LLaVA GGUF Model (Recommended)
python download_llava_gguf.py
# Downloads:
#   - models/ggml-model-q4_k.gguf (4.08GB)
#   - models/mmproj-model-f16.gguf (624MB)

6. Setup Ollama (for JSON Structuring)

# Install Ollama
# https://ollama.com/download

# Pull Swallow-8B model
ollama pull swallow8b-lora-n4000-v09-q4:latest

Usage

Quick Start

# Test single image (~42s)
python quickstart.py --mode 1

# Process 10-image batch (~8.5 min)
python quickstart.py --mode 2

# Process 50 images (~43 min)
python quickstart.py --mode 3

# Process all 254 images (~3.6 hours)
python quickstart.py --mode 4

Output Files

data/outputs/
โ”œโ”€โ”€ quickstart_single.csv        # Single image result
โ”œโ”€โ”€ quickstart_10images.csv      # 10-image results
โ”œโ”€โ”€ quickstart_50images.csv      # 50-image results
โ””โ”€โ”€ quickstart_254images.csv     # Full dataset results

Output Format

CSV Example:

image_name,damage_type,severity,location,risk,priority_score,priority_level,description
kensg-rebarexposureRb_001.png,crack,high,girder,structural,0.952,5,Extensive cracking observed...

JSON Structure:

{
  "damage_type": "rebar_exposure",
  "severity": "high",
  "location": "girder",
  "risk": "structural",
  "description_ja": "้‰„็ญ‹้œฒๅ‡บใŒ่ฆ‹ใ‚‰ใ‚Œใ€่…้ฃŸใŒ้€ฒ่กŒใ—ใฆใ„ใ‚‹...",
  "key_features": ["rebar exposure", "moderate corrosion"],
  "priority_score": 0.952,
  "priority_level": 5
}

Custom Usage

from src.pipeline.end_to_end import DamageAnalysisPipeline

# Initialize pipeline
pipeline = DamageAnalysisPipeline("config.yaml")

# Process single image
result = pipeline.process_image("path/to/image.png")

# Batch processing
results = pipeline.process_batch(image_paths, output_csv="results.csv")

Model Comparison

Vision Model Performance

ModeModelSizeTime/ImageGPU UsageRating
llama-cpp-pythonLLaVA-1.5-7B Q4_K_M4.08GB51.6s100%โญโญโญโญโญ
HuggingFacellava-1.5-7b-hf14GB45s100%โญโญโญโญ
Ollamallava:7b4.7GB88s0% (CPU)โญโญ

Selection Criteria

  • llama-cpp-python (Recommended)

    • โœ… Lightweight (4GB)
    • โœ… Full GPU utilization
    • โœ… Ollama-independent
    • โœ… Stable operation
    • โš ๏ธ Slight accuracy reduction due to quantization
  • HuggingFace

    • โœ… Highest accuracy
    • โœ… Full GPU utilization
    • โš ๏ธ Large size (14GB)
    • โš ๏ธ High VRAM requirement
  • Ollama

    • โš ๏ธ CPU-only operation (slow)
    • โš ๏ธ No GPU utilization
    • โœ… Easy setup

Tech Stack

Frameworks

  • PyTorch 2.6.0 - Deep learning framework
  • Transformers 4.57.6 - HuggingFace model hub
  • llama-cpp-python 0.3.16 - GGUF inference engine
  • OpenCV 4.12.0 - Image processing

Models

  • LLaVA-1.5-7B - Vision-Language Model

  • Swallow-8B - Japanese LLM

    • Developer: TokyoTech LLM Project
    • Specialized for JSON structuring

Libraries

  • pandas 2.2.3 - Data manipulation
  • pyyaml 6.0.2 - Configuration management
  • tqdm 4.67.1 - Progress bars
  • pillow 11.1.0 - Image processing

Directory Structure

damage_vlm_finetune/
โ”œโ”€โ”€ .venv-train/                    # Virtual environment: training (v0.7+)
โ”œโ”€โ”€ .venv-pred/                     # Virtual environment: inference/Unsloth (v0.5+)
โ”œโ”€โ”€ data/                           # Datasets
โ”‚   โ”œโ”€โ”€ image_text_inspect_n10789/  # Master dataset (v0.3)
โ”‚   โ”‚   โ”œโ”€โ”€ Rank_c_image_text_n10789.xlsx  # 10,789 annotations
โ”‚   โ”‚   โ””โ”€โ”€ rank_c_images_n10789/   # Image files
โ”‚   โ”œโ”€โ”€ v03_fine_tuning/            # v0.3 prepared datasets โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ test_set_n800.csv       # Fixed test set
โ”‚   โ”‚   โ”œโ”€โ”€ train_1k.csv            # Training: 1k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_2k.csv            # Training: 2k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_3k.csv            # Training: 3k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_4k.csv            # Training: 4k samples
โ”‚   โ”‚   โ”œโ”€โ”€ dataset_preparation_report.md
โ”‚   โ”‚   โ”œโ”€โ”€ evaluations/            # Evaluation results (v0.5)
โ”‚   โ”‚   โ””โ”€โ”€ reports/                # Progressive training reports
โ”‚   โ”œโ”€โ”€ rebar_exposure_n254/        # v0.2 validation dataset
โ”‚   โ”‚   โ””โ”€โ”€ outputs/                # v0.2 outputs
โ”‚   โ””โ”€โ”€ preprocessed_640x480_n10789/  # Preprocessed images
โ”œโ”€โ”€ models/                         # Model files
โ”‚   โ”œโ”€โ”€ llava-v1.5-7b-Q5_K_M.gguf   # Base model (v0.2)
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_1k/         # v0.4.1 LoRA adapters โœ…
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_2k/         # v0.4.2 โœ… Recommended
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_3k/         # v0.4.3 โœ…
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_4k/         # v0.4.4 โœ…
โ”‚   โ””โ”€โ”€ scoring_rules.yaml          # Rule-based scoring
โ”œโ”€โ”€ src/                            # Source code
โ”‚   โ”œโ”€โ”€ preprocessing/              # Image preprocessing
โ”‚   โ”‚   โ””โ”€โ”€ image_preprocessor.py
โ”‚   โ”œโ”€โ”€ vision/                     # Vision analysis (v0.1-v0.2)
โ”‚   โ”‚   โ”œโ”€โ”€ llama_cpp_vision.py     # llama-cpp-python
โ”‚   โ”‚   โ”œโ”€โ”€ gguf_vlm_analyzer.py    # GGUF wrapper
โ”‚   โ”‚   โ””โ”€โ”€ ollama_vision.py        # Ollama integration
โ”‚   โ”œโ”€โ”€ structuring/                # JSON structuring
โ”‚   โ”‚   โ””โ”€โ”€ json_structurer.py
โ”‚   โ”œโ”€โ”€ scoring/                    # Priority scoring
โ”‚   โ”‚   โ””โ”€โ”€ priority_scorer.py
โ”‚   โ”œโ”€โ”€ evaluation/                 # v0.5 evaluation โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ vector_similarity_evaluator.py
โ”‚   โ”œโ”€โ”€ pipeline/                   # Pipeline orchestration
โ”‚   โ”‚   โ””โ”€โ”€ end_to_end.py
โ”‚   โ””โ”€โ”€ utils/                      # Utilities
โ”‚       โ”œโ”€โ”€ config.py
โ”‚       โ””โ”€โ”€ ollama_client.py
โ”œโ”€โ”€ paper_damage_vlm/               # v0.6 Academic paper
โ”‚   โ”œโ”€โ”€ 0_Format_arXiv_pdfLaTex/
โ”‚   โ”‚   โ”œโ”€โ”€ bridge_damage_vlm_quantization_2026.tex
โ”‚   โ”‚   โ”œโ”€โ”€ bridge_damage_vlm_quantization_2026.bib
โ”‚   โ”‚   โ””โ”€โ”€ figures/
โ”‚   โ””โ”€โ”€ 1_Methodology/
โ”œโ”€โ”€ docs/                           # Documentation
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md
โ”‚   โ”œโ”€โ”€ GPU_SETUP.md
โ”‚   โ”œโ”€โ”€ VLM_COMPARISON_PLAN_v02.md
โ”‚   โ””โ”€โ”€ VLM_VALIDATION_REPORT_v02.md
โ”œโ”€โ”€ prepare_v03_dataset.py          # v0.3 dataset preparation โœ…
โ”œโ”€โ”€ train_v03_qlora.py              # v0.4 QLoRA training โœ…
โ”œโ”€โ”€ create_progressive_training_report.py  # v0.5 reporting โœ…
โ”œโ”€โ”€ config.yaml                     # Unified configuration โœ…
โ”œโ”€โ”€ SETUP_VENV_VLM.md               # v0.3 setup guide โœ…
โ”œโ”€โ”€ QUICKSTART_V03_V05.md           # v0.3-v0.5 workflow โœ…
โ”œโ”€โ”€ V03_V05_IMPLEMENTATION_SUMMARY.md  # Implementation summary โœ…
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ”œโ”€โ”€ README.md                       # This file (English)
โ”œโ”€โ”€ README_JP.md                    # Japanese documentation
โ”œโ”€โ”€ CHANGELOG.md                    # Version history
โ””โ”€โ”€ LICENSE                         # Apache License 2.0

Legend:

  • โœ… Implemented: Files/modules completed and tested
  • โณ Pending: Planned but not yet executed

Troubleshooting

Character Encoding Issues (Windows)

Symptom: Japanese characters appear garbled in PowerShell

Solution:

# Change to UTF-8
chcp 65001
python quickstart.py

CUDA Out of Memory

Symptom: CUDA out of memory error

Solution:

# config.yaml
llama_cpp_vision:
  n_gpu_layers: 20  # Reduce from -1 (all layers) to partial GPU

Ollama Connection Error

Symptom: Failed to connect to Ollama

Solution:

# Check Ollama server
ollama list

# Restart server
ollama serve

llama-cpp-python Installation Error

Symptom: Failed building wheel for llama-cpp-python

Solution:

# Install CUDA version explicitly
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124

# Or enable CUDA via environment variable
$env:CMAKE_ARGS="-DLLAMA_CUBLAS=on"
pip install llama-cpp-python --force-reinstall --no-cache-dir

Roadmap

โœ… Completed

v0.1 (2025-12)

  • โœ… End-to-end pipeline implementation
  • โœ… Three vision analysis modes (llama-cpp-python, HuggingFace, Ollama)
  • โœ… JSON structuring with Swallow-8B
  • โœ… Rule-based priority scoring
  • โœ… 10-image validation test (100% success rate)

v0.2 (2026-03)

  • โœ… LLaVA quantization comparison (Q4_K_M, Q5_K_M, Q8_0)
  • โœ… 254-image full dataset processing
  • โœ… 5-point quality scoring framework
  • โœ… Statistical analysis and visualization
  • โœ… Recommendation: Q5_K_M optimal for production

v0.3 (2026-05-22)

  • โœ… Dataset preparation pipeline (10,789 images)
  • โœ… Quality filtering (text length, keywords, patterns)
  • โœ… Stratified sampling (component ร— damage type)
  • โœ… Progressive training sets (1k/2k/3k/4k)
  • โœ… Fixed test set (800 images)
  • โœ… Comprehensive documentation (setup, quickstart, implementation summary)

v0.4 (2026-05-23)

  • โœ… Stage 1: Trained on 1k samples (1:22:57, val_loss=3.135)
  • โœ… Stage 2: Trained on 2k samples (2:55:37, val_loss=3.073)
  • โœ… Stage 3: Trained on 3k samples (4:31:44, val_loss=3.073)
  • โœ… Stage 4: Trained on 4k samples (6:19:10, val_loss=3.067)
  • โœ… Generated LoRA adapters for all 4 stages (134.5 MB each)
  • โœ… Identified optimal model: 2k samples (best cost-benefit)
  • โœ… Comprehensive training analysis report (Result_QLoRA_Scale.md)

v0.5.1 (2026-05-24)

  • โœ… Inference pipeline for all 4 fine-tuned models (inference_v051_qlora.py)
  • โœ… n=800 evaluation with Japanese Sentence-BERT cosine similarity
  • โœ… Inverted-U performance curve: 3k model peaks (mean=0.6909)
  • โœ… 4k overfitting confirmed (โˆ’2.5% from 3k)
  • โœ… 5 publication-quality visualization figures
  • โœ… Paper methodology section drafted (v0.5 results)

v0.6.3 (2026-05-25)

  • โœ… Two-stage Quality Guard Agent implemented (Rule-based + Swallow-8B SLM)
  • โœ… CJK-aware token counting (correct Japanese tokenization)
  • โœ… Empirical threshold calibration (ฮธ_low=98, ฮธ_high=202 at 5th/95th percentile)
  • โœ… Full n=800 evaluation: PASS=727 (90.9%), FAIL=73 (9.1%)
  • โœ… End-to-end throughput: 8.97 s/row (~2.0 h total)
  • โœ… Stage 2 (Swallow-8B) saturation finding: 0 additional rejections
  • โœ… Output mode collapse discovery: Main Girder 100%, Rebar Exposure 99.6%
  • โœ… Priority Level 3 saturation analysis (all 727 PASS โ†’ score=0.54)
  • โœ… 2 analysis figures generated (violin plots + member/damage heatmap)
  • โœ… Paper complete: 25 pages, 10 figures, all sections (pdflatex, no errors)

v0.7.1 (2026-05-26)

  • โœ… Image size optimization: confirmed 336px as optimal for LLaVA QLoRA
  • โœ… pairdata_v2 construction: noise-removed 2,969-sample corpus (inspect_images_336)
  • โœ… S.5 image-size analysis added to methodology_supp.tex

v0.7.2 (2026-05-27)

  • โœ… Full progressive QLoRA retraining on pairdata_v2 (1k/2k/3k/4k scales)
  • โœ… 3k model selected: peak mean cosine similarity (\u03c1=0.6013), lowest Very Poor rate (21.5%)
  • โœ… S.6 semantic similarity evaluation added to methodology_supp.tex
  • โœ… 3 evaluation figures generated (similarity by scale, tier distribution, cosine violin)

v0.7.3 (2026-05-28)

  • โœ… Quality Guard recalibrated: ฮธ_low 98โ†’30, ฮธ_high 202โ†’200
  • โœ… Keyword-based structuring (1s vs 2h Swallow-8B LLM)
  • โœ… Full pipeline (n=800): PASS=787 (98.4%), FAIL=13 (1.6%)
  • โœ… Scoring saturation resolved: Level 4โ€“5 = 97.3% (was 100% Level 3)
  • โœ… Output bias suppression confirmed via member/damage comparison
  • โœ… S.7, S.7.1, S.7.2 added to methodology_supp.tex (10 pages)
  • โœ… 5 new figures generated (Figure 15โ€“19)

v0.7.4 (2026-05-29)

  • โœ… 2048-dim composite embedding evaluator implemented (M1: 1024-dim + M2: 1024-dim)
  • โœ… Independent .venv-eval environment (CPU-only, separate from .venv-pred)
  • โœ… n=800 evaluation ร— 4 scales (1k/2k/3k/4k) completed
  • โœ… Optimal scale revised: 2k (mean ฯ=0.6950, median=0.7053, Good+=53.1%)
  • โœ… Very Poor rate dropped from โ‰ค32.9% (384-dim) to โ‰ˆ0.4% across all scales
  • โœ… S.6 fully rewritten with 2048-dim results + mathematical formulas in methodology_supp.tex
  • โœ… Figure 12/13/14 regenerated from 2048-dim JSON results
  • โœ… SETUP_ENV_EVAL.md created (.venv-eval setup guide)

v0.7.5 (2026-05-29)

  • โœ… 2k model established as primary pipeline variant (v0.7.5) based on v0.7.4 optimal-scale finding
  • โœ… Figure 19 generated: member & damage type comparison v0.7.3 (3k) vs v0.7.5 (2k)
  • โœ… Figure 20 generated: priority score violin for v0.6.3 / v0.7.3 / v0.7.5 (3-version comparison)
  • โœ… S.7.1 updated: model scale comparison paragraph (Cross Beam 98.3% in 2k; ฮผ=0.811/std=0.025 vs 3k ฮผ=0.838/std=0.070)
  • โœ… S.7.2 updated: Priority Score Distribution violin replaced (old Priority Level bar โ†’ new violin figure)
  • โœ… S.8 fully updated: 12-panel dual-model qualitative analysis (Predโ‚=v0.7.5 2k, Predโ‚‚=v0.7.3 3k)
  • โœ… GT/Predโ‚ and GT/Predโ‚‚ shared keywords bold-highlighted in all 12 panels
  • โœ… Image size reduced to 0.675\linewidth (ร—0.9 from 0.75) in all S.8 figures
  • โœ… methodology_supp.pdf: 17 pages, no errors (pdflatex)

v0.8 (2026-05-30)

  • โœ… pairdata_v3 denoising pipeline: 10,789 โ†’ 2,500-sample training corpus
  • โœ… LoRA rank ablation on pairdata_v3 (r=16/32/64, 2,500 samples each)
    • r=16: eval_loss=3.138, token_acc=98.73%, 3h24m
    • r=32: eval_loss=3.133, token_acc=98.83%, 5h36m
    • r=64: eval_loss=3.122, token_acc=98.90%, 3h27m (selected)
  • โœ… r=64 selected as optimal (168.8M params / 4.56% of backbone, no extra GPU cost)
  • โœ… Supplementary 2 (methodology_supp2.tex) fully documented: U.1โ€“U.8
  • โœ… Figure 21: LoRA rank ablation validation loss trajectories (pairdata_v3)
  • โœ… U.4 Analysis: adapter capacity argument (168M vs 42M/84M for domain specificity)

v0.8.1 (2026-05-30)

  • โœ… DoRA training (use_dora=True, r=64, alpha=128) on pairdata_v3 2,500 samples
  • โœ… DoRA eval_loss: 3.119 (best, epoch 2.421) โ€” โˆ’0.003 improvement over LoRA r=64 (3.122)
  • โœ… DoRA token_acc: 98.92% (best), 98.95% (final), train_loss=3.417, 6h51m
  • โœ… Research question (i) validated: DoRA achieves lower eval_loss at same rank/VRAM
  • โœ… U.8 in Supplementary 2 fully updated: Config (r=32โ†’r=64), Results table (TBDโ†’actual), Repro Commands
  • โœ… U.8 Motivation rewritten: r=64 basis, 3 research questions (val loss, cosine sim, hallucination)
  • โœ… methodology_supp2.pdf: 15 pages, no errors (pdflatex)

v0.8.2 (2026-05-31)

  • โœ… 2048-dim Sentence-BERT evaluation on all 4 adapters (n=800 test set)
  • โœ… DoRA r=64: highest embedding score (cosine 0.6846, Good+ 41.0%) but output-level mode collapse confirmed
  • โœ… Quality Guard + Priority Scoring: both models PASS 99.8%; DoRA all Level 4 (100%), LoRA r=32 L3/4/5 distributed
  • โœ… U.6.1 Structural Member & Damage Type analysis: DoRA stereotyped (Main Girder+Deck Slab 100%, 3 damage types 100%)
  • โœ… DoRA r=64 fine-tuning declared failed โ€” r=64 likely excessive; DoRA protocol left as future work
  • โœ… LoRA r=32 (v0.8) adopted as final pipeline model
  • โœ… Supplementary 2 updated: U.5 table+figures+analysis, U.6 2-model comparison, U.6.1 new subsection (Figure 28)
  • โœ… methodology_supp2.pdf: 21 pages

v0.8.3 (2026-05-31)

  • โœ… U.7 qualitative analysis section fully rebuilt on pairdata v3 (inference_r32.csv)
  • โœ… 12 representative PASS images re-selected with greedy member ร— damage diversity
  • โœ… Caption simplified to 3-item format: Quality Metrics / GT / Pred
  • โœ… Shared keyword highlighting added (CJK gothic font)
  • โœ… s8 folder replaced (figures_vlm/s8/s8_01โ€“s8_12)
  • โœ… methodology_supp2.pdf: 19 pages, no errors

v0.8.4 (2026-06-01)

  • โœ… DoRA r=16 full pipeline: train (eval_loss=3.138, 6h48m) โ†’ merge (85 shards) โ†’ inference (800 rows, 798 OK) โ†’ SBERT (mean=0.6717, Good+=36.0%) โ†’ pipeline (PASS=99.6%, L3:61/L4:705/L5:31)
  • โœ… 3-way rank ablation confirmed: LoRA r=32 vs. DoRA r=32 vs. DoRA r=16
  • โœ… Key finding: DoRA r=64 mode collapse (all Level 4); DoRA r=16 most balanced priority distribution
  • โœ… Figure 41: validation loss trajectories for 3-way ablation (added to U.7.1)
  • โœ… Figures 35โ€“40: 6-panel 3-way comparison (generated by create_u72_dora_ablation.py)
  • โœ… U.7.2 replaced: title โ†’ โ€œDoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16โ€
  • โœ… U.7.2 Discussion added: gradient collapse analysis, r=16 equitable output, DoRA r=24 proposed
  • โœ… methodology_supp2.pdf: 5648 KB, no errors

v0.8.5 (2026-06-02)

  • โœ… DoRA r=24 full pipeline: train (eval_loss=3.137, ~6h50m) โ†’ merge โ†’ inference (800 rows, 798 OK)
  • โœ… SBERT: mean=0.6791, std=0.0635, median=0.6834, Good+=37.8% โ€” best among all 7 adapters tested
  • โœ… Quality Guard + Priority: PASS=798 (99.8%), L3=48/L4=674/L5=78, token_mean=90.6
  • โœ… DoRA r=24 selected as v1.0.0 final model (peak SBERT + balanced L3/4/5 distribution)
  • โœ… Figure 15 updated: โ€œfour modelsโ€; DoRA r=24 (eval_loss=3.137) added as 4th validation loss curve
  • โœ… Figures 35โ€“40: regenerated as 4-way comparison (LoRA r=32, DoRA r=32/16/24)
  • โœ… U.7.2 Discussion extended to 6 paragraphs: rankโ€“quality relationship + figure-level evidence + final model selection
  • โœ… U.7.3 added: Qualitative Analysis: Finetuned Model Predictions DoRA r=24 (12 panels)
  • โœ… methodology_supp2.pdf: rebuilt, no errors

๐Ÿ”ฎ Future Work

v1.0.0 (2026-06-03) ๐ŸŽ‰ Latest Release โ€” Full Dataset Inference

  • โœ… Full inference completed: 10,903 rows, DoRA r=24, batch_size=4, 10.55 h (3.5 s/image)
  • โœ… Quality Guard PASS=10,668 (97.8%), FAIL=0 (0.0%), MISSING=235 (2.2%)
  • โœ… Priority: L3=454 (4.3%) / L4=9,185 (86.1%) / L5=1,029 (9.6%)
  • โœ… Output: data/v10_full/v10_full_r24_dora.xlsx (10,903 rows)
  • โœ… Member x damage figure: create_figures_u74.py -> figures_vlm/u74_member_damage_analysis.png
  • โœ… U.7.4 added to Supplementary 2: inference config, results table, figure, discussion
  • โœ… methodology_supp2.pdf: rebuilt, no errors

v1.1 (2026 Q3) - Production Deployment

  • Web UI (Streamlit/Gradio)
  • REST API server (FastAPI)
  • Docker containerization
  • CI/CD pipeline
  • Comprehensive unit tests
  • Performance benchmarking

Research Extensions

  • Balanced training corpus to address output mode collapse
  • Constrained-generation prompts (per-member damage reporting)
  • Priority scoring recalibration with explicit severity keywords
  • Multi-damage type support (crack detection, leakage, scaling)
  • Active learning for annotation efficiency
  • Multi-language support (Japanese โ†” English)
  • Real-time video analysis
  • Integration with bridge inspection databases
  • Explainable AI (attention visualization, saliency maps)
  • Alternative VLMs (Qwen2-VL, InternVL2, GPT-4V)

Citation

If you use this project in your research, please cite:

@software{bridge_damage_assessment_2026,
  title = {Bridge Damage Assessment and Repair Priority Scoring System},
  author = {Your Name},
  year = {2026},
  version = {0.1.0},
  url = {https://github.com/your-username/damage_text_score}
}

References

  1. Liu et al. (2023). "Visual Instruction Tuning" - LLaVA [arXiv:2304.08485]
  2. TokyoTech LLM Project - Swallow Models [GitHub]
  3. Georgi Gerganov - llama.cpp [GitHub]

License

Apache License 2.0 - See LICENSE for details



๐Ÿ“ˆ v0.7.3: Quality Guard Recalibration & Full Pipeline

Status: โœ… Complete

Completion Date: 2026-05-28
Scope: Quality Guard recalibration + keyword structuring pipeline on 3k pairdata_v2 model (n=800)

What Was Completed

  • Quality Guard recalibration: ฮธ_low 98 โ†’ 30 (captures only ERROR outputs); ฮธ_high 202 โ†’ 200
    • Old threshold rejected all valid short descriptions produced by the pairdata_v2 model
    • New threshold retains all structurally valid predictions
  • Keyword-based structuring: Replaced 2-hour Swallow-8B LLM with 1-second keyword matching
  • Full pipeline run (pipeline_v073.py): n=800 in < 2 seconds
  • Output mode collapse resolved: pairdata_v2 noise removal suppressed hallucinated co-occurrence patterns

Pipeline Results (n=800)

VerdictCountRate
PASS โ€” High Quality78798.4%
FAIL โ€” Error / Too short131.6%

Priority Level Distribution (PASS n=787)

LevelDescriptionCountRate
3Planned maintenance212.7%
4Priority repair65182.7%
5Immediate repair11514.6%

Contrast with v0.6.3 where 100% of PASS samples scored Level 3 (scoring saturation at 0.54).

Key Findings

  • Scoring saturation resolved: Level 4โ€“5 now accounts for 97.3% of PASS predictions
  • Bias suppression: Lime Efflorescence dropped 49.0% โ†’ 13.3%; Curb emerged as secondary member (92.5%)
  • PASS rate: 98.4% vs. 90.9% in v0.6.3 (quality improvement from pairdata_v2 denoising)
  • Throughput: Full 800-image pipeline in < 2 seconds

Figures Generated

FigureFileDescription
1515_v073_token_distribution.pngToken count with recalibrated thresholds
1616_v073_guard_breakdown.pngPASS/FAIL verdict breakdown
1717_v073_priority_distribution.pngPriority level distribution
1818_member_damage_comparison.pngMember ร— Damage comparison (v0.6.3 vs v0.7.3)
1919_priority_comparison.pngPriority level comparison (v0.6.3 vs v0.7.3)

Repro Commands

.\.venv-pred\Scripts\Activate.ps1
python pipeline_v073.py

Paper Artifacts Updated

  • methodology_supp.tex โ€” S.7 Quality Guard Recalibration
  • methodology_supp.tex โ€” S.7.1 Member & Damage Type comparison
  • methodology_supp.tex โ€” S.7.2 Priority Level comparison
  • methodology_supp.pdf โ€” 10 pages, no errors

Last Updated: May 29, 2026 (v0.7.3 โ€” Quality Guard recalibration, full pipeline, scoring saturation resolved)


๐Ÿ”ข v0.7.4: 2048-Dimensional Composite Embedding Evaluation

Status: โœ… Complete โ€” ๐ŸŽ‰ Latest Release

Completion Date: 2026-05-29
Scope: Extended semantic similarity evaluation using a 2,048-dimensional composite embedding (n=800 test set ร— 4 scales)

Overview

v0.7.4 replaces the 384-dimensional single-model evaluator (paraphrase-multilingual-MiniLM-L12-v2) with a 2,048-dimensional composite embedding formed by combining two complementary Japanese-capable sentence encoders. This yields substantially higher and more discriminative cosine similarity scores and revises the optimal training scale from 3k to 2k.

Composite Evaluator Architecture

ComponentModelDimensionsProperties
M1hotchpotch/static-embedding-japanese1,024Static EmbeddingBag, CPU-native, Japanese-specialised
M2intfloat/multilingual-e5-large1,024Transformer encoder, 100+ languages, STS prefix "query: "
CombinedL2-normalise โ†’ concat โ†’ re-normalise2,048Arithmetic mean of per-model cosine similarities

Mathematical Formulation

Given ground-truth text $t^{gt}$ and prediction $t^{pred}$:

  1. Each encoder produces an $L_2$-normalised embedding:
    • $\mathbf{e}1(t) = f{M1}(t) / |f_{M1}(t)|$
    • $\mathbf{e}2(t) = f{M2}(\text{"query: "} | t) / |f_{M2}(\cdot)|$
  2. Concatenate and re-normalise (each half has unit norm, so denominator is $\sqrt{2}$):
    • $\mathbf{e}(t) = [\mathbf{e}_1; \mathbf{e}_2] / \sqrt{2}$
  3. Cosine similarity reduces to the arithmetic mean of the two per-model similarities:
    • $\rho_{2048} = \mathbf{e}^{gt} \cdot \mathbf{e}^{pred} = (\rho_1 + \rho_2) / 2$

Evaluation Results (2048-dim)

Test set: n=800 (pairdata-v2 ground truth), CPU inference
Tier thresholds: Excellent โ‰ฅ 0.85 ยท Good โ‰ฅ 0.70 ยท Acceptable โ‰ฅ 0.55 ยท Poor โ‰ฅ 0.40 ยท Very Poor < 0.40

ScaleMean ฯฯƒMedianGood+ (%)V.Poor (%)
1k0.67250.07060.674937.80.4
2k โœ…0.69500.08240.705353.10.4
3k0.67670.07510.679937.80.4
4k0.67490.07420.680338.40.4

Comparison: 384-dim vs 2048-dim Evaluators

Scale384-dim MiniLM2048-dim Compositeฮ”
1k0.56570.6725+18.9%
2k0.60110.6950+15.6%
3k0.60130.6767+12.5%
4k0.57420.6749+17.5%

Very Poor rate: 384-dim was 21.5โ€“32.9%; 2048-dim is uniformly โ‰ˆ0.4%.

Key Findings

  1. Optimal scale revised to 2k: 2k achieves mean ฯ=0.6950 and median=0.7053 (above Good threshold), with 53.1% Good+ โ€” significantly better than 3k/4k.
  2. Overfitting pattern confirmed: 2k peaks, then 3k/4k both regress, consistent with pairdata-v2 diminishing-returns pattern found in token-accuracy analysis.
  3. Very Poor near-elimination: 2048-dim composite scores are far more discriminative; catastrophic mismatch cases detected by 384-dim (VPoor โ‰ค32.9%) essentially disappear (โ‰ˆ0.4%).
  4. Good+ majority at 2k: 53.1% of 2k predictions reach the Good+ tier, reflecting M2โ€™s stronger multilingual semantic understanding.

Figures Updated

FigureFileDescription
Fig. 12figures_vlm/12_v072_similarity_by_scale.pngMean/median ฯ by scale; red dashed = 384-dim baseline
Fig. 13figures_vlm/13_v072_tier_distribution.pngQuality-tier stacked bar chart (2048-dim results)
Fig. 14figures_vlm/14_v072_cosine_violin.pngCosine similarity violin plots (2048-dim results)

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” S.6 fully rewritten: evaluator description, Table with 2048-dim values, Key findings (2k peak), Figure 12/13/14 captions, Model selection (3k โ†’ 2k), Extended Evaluation subsubsection with three mathematical formulas
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf โ€” 14 pages, recompiled (no errors)

New Files

FilePurpose
evaluate_2048dim.py2048-dim composite embedding evaluation script
create_figures_v072_2048dim.pyFigure 12/13/14 generator from 2048-dim JSON results
SETUP_ENV_EVAL.md.venv-eval environment setup guide

Repro Commands

# 1. Create evaluation environment (CPU-only, independent of .venv-pred)
python -m venv .venv-eval
.venv-eval\Scripts\pip.exe install "torch==2.6.0+cpu" --index-url https://download.pytorch.org/whl/cpu
.venv-eval\Scripts\pip.exe install "sentence-transformers==3.3.1" numpy pandas scikit-learn matplotlib seaborn

# 2. Run evaluation (n=800 x 4 scales, ~26 min total on CPU)
.venv-eval\Scripts\python.exe evaluate_2048dim.py

# 3. Regenerate Figure 12/13/14
.venv-eval\Scripts\python.exe create_figures_v072_2048dim.py

Output JSON files: data/v07_fine_tuning/evaluations_2048dim/evaluation_2048dim_{1k,2k,3k,4k}.json


๐Ÿ“Š v0.7.5: 2k Pipeline Evaluation & Supplementary Paper Update

Status: โœ… Complete

Last Updated: May 29, 2026
Scope: 2k model established as primary pipeline; cross-model comparison figures; full S.7โ€“S.8 supplementary paper update

Overview

Building on the v0.7.4 finding that the 2k model is optimal (mean ฯ=0.6950, Good+=53.1%), v0.7.5 designates the 2k QLoRA pipeline as the primary production variant and adds cross-model comparative analysis to the supplementary paper.

Key Deliverables

Figure 19: Member & Damage Type Comparison (v0.7.3 vs v0.7.5)

figures_vlm/19_member_damage_v073_v075.png

Side-by-side frequency bars and co-occurrence heatmaps comparing the 3k model (v0.7.3) against the 2k model (v0.7.5).

Notable finding โ€” Cross Beam saturation in 2k:

Memberv0.7.3 (3k)v0.7.5 (2k)
Main Girder~100.0%~100.0%
Cross Beam~40%98.3%
Rebar Exposure~99%~99%

The 2k model systematically appends cross beam descriptors in 98.3% of all predictions, reflecting template-driven vocabulary learned from the smaller training corpus.

Figure 20: Priority Score Violin โ€” 3-Version Comparison

figures_vlm/20_priority_score_violin.png

Violin plots comparing priority score distributions across all three pipeline versions:

VersionModelMeanStdLevel 4โ€“5
v0.6.3pairdata-v1 3k0.54 (point mass)0.0000%
v0.7.3pairdata-v2 3k0.8380.07097.3%
v0.7.5pairdata-v2 2k0.8110.025~97%

Interpretation: v0.6.3 collapses to a single value (mode-collapsed outputs). Both v0.7.x models restore discriminability; v0.7.5 (2k) shows a tighter, more predictable Level-4 cluster (std=0.025) while v0.7.3 (3k) reaches higher scores with greater variance (std=0.070), reflecting its longer training.

S.8 Qualitative Analysis โ€” Dual-Model Comparison (12 Panels)

paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” Section S.8

All 12 representative PASS panels updated to display three rows per image:

RowSourceNotes
GTOriginal inspection recordTerms shared with Predโ‚ and Predโ‚‚ both bold
Predโ‚ (2k)v0.7.5 pipeline outputTerms shared with GT bold
Predโ‚‚ (3k)v0.7.3 pipeline outputTerms shared with GT bold

Additional formatting changes applied to all 12 panels:

  • Sim(emb) values reflect the 2k model (Predโ‚)
  • Image size reduced to 0.675\linewidth (ร—0.9 from 0.75)
  • Caption: "GT/Pred$_1$ shared terms bold in Pred$_1$; GT/Pred$_2$ shared terms bold in Pred$_2$"

Cosine Similarity (Sim(emb)) โ€” 12 Selected Panels

#Sim(emb) 2k (Predโ‚)Sim(emb) 3k (Predโ‚‚)ฮ”
010.5520.394+0.158
020.4180.400+0.018
030.6580.668โˆ’0.010
040.4410.397+0.044
050.5370.504+0.033
060.6430.622+0.021
070.5930.592+0.001
080.7000.685+0.015
090.5550.489+0.066
100.7700.756+0.014
110.7980.783+0.015
120.6560.722โˆ’0.066

The 2k model achieves higher Sim(emb) in 9 of 12 panels; the 3k model leads in 3 (panels 03, 07, 12).

Scripts

FilePurpose
create_figures_v075_s71_s72.pyGenerates Figure 19 (member/damage comparison) and Figure 20 (priority score violin)

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” S.7.1, S.7.2, S.8 fully updated
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf โ€” 17 pages, no errors (pdflatex)

Repro Commands

# Generate Figure 19 and Figure 20
.venv-eval\Scripts\python.exe create_figures_v075_s71_s72.py

# Recompile supplementary PDF
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp.tex

Last Updated: June 1, 2026 (v0.8.4 โ€” DoRA rank ablation r=16/32 full pipeline complete; DoRA r=16 achieves best Good+ rate 36.0% and most balanced priority distribution; U.7.2 updated with 3-way comparison Figures 35โ€“41; DoRA r=24 proposed as next experiment)

automated-diagnostics
bridge-damage-detection
civil-engineering-ai
damage-severity-assessment
image-to-text
infrastructure-inspection
llava
repair-prioritization
structural-health-monitoring
vision-language-models

tk-yasuno/damage_vlm_finetune

An end-to-end pipeline for automated analysis of bridge structural damage (rebar exposure, cracks, corrosion) using LLaVA (Large Language and Vision Assistant). The system generates expert-level damage descriptions from images and produces structured prioritization scores for repair planning.

Python

1

18 commits

updated Jun 3, 2026

See the code

README

Bridge Damage VLM Fine-Tuning: Automated Assessment System v1.0.0

Progressive Fine-Tuning of LLaVA-1.5-7B with Quality Guard Agent for Bridge Damage Analysis and Repair Priority Scoring

Python PyTorch CUDA License

๐ŸŒ ๆ—ฅๆœฌ่ชž็‰ˆใƒ‰ใ‚ญใƒฅใƒกใƒณใƒˆ (Japanese Documentation)

๐Ÿ“‹ Table of Contents


Overview

An end-to-end pipeline for automated analysis of bridge structural damage (rebar exposure, cracks, corrosion) using LLaVA (Large Language and Vision Assistant). The system generates expert-level damage descriptions from images and produces structured prioritization scores for repair planning.

Key Features

  • Multi-Modal Vision Analysis: Leverages LLaVA-1.5-7B for accurate damage assessment
  • Automated Structuring: Converts natural language descriptions to structured JSON using Swallow-8B (Japanese LLM)
  • Intelligent Scoring: Rule-based prioritization system (1-5 scale)
  • Production-Ready: 100% success rate on 10-image test batch
  • GPU-Optimized: Full GPU acceleration with quantized GGUF models (4GB)

Pipeline Architecture

High-Level Flow

graph TB
    A[Input Images<br/>254 Bridge Damage Photos] --> B[Preprocessing<br/>Denoise/Resize/Contrast]
    B --> C[Vision Analysis<br/>LLaVA-1.5-7B GGUF]
    C --> D[JSON Structuring<br/>Swallow-8B]
    D --> E[Priority Scoring<br/>Rule-Based Engine]
    E --> F[Output<br/>CSV/JSON Reports]
  
    style A fill:#e1f5ff
    style C fill:#fff4e1
    style E fill:#ffe1e1
    style F fill:#e1ffe1

Detailed Pipeline Components

flowchart LR
    subgraph Input["๐Ÿ“ Input Stage"]
        A1[Raw Images<br/>PNG/JPG]
    end
  
    subgraph Preprocess["๐Ÿ”ง Preprocessing"]
        B1[Noise Reduction<br/>NL-Means]
        B2[Resize<br/>Max 1024x1024]
        B3[Contrast<br/>CLAHE]
    end
  
    subgraph Vision["๐Ÿ‘๏ธ Vision Analysis"]
        C1[Image Encoding<br/>CLIP Vision]
        C2[LLaVA Inference<br/>Q4_K_M Quantized]
        C3[Damage Description<br/>Japanese Text]
    end
  
    subgraph Structure["๐Ÿ“Š Structuring"]
        D1[Swallow-8B LLM<br/>via Ollama]
        D2[JSON Parsing<br/>Multi-Pattern]
        D3[Structured Data<br/>Type/Severity/Location]
    end
  
    subgraph Score["๐ŸŽฏ Scoring"]
        E1[Rule Evaluation<br/>40% Severity<br/>35% Type<br/>15% Location<br/>10% Risk]
        E2[Priority Calculation<br/>0.0-1.0 Score]
        E3[Level Assignment<br/>1-5 Priority]
    end
  
    subgraph Output["๐Ÿ’พ Output"]
        F1[CSV Export<br/>Batch Results]
        F2[JSON Export<br/>Detailed Records]
    end
  
    A1 --> B1 --> B2 --> B3
    B3 --> C1 --> C2 --> C3
    C3 --> D1 --> D2 --> D3
    D3 --> E1 --> E2 --> E3
    E3 --> F1
    E3 --> F2
  
    style Input fill:#e1f5ff
    style Vision fill:#fff4e1
    style Score fill:#ffe1e1
    style Output fill:#e1ffe1

Component Details

StageModulePurposeTechnology
Preprocessingimage_preprocessor.pyImage quality enhancementOpenCV 4.12
Vision Analysisllama_cpp_vision.pyDamage description generationLLaVA-1.5-7B Q4_K_M (4GB)
Structuringjson_structurer.pyNatural language โ†’ JSONSwallow-8B (Ollama)
Scoringpriority_scorer.pyRepair priority calculationRule-based (YAML)
Pipelineend_to_end.pyOrchestrationPython 3.12

Processing Time Breakdown (per image):

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Preprocessing:     ~2s  (4%)            โ”‚
โ”‚ Vision Analysis:  ~42s  (81%)           โ”‚
โ”‚ JSON Structuring:  ~5s  (10%)           โ”‚
โ”‚ Scoring:          <1s   (2%)            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Total: ~51.6 seconds/image              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

v0.1 Achievements

โœ… Completed Features

  • 3 Vision Modes Implemented

    • llama-cpp-python + GGUF (Recommended): Lightweight, fast, full GPU utilization
    • HuggingFace Transformers: Stable, high accuracy
    • Ollama Integration: Easy setup (Note: CPU-only, slower)
  • Complete Pipeline

    • Preprocessing module (OpenCV)
    • Vision analysis (LLaVA-1.5-7B)
    • JSON structuring (Swallow-8B via Ollama)
    • Priority scoring (Rule-based)
  • Validation Tests

    • โœ… Single image: 42s/image
    • โœ… 10-image batch: 51.6s/image avg, 100% success rate
    • Priority distribution: Critical (Level 5) 60%, Moderate (Level 3) 40%
  • Windows Encoding Issues Resolved

    • PowerShell cp932 support
    • llama.cpp C++ log suppression
    • UTF-8 encoding standardization

๐Ÿ“Š Validation Data

  • Dataset: 254 images of rebar exposure damage
  • GPU: NVIDIA GeForce RTX 4060 Ti (16GB VRAM)
  • OS: Windows 11
  • Environment: Python 3.12.10 + CUDA 12.4

๐Ÿ”ฌ v0.2: Quantization Comparison Study

Objective

Comprehensive evaluation of LLaVA-1.5-7B quantization levels (Q4_K_M, Q5_K_M, Q8_0) to determine the optimal balance between accuracy, speed, and model size for bridge damage assessment.

Experimental Setup

  • Test Dataset: 254 rebar exposure images (full dataset)
  • Models Tested:
    • Q4_K_M: 4.1GB (4-bit quantization, medium)
    • Q5_K_M: 4.8GB (5-bit quantization, medium)
    • Q8_0: 7.2GB (8-bit quantization, baseline)
  • Hardware: NVIDIA RTX 4060 Ti 16GB, CUDA 12.4
  • Software: llama-cpp-python 0.2.90 (GPU-enabled)

Quality Evaluation Framework

Developed a 5-point quality scoring system (v0.2 design) to assess damage description completeness:

ComponentMax PointsCriteria
Damage Types2.0Recognition of crack, rebar exposure, corrosion, spalling, section loss
Severity Level1.0Minor, moderate, severe classification
Location Info1.0Spatial information (top, bottom, left, right, etc.)
Extent Info1.0Coverage description (local, widespread, partial, etc.)
Total5.0Comprehensive damage assessment score

Results Summary

QuantizationModel SizeInit TimeAvg InferenceQuality ScoreText LengthSuccess Rate
Q4_K_M4.1GB3.6s5.43s2.93 ยฑ 1.53168 ยฑ 41254/254 (100%)
Q5_K_M โญ4.8GB4.5s5.67s3.18 ยฑ 1.35160 ยฑ 37254/254 (100%)
Q8_07.2GB5.9s7.63s3.27 ยฑ 1.39162 ยฑ 39254/254 (100%)

Performance Comparison:

  • Q5_K_M vs Q4_K_M: +17.1% size, +4.5% slower, +8.5% quality โฌ†๏ธ
  • Q8_0 vs Q5_K_M: +50.0% size, +34.6% slower, +3.0% quality (not significant, p=0.16)

Visualization

Basic Comparison Results

LLaVA Quantization Comparison

Figure 1: Performance metrics across quantization levels (N=254). Shows average inference time, model size vs total time, quality score comparison, and summary statistics.

๐Ÿ“Š English Version | Japanese Version

Statistical Analysis

Statistical Analysis

Figure 2: Comprehensive statistical analysis including violin plots (quality, text length, inference time), box plots, scatter plots (quality vs text length/inference time), and detailed statistics table.

Key Findings

1. Quality Score Distribution

Violin Plot Analysis:

  • Q4_K_M: Bimodal distribution (46 images at 0-1 score, 46 at 5.0) โ†’ High variance
  • Q5_K_M: Concentrated at 3-4 points (75 images) โ†’ Stable mid-high quality
  • Q8_0: Similar to Q5_K_M (81 images at 3-4 points) โ†’ Stable but slower

Statistical Significance (Mann-Whitney U Test):

  • Q5_K_M vs Q4_K_M: U=34822.5, p=0.0591 (marginal significance)
  • Q8_0 vs Q5_K_M: U=33870.0, p=0.1627 (not significant)
  • Q8_0 vs Q4_K_M: U=36289.5, p=0.0069 โœ“ (significant, p<0.01)

2. Text Length vs Quality Correlation

QuantizationCorrelation CoefficientInterpretation
Q4_K_M-0.559Moderate negative (longer โ†’ lower quality)
Q5_K_M-0.148Weak negative (stable across lengths)
Q8_0-0.393Moderate negative

Insight: Q5_K_M maintains consistent quality regardless of description length, indicating robust performance.

3. Inference Time Analysis

  • Q4_K_M: Fastest (5.43s ยฑ 1.07s), but quality variance is high
  • Q5_K_M: Slightly slower (5.67s ยฑ 1.14s), best quality-speed balance
  • Q8_0: Slowest (7.63s ยฑ 1.42s), minimal quality improvement over Q5_K_M

Speed-Quality Efficiency:

Q4_K_M: 0.54 quality/sec (2.93 / 5.43)
Q5_K_M: 0.56 quality/sec (3.18 / 5.67) โ† BEST โญ
Q8_0:   0.43 quality/sec (3.27 / 7.63)

Discussion

Why Q5_K_M is Optimal

  1. Best Quality-Speed Balance

    • Only 4.5% slower than Q4_K_M
    • 8.5% higher quality than Q4_K_M (approaching statistical significance)
    • Statistically equivalent quality to Q8_0 (p=0.16)
  2. Stable Performance

    • Lowest text-length correlation (-0.148) โ†’ consistent output
    • Tight standard deviation (1.35 vs 1.53 for Q4_K_M)
    • Predictable inference time (5.67s ยฑ 1.14s)
  3. Resource Efficiency

    • 33% smaller than Q8_0 (4.8GB vs 7.2GB)
    • 25% faster than Q8_0 (34.6% speed advantage)
    • Fits comfortably in 8GB VRAM GPUs

Q8_0 Limitations

  • Diminishing Returns: Only 3% quality improvement over Q5_K_M
  • Slower: 34.6% longer inference time without significant quality gain
  • Larger: 50% more disk space and VRAM usage
  • Not Cost-Effective: Poor quality/sec efficiency (0.43 vs 0.56 for Q5_K_M)

Q4_K_M Use Cases

  • Rapid Prototyping: Fastest iteration for development
  • Resource-Constrained Environments: When speed is critical
  • Not Recommended for Production: High quality variance (SD=1.53) creates inconsistent results

Recommendations

PriorityQuantizationUse Case
๐Ÿฅ‡RecommendedQ5_K_MProduction deployment (best balance)
๐Ÿฅˆ AlternativeQ8_0High-accuracy applications (if speed is not critical)
๐Ÿฅ‰ DevelopmentQ4_K_MFast prototyping only

For Bridge Damage Assessment:

  • Deploy Q5_K_M for operational use (254 images in ~24 minutes)
  • Avoid Q8_0 unless accuracy requirements justify 35% slower processing
  • Use Q4_K_M only for development/testing

Lessons Learned (v0.2)

  1. Quantization is Not Free

    • Q4_K_M's speed advantage comes at the cost of quality variance
    • Bimodal distribution (0-1 or 5 points) indicates unstable outputs
  2. Sweet Spot Exists

    • Q5_K_M achieves 97% of Q8_0's quality with 25% speed improvement
    • Middle-ground quantization often optimal for production
  3. Statistical Validation is Essential

    • Correlation analysis revealed Q5_K_M's consistency advantage
    • Mann-Whitney U test confirmed Q8_0 vs Q5_K_M differences are not significant
  4. GPU Compatibility Matters

    • llama-cpp-python 0.2.90 required for GPU support on Windows
    • Newer versions (0.3.x) have Visual Studio CUDA integration issues
  5. Quality Metrics Enable Optimization

    • 5-point scoring framework made quantization trade-offs measurable
    • Violin plots revealed distribution differences invisible in averages

๐ŸŽฏ v0.3: Dataset Preparation & Progressive Fine-Tuning

Objective

Prepare high-quality training datasets from n=10,789 bridge damage images for progressive QLoRA fine-tuning of LLaVA-1.5-7B to improve damage description quality from 3.18/5.0 โ†’ 4.5+/5.0.

Status: โœ… Phase 1 Complete (Dataset Preparation)

Completion Date: 2026-05-22

Dataset Overview

  • Source: 10,789 bridge damage images with Japanese ground truth annotations
  • Master File: Rank_c_image_text_n10789.xlsx
  • Quality Filtering: Applied to ensure high-quality training data
  • Stratified Sampling: Maintains balanced distribution across damage scenarios
  • Progressive Scaling: 1k โ†’ 2k โ†’ 3k โ†’ 4k training sets for systematic evaluation

Data Preparation Pipeline

1. Quality Filtering Criteria

Text Length: 15-500 characters
Excluded Patterns:
  - Empty or whitespace only
  - Question marks only ("???")
  - "ใชใ—" (none), "่ฉฒๅฝ“ใชใ—" (not applicable)
Required Keywords (at least one):
  Damage Types: ใฒใณๅ‰ฒใ‚Œ, ใ‚ฏใƒฉใƒƒใ‚ฏ, ้‰„็ญ‹, ่…้ฃŸ, ๅ‰ฅ้›ข, ๅŠฃๅŒ–
  Components: ๆก, ๅบŠ็‰ˆ, ๆ”ฏๆ‰ฟ, ๆฉ‹่„š, ใ‚ณใƒณใ‚ฏใƒชใƒผใƒˆ
  Severity: ่‘—ใ—ใ„, ้ก•่‘—, ้€ฒ่กŒ, ่ปฝๅพฎ

Expected Retention Rate: ~70-80% (7,600-8,600 images passing filters)

2. Stratified Sampling Strategy

Purpose: Maintain representative distribution of component types and damage types across all datasets.

Methodology:

  • Strata Definition: Joint distribution of component_type ร— damage_type
  • Proportional Allocation: Each stratum represented according to its frequency
  • Fixed Random Seed: seed=42 for reproducibility

Benefits:

  • โœ… Prevents model bias toward frequent categories
  • โœ… Ensures test set covers all damage scenarios
  • โœ… Enables fair comparison across training scales (1k/2k/3k/4k)

3. Dataset Splits

SplitSizeSeedPurpose
Test Set80042Fixed evaluation set (never used in training)
Train 1k1,00042+1000Initial fine-tuning baseline
Train 2k2,00042+2000Scaling experiment (2x data)
Train 3k3,00042+3000Scaling experiment (3x data)
Train 4k4,00042+4000Maximum scale experiment

Note: Each training set is independently sampled (not cumulative) to measure pure dataset size effects.

Implementation

Script: prepare_v03_dataset.py

Features:

  • Loads Excel master data (10,789 rows)
  • Applies 4-stage quality filtering
  • Merges v0.2 metadata for stratification (if available)
  • Creates fixed test set (800 samples)
  • Generates progressive training sets (1k/2k/3k/4k)
  • Produces comprehensive statistics report

Usage:

# Activate virtual environment (training)
.\.venv-train\Scripts\Activate.ps1

# Run dataset preparation
python prepare_v03_dataset.py

Output Files:

data/v03_fine_tuning/
โ”œโ”€โ”€ test_set_n800.csv              # Fixed test set
โ”œโ”€โ”€ train_1k.csv                    # 1,000 training samples
โ”œโ”€โ”€ train_2k.csv                    # 2,000 training samples
โ”œโ”€โ”€ train_3k.csv                    # 3,000 training samples
โ”œโ”€โ”€ train_4k.csv                    # 4,000 training samples
โ””โ”€โ”€ dataset_preparation_report.md   # Statistics & distribution analysis

CSV Format:

ใƒ•ใ‚กใ‚คใƒซใƒ‘ใ‚น,ๆ‰€่ฆ‹,component_type,damage_type,text_length
rank_c_images_n10789/IMG_0001.jpg,"ๅบŠ็‰ˆไธ‹้ขใซ้ก•่‘—ใชใฒใณๅ‰ฒใ‚Œ...",ๅบŠ็‰ˆ,ใฒใณๅ‰ฒใ‚Œ,85

Why Progressive Training (1kโ†’2kโ†’3kโ†’4k)?

Rationale

  1. Measure Dataset Size Impact

    • Compare model performance at different data scales
    • Identify diminishing returns threshold
    • Determine optimal dataset size for cost-benefit
  2. Detect Overfitting Threshold

    • Monitor when additional data stops improving quality
    • Observe if validation scores plateau or decline
    • Adjust regularization if needed
  3. Resource Planning

    • Estimate training time per 1k samples (~2-4 hours)
    • Total time: ~20-40 hours across all 4 stages
    • Budget GPU hours for future scaling
  4. Ablation Study

    • Isolate effect of data quantity vs quality
    • Validate that improvements are from data, not hyperparameters
    • Support academic publication (arXiv paper)

v0.4-v0.6 Roadmap (Next Phases)


๐ŸŽ“ v0.4: QLoRA Progressive Training

Status: โœ… Complete

Completion Date: 2026-05-23
Training Period: 2026-05-22 01:59 - 2026-05-23 00:17 (Total: ~15 hours)

Objective

Execute progressive QLoRA fine-tuning of LLaVA-1.5-7B across four dataset scales (1k, 2k, 3k, 4k samples) to measure dataset size impact on model performance and identify the optimal training data volume.

Training Results Summary

StageDatasetTraining TimeTrain/Val SamplesFinal Val LossBest CheckpointLoss Improvement
v0.4.11k1:22:57799 / 2003.135checkpoint-100- (baseline)
v0.4.22k2:55:371,599 / 4003.073checkpoint-300โ†“ 1.98%
v0.4.33k4:31:442,398 / 6003.073checkpoint-400โ†” 0.00%
v0.4.44k6:19:103,196 / 7993.067checkpoint-600โ†“ 0.20%

Key Findings

  1. Performance Plateau at 2k-3k Range

    • Significant improvement from 1kโ†’2k (+1.98%)
    • Plateau at 2kโ†’3k (0% improvement)
    • Marginal improvement at 3kโ†’4k (+0.20%)
  2. Optimal Model: 2k Samples (v0.4.2)

    • Best cost-benefit ratio: 2.2x faster than 4k for only 0.2% worse loss
    • Stable training with minimal overfitting
    • Validation loss: 3.073 (vs 3.067 for 4k)
  3. Diminishing Returns

    • Loss convergence confirms limited benefit beyond 2k samples
    • Training time scales approximately linearly with data size
    • Resource efficiency decreases significantly after 2k

Training Configuration

Base Model: llava-hf/llava-1.5-7b-hf
Quantization: 4-bit NF4 with double quantization

LoRA Parameters:
  rank: 32
  alpha: 64
  dropout: 0.05
  target_modules: [q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj]

Training Hyperparameters:
  batch_size: 4
  gradient_accumulation_steps: 4  # Effective batch size: 16
  learning_rate: 2e-4
  num_epochs: 3
  warmup_steps: 50
  max_grad_norm: 1.0
  weight_decay: 0.01
  optimizer: AdamW
  lr_scheduler: cosine
  mixed_precision: fp16

Hardware:
  GPU: NVIDIA GeForce RTX 4060 Ti 16GB
  CUDA: 12.4
  PyTorch: 2.6.0

Loss Convergence Visualization

Validation Loss
3.14 โ”ค
     โ”‚ 1k โ—
3.12 โ”ค     โ•ฒ
     โ”‚      โ•ฒ
3.10 โ”ค       โ•ฒ 2k โ—โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ—โ”โ”โ”โ”โ— (plateau)
     โ”‚              3k            4k
3.08 โ”ค
     โ”‚
3.06 โ”ค                              โ—
     โ”‚                             4k
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      1k    2k    3k    4k

Model Artifacts

models/
โ”œโ”€โ”€ llava_v03_qlora_1k/    # 134.5 MB (v0.4.1) โœ…
โ”œโ”€โ”€ llava_v03_qlora_2k/    # 134.5 MB (v0.4.2) โœ… Recommended
โ”œโ”€โ”€ llava_v03_qlora_3k/    # 134.5 MB (v0.4.3) โœ…
โ””โ”€โ”€ llava_v03_qlora_4k/    # 134.5 MB (v0.4.4) โœ…

Detailed Analysis

See Result_QLoRA_Scale.md for:

  • Detailed loss curves for all 4 stages
  • Cost-benefit analysis
  • Training time scaling analysis
  • Validation loss stability comparison
  • Recommendations for production deployment

Documentation


๐Ÿ“Š v0.5.1: Model Evaluation & Visualization

Status: โœ… Complete

Completion Date: 2026-05-24
Evaluation Period: 2026-05-23 - 2026-05-24

Objective

Comprehensive evaluation of all 4 QLoRA fine-tuned models (1k/2k/3k/4k) using semantic similarity metrics and creation of publication-quality visualizations for ACVR 2026 paper submission.

Evaluation Framework

Semantic Similarity Metric (Sentence-BERT)

Replaced simple quality scoring with Japanese Sentence-BERT cosine similarity:

  • Model: sonoisa/sentence-bert-base-ja-mean-tokens-v2
  • Metric: Cosine similarity between model predictions and ground truth
  • Range: 0.0 (completely different) โ†’ 1.0 (identical)
  • Test Set: 800 samples (fixed from v0.3)

Quality Tier Classification

TierSimilarity RangeInterpretation
Excellentฯ โ‰ฅ 0.85Near-perfect match
Good0.75 โ‰ค ฯ < 0.85High quality, minor differences
Acceptable0.65 โ‰ค ฯ < 0.75Adequate, usable
Poor0.50 โ‰ค ฯ < 0.65Significant gaps
Very Poorฯ < 0.50Unacceptable quality

Evaluation Results

Cosine Similarity Performance

ModelMean ยฑ StdMedianMinMaxTier
1k0.6491 ยฑ 0.08750.65360.08090.8462Acceptable
2k0.6850 ยฑ 0.08140.69330.08090.8526Acceptable
3k0.6909 ยฑ 0.07840.70810.08090.8540Acceptable+
4k0.6739 ยฑ 0.07950.68080.08090.8492Acceptable

Quality Tier Distribution

ModelExcellentGoodAcceptablePoorVery Poor
1k0.0%11.9%40.0%42.9%5.2%
2k0.1%20.8%50.6%26.2%2.2%
3k0.0%21.0%48.9%27.6%2.5%
4k0.0%15.9%51.9%32.1%0.1%

Key Findings: Inverted-U Relationship

1. Performance Trajectory

Cosine Similarity
0.70 โ”ค           โ•ญโ”€โ”€โ— 3k (Peak)
     โ”‚          โ•ฑ    โ•ฒ
0.68 โ”ค        โ—        โ•ฒโ— 4k (Degradation)
     โ”‚      โ•ฑ  2k       โ•ฒ
0.66 โ”ค    โ•ฑ              โ•ฒ
     โ”‚  โ—                 โ•ฒ
0.64 โ”ค 1k
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
      1k    2k    3k    4k

Observation: Semantic similarity improves from 1kโ†’2k (+5.5%) โ†’ 3k (+0.9%), but degrades at 4k (-2.5%).

2. Optimal Model: 3k Samples

  • Highest Mean: 0.6909 (closest to "Good" tier boundary of 0.70)
  • Highest Median: 0.7081 (actually reaches "Good" tier)
  • Best Good+ Ratio: 21.0% (vs 20.8% for 2k, 15.9% for 4k)
  • Lowest Standard Deviation: 0.0784 (most consistent)

3. Cost-Benefit Winner: 2k Samples

  • Near-Optimal Performance: 0.6850 (only -0.9% below 3k)
  • Best Good+ Distribution: 20.8% Good + 0.1% Excellent
  • Lowest Very Poor Rate: 2.2% (vs 5.2% for 1k)
  • Training Efficiency: 2.9 hours (vs 4.5 hours for 3k, 6.3 hours for 4k)
  • Recommended for Production: Best quality/time ratio

4. Overfitting at 4k

Evidence:

  • 2.5% performance drop from 3k despite 33% more data
  • Good tier collapses from 21.0% (3k) โ†’ 15.9% (4k)
  • Poor tier expands from 27.6% (3k) โ†’ 32.1% (4k)
  • Validation loss: 3.073 (2k/3k) vs 3.067 (4k) โ€” lower loss but worse test performance

Hypothesis: Additional data introduces label noise or vocabulary saturation.

Visualizations (Publication Quality)

Created 5 comprehensive figures for ACVR 2026 paper:

Figure 3: Similarity Comparison

Similarity Comparison

Bar chart comparing mean cosine similarity across all 4 models with error bars (ยฑ1ฯƒ).

Figure 4: Tier Distribution (Stacked)

Tier Stacked

100% stacked bar chart showing quality tier proportions per model.

Figure 5: Tier Distribution (Grouped)

Tier Grouped

Grouped bar chart enabling direct comparison within each quality tier.

Figure 6: Violin Plots

Violin Plots

Distribution visualization showing density concentration (2k/3k near Good/Acceptable boundaries).

Figure 7: Summary Table

Summary Table

Comprehensive statistical summary with mean/std/min/max/median and tier percentages.

Paper Integration

Submitted to: ACVR 2026 (Asian Conference on Computer Vision and Robotics)
Paper: methodology.tex
Total Pages: 16 pages
Figures: 7 figures (including Validation Loss curve)

Key Sections

  1. Results (ยง4): Quantitative evaluation with all 5 visualization figures
  2. Discussion (ยง5):
    • ยง5.1: The 3k Peak and 4k Degradation (inverted-U analysis)
    • ยง5.2: Validation Loss interpretation (train-test discrepancy)
    • ยง5.3: Inference speed optimization (warm-up hypothesis)

Critical Insights for Paper

  1. Loss-Based Early Stopping Limitation
    4k model achieves lowest validation loss (3.067) but worst test performance (0.6739) โ€” highlights need for domain-specific metrics beyond perplexity.

  2. Mid-Scale Training Advantage
    2k-3k range achieves optimal quality-cost balance, challenging "more data = better" assumption in specialized domains.

  3. Overfitting in Low-Resource Domains
    Vocabulary saturation and label noise become dominant factors beyond ~3k samples for Japanese bridge damage terminology.

Scripts & Tools

Next Steps (v0.6)

  1. ACVR 2026 Submission: Complete camera-ready version with reviewer feedback
  2. Production Deployment: Deploy 2k model for operational bridge inspection
  3. Ablation Studies:
    • Test alternative PEFT methods (IAยณ, Prompt Tuning)
    • Experiment with different base models (LLaVA-v1.6, Qwen-VL)
  4. Expand Test Coverage: Evaluate on different damage types (cracks, corrosion without rebar exposure)

v0.5-v0.6 Roadmap (Next Phases)

Phase 2: v0.4 QLoRA Fine-Tuning (โณ Pending)

Script: train_v03_qlora.py

QLoRA Configuration:

Base Model: llava-hf/llava-1.5-7b-hf
Quantization: 4-bit NF4 with double quantization
LoRA Parameters:
  rank: 32
  alpha: 64
  dropout: 0.05
  target_modules: [q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj]
Training Hyperparameters:
  batch_size: 4
  gradient_accumulation_steps: 4  # Effective batch size: 16
  learning_rate: 2e-4
  num_epochs: 3
  optimizer: AdamW
  lr_scheduler: cosine with warmup (50 steps)
  mixed_precision: fp16

Training Stages:

# Stage 1: 1k samples (~2-4 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_1k.csv --output-dir models/llava_v03_qlora_1k

# Stage 2: 2k samples (~4-8 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_2k.csv --output-dir models/llava_v03_qlora_2k

# Stage 3: 3k samples (~6-12 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_3k.csv --output-dir models/llava_v03_qlora_3k

# Stage 4: 4k samples (~8-16 hours)
python train_v03_qlora.py --train-data data/v03_fine_tuning/train_4k.csv --output-dir models/llava_v03_qlora_4k

Expected Output:

  • LoRA adapter weights (adapter_model.safetensors)
  • Training configuration (adapter_config.json)
  • Training logs (TensorBoard format)
  • Training summary (JSON with loss curves, timing)

Phase 3: v0.5 Vector Similarity Evaluation (โณ Pending)

Script: src/evaluation/vector_similarity_evaluator.py

Evaluation Method:

  • Model: Sentence-BERT Japanese (sonoisa/sentence-bert-base-ja-mean-tokens-v2)
  • Metric: Cosine similarity between ground truth and predictions
  • Test Set: Fixed 800 images (test_set_n800.csv)

Quality Thresholds:

Excellent:   โ‰ฅ0.85
Good:        โ‰ฅ0.75
Acceptable:  โ‰ฅ0.65
Poor:        โ‰ฅ0.50
Very Poor:   <0.50

Usage:

# Evaluate single model
python -m src.evaluation.vector_similarity_evaluator \
  --csv inference_1k_results.csv \
  --gt-col "ๆ‰€่ฆ‹" \
  --pred-col "prediction" \
  --output data/v03_fine_tuning/evaluations/evaluation_train_1k.json

# Generate progressive training report
python create_progressive_training_report.py \
  --eval-dir data/v03_fine_tuning/evaluations \
  --output-dir data/v03_fine_tuning/reports

Expected Improvements:

Metricv0.2 (Q5_K_M)v0.3 TargetImprovement
Mean Cosine Similarity0.68-0.720.78-0.85+15-20%
Quality Distribution (โ‰ฅ0.75)~45%70-80%+55-78%
Standard Deviation0.18-0.220.12-0.16Better consistency

Phase 4: v0.6 Academic Paper (โณ Pending)

Target: arXiv preprint submission

Paper Structure:

  1. Abstract: Progressive fine-tuning approach for bridge damage VLM
  2. Introduction: Motivation, challenges in civil engineering AI
  3. Methodology:
    • Dataset construction (10,789 images โ†’ filtered โ†’ stratified)
    • QLoRA configuration (4-bit, rank=32)
    • Progressive training strategy (1kโ†’4k)
    • Vector similarity evaluation
  4. Results:
    • Quantization comparison (v0.2)
    • Fine-tuning performance scaling (v0.3-v0.5)
    • Ablation studies
  5. Discussion: Optimal dataset size, cost-benefit analysis
  6. Conclusion: Recommendations for domain-specific VLM deployment

LaTeX Source: paper_damage_vlm/0_Format_arXiv_pdfLaTex/bridge_damage_vlm_quantization_2026.tex

Current Status Summary

PhaseStatusCompletion Date
v0.1: Baseline Pipelineโœ… Complete2025-12
v0.2: Quantization Studyโœ… Complete2026-03
v0.3: Dataset Preparationโœ… Complete2026-05-22
v0.4: QLoRA Trainingโœ… Complete2026-05-23
v0.5.1: Evaluation & Visualizationโœ… Complete2026-05-24
v0.6.3: Quality Guard + Full Pipelineโœ… Complete2026-05-25
v0.7.1: Image Size Optimizationโœ… Complete2026-05-26
v0.7.2: pairdata_v2 Progressive Retrainingโœ… Complete2026-05-27
v0.7.3: Quality Guard Recalibration & Full Pipelineโœ… Complete2026-05-28
v0.7.4: 2048-Dimensional Composite Embedding Evaluationโœ… Complete2026-05-29
v0.7.5: 2k Pipeline Evaluation & Supplementary Paper Updateโœ… Complete2026-05-29
v0.8: pairdata_v3 QLoRA Rank Ablation (r=16/32/64)โœ… Complete2026-05-30
v0.8.1: DoRA vs. LoRA Comparison (r=64)โœ… Complete2026-05-30
v0.8.2: Embedding Eval + QG Assessment โ†’ LoRA r=32 Adoptedโœ… Complete2026-05-31
v0.8.3: U.7 Qualitative Analysis Full Update (pairdata v3)โœ… Complete2026-05-31
v0.8.4: DoRA Rank Ablation Study (r=16/32 vs LoRA r=32)โœ… Complete2026-06-01
v0.8.5: DoRA r=24 Final Rank Ablation & v1.0.0 Model Selectionโœ… Complete2026-06-02

Documentation


๐Ÿ›ก๏ธ v0.6.3: Quality Guard Agent & Full Pipeline Evaluation

Status: โœ… Complete

Completion Date: 2026-05-25
Evaluation: Full n=800 test set (v0.6.3 pipeline, 3k model)

Overview

v0.6.3 introduces a two-stage Quality Guard Agent that filters low-quality VLM outputs before priority scoring, completing the end-to-end production pipeline:

Image โ†’ LLaVA-1.5-7B (3k QLoRA) โ†’ Quality Guard (Stage 1 + 2) โ†’ Priority Scorer โ†’ Report

Quality Guard Agent Architecture

Stage 1: Rule-Based Filter (CPU, ~0.01 s/row)

RuleThresholdReject Code
Token count below minimumฮธ_low = 98 (5th percentile)short_description
Token count above maximumฮธ_high = 202 (95th percentile)dirty_or_noisy
Excessive repetition (โ‰ฅ 3 repeated n-grams)โ€”dirty_or_noisy
No damage keyword presentโ€”dirty_or_noisy
Image file missingโ€”no_such_file

Token counting uses CJK + ASCII tokenization to correctly handle Japanese text.

Stage 2: SLM Judge (Swallow-8B NF4, GPU, Unsloth)

Applies natural-language judgement to Stage 1 PASS outputs as a second verification layer. Empirical result: Stage 2 produced 0 additional rejections for the 3k model โ€” the rule-based Stage 1 alone was sufficient.

n=800 Evaluation Results

MetricValue%
Total images800100.0%
PASS (High Quality)72790.9%
FAIL โ€” Dirty or Noisy364.5%
FAIL โ€” Short description354.4%
FAIL โ€” No such file20.2%
Stage 2 additional rejections0โ€”
End-to-end throughput8.97 s/rowโ€”
Total elapsed7,178 s (โ‰ˆ 2.0 h)โ€”

Priority Scoring Results (PASS n=727)

MetricValue
Priority LevelAll Level 3 (100%)
Priority Score0.54 (uniform)
Cosine Similarity (median)0.705 (Good tier boundary)
Token Count (median)120 tokens

Finding โ€” Output Mode Collapse: The 3k model generates near-identical descriptions for all PASS images. Main Girder is mentioned in 100% of predictions; Rebar Exposure in 99.6%; Spalling in 98.6%. This stereotyped output pattern causes uniform priority scores (Level 3 saturation). See paper_damage_vlm/1_Methodology/methodology.tex for full analysis.

Quality Metric Distributions

MetricPASS (n=727)FAIL (n=73)
Cosine similarity (median)0.7050.659
Token count (median)12097 โ‰ˆ ฮธ_low

The Quality Guard preferentially retains predictions with higher semantic alignment โ€” even though the filter is defined only on output-text properties, it acts as a proxy for semantic quality.

Key Findings

  1. Stage 1 sufficiency: The lightweight CPU rule filter achieves the same classification as the full two-stage pipeline for the 3k model and this corpus.
  2. Output mode collapse: Fine-tuning on a skewed training corpus causes the model to default to a dominant memberโ€“damage template. Requires data balancing or constrained-generation prompts.
  3. Priority scoring calibration gap: All 727 PASS samples receive Priority Level 3, indicating the YAML rules need recalibration or VLM prompts need explicit severity keywords.
  4. Throughput: 8.97 s/row (batch_size=8, torch.compile()) enables processing of 800 images in ~2 hours on RTX 4060 Ti 16GB.

Generated Figures

FigureDescription
figures_vlm/10_priority_score_violin.pngPriority score saturation + PASS vs FAIL cosine similarity + token count violin
figures_vlm/10_member_damage_analysis.pngMember/damage frequency bars + co-occurrence heatmap

Scripts

  • Pipeline: pipeline_v063.py โ€” Full end-to-end v0.6.3 pipeline
  • Figure generation: create_figures_10.py โ€” Analysis figures for n=800 results
  • Output CSV: data/v03_fine_tuning/evaluations/v063_scoring_results.csv (800 rows, 22 columns)

Paper Status

The academic paper (paper_damage_vlm/1_Methodology/methodology.tex) is complete with all v0.6.3 results:

  • Quality Guard Agent methodology section (TikZ algorithm flow diagram)
  • n=800 results tables (tab:qg_final)
  • Output mode collapse analysis (fig:member_damage)
  • Priority scoring distribution (fig:priority_violin)
  • Discussion: Quality Guard efficacy, mode collapse, calibration
  • 25 pages, 10 figures โ€” compiled with pdflatex (no errors)

๐Ÿ–ผ๏ธ v0.7.1: Image Size Optimization for QLoRA Fine-Tuning

Status: โœ… Complete

Completion Date: 2026-05-25
Experiment: Controlled comparison of 3 input image datasets at 1k scale

Background

LLaVA-1.5-7B uses a CLIP ViT-L/14-336 vision encoder pretrained at 336ร—336 px. Feeding images at arbitrary sizes forces internal rescaling and introduces resampling artifacts into the patch embeddings, potentially degrading fine-tuning quality. This experiment quantifies the impact of pre-standardising training images to the model's native resolution.

Image Preprocessing Pipeline

StepDescriptionOutput
1Long-side resize to 1024 px (aspect-ratio preserved)data/inspect_images_v2/ โ€” 10,789 images
2Manual removal of blueprints / blank / corrupted images10,668 images remain (121 removed)
3aCenter-crop to square โ†’ resize to 336ร—336data/inspect_images_336/ โ€” 10,668 images, ~0.034 MB avg
3bCenter-crop to square โ†’ resize to 448ร—448data/inspect_images_448/ โ€” 10,668 images, ~0.060 MB avg

Center-crop (rather than pad-and-resize) was chosen because bridge damage photos are mixed portrait/landscape. Padding introduces black borders that divert the vision encoder's attention from damage regions.

Comparative Training Results (1k Scale, 3 Epochs)

DatasetImage SourceImage SizeTraining Timeeval_losseval Token Accuracy
pairdata_v2-1rank_c_images_n10789Variable (original)1:34:533.18989.5%
pairdata_v2-2inspect_images_336336ร—336 px1:21:463.19490.1%
pairdata_v2-3inspect_images_448448ร—448 px1:21:573.20289.9%

All runs: train_v07_qlora.py, LoRA r=32/ฮฑ=64, LR=2e-4, batch_size=4, BF16, RTX 4060 Ti 16GB

Key Finding

336ร—336 px is the optimal input size for LLaVA-1.5-7B fine-tuning on bridge damage images:

  • +0.6 pt token accuracy vs. variable-size originals
  • 14% shorter training time (1:34:53 โ†’ 1:21:46) due to uniform tensor shapes enabling better GPU batching
  • 448ร—448 px shows no accuracy gain over 336ร—336 px, despite 76% larger file size โ€” the CLIP encoder's 336 px pretraining is the binding constraint

Configuration Update

config.yaml and train_v07_qlora.py now default to data/inspect_images_336/:

# config.yaml โ€” v0.7.1
v03_dataset:
  image_dir: "data/inspect_images_336"   # 336ร—336 center-crop (LLaVA-1.5 native)
  # image_dir: "data/inspect_images_448"  # 448ร—448 alternative
  # image_dir: "data/inspect_images_v2"   # max 1024px long side (original)

Scripts

  • resize_images_v2.py โ€” Step 1: long-side 1024 px resize
  • crop_resize_images.py โ€” Steps 3a/3b: center-crop + resize to 336 and 448
  • train_v07_qlora.py โ€” Added --image-base-dir CLI option for dataset switching

Further Reading


๐Ÿ“ˆ v0.7.2: pairdata_v2 Progressive Retraining (1k-4k)

Status: โœ… Complete

Completion Date: 2026-05-27
Scope: Full progressive QLoRA retraining on denoised pairdata_v2 with inspect_images_336

What Was Completed

  • Completed all four scales (1k, 2k, 3k, 4k) under a fixed training recipe
  • Updated supplementary section S.4 in methodology with final tables and observations
  • Added S.4 figure using the same plotting style as Figure 9:
    • paper_damage_vlm/1_Methodology/figures_vlm/11_s4_validation_loss_pairdata_v2.png
    • plotted from raw eval checkpoints (no interpolation) for fair comparison

Final Progressive Results (pairdata_v2)

ScaleTrainValSkipDurationFinal eval_lossFinal eval Token Accuracy
1k792198101h 21m3.19490.1%
2k1579395262h 56m3.15198.7%
3k2374594324h 24m3.13599.0%
4k3168792405h 55m3.12599.2%

Key Findings

  • Strongest gain is 1k -> 2k (-0.043 nats eval loss, +8.6 pp token accuracy)
  • Clear diminishing returns beyond 2k:
    • 2k -> 3k: -0.016 nats, +0.3 pp
    • 3k -> 4k: -0.010 nats, +0.2 pp
  • In 4k run, minimum eval loss appears at epoch 2 (3.124), then slightly increases at epoch 3 (3.125), suggesting near-convergence

Semantic Similarity Evaluation on Denoised Test Set (S.6)

Test set: n=800, pairdata-v2 ground truth
Evaluator: paraphrase-multilingual-MiniLM-L12-v2 (cosine similarity)
Tier thresholds: Excellent โ‰ฅ 0.85 ยท Good โ‰ฅ 0.70 ยท Acceptable โ‰ฅ 0.55 ยท Poor โ‰ฅ 0.40 ยท Very Poor < 0.40

ScaleMean ฯฯƒMedianGood+ (%)V.Poor (%)
1k0.56570.15730.591635.232.9
2k0.60110.13670.613740.621.9
3k โœ…0.60130.14370.621339.821.5
4k0.57420.13980.601433.828.2

All four models fall in the Acceptable tier under pairdata-v2 thresholds.
Absolute values are ~0.08โ€“0.09 lower than pairdata-v1 results, reflecting the harder matching task of shorter denoised ground-truth texts.

Key findings:

  • 1k โ†’ 2k: +6.3% mean gain (largest improvement)
  • 2k โ‰ˆ 3k: ฮ”ฯ = 0.0002 (saturation)
  • 4k: โˆ’4.5% from 3k (overfitting: VPoor rises 21.5% โ†’ 28.2%)

Model selected: 3k
Rationale: peak mean (0.6013) + highest median (0.6213) + lowest Very Poor rate (21.5%).
Result is consistent with pairdata-v1 finding where 3k also achieved peak performance (ฯ = 0.6909).

Figures generated:

  • paper_damage_vlm/1_Methodology/figures_vlm/12_v072_similarity_by_scale.png
  • paper_damage_vlm/1_Methodology/figures_vlm/13_v072_tier_distribution.png
  • paper_damage_vlm/1_Methodology/figures_vlm/14_v072_cosine_violin.png

Repro Commands

.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 1k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 2k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 3k
.\.venv-train\Scripts\Activate.ps1 ; python -u train_v07_qlora.py --train-size 4k

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology.tex (ๆœฌ็ทจใฎใฟใ€Supplementaryๅˆ†้›ขๆธˆใฟ)
  • paper_damage_vlm/1_Methodology/methodology_supp.tex (Supplementary ็‹ฌ็ซ‹ใƒ•ใ‚กใ‚คใƒซใ€S.6็ต่ซ–ๅซใ‚€)
  • paper_damage_vlm/1_Methodology/methodology.pdf (23 pages, recompiled)
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf (7 pages, recompiled)

๐Ÿ”ฌ v0.8: pairdata_v3 QLoRA Rank Ablation

Status: โœ… Complete

Completion Date: 2026-05-30
Scope: pairdata_v3 denoising; LoRA rank ablation r=16/32/64 at 2,500-sample scale; Supplementary 2 full documentation

LoRA Rank Ablation Results (pairdata_v3, 2,500 samples)

Runreval_loss (best)token_acc (best)train_lossDuration
v0.8-r16163.13898.73%3.5673h24m
v0.8-r32323.13398.83%3.4895h36m
v0.8-r64643.12298.90%3.4193h27m

All best checkpoints at epoch 2.421 of 3.

Key Finding

r=64 selected as optimal: 168.8M trainable parameters (4.56% of 7B backbone) provide sufficient representation space to learn the fine-grained correspondence between complex damage imagery and structured recognition text (member type ร— damage category). r=16/32 (42M/84M) leave a residual alignment gap. Critically, r=64 adds no measurable GPU cost over r=16 (3h24m vs 3h27m on RTX 4060 Ti 16GB).

Supplementary 2 Documentation

  • U.1: Motivation (pairdata_v3 noise removal rationale)
  • U.2: Extended noise pattern definition
  • U.3: Pairdata v2 vs v3 statistics comparison
  • U.4: QLoRA training at 2,500-sample scale โ€” rank ablation table + Figure 21 + analysis
  • U.5โ€“U.7: Semantic similarity, Quality Guard, Qualitative analysis (pending v0.8 inference)
  • U.8: DoRA vs. LoRA comparison (filled in v0.8.1)

๐Ÿ”ฌ v0.8.1: DoRA vs. LoRA Comparison (r=64)

Status: โœ… Complete

Completion Date: 2026-05-30
Scope: DoRA fine-tuning (use_dora=True, r=64) on pairdata_v3 2,500 samples; U.8 Supplementary 2 fully documented

DoRA vs. LoRA Results (pairdata_v3, 2,500 samples, r=64)

RunAdaptereval_loss (best)token_acc (best)train_lossDurationฮ”eval
v0.8-r64LoRA3.12298.90%3.4193h27mโ€”
v0.9-r64DoRA3.11998.92%3.4176h51mโˆ’0.003

Best checkpoints at epoch 2.421; final-epoch: LoRA 3.132/98.93%, DoRA 3.132/98.95%.

Research Questions Answered

#QuestionResult
(i)DoRA lower eval_loss than LoRA at same r?โœ… 3.119 < 3.122 (ฮ”=โˆ’0.003)
(ii)Cosine similarity improvement?๐Ÿ”„ Pending inference on n=800 test set
(iii)Hallucination reduction?๐Ÿ”„ Pending inference on n=800 test set

Supplementary 2 Updates (U.8)

  • Configuration table: r=32/alpha=64 โ†’ r=64/alpha=128
  • Training Results table: TBD values filled with actual DoRA results
  • Motivation rewritten: r=64 basis from U.4 ablation; 3 research questions
  • Adapter capacity analysis: 168.8M params at 4.56% provides bridge-domain bandwidth
  • Repro Commands: updated to train_v09_dora.py --lora-r 64

Reproduce

# DoRA training
.venv-train\Scripts\Activate.ps1
python -u train_v09_dora.py --lora-r 64 *> v09_dora_r64_log.txt
# Output: models/llava_v09_dora_r64_2500

# Recompile Supplementary 2
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.2: Embedding Evaluation + Quality Guard Assessment

Status: โœ… Complete

Completion Date: 2026-05-31
Scope: 2048-dim Sentence-BERT evaluation of all 4 adapters on n=800 test set; Quality Guard + Priority Scoring for LoRA r=32 and DoRA r=64; Structural Member & Damage Type analysis; final model selection

Sentence-BERT Evaluation Results (2048-dim composite, n=800)

ModelAdapterMean CosineMedian CosineGood+ RateExcellent Rate
v0.8-r16LoRA r=160.64640.648018.9%0.0%
v0.8-r32LoRA r=320.67000.668932.9%0.0%
v0.8-r64LoRA r=640.65710.660628.4%0.0%
v0.9-r64DoRA r=640.68460.683541.0%0.0%

Embedding model: hotchpotch/static-embedding-japanese (1024-dim) โŠ• intfloat/multilingual-e5-large (1024-dim), L2-normalized concatenation.

Quality Guard + Priority Scoring Results (n=800)

ModelPASSFAILToken MeanToken ฯƒLevel 3Level 4Level 5
LoRA r=32 (v0.8)798 (99.8%)2 (0.2%)89.518.98.0%79.2%12.8%
DoRA r=64 (v0.9)798 (99.8%)2 (0.2%)84.34.50.0%100%0.0%

ฮธ_low=30, ฮธ_high=200 (retained from v0.7.3).

Key Findings

#FindingDetail
(i)DoRA r=64: highest embedding scoreMean cosine 0.6846, Good+ 41.0% โ€” best among all adapters
(ii)DoRA r=64: output-level mode collapseToken ฯƒ=4.5 (vs LoRA 18.9); all 798 PASS โ†’ Level 4 (100%)
(iii)DoRA r=64: structural member/damage collapseMain Girder+Deck Slab 100%, Crack/Rebar/Spalling 100% โ€” stereotyped template
(iv)LoRA r=32: balanced severity distributionLevel 3โ†‘ (8.0% vs v0.7.3-3k 2.7%); Level 3/4/5 distribution improves fairness
(v)DoRA r=64 fine-tuning failedr=64 likely excessive for DoRA; fine-tuning protocol to be established as future work
(vi)LoRA r=32 (v0.8) adopted as final modelBest balance of embedding quality and output diversity

Structural Member & Damage Type Analysis (U.6.1)

ModelMain GirderCurbDeck SlabCrackRebar Exp.SpallingLime Effl.
LoRA r=32100%60.0%9.9%100%88.1%99.0%73.9%
DoRA r=64100%0%100%100%100%100%0%

DoRA r=64 assigns exactly 3 damage types to exactly 2 members across all 798 predictions: clear evidence of fine-tuning failure.

Supplementary 2 Updates (U.5โ€“U.6.1)

  • U.5: Sentence-BERT results table filled (TBDโ†’actual); Figures 22/23/24 inserted; Analysis paragraph added
  • U.6: Quality Guard table (2-model comparison); Priority table; Analysis rewritten with v0.7.3-3k comparison and DoRA failure conclusion
  • U.6.1: New subsection โ€” Structural Member & Damage Type (Figure 28, same style as S.7.1)
  • U.5 conclusion: Revised from "DoRA adopted" to "both forwarded to QG for evaluation"
  • Final conclusion: LoRA r=32 (v0.8) adopted; DoRA finetuning left as future work
  • methodology_supp2.pdf: 21 pages

Figures Generated

FigureFileContent
Fig. 2222_v08_similarity_by_adapter.pngMean/Median cosine similarity by adapter
Fig. 2323_v08_tier_distribution.pngTier distribution stacked bar
Fig. 2424_v08_cosine_violin.pngCosine similarity violin plots
Fig. 2525_v08_token_distribution.pngToken count histograms (LoRA r=32 vs DoRA r=64)
Fig. 2626_v08_guard_breakdown.pngPASS/FAIL + reason code breakdown
Fig. 2727_v08_priority_distribution.pngPriority level distribution
Fig. 2828_v08_member_damage_r32_dora.pngStructural member ร— damage co-occurrence (S.7.1 style)

Reproduce

# Sentence-BERT evaluation (4 models)
.venv-eval\Scripts\Activate.ps1
python -u evaluate_v08_sbert.py

# Quality Guard + Priority Scoring
python -u pipeline_v08.py

# Generate Figures 22-24 (U.5)
python -u create_u8_figures.py

# Generate Figures 25-27 (U.6)
python -u create_u6_figures.py

# Generate Figure 28 (U.6.1, S.7.1 style)
python -u create_u61_figures.py

# Recompile Supplementary 2 (21 pages)
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.3: U.7 Qualitative Analysis Full Update (pairdata v3)

Status: โœ… Complete

Completion Date: 2026-05-31
Scope: U.7 qualitative analysis section fully rebuilt on pairdata v3 (inference_r32.csv); 12 representative PASS images re-selected with member ร— damage diversity; caption simplified and enriched; shared keyword highlighting added

Changes

ItemDescription
Image selection12 images re-selected from inference_r32.csv (pairdata v3 test set) using greedy member ร— damage diversity
Caption structureSimplified to 3 items: Quality Metrics / GT / Pred
Quality MetricsSim(emb) (2048-dim cosine) + Priority Score (0โ€“1) + Level (priority tier 3/4/5)
Keyword highlightKeywords appearing in both GT and Pred rendered in gothic font (\CJKfamily{ipxg}) for visual emphasis
s8 folderAll 12 JPEGs replaced (figures_vlm/s8/s8_01_*.jpg โ€“ s8_12_*.jpg)
PDFmethodology_supp2.pdf rebuilt โ†’ 19 pages

Selected Images (12 panels, member ร— damage)

#MemberDamageSim(emb)PriorityLevel
01girdercracking0.8401.005
02girderrebar_exposure0.8080.814
03girderspalling0.7740.814
04girdercorrosion0.7130.814
05girdersettlement0.5720.814
06girderother0.5850.814
07slabcracking0.8061.005
08slabrebar_exposure0.7780.814
09slabcorrosion0.7410.814
10abutmentcracking0.7981.005
11abutmentrebar_exposure0.7970.814
12abutmentspalling0.6690.814

Reproduce

.venv-eval\Scripts\Activate.ps1
python create_u7_figures.py

cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp2.tex

๐Ÿ”ฌ v0.8.4: DoRA Rank Ablation Study

Status: โœ… Complete

Completion Date: 2026-06-01
Scope: DoRA fine-tuning at r=16 (full pipeline: train โ†’ merge โ†’ inference โ†’ SBERT โ†’ quality guard โ†’ figures); 3-way rank ablation (LoRA r=32 vs. DoRA r=32 vs. DoRA r=16) with Figures 35โ€“41 and U.7.2 discussion update

Overview

v0.8.4 extends the DoRA investigation with a lower-rank variant (r=16) and performs a full 3-way comparison against the LoRA r=32 baseline and DoRA r=32. The ablation reveals a non-monotone relationship between DoRA rank and output quality: r=16 achieves the most balanced priority distribution despite having the smallest trainable capacity.

DoRA r=16 Training Details

ItemValue
Scripttrain_v09_dora.py --lora-r 16
AdapterDoRA (use_dora=True), r=16, alpha=32, dropout=0.05
Datasetpairdata-v3, 2,500 samples (80/20 split)
eval_loss (best, ep 2.421)3.135
eval_loss (final, ep 3.0)3.138
Training duration6h 48m 26s
Merged modelmodels/llava_v09_dora_r16_merged/ (85 shards, max_shard_size=200MB)

3-Way Ablation Results (n=800)

SBERT Cosine Similarity (2048-dim composite evaluator)

ModelMeanStdMedianGood+ (โ‰ฅ0.70)
LoRA r=32 (v0.8 baseline)0.67000.06570.685432.9%
DoRA r=32 (v0.9)0.65640.06820.669125.0%
DoRA r=16 (v0.9)0.67170.06390.681136.0%

Quality Guard & Priority Distribution (n=800)

ModelPASSFAILL3L4L5Token mean
LoRA r=32798 (99.8%)26463210289.5
DoRA r=32798 (99.8%)265726788.0
DoRA r=16797 (99.6%)3617053174.5
DoRA r=64 (ref)798 (99.8%)20798084.3

Key finding: DoRA r=64 undergoes complete mode collapse (all Level 4). DoRA r=16 achieves the most balanced Level 3/4/5 distribution among DoRA variants.

Figures Generated

FigureFileContent
3535_u72_similarity.pngMean/median cosine similarity (3-way bar)
3636_u72_tier.pngQuality tier distribution
3737_u72_violin.pngCosine similarity violin plots
3838_u72_token.pngToken count histograms
3939_u72_priority.pngPriority level distribution
4040_u72_member_damage.pngMember ร— damage co-occurrence analysis
4141_u7_dora_rank_training_loss.pngValidation loss trajectories (3 models)

Supplementary Paper Updates

SectionChange
U.7.1Figure 41 (validation loss) + "Training dynamics" analysis paragraph added
U.7.2Title updated to "DoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16"
U.7.2Figures 35โ€“40 inserted (3-way 6-panel comparison)
U.7.2 DiscussionDoRA r=64 gradient collapse, r=16 balanced output, r=24 proposed as future work
PDFmethodology_supp2.pdf rebuilt โ†’ 5648 KB

Discussion Summary

  • DoRA r=64: Directionโ€“magnitude decomposition exceeded model capacity at 2500-sample scale โ†’ priority output collapsed to Level 4 (100%), losing member/damage diversity
  • DoRA r=32: Approached LoRA r=32 in similarity but skewed to Level 4 (91%), Level 5 nearly absent
  • DoRA r=16: Smallest capacity but most equitable priority distribution (L3: 7.7%, L4: 88.5%, L5: 3.9%); best Good+ rate (36.0%) among DoRA variants
  • Next step: DoRA r=24 proposed to explore the non-monotone rankโ€“quality tradeoff

Reproduce

# Phase 1: Training (requires .venv-train)
.\.venv-train\Scripts\python.exe train_v09_dora.py --lora-r 16

# Phase 2: Merge (requires .venv-dora)
.\.venv-dora\Scripts\python.exe merge_dora.py

# Phase 3: Inference (requires .venv-dora, NOT .venv-eval)
.\.venv-dora\Scripts\python.exe inference_v082_lora_dora.py --models r16_dora

# Phase 4: SBERT evaluation
.\.venv-eval\Scripts\python.exe evaluate_v08_sbert.py

# Phase 5: Quality Guard + Priority Scoring
.\.venv-eval\Scripts\python.exe pipeline_v08.py

# Phase 6: Figures 35-40 + U.7.2 update
.\.venv-eval\Scripts\python.exe create_u72_dora_ablation.py

# PDF recompile
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

๐ŸŽ‰ v0.8.5: DoRA r=24 Final Rank Ablation & v1.0.0 Model Selection

Status: โœ… Complete

Completion Date: 2026-06-02
Scope: DoRA r=24 full pipeline; 4-way rank ablation (LoRA r=32 + DoRA r=32/16/24); Figure 15 & Figures 35โ€“40 updated to 4-model comparison; U.7.2 Discussion extended; U.7.3 Qualitative Analysis added; DoRA r=24 selected as v1.0.0 final model

Overview

v0.8.5 completes the DoRA rank ablation study by adding DoRA r=24 โ€” the midpoint proposed in v0.8.4 to resolve the non-monotone rankโ€“quality tradeoff. The experiment confirms that DoRA r=24 achieves the best overall balance among all tested variants, leading to its adoption as the production model for v1.0.0.

DoRA r=24 Training Details

ItemValue
Scripttrain_v09_dora.py --lora-r 24
AdapterDoRA (use_dora=True), r=24, alpha=48, dropout=0.05
Datasetpairdata-v3, 2,500 samples (80/20 split)
eval_loss (best, ep 2.421)3.137
Training duration~6h 50m
Merged modelmodels/llava_v09_dora_r24_merged/

4-Way Ablation Results (n=800)

SBERT Cosine Similarity (2048-dim composite evaluator)

ModelMeanStdMedianGood+ (โ‰ฅ0.70)
LoRA r=32 (v0.8 baseline)0.67000.06670.668932.9%
DoRA r=32 (v0.9)0.65640.06300.660225.0%
DoRA r=16 (v0.9)0.67170.06390.681136.0%
DoRA r=24 (v0.9)0.67910.06350.683437.8%

Quality Guard & Priority Distribution (n=800)

ModelPASSFAILL3L4L5Token mean
LoRA r=32798 (99.8%)26463210289.5
DoRA r=32798 (99.8%)265726788.0
DoRA r=16797 (99.6%)3617053174.5
DoRA r=24798 (99.8%)2486747890.6

Key finding: DoRA r=24 achieves the highest SBERT similarity (mean=0.6791, Good+=37.8%) while maintaining a balanced priority distribution (L3/L4/L5 = 6.0%/84.5%/9.8%). This non-monotone optimum confirms DoRA r=24 as the sweet spot for LLaVA-1.5-7B on this structural damage domain.

Paper Updates

SectionChange
Figure 15Updated to "four models"; DoRA r=24 (eval_loss=3.137) added as 4th curve
Training dynamics paragraphDoRA r=24 convergence behaviour added
U.7.2 titleโ†’ "DoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16/24"
U.7.2 Figures 35โ€“40Regenerated as 4-model comparison (added DoRA r=24 column)
U.7.2 DiscussionExpanded to 6 paragraphs: rankโ€“quality relationship; figure-level evidence for each of Figs 35โ€“40; final model selection
U.7.3New subsection: Qualitative Analysis: Finetuned Model Predictions DoRA r=24 (12 panels, Figure 12โ€“14 style)
PDFmethodology_supp2.pdf rebuilt, no errors

Final Model Selection: DoRA r=24

DoRA r=24 (v0.9) is adopted as the v1.0.0 production model based on:

  1. Highest SBERT similarity: mean=0.6791, Good+=37.8% (best across all 7 tested adapters)
  2. Balanced priority distribution: L5 rate 9.8% โ€” higher than DoRA r=16 (3.9%) and DoRA r=32 (0.9%), more discriminative than LoRA r=32 (12.8%)
  3. Non-collapse output: token ฯƒโ‰ˆ6 (stable), no mode collapse to single level
  4. Optimal adapter capacity: 126M trainable parameters โ€” sufficient for bridge-domain fine-grained semantics without over-parameterisation (r=64โ†’collapse; r=16โ†’lower similarity)

v1.0.0 Full Inference (โœ… Complete)

ItemValue
Scriptinference_v10_full.py
ModelDoRA r=24 merged (models/llava_v09_dora_r24_merged/)
InputRank_c_image_text_n10789.xlsx (10,903 rows)
PipelineVLM inference + Quality Guard + Priority Scoring (single pass)
Checkpointevery 2,000 rows โ†’ data/v10_full/checkpoint_{n:06d}.xlsx
Speed3.5 s/image (batch_size=4, RTX 4060 Ti 16GB)
Total time10.55 h (37,968 s)
Outputdata/v10_full/v10_full_r24_dora.xlsx

Figures Generated

FigureFileContent
1515_training_dynamics.pngValidation loss curves โ€” 4 models
3535_u72_similarity.pngMean/median cosine similarity (4-model bar)
3636_u72_tier.pngQuality tier distribution (4 models)
3737_u72_violin.pngCosine similarity violin plots (4 models)
3838_u72_token.pngToken count histograms (4 panels)
3939_u72_priority.pngPriority level distribution (4 models)
4040_u72_member_damage.pngMember ร— damage co-occurrence (4 columns)
U.7.3 Figss9/s9_01โ€“s9_12.jpgDoRA r=24 qualitative panels

Reproduce

# Phase 1: Training (requires .venv-train)
.\.venv-train\Scripts\python.exe train_v09_dora.py --lora-r 24

# Phase 2: Merge (requires .venv-dora)
.\.venv-dora\Scripts\python.exe merge_dora.py --rank 24

# Phase 3: Inference n=800 (requires .venv-dora)
.\.venv-dora\Scripts\python.exe inference_v082_lora_dora.py --models r24_dora

# Phase 4: SBERT evaluation
.\.venv-eval\Scripts\python.exe evaluate_v08_sbert.py

# Phase 5: Quality Guard + Priority Scoring
.\.venv-eval\Scripts\python.exe pipeline_v08.py

# Phase 6: Figures 35-40 (4-way) + U.7.2 Discussion update
.\.venv-eval\Scripts\python.exe create_u72_dora_4way.py

# Phase 7: U.7.3 Qualitative Analysis
.\.venv-eval\Scripts\python.exe create_u73_qualitative.py

# Phase 8: PDF recompile
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

# Phase 9: v1.0.0 full inference โ†’ see v1.0.0 section below
chcp 65001 | Out-Null; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
.\.venv-dora\Scripts\python.exe -u inference_v10_full.py --checkpoint-every 2000 2>&1 | Tee-Object -FilePath "v10_full_r24_dora_log.txt"

๐Ÿš€ v1.0.0: Production Full Inference (n=10,903)

Status: โœ… Complete โ€” ๐ŸŽ‰ Latest Release

Execution period: 2026-06-02 20:20 โ†’ 2026-06-03 06:53 JST
Scope: Full-dataset deployment of DoRA r=24 model over all 10,903 records; Quality Guard + Priority Scoring end-to-end; member ร— damage analysis; Supplementary 2 U.7.4 added to paper

Inference Results

MetricCountRatio (%)
Total records10,903100.0
Quality Guard PASS10,66897.8
Quality Guard FAIL00.0
Missing (no image)2352.2
Priority Level 34544.3
Priority Level 49,18586.1
Priority Level 51,0299.6
Total processing time10.55 h (37,968 s)โ€”
Mean speed (batch=4)3.5 s/imageโ€”

Key finding: PASS rate 97.8% at production scale (n=10,903) is consistent with the validation-set rate. Zero FAIL outputs confirm robust generalisation across the full field dataset. Batch-size-4 processing delivers a 50% speed improvement over single-image inference.

Structural Member & Damage Type Analysis (PASS n=10,668)

Member Frequency

MemberCount% of PASS
Main Girder8,29377.7%
Deck Slab4,13938.8%
Curb3,40431.9%
Railing/Parapet2,86226.8%
Abutment2,18020.4%
Expansion Joint5325.0%
Drainage1381.3%
Bearing780.7%

Damage Type Frequency

Damage TypeCount% of PASS
Crack10,666100.0%
Rebar Exposure9,83792.2%
Spalling4,27740.1%
Lime Efflorescence3,69734.7%
Corrosion3,64534.2%
Deformation2,94327.6%
Delamination6756.3%
Deterioration4684.4%

Key Co-occurrence Findings

MemberMost Associated DamageCo-occ. Rate
Main GirderCrack100.0%
Main GirderRebar Exposure92.4%
Deck SlabCrack + Rebar Exposure100.0%
CurbCorrosion81.5%
Railing/ParapetDeformation99.9%
AbutmentRebar Exposure99.4%

Paper Update

SectionChange
U.7.4 (new)"Damage VLM Apps v1.0.0 Test Prediction: n=10,903" โ€” inference config table, results table, memberร—damage figure & discussion
Figure (fig:u74_member_damage)3-panel: member frequency / damage type frequency / memberร—damage heatmap for PASS n=10,668
PDFmethodology_supp2.pdf rebuilt, no errors

Output Files

FileDescription
data/v10_full/v10_full_r24_dora.xlsxFinal predictions (10,903 rows)
data/v10_full/checkpoint_{002000โ€ฆ010903}.xlsxCheckpoints every 2,000 rows
paper_damage_vlm/1_Methodology/figures_vlm/u74_member_damage_analysis.pngMemberร—damage analysis figure

Reproduce

# Full inference (10,903 rows, batch_size=4, ~10.5 h on RTX 4060 Ti 16GB)
chcp 65001 | Out-Null; [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
.\.venv-dora\Scripts\python.exe -u inference_v10_full.py --checkpoint-every 2000 2>&1 | Tee-Object -FilePath "v10_full_r24_dora_log.txt"

# Member ร— Damage analysis figure (U.7.4)
.\.venv-eval\Scripts\python.exe create_figures_u74.py

# Recompile paper (run twice for cross-references)
Set-Location "paper_damage_vlm\1_Methodology"
pdflatex -interaction=nonstopmode methodology_supp2.tex
pdflatex -interaction=nonstopmode methodology_supp2.tex
Set-Location "..\.."

Performance Metrics

v0.1 Test Results

Test ScaleProcessing TimeSuccess RateAvg Time/Image
Single Image42s100%42s
10-Image Batch8m 35s100%51.6s
50-Image (Est.)~43m-~52s
254-Image (Est.)~3.6h-~51s

Priority Distribution (10-Image Test)

  • Priority 5 (Immediate Repair Required): 6 images (60%)
  • Priority 3 (Planned Maintenance): 4 images (40%)

Resource Utilization

  • GPU Usage: 100% (all layers on GPU)
  • VRAM: ~8GB / 16GB
  • Model Size: 4.08GB (quantized GGUF)
  • Processing Speed: ~51.6s/image

Setup

1. System Requirements

  • OS: Windows 10/11, Linux, or macOS
  • GPU: NVIDIA GPU with 8GB+ VRAM (16GB recommended)
  • Python: 3.10 or higher
  • CUDA: 12.1 or higher
  • Storage: 20GB+ free space

2. Clone Repository

git clone https://github.com/your-username/damage_text_score.git
cd damage_text_score

3. Create Virtual Environment

# Windows PowerShell
python -m venv .venv
.venv\Scripts\Activate.ps1

# Linux/macOS
python -m venv .venv
source .venv/bin/activate

4. Install Dependencies

# PyTorch (CUDA 12.4)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

# llama-cpp-python (GPU version)
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124

# Other dependencies
pip install -r requirements.txt

5. Download Models

# LLaVA GGUF Model (Recommended)
python download_llava_gguf.py
# Downloads:
#   - models/ggml-model-q4_k.gguf (4.08GB)
#   - models/mmproj-model-f16.gguf (624MB)

6. Setup Ollama (for JSON Structuring)

# Install Ollama
# https://ollama.com/download

# Pull Swallow-8B model
ollama pull swallow8b-lora-n4000-v09-q4:latest

Usage

Quick Start

# Test single image (~42s)
python quickstart.py --mode 1

# Process 10-image batch (~8.5 min)
python quickstart.py --mode 2

# Process 50 images (~43 min)
python quickstart.py --mode 3

# Process all 254 images (~3.6 hours)
python quickstart.py --mode 4

Output Files

data/outputs/
โ”œโ”€โ”€ quickstart_single.csv        # Single image result
โ”œโ”€โ”€ quickstart_10images.csv      # 10-image results
โ”œโ”€โ”€ quickstart_50images.csv      # 50-image results
โ””โ”€โ”€ quickstart_254images.csv     # Full dataset results

Output Format

CSV Example:

image_name,damage_type,severity,location,risk,priority_score,priority_level,description
kensg-rebarexposureRb_001.png,crack,high,girder,structural,0.952,5,Extensive cracking observed...

JSON Structure:

{
  "damage_type": "rebar_exposure",
  "severity": "high",
  "location": "girder",
  "risk": "structural",
  "description_ja": "้‰„็ญ‹้œฒๅ‡บใŒ่ฆ‹ใ‚‰ใ‚Œใ€่…้ฃŸใŒ้€ฒ่กŒใ—ใฆใ„ใ‚‹...",
  "key_features": ["rebar exposure", "moderate corrosion"],
  "priority_score": 0.952,
  "priority_level": 5
}

Custom Usage

from src.pipeline.end_to_end import DamageAnalysisPipeline

# Initialize pipeline
pipeline = DamageAnalysisPipeline("config.yaml")

# Process single image
result = pipeline.process_image("path/to/image.png")

# Batch processing
results = pipeline.process_batch(image_paths, output_csv="results.csv")

Model Comparison

Vision Model Performance

ModeModelSizeTime/ImageGPU UsageRating
llama-cpp-pythonLLaVA-1.5-7B Q4_K_M4.08GB51.6s100%โญโญโญโญโญ
HuggingFacellava-1.5-7b-hf14GB45s100%โญโญโญโญ
Ollamallava:7b4.7GB88s0% (CPU)โญโญ

Selection Criteria

  • llama-cpp-python (Recommended)

    • โœ… Lightweight (4GB)
    • โœ… Full GPU utilization
    • โœ… Ollama-independent
    • โœ… Stable operation
    • โš ๏ธ Slight accuracy reduction due to quantization
  • HuggingFace

    • โœ… Highest accuracy
    • โœ… Full GPU utilization
    • โš ๏ธ Large size (14GB)
    • โš ๏ธ High VRAM requirement
  • Ollama

    • โš ๏ธ CPU-only operation (slow)
    • โš ๏ธ No GPU utilization
    • โœ… Easy setup

Tech Stack

Frameworks

  • PyTorch 2.6.0 - Deep learning framework
  • Transformers 4.57.6 - HuggingFace model hub
  • llama-cpp-python 0.3.16 - GGUF inference engine
  • OpenCV 4.12.0 - Image processing

Models

  • LLaVA-1.5-7B - Vision-Language Model

  • Swallow-8B - Japanese LLM

    • Developer: TokyoTech LLM Project
    • Specialized for JSON structuring

Libraries

  • pandas 2.2.3 - Data manipulation
  • pyyaml 6.0.2 - Configuration management
  • tqdm 4.67.1 - Progress bars
  • pillow 11.1.0 - Image processing

Directory Structure

damage_vlm_finetune/
โ”œโ”€โ”€ .venv-train/                    # Virtual environment: training (v0.7+)
โ”œโ”€โ”€ .venv-pred/                     # Virtual environment: inference/Unsloth (v0.5+)
โ”œโ”€โ”€ data/                           # Datasets
โ”‚   โ”œโ”€โ”€ image_text_inspect_n10789/  # Master dataset (v0.3)
โ”‚   โ”‚   โ”œโ”€โ”€ Rank_c_image_text_n10789.xlsx  # 10,789 annotations
โ”‚   โ”‚   โ””โ”€โ”€ rank_c_images_n10789/   # Image files
โ”‚   โ”œโ”€โ”€ v03_fine_tuning/            # v0.3 prepared datasets โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ test_set_n800.csv       # Fixed test set
โ”‚   โ”‚   โ”œโ”€โ”€ train_1k.csv            # Training: 1k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_2k.csv            # Training: 2k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_3k.csv            # Training: 3k samples
โ”‚   โ”‚   โ”œโ”€โ”€ train_4k.csv            # Training: 4k samples
โ”‚   โ”‚   โ”œโ”€โ”€ dataset_preparation_report.md
โ”‚   โ”‚   โ”œโ”€โ”€ evaluations/            # Evaluation results (v0.5)
โ”‚   โ”‚   โ””โ”€โ”€ reports/                # Progressive training reports
โ”‚   โ”œโ”€โ”€ rebar_exposure_n254/        # v0.2 validation dataset
โ”‚   โ”‚   โ””โ”€โ”€ outputs/                # v0.2 outputs
โ”‚   โ””โ”€โ”€ preprocessed_640x480_n10789/  # Preprocessed images
โ”œโ”€โ”€ models/                         # Model files
โ”‚   โ”œโ”€โ”€ llava-v1.5-7b-Q5_K_M.gguf   # Base model (v0.2)
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_1k/         # v0.4.1 LoRA adapters โœ…
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_2k/         # v0.4.2 โœ… Recommended
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_3k/         # v0.4.3 โœ…
โ”‚   โ”œโ”€โ”€ llava_v03_qlora_4k/         # v0.4.4 โœ…
โ”‚   โ””โ”€โ”€ scoring_rules.yaml          # Rule-based scoring
โ”œโ”€โ”€ src/                            # Source code
โ”‚   โ”œโ”€โ”€ preprocessing/              # Image preprocessing
โ”‚   โ”‚   โ””โ”€โ”€ image_preprocessor.py
โ”‚   โ”œโ”€โ”€ vision/                     # Vision analysis (v0.1-v0.2)
โ”‚   โ”‚   โ”œโ”€โ”€ llama_cpp_vision.py     # llama-cpp-python
โ”‚   โ”‚   โ”œโ”€โ”€ gguf_vlm_analyzer.py    # GGUF wrapper
โ”‚   โ”‚   โ””โ”€โ”€ ollama_vision.py        # Ollama integration
โ”‚   โ”œโ”€โ”€ structuring/                # JSON structuring
โ”‚   โ”‚   โ””โ”€โ”€ json_structurer.py
โ”‚   โ”œโ”€โ”€ scoring/                    # Priority scoring
โ”‚   โ”‚   โ””โ”€โ”€ priority_scorer.py
โ”‚   โ”œโ”€โ”€ evaluation/                 # v0.5 evaluation โœ…
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ vector_similarity_evaluator.py
โ”‚   โ”œโ”€โ”€ pipeline/                   # Pipeline orchestration
โ”‚   โ”‚   โ””โ”€โ”€ end_to_end.py
โ”‚   โ””โ”€โ”€ utils/                      # Utilities
โ”‚       โ”œโ”€โ”€ config.py
โ”‚       โ””โ”€โ”€ ollama_client.py
โ”œโ”€โ”€ paper_damage_vlm/               # v0.6 Academic paper
โ”‚   โ”œโ”€โ”€ 0_Format_arXiv_pdfLaTex/
โ”‚   โ”‚   โ”œโ”€โ”€ bridge_damage_vlm_quantization_2026.tex
โ”‚   โ”‚   โ”œโ”€โ”€ bridge_damage_vlm_quantization_2026.bib
โ”‚   โ”‚   โ””โ”€โ”€ figures/
โ”‚   โ””โ”€โ”€ 1_Methodology/
โ”œโ”€โ”€ docs/                           # Documentation
โ”‚   โ”œโ”€โ”€ ARCHITECTURE.md
โ”‚   โ”œโ”€โ”€ GPU_SETUP.md
โ”‚   โ”œโ”€โ”€ VLM_COMPARISON_PLAN_v02.md
โ”‚   โ””โ”€โ”€ VLM_VALIDATION_REPORT_v02.md
โ”œโ”€โ”€ prepare_v03_dataset.py          # v0.3 dataset preparation โœ…
โ”œโ”€โ”€ train_v03_qlora.py              # v0.4 QLoRA training โœ…
โ”œโ”€โ”€ create_progressive_training_report.py  # v0.5 reporting โœ…
โ”œโ”€โ”€ config.yaml                     # Unified configuration โœ…
โ”œโ”€โ”€ SETUP_VENV_VLM.md               # v0.3 setup guide โœ…
โ”œโ”€โ”€ QUICKSTART_V03_V05.md           # v0.3-v0.5 workflow โœ…
โ”œโ”€โ”€ V03_V05_IMPLEMENTATION_SUMMARY.md  # Implementation summary โœ…
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ”œโ”€โ”€ README.md                       # This file (English)
โ”œโ”€โ”€ README_JP.md                    # Japanese documentation
โ”œโ”€โ”€ CHANGELOG.md                    # Version history
โ””โ”€โ”€ LICENSE                         # Apache License 2.0

Legend:

  • โœ… Implemented: Files/modules completed and tested
  • โณ Pending: Planned but not yet executed

Troubleshooting

Character Encoding Issues (Windows)

Symptom: Japanese characters appear garbled in PowerShell

Solution:

# Change to UTF-8
chcp 65001
python quickstart.py

CUDA Out of Memory

Symptom: CUDA out of memory error

Solution:

# config.yaml
llama_cpp_vision:
  n_gpu_layers: 20  # Reduce from -1 (all layers) to partial GPU

Ollama Connection Error

Symptom: Failed to connect to Ollama

Solution:

# Check Ollama server
ollama list

# Restart server
ollama serve

llama-cpp-python Installation Error

Symptom: Failed building wheel for llama-cpp-python

Solution:

# Install CUDA version explicitly
pip install llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124

# Or enable CUDA via environment variable
$env:CMAKE_ARGS="-DLLAMA_CUBLAS=on"
pip install llama-cpp-python --force-reinstall --no-cache-dir

Roadmap

โœ… Completed

v0.1 (2025-12)

  • โœ… End-to-end pipeline implementation
  • โœ… Three vision analysis modes (llama-cpp-python, HuggingFace, Ollama)
  • โœ… JSON structuring with Swallow-8B
  • โœ… Rule-based priority scoring
  • โœ… 10-image validation test (100% success rate)

v0.2 (2026-03)

  • โœ… LLaVA quantization comparison (Q4_K_M, Q5_K_M, Q8_0)
  • โœ… 254-image full dataset processing
  • โœ… 5-point quality scoring framework
  • โœ… Statistical analysis and visualization
  • โœ… Recommendation: Q5_K_M optimal for production

v0.3 (2026-05-22)

  • โœ… Dataset preparation pipeline (10,789 images)
  • โœ… Quality filtering (text length, keywords, patterns)
  • โœ… Stratified sampling (component ร— damage type)
  • โœ… Progressive training sets (1k/2k/3k/4k)
  • โœ… Fixed test set (800 images)
  • โœ… Comprehensive documentation (setup, quickstart, implementation summary)

v0.4 (2026-05-23)

  • โœ… Stage 1: Trained on 1k samples (1:22:57, val_loss=3.135)
  • โœ… Stage 2: Trained on 2k samples (2:55:37, val_loss=3.073)
  • โœ… Stage 3: Trained on 3k samples (4:31:44, val_loss=3.073)
  • โœ… Stage 4: Trained on 4k samples (6:19:10, val_loss=3.067)
  • โœ… Generated LoRA adapters for all 4 stages (134.5 MB each)
  • โœ… Identified optimal model: 2k samples (best cost-benefit)
  • โœ… Comprehensive training analysis report (Result_QLoRA_Scale.md)

v0.5.1 (2026-05-24)

  • โœ… Inference pipeline for all 4 fine-tuned models (inference_v051_qlora.py)
  • โœ… n=800 evaluation with Japanese Sentence-BERT cosine similarity
  • โœ… Inverted-U performance curve: 3k model peaks (mean=0.6909)
  • โœ… 4k overfitting confirmed (โˆ’2.5% from 3k)
  • โœ… 5 publication-quality visualization figures
  • โœ… Paper methodology section drafted (v0.5 results)

v0.6.3 (2026-05-25)

  • โœ… Two-stage Quality Guard Agent implemented (Rule-based + Swallow-8B SLM)
  • โœ… CJK-aware token counting (correct Japanese tokenization)
  • โœ… Empirical threshold calibration (ฮธ_low=98, ฮธ_high=202 at 5th/95th percentile)
  • โœ… Full n=800 evaluation: PASS=727 (90.9%), FAIL=73 (9.1%)
  • โœ… End-to-end throughput: 8.97 s/row (~2.0 h total)
  • โœ… Stage 2 (Swallow-8B) saturation finding: 0 additional rejections
  • โœ… Output mode collapse discovery: Main Girder 100%, Rebar Exposure 99.6%
  • โœ… Priority Level 3 saturation analysis (all 727 PASS โ†’ score=0.54)
  • โœ… 2 analysis figures generated (violin plots + member/damage heatmap)
  • โœ… Paper complete: 25 pages, 10 figures, all sections (pdflatex, no errors)

v0.7.1 (2026-05-26)

  • โœ… Image size optimization: confirmed 336px as optimal for LLaVA QLoRA
  • โœ… pairdata_v2 construction: noise-removed 2,969-sample corpus (inspect_images_336)
  • โœ… S.5 image-size analysis added to methodology_supp.tex

v0.7.2 (2026-05-27)

  • โœ… Full progressive QLoRA retraining on pairdata_v2 (1k/2k/3k/4k scales)
  • โœ… 3k model selected: peak mean cosine similarity (\u03c1=0.6013), lowest Very Poor rate (21.5%)
  • โœ… S.6 semantic similarity evaluation added to methodology_supp.tex
  • โœ… 3 evaluation figures generated (similarity by scale, tier distribution, cosine violin)

v0.7.3 (2026-05-28)

  • โœ… Quality Guard recalibrated: ฮธ_low 98โ†’30, ฮธ_high 202โ†’200
  • โœ… Keyword-based structuring (1s vs 2h Swallow-8B LLM)
  • โœ… Full pipeline (n=800): PASS=787 (98.4%), FAIL=13 (1.6%)
  • โœ… Scoring saturation resolved: Level 4โ€“5 = 97.3% (was 100% Level 3)
  • โœ… Output bias suppression confirmed via member/damage comparison
  • โœ… S.7, S.7.1, S.7.2 added to methodology_supp.tex (10 pages)
  • โœ… 5 new figures generated (Figure 15โ€“19)

v0.7.4 (2026-05-29)

  • โœ… 2048-dim composite embedding evaluator implemented (M1: 1024-dim + M2: 1024-dim)
  • โœ… Independent .venv-eval environment (CPU-only, separate from .venv-pred)
  • โœ… n=800 evaluation ร— 4 scales (1k/2k/3k/4k) completed
  • โœ… Optimal scale revised: 2k (mean ฯ=0.6950, median=0.7053, Good+=53.1%)
  • โœ… Very Poor rate dropped from โ‰ค32.9% (384-dim) to โ‰ˆ0.4% across all scales
  • โœ… S.6 fully rewritten with 2048-dim results + mathematical formulas in methodology_supp.tex
  • โœ… Figure 12/13/14 regenerated from 2048-dim JSON results
  • โœ… SETUP_ENV_EVAL.md created (.venv-eval setup guide)

v0.7.5 (2026-05-29)

  • โœ… 2k model established as primary pipeline variant (v0.7.5) based on v0.7.4 optimal-scale finding
  • โœ… Figure 19 generated: member & damage type comparison v0.7.3 (3k) vs v0.7.5 (2k)
  • โœ… Figure 20 generated: priority score violin for v0.6.3 / v0.7.3 / v0.7.5 (3-version comparison)
  • โœ… S.7.1 updated: model scale comparison paragraph (Cross Beam 98.3% in 2k; ฮผ=0.811/std=0.025 vs 3k ฮผ=0.838/std=0.070)
  • โœ… S.7.2 updated: Priority Score Distribution violin replaced (old Priority Level bar โ†’ new violin figure)
  • โœ… S.8 fully updated: 12-panel dual-model qualitative analysis (Predโ‚=v0.7.5 2k, Predโ‚‚=v0.7.3 3k)
  • โœ… GT/Predโ‚ and GT/Predโ‚‚ shared keywords bold-highlighted in all 12 panels
  • โœ… Image size reduced to 0.675\linewidth (ร—0.9 from 0.75) in all S.8 figures
  • โœ… methodology_supp.pdf: 17 pages, no errors (pdflatex)

v0.8 (2026-05-30)

  • โœ… pairdata_v3 denoising pipeline: 10,789 โ†’ 2,500-sample training corpus
  • โœ… LoRA rank ablation on pairdata_v3 (r=16/32/64, 2,500 samples each)
    • r=16: eval_loss=3.138, token_acc=98.73%, 3h24m
    • r=32: eval_loss=3.133, token_acc=98.83%, 5h36m
    • r=64: eval_loss=3.122, token_acc=98.90%, 3h27m (selected)
  • โœ… r=64 selected as optimal (168.8M params / 4.56% of backbone, no extra GPU cost)
  • โœ… Supplementary 2 (methodology_supp2.tex) fully documented: U.1โ€“U.8
  • โœ… Figure 21: LoRA rank ablation validation loss trajectories (pairdata_v3)
  • โœ… U.4 Analysis: adapter capacity argument (168M vs 42M/84M for domain specificity)

v0.8.1 (2026-05-30)

  • โœ… DoRA training (use_dora=True, r=64, alpha=128) on pairdata_v3 2,500 samples
  • โœ… DoRA eval_loss: 3.119 (best, epoch 2.421) โ€” โˆ’0.003 improvement over LoRA r=64 (3.122)
  • โœ… DoRA token_acc: 98.92% (best), 98.95% (final), train_loss=3.417, 6h51m
  • โœ… Research question (i) validated: DoRA achieves lower eval_loss at same rank/VRAM
  • โœ… U.8 in Supplementary 2 fully updated: Config (r=32โ†’r=64), Results table (TBDโ†’actual), Repro Commands
  • โœ… U.8 Motivation rewritten: r=64 basis, 3 research questions (val loss, cosine sim, hallucination)
  • โœ… methodology_supp2.pdf: 15 pages, no errors (pdflatex)

v0.8.2 (2026-05-31)

  • โœ… 2048-dim Sentence-BERT evaluation on all 4 adapters (n=800 test set)
  • โœ… DoRA r=64: highest embedding score (cosine 0.6846, Good+ 41.0%) but output-level mode collapse confirmed
  • โœ… Quality Guard + Priority Scoring: both models PASS 99.8%; DoRA all Level 4 (100%), LoRA r=32 L3/4/5 distributed
  • โœ… U.6.1 Structural Member & Damage Type analysis: DoRA stereotyped (Main Girder+Deck Slab 100%, 3 damage types 100%)
  • โœ… DoRA r=64 fine-tuning declared failed โ€” r=64 likely excessive; DoRA protocol left as future work
  • โœ… LoRA r=32 (v0.8) adopted as final pipeline model
  • โœ… Supplementary 2 updated: U.5 table+figures+analysis, U.6 2-model comparison, U.6.1 new subsection (Figure 28)
  • โœ… methodology_supp2.pdf: 21 pages

v0.8.3 (2026-05-31)

  • โœ… U.7 qualitative analysis section fully rebuilt on pairdata v3 (inference_r32.csv)
  • โœ… 12 representative PASS images re-selected with greedy member ร— damage diversity
  • โœ… Caption simplified to 3-item format: Quality Metrics / GT / Pred
  • โœ… Shared keyword highlighting added (CJK gothic font)
  • โœ… s8 folder replaced (figures_vlm/s8/s8_01โ€“s8_12)
  • โœ… methodology_supp2.pdf: 19 pages, no errors

v0.8.4 (2026-06-01)

  • โœ… DoRA r=16 full pipeline: train (eval_loss=3.138, 6h48m) โ†’ merge (85 shards) โ†’ inference (800 rows, 798 OK) โ†’ SBERT (mean=0.6717, Good+=36.0%) โ†’ pipeline (PASS=99.6%, L3:61/L4:705/L5:31)
  • โœ… 3-way rank ablation confirmed: LoRA r=32 vs. DoRA r=32 vs. DoRA r=16
  • โœ… Key finding: DoRA r=64 mode collapse (all Level 4); DoRA r=16 most balanced priority distribution
  • โœ… Figure 41: validation loss trajectories for 3-way ablation (added to U.7.1)
  • โœ… Figures 35โ€“40: 6-panel 3-way comparison (generated by create_u72_dora_ablation.py)
  • โœ… U.7.2 replaced: title โ†’ โ€œDoRA Rank Ablation Studies: LoRA r=32 vs. DoRA r=32/16โ€
  • โœ… U.7.2 Discussion added: gradient collapse analysis, r=16 equitable output, DoRA r=24 proposed
  • โœ… methodology_supp2.pdf: 5648 KB, no errors

v0.8.5 (2026-06-02)

  • โœ… DoRA r=24 full pipeline: train (eval_loss=3.137, ~6h50m) โ†’ merge โ†’ inference (800 rows, 798 OK)
  • โœ… SBERT: mean=0.6791, std=0.0635, median=0.6834, Good+=37.8% โ€” best among all 7 adapters tested
  • โœ… Quality Guard + Priority: PASS=798 (99.8%), L3=48/L4=674/L5=78, token_mean=90.6
  • โœ… DoRA r=24 selected as v1.0.0 final model (peak SBERT + balanced L3/4/5 distribution)
  • โœ… Figure 15 updated: โ€œfour modelsโ€; DoRA r=24 (eval_loss=3.137) added as 4th validation loss curve
  • โœ… Figures 35โ€“40: regenerated as 4-way comparison (LoRA r=32, DoRA r=32/16/24)
  • โœ… U.7.2 Discussion extended to 6 paragraphs: rankโ€“quality relationship + figure-level evidence + final model selection
  • โœ… U.7.3 added: Qualitative Analysis: Finetuned Model Predictions DoRA r=24 (12 panels)
  • โœ… methodology_supp2.pdf: rebuilt, no errors

๐Ÿ”ฎ Future Work

v1.0.0 (2026-06-03) ๐ŸŽ‰ Latest Release โ€” Full Dataset Inference

  • โœ… Full inference completed: 10,903 rows, DoRA r=24, batch_size=4, 10.55 h (3.5 s/image)
  • โœ… Quality Guard PASS=10,668 (97.8%), FAIL=0 (0.0%), MISSING=235 (2.2%)
  • โœ… Priority: L3=454 (4.3%) / L4=9,185 (86.1%) / L5=1,029 (9.6%)
  • โœ… Output: data/v10_full/v10_full_r24_dora.xlsx (10,903 rows)
  • โœ… Member x damage figure: create_figures_u74.py -> figures_vlm/u74_member_damage_analysis.png
  • โœ… U.7.4 added to Supplementary 2: inference config, results table, figure, discussion
  • โœ… methodology_supp2.pdf: rebuilt, no errors

v1.1 (2026 Q3) - Production Deployment

  • Web UI (Streamlit/Gradio)
  • REST API server (FastAPI)
  • Docker containerization
  • CI/CD pipeline
  • Comprehensive unit tests
  • Performance benchmarking

Research Extensions

  • Balanced training corpus to address output mode collapse
  • Constrained-generation prompts (per-member damage reporting)
  • Priority scoring recalibration with explicit severity keywords
  • Multi-damage type support (crack detection, leakage, scaling)
  • Active learning for annotation efficiency
  • Multi-language support (Japanese โ†” English)
  • Real-time video analysis
  • Integration with bridge inspection databases
  • Explainable AI (attention visualization, saliency maps)
  • Alternative VLMs (Qwen2-VL, InternVL2, GPT-4V)

Citation

If you use this project in your research, please cite:

@software{bridge_damage_assessment_2026,
  title = {Bridge Damage Assessment and Repair Priority Scoring System},
  author = {Your Name},
  year = {2026},
  version = {0.1.0},
  url = {https://github.com/your-username/damage_text_score}
}

References

  1. Liu et al. (2023). "Visual Instruction Tuning" - LLaVA [arXiv:2304.08485]
  2. TokyoTech LLM Project - Swallow Models [GitHub]
  3. Georgi Gerganov - llama.cpp [GitHub]

License

Apache License 2.0 - See LICENSE for details



๐Ÿ“ˆ v0.7.3: Quality Guard Recalibration & Full Pipeline

Status: โœ… Complete

Completion Date: 2026-05-28
Scope: Quality Guard recalibration + keyword structuring pipeline on 3k pairdata_v2 model (n=800)

What Was Completed

  • Quality Guard recalibration: ฮธ_low 98 โ†’ 30 (captures only ERROR outputs); ฮธ_high 202 โ†’ 200
    • Old threshold rejected all valid short descriptions produced by the pairdata_v2 model
    • New threshold retains all structurally valid predictions
  • Keyword-based structuring: Replaced 2-hour Swallow-8B LLM with 1-second keyword matching
  • Full pipeline run (pipeline_v073.py): n=800 in < 2 seconds
  • Output mode collapse resolved: pairdata_v2 noise removal suppressed hallucinated co-occurrence patterns

Pipeline Results (n=800)

VerdictCountRate
PASS โ€” High Quality78798.4%
FAIL โ€” Error / Too short131.6%

Priority Level Distribution (PASS n=787)

LevelDescriptionCountRate
3Planned maintenance212.7%
4Priority repair65182.7%
5Immediate repair11514.6%

Contrast with v0.6.3 where 100% of PASS samples scored Level 3 (scoring saturation at 0.54).

Key Findings

  • Scoring saturation resolved: Level 4โ€“5 now accounts for 97.3% of PASS predictions
  • Bias suppression: Lime Efflorescence dropped 49.0% โ†’ 13.3%; Curb emerged as secondary member (92.5%)
  • PASS rate: 98.4% vs. 90.9% in v0.6.3 (quality improvement from pairdata_v2 denoising)
  • Throughput: Full 800-image pipeline in < 2 seconds

Figures Generated

FigureFileDescription
1515_v073_token_distribution.pngToken count with recalibrated thresholds
1616_v073_guard_breakdown.pngPASS/FAIL verdict breakdown
1717_v073_priority_distribution.pngPriority level distribution
1818_member_damage_comparison.pngMember ร— Damage comparison (v0.6.3 vs v0.7.3)
1919_priority_comparison.pngPriority level comparison (v0.6.3 vs v0.7.3)

Repro Commands

.\.venv-pred\Scripts\Activate.ps1
python pipeline_v073.py

Paper Artifacts Updated

  • methodology_supp.tex โ€” S.7 Quality Guard Recalibration
  • methodology_supp.tex โ€” S.7.1 Member & Damage Type comparison
  • methodology_supp.tex โ€” S.7.2 Priority Level comparison
  • methodology_supp.pdf โ€” 10 pages, no errors

Last Updated: May 29, 2026 (v0.7.3 โ€” Quality Guard recalibration, full pipeline, scoring saturation resolved)


๐Ÿ”ข v0.7.4: 2048-Dimensional Composite Embedding Evaluation

Status: โœ… Complete โ€” ๐ŸŽ‰ Latest Release

Completion Date: 2026-05-29
Scope: Extended semantic similarity evaluation using a 2,048-dimensional composite embedding (n=800 test set ร— 4 scales)

Overview

v0.7.4 replaces the 384-dimensional single-model evaluator (paraphrase-multilingual-MiniLM-L12-v2) with a 2,048-dimensional composite embedding formed by combining two complementary Japanese-capable sentence encoders. This yields substantially higher and more discriminative cosine similarity scores and revises the optimal training scale from 3k to 2k.

Composite Evaluator Architecture

ComponentModelDimensionsProperties
M1hotchpotch/static-embedding-japanese1,024Static EmbeddingBag, CPU-native, Japanese-specialised
M2intfloat/multilingual-e5-large1,024Transformer encoder, 100+ languages, STS prefix "query: "
CombinedL2-normalise โ†’ concat โ†’ re-normalise2,048Arithmetic mean of per-model cosine similarities

Mathematical Formulation

Given ground-truth text $t^{gt}$ and prediction $t^{pred}$:

  1. Each encoder produces an $L_2$-normalised embedding:
    • $\mathbf{e}1(t) = f{M1}(t) / |f_{M1}(t)|$
    • $\mathbf{e}2(t) = f{M2}(\text{"query: "} | t) / |f_{M2}(\cdot)|$
  2. Concatenate and re-normalise (each half has unit norm, so denominator is $\sqrt{2}$):
    • $\mathbf{e}(t) = [\mathbf{e}_1; \mathbf{e}_2] / \sqrt{2}$
  3. Cosine similarity reduces to the arithmetic mean of the two per-model similarities:
    • $\rho_{2048} = \mathbf{e}^{gt} \cdot \mathbf{e}^{pred} = (\rho_1 + \rho_2) / 2$

Evaluation Results (2048-dim)

Test set: n=800 (pairdata-v2 ground truth), CPU inference
Tier thresholds: Excellent โ‰ฅ 0.85 ยท Good โ‰ฅ 0.70 ยท Acceptable โ‰ฅ 0.55 ยท Poor โ‰ฅ 0.40 ยท Very Poor < 0.40

ScaleMean ฯฯƒMedianGood+ (%)V.Poor (%)
1k0.67250.07060.674937.80.4
2k โœ…0.69500.08240.705353.10.4
3k0.67670.07510.679937.80.4
4k0.67490.07420.680338.40.4

Comparison: 384-dim vs 2048-dim Evaluators

Scale384-dim MiniLM2048-dim Compositeฮ”
1k0.56570.6725+18.9%
2k0.60110.6950+15.6%
3k0.60130.6767+12.5%
4k0.57420.6749+17.5%

Very Poor rate: 384-dim was 21.5โ€“32.9%; 2048-dim is uniformly โ‰ˆ0.4%.

Key Findings

  1. Optimal scale revised to 2k: 2k achieves mean ฯ=0.6950 and median=0.7053 (above Good threshold), with 53.1% Good+ โ€” significantly better than 3k/4k.
  2. Overfitting pattern confirmed: 2k peaks, then 3k/4k both regress, consistent with pairdata-v2 diminishing-returns pattern found in token-accuracy analysis.
  3. Very Poor near-elimination: 2048-dim composite scores are far more discriminative; catastrophic mismatch cases detected by 384-dim (VPoor โ‰ค32.9%) essentially disappear (โ‰ˆ0.4%).
  4. Good+ majority at 2k: 53.1% of 2k predictions reach the Good+ tier, reflecting M2โ€™s stronger multilingual semantic understanding.

Figures Updated

FigureFileDescription
Fig. 12figures_vlm/12_v072_similarity_by_scale.pngMean/median ฯ by scale; red dashed = 384-dim baseline
Fig. 13figures_vlm/13_v072_tier_distribution.pngQuality-tier stacked bar chart (2048-dim results)
Fig. 14figures_vlm/14_v072_cosine_violin.pngCosine similarity violin plots (2048-dim results)

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” S.6 fully rewritten: evaluator description, Table with 2048-dim values, Key findings (2k peak), Figure 12/13/14 captions, Model selection (3k โ†’ 2k), Extended Evaluation subsubsection with three mathematical formulas
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf โ€” 14 pages, recompiled (no errors)

New Files

FilePurpose
evaluate_2048dim.py2048-dim composite embedding evaluation script
create_figures_v072_2048dim.pyFigure 12/13/14 generator from 2048-dim JSON results
SETUP_ENV_EVAL.md.venv-eval environment setup guide

Repro Commands

# 1. Create evaluation environment (CPU-only, independent of .venv-pred)
python -m venv .venv-eval
.venv-eval\Scripts\pip.exe install "torch==2.6.0+cpu" --index-url https://download.pytorch.org/whl/cpu
.venv-eval\Scripts\pip.exe install "sentence-transformers==3.3.1" numpy pandas scikit-learn matplotlib seaborn

# 2. Run evaluation (n=800 x 4 scales, ~26 min total on CPU)
.venv-eval\Scripts\python.exe evaluate_2048dim.py

# 3. Regenerate Figure 12/13/14
.venv-eval\Scripts\python.exe create_figures_v072_2048dim.py

Output JSON files: data/v07_fine_tuning/evaluations_2048dim/evaluation_2048dim_{1k,2k,3k,4k}.json


๐Ÿ“Š v0.7.5: 2k Pipeline Evaluation & Supplementary Paper Update

Status: โœ… Complete

Last Updated: May 29, 2026
Scope: 2k model established as primary pipeline; cross-model comparison figures; full S.7โ€“S.8 supplementary paper update

Overview

Building on the v0.7.4 finding that the 2k model is optimal (mean ฯ=0.6950, Good+=53.1%), v0.7.5 designates the 2k QLoRA pipeline as the primary production variant and adds cross-model comparative analysis to the supplementary paper.

Key Deliverables

Figure 19: Member & Damage Type Comparison (v0.7.3 vs v0.7.5)

figures_vlm/19_member_damage_v073_v075.png

Side-by-side frequency bars and co-occurrence heatmaps comparing the 3k model (v0.7.3) against the 2k model (v0.7.5).

Notable finding โ€” Cross Beam saturation in 2k:

Memberv0.7.3 (3k)v0.7.5 (2k)
Main Girder~100.0%~100.0%
Cross Beam~40%98.3%
Rebar Exposure~99%~99%

The 2k model systematically appends cross beam descriptors in 98.3% of all predictions, reflecting template-driven vocabulary learned from the smaller training corpus.

Figure 20: Priority Score Violin โ€” 3-Version Comparison

figures_vlm/20_priority_score_violin.png

Violin plots comparing priority score distributions across all three pipeline versions:

VersionModelMeanStdLevel 4โ€“5
v0.6.3pairdata-v1 3k0.54 (point mass)0.0000%
v0.7.3pairdata-v2 3k0.8380.07097.3%
v0.7.5pairdata-v2 2k0.8110.025~97%

Interpretation: v0.6.3 collapses to a single value (mode-collapsed outputs). Both v0.7.x models restore discriminability; v0.7.5 (2k) shows a tighter, more predictable Level-4 cluster (std=0.025) while v0.7.3 (3k) reaches higher scores with greater variance (std=0.070), reflecting its longer training.

S.8 Qualitative Analysis โ€” Dual-Model Comparison (12 Panels)

paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” Section S.8

All 12 representative PASS panels updated to display three rows per image:

RowSourceNotes
GTOriginal inspection recordTerms shared with Predโ‚ and Predโ‚‚ both bold
Predโ‚ (2k)v0.7.5 pipeline outputTerms shared with GT bold
Predโ‚‚ (3k)v0.7.3 pipeline outputTerms shared with GT bold

Additional formatting changes applied to all 12 panels:

  • Sim(emb) values reflect the 2k model (Predโ‚)
  • Image size reduced to 0.675\linewidth (ร—0.9 from 0.75)
  • Caption: "GT/Pred$_1$ shared terms bold in Pred$_1$; GT/Pred$_2$ shared terms bold in Pred$_2$"

Cosine Similarity (Sim(emb)) โ€” 12 Selected Panels

#Sim(emb) 2k (Predโ‚)Sim(emb) 3k (Predโ‚‚)ฮ”
010.5520.394+0.158
020.4180.400+0.018
030.6580.668โˆ’0.010
040.4410.397+0.044
050.5370.504+0.033
060.6430.622+0.021
070.5930.592+0.001
080.7000.685+0.015
090.5550.489+0.066
100.7700.756+0.014
110.7980.783+0.015
120.6560.722โˆ’0.066

The 2k model achieves higher Sim(emb) in 9 of 12 panels; the 3k model leads in 3 (panels 03, 07, 12).

Scripts

FilePurpose
create_figures_v075_s71_s72.pyGenerates Figure 19 (member/damage comparison) and Figure 20 (priority score violin)

Paper Artifacts Updated

  • paper_damage_vlm/1_Methodology/methodology_supp.tex โ€” S.7.1, S.7.2, S.8 fully updated
  • paper_damage_vlm/1_Methodology/methodology_supp.pdf โ€” 17 pages, no errors (pdflatex)

Repro Commands

# Generate Figure 19 and Figure 20
.venv-eval\Scripts\python.exe create_figures_v075_s71_s72.py

# Recompile supplementary PDF
cd paper_damage_vlm\1_Methodology
pdflatex -interaction=nonstopmode methodology_supp.tex

Last Updated: June 1, 2026 (v0.8.4 โ€” DoRA rank ablation r=16/32 full pipeline complete; DoRA r=16 achieves best Good+ rate 36.0% and most balanced priority distribution; U.7.2 updated with 3-way comparison Figures 35โ€“41; DoRA r=24 proposed as next experiment)

automated-diagnostics
bridge-damage-detection
civil-engineering-ai
damage-severity-assessment
image-to-text
infrastructure-inspection
llava
repair-prioritization
structural-health-monitoring
vision-language-models