LLM 추론을 위한 Temporal Logic 기반 Confidence Calibration
Confidence over Time: Confidence Calibration with Temporal Logic for Large Language Model Reasoning
TL;DR Highlight
LLM이 추론하는 동안 단계별로 확신이 어떻게 변하는지를 시간 흐름으로 분석해, 기존보다 훨씬 정확하게 '이 답이 틀릴 것 같다'를 예측하는 방법
Who Should Read
LLM 기반 서비스에서 hallucination 감지나 답변 신뢰도 점수를 다루는 ML 엔지니어 또는 연구자. 특히 수학·과학 추론 파이프라인에서 모델 출력의 신뢰성을 높이거나 재생성 여부를 판단하는 로직을 만들고 싶은 개발자.
Core Mechanics
- LLM confidence를 하나의 숫자로 뭉개지 말고, 추론 단계별 시계열 신호로 봐야 한다는 아이디어 — 기존 방법들은 응답 길이나 문체에 영향받아 miscalibration이 심함
- Signal Temporal Logic(STL)으로 '올바른 답변의 confidence 흐름 패턴'과 '틀린 답변의 패턴'을 데이터에서 자동 발굴 — 예: 중간에 급락(SharpDrop)하거나 마지막에 낮아지면(EndLow) 위험 신호
- 틀린 답변의 STL 패턴은 태스크가 달라져도 재사용 가능 (Qwen3-8B 기준 Jaccard 유사도 0.811), 반면 맞는 답변 패턴은 태스크별로 크게 달라짐 — 실패 패턴이 성공 패턴보다 더 보편적
- 같은 STL 구조여도 질문마다 최적 파라미터(임계값 등)가 크게 달라서, 질문을 입력받아 STL 파라미터를 예측하는 hypernetwork(소형 보조 네트워크)를 붙여야 최상의 성능
- Qwen3-8B, Gemma-3-12B, Llama-3-8B 3개 모델 × 4개 벤치마크에서 기존 self-consistency, SAR, Self-Eval 등을 ECE·Brier Score 기준으로 전반적으로 앞섬
- 추론 시간 평균 0.55초/예시로, 여러 번 샘플링하는 self-consistency 방식보다 훨씬 빠르면서 단일 샘플로 더 좋은 calibration 달성
Evidence
- 틀린 답변 STL 패턴의 태스크 간 Jaccard 유사도: Qwen3 0.811, Gemma3 0.789, Llama 0.744 — 맞는 답변 패턴(0.47~0.55)보다 훨씬 높아 범용 재사용 가능
- CLadder 벤치마크에서 Qwen3 기준 ECE: AveLogit 0.200 → Ours 0.035, Self-Consistency 0.223 → Ours 0.035로 약 6배 개선
- BBH 벤치마크에서 Qwen3 기준 ECE: AveLogit 0.339 → Ours 0.052, Self-Eval 0.197 → Ours 0.052
- STL 템플릿 수 실험: 10개(5+ 5-)일 때 ECE 0.020, AUROC 0.617로 최적 — 너무 적거나 많으면 성능 하락
How to Apply
- Chain-of-Thought 응답을 문장/단계 단위로 나눠 각 구간의 평균 토큰 확률을 confidence 시계열로 만든 뒤, SharpDrop(급락)·EndLow(마지막 단계 낮음)·Recovery(떨어졌다 올라오는 패턴) 중 하나라도 해당하면 해당 답변에 낮은 신뢰도 플래그를 달거나 재생성을 트리거
- 틀린 답변의 STL 패턴은 태스크 전반에 재사용 가능하므로, BBH 같은 공개 데이터셋으로 미리 마이닝한 negative STL 패턴들을 다른 도메인 서비스에 confidence filter로 그대로 이식 가능
- 오픈소스 LLM(Qwen3-8B, Llama-3-8B 등)의 logprobs를 추출해 STL 블록에 넣는 경량 confidence scorer를 RAG 파이프라인의 답변 검증 레이어나 에이전트의 자기 검토 단계에 추가해 hallucination 위험 답변을 사전 필터링
Code Example
import numpy as np
def extract_step_confidence(token_probs: list[float], step_boundaries: list[tuple]) -> np.ndarray:
"""각 추론 단계의 평균 토큰 확률 → confidence 시계열"""
step_conf = []
for start, end in step_boundaries:
chunk = [p for p in token_probs[start:end] if p > 0]
step_conf.append(np.mean(chunk) if chunk else 0.0)
return np.array(step_conf)
def stl_end_low(signal: np.ndarray, k: int = 2, mu: float = 0.7) -> float:
"""EndLow 패턴: 마지막 k 스텝이 mu 이하 (음수면 위반, 양수면 위험 감지)"""
last_k = signal[-k:]
return float(np.min(mu - last_k)) # > 0 이면 EndLow 패턴 감지
def stl_sharp_drop(signal: np.ndarray, epsilon: float = 0.1) -> float:
"""SharpDrop 패턴: epsilon 이상 급락 발생 (양수면 감지)"""
diffs = np.diff(signal)
return float(np.max(-diffs - epsilon)) # > 0 이면 SharpDrop 감지
def is_likely_incorrect(token_probs, step_boundaries, mu=0.7, epsilon=0.1) -> bool:
signal = extract_step_confidence(token_probs, step_boundaries)
end_low_score = stl_end_low(signal, k=2, mu=mu)
sharp_drop_score = stl_sharp_drop(signal, epsilon=epsilon)
return end_low_score > 0 or sharp_drop_score > 0
# 사용 예시 (CoT 3단계 응답의 토큰 확률)
token_probs = [0.92, 0.88, 0.91, 0.85, 0.60, 0.55, 0.52]
step_boundaries = [(0, 2), (2, 4), (4, 7)] # 단계별 토큰 인덱스 범위
signal = extract_step_confidence(token_probs, step_boundaries)
print(f"Step confidence: {signal}") # [0.90, 0.88, 0.556]
print(f"SharpDrop: {stl_sharp_drop(signal):.3f}") # > 0 → 급락 감지
print(f"EndLow: {stl_end_low(signal):.3f}") # > 0 → 마지막 낮음
print(f"재생성 필요: {is_likely_incorrect(token_probs, step_boundaries)}") # TrueTerminology
Original Abstract (Expand)
Large Language Models (LLMs) increasingly rely on long-form, multi-step reasoning to solve complex tasks such as mathematical problem solving and scientific question answering. Despite strong performance, existing confidence estimation methods typically reduce an entire reasoning process to a single scalar score, ignoring how confidence evolves throughout the generation. As a result, these methods are often sensitive to superficial factors such as response length or verbosity, and struggle to distinguish correct reasoning from confidently stated errors. We propose to characterize the stepwise confidence signal using Signal Temporal Logic (STL). Using a discriminative STL mining procedure, we discover temporal formulas that distinguish confidence signals of correct and incorrect responses. Our analysis found that the STL patterns generalize across tasks, and numeric parameters exhibit sensitivity to individual questions. Based on these insights, we develop a confidence estimation approach that informs STL blocks with parameter hypernetworks. Experiments on multiple reasoning tasks show our confidence scores are more calibrated than the baselines.