yasunotkt/damage-cause-encoder-v05
Bridge Damage Cause Encoder v0.5 (QLoRA)
橋梁損傷原因分類のための日本語BERTベースのQLoRAモデル
このモデルは、橋梁の損傷記述から原因を10カテゴリに分類する深層学習モデルです。RC床版、コンクリート桁橋、床版橋の診断ロジックPDFから抽出した因果トリプル(Si → Ci)を活用し、4-bit量子化LoRA(QLoRA)で効率的にファインチューニングされています。
モデル概要
性能指標
比較(v0.5実験結果):
- LoRA (FP16): Test 87.07%, Diverse 34.0%, 1.45 GB GPU
- QLoRA (4-bit): Test 87.07%, Diverse 47.0% ⭐, 0.40 GB GPU (-72%)
- QA-LoRA: Test 85.34%, Diverse 30.0%, 0.42 GB GPU
→ QLoRAが最善: 同等のテスト精度で、未見パターンへの汎化が13%向上、GPU使用量72%削減
損傷原因カテゴリ(10クラス)
使用方法
必要なライブラリ
pip install transformers peft torch bitsandbytes sentence-transformers faiss-cpu推論コード
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from peft import PeftModel, PeftConfig
# モデルとトークナイザーのロード
model_id = "yasunotkt/damage-cause-encoder-v05"
config = PeftConfig.from_pretrained(model_id)
base_model = AutoModelForSequenceClassification.from_pretrained(
config.base_model_name_or_path,
num_labels=10,
device_map="auto"
)
model = PeftModel.from_pretrained(base_model, model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# 推論
def predict_damage_cause(damage_description, context=""):
"""
損傷記述から原因を予測
Args:
damage_description: 損傷の記述(Si)
context: 関連する因果知識(Ci)。オプション。
Returns:
予測ラベルID、ラベル名、確率
"""
labels = ["塩害", "凍害", "土砂化", "疲労", "鉄筋腐食", "ASR",
"ボイド管浮き陥没", "滞水", "連結桁", "その他"]
# 入力テキストの作成
text = damage_description
if context:
text = f"{damage_description} {tokenizer.sep_token} {context}"
# トークナイズと推論
inputs = tokenizer(text, return_tensors="pt", max_length=512,
truncation=True, padding=True).to(model.device)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
pred_id = torch.argmax(probs, dim=1).item()
confidence = probs[0][pred_id].item()
return pred_id, labels[pred_id], confidence
# 使用例
damage_text = "床版下面に遊離石灰が白く析出し、鉄筋位置に沿って縦方向のひびわれが確認される"
pred_id, cause, conf = predict_damage_cause(damage_text)
print(f"予測原因: {cause} (ID: {pred_id})")
print(f"確信度: {conf:.2%}")FAISSを使った文脈取得付き推論
完全な推論パイプライン(FAISS triple index + LLM filter + QLoRA)については、プロジェクトリポジトリをご覧ください: https://github.com/tk-yasuno/damagecauseencoder
トレーニング詳細
データセット
- ソース: 35 PDF files(RC床版、コンクリート桁橋、床版橋の診断ロジック)
- 抽出トリプル: 6,745件(テキスト + 図表)
- トレーニングサンプル: 342件
- 検証サンプル: 115件
- テストセット(Golden): 116件(15 PDFから手動作成)
ハイパーパラメータ
base_model: cl-tohoku/bert-large-japanese-v2
quantization: 4-bit NF4 + double quantization
lora_r: 16
lora_alpha: 32
lora_dropout: 0.1
target_modules: [query, key, value, dense]
learning_rate: 2e-4
batch_size: 4
gradient_accumulation_steps: 8
epochs: 20
max_length: 512
optimizer: AdamW
loss_function: Weighted CrossEntropy (inverse frequency)トレーニング環境
- GPU: NVIDIA RTX 4060 Ti 16GB
- CUDA: 12.6
- メモリ使用量: 0.40 GB (QLoRA)
- トレーニング時間: ~10分(20 epochs)
- フレームワーク: PyTorch 2.6.0, Transformers, PEFT, BitsAndBytes
アルゴリズムパイプライン
1. PDFからOCR抽出(PaddleOCR + pypdfium2)
↓
2. 因果トリプル抽出(Qwen2.5 7B)
↓
3. FAISS dense retrieval(hotchpotch/static-embedding-japanese)
↓
4. LLM relevance filter(Qwen2.5 7B)
↓
5. QLoRA分類器(本モデル)
↓
6. 損傷原因(10クラス)制限事項と今後の展望
制限事項
- 日本語専用 - 橋梁診断の専門用語に特化
- 限定的なドメイン - RC床版、コンクリート桁橋、床版橋のみ
- 小規模データセット - 35 PDF、~400サンプル
- クラス不均衡 - 「塩害」が支配的(バランシング済み)
- 文脈依存 - 最適性能にはFAISSによる文脈取得が必要
v1.0での改善予定
- マルチモーダル融合(Vision Encoder + Text Encoder)
- ハイブリッド検索(BM25 + Dense + Reranker)
- より大規模なデータセット(100+ PDFs)
- テストセットによる厳密な評価(70/15/15 split)
引用
このモデルを研究で使用する場合は、以下を引用してください:
@software{damage_cause_encoder_v05,
title = {Damage Cause Encoder: Deep Learning for Bridge Damage Classification with QLoRA},
author = {Damage Cause Encoder Project Team},
year = {2026},
version = {0.5},
url = {https://github.com/tk-yasuno/damage_cause_encoder},
note = {QLoRA achieves 87.07\% test accuracy with 72\% GPU memory reduction}
}関連リンク
- GitHub: https://github.com/tk-yasuno/damagecauseencoder
- 詳細ドキュメント: LESSON_v05_LoRA_Comparison.md
- 実験レポート: RESULT_15pdf_10class_n428.md
謝辞
- ベースモデル: cl-tohoku/bert-large-japanese-v2 by Tohoku NLP Group
- PEFT/LoRA: Hugging Face PEFT library
- QLoRA: Tim Dettmers et al., arXiv:2305.14314
開発者: Damage Cause Encoder Project Team 最終更新: 2026-07-25 バージョン: v0.5 連絡先: GitHub Issues
Speeds, Sizes, Times [optional]
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
[More Information Needed]
Evaluation
<!-- This section describes the evaluation protocols and provides the results. -->
Testing Data, Factors & Metrics
Testing Data
<!-- This should link to a Dataset Card if possible. -->
[More Information Needed]
Factors
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
[More Information Needed]
Metrics
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
<!-- Relevant interpretability work for the model goes here -->
[More Information Needed]
Environmental Impact
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Framework versions
- PEFT 0.19.1
