콘텐츠로 이동
Data Prep
상세

Test-Time Compute Scaling

메타 정보

항목 내용
핵심 논문 Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters
저자 Charlie Snell, Jaehoon Lee, Kelvin Xu, Aviral Kumar (DeepMind, UC Berkeley)
학회 ICLR 2025 (Oral)
arXiv 2408.03314
관련 논문 Inference Scaling Laws (arXiv:2408.00724)
분야 LLM Reasoning, Inference Optimization, Scaling Laws

1. 핵심 아이디어

Test-Time Compute Scaling (TTS)은 모델 파라미터를 늘리는 대신 추론 시점에 더 많은 연산을 투입하여 성능을 향상시키는 패러다임이다. OpenAI o1, o3 같은 reasoning 모델의 핵심 원리.

기존 스케일링 vs Test-Time 스케일링

┌────────────────────────────────────────────────────────────────┐
│            Scaling Paradigm Comparison                         │
├────────────────────────────────────────────────────────────────┤
│                                                                │
│  [Traditional Scaling]                                         │
│                                                                │
│    Training Compute ↑  -->  Model Size ↑  -->  Performance ↑   │
│         (FLOPS)           (Parameters)         (Accuracy)      │
│                                                                │
│    한계: pre-training 비용 기하급수적 증가                      │
│          (GPT-4: ~$100M 추정)                                  │
│                                                                │
├────────────────────────────────────────────────────────────────┤
│                                                                │
│  [Test-Time Scaling]                                           │
│                                                                │
│    Fixed Model  +  Inference Compute ↑  -->  Performance ↑     │
│    (Pretrained)        (per query)            (Accuracy)       │
│                                                                │
│    장점: 쿼리별 적응적 연산 할당 가능                           │
│          어려운 문제에만 더 많은 compute 투입                   │
│                                                                │
└────────────────────────────────────────────────────────────────┘

2. Test-Time Scaling 메커니즘

2.1 두 가지 주요 접근법

접근법 설명 예시
Search-based Verifier 모델로 다수 후보 평가 후 최선 선택 Best-of-N, MCTS, Beam Search
Revision-based 프롬프트에 맞게 출력 분포를 반복 수정 Self-Refinement, Sequential Revisions

2.2 Search-based 방법

┌─────────────────────────────────────────────────────────────────┐
│               Search-based Test-Time Scaling                    │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  [Input Prompt]                                                 │
│       │                                                         │
│       ▼                                                         │
│  ┌─────────┐     ┌─────────┐     ┌─────────┐                   │
│  │Response1│     │Response2│     │Response3│  ... N responses   │
│  └────┬────┘     └────┬────┘     └────┬────┘                   │
│       │               │               │                         │
│       ▼               ▼               ▼                         │
│  ┌─────────────────────────────────────────┐                   │
│  │         Process Reward Model (PRM)       │                   │
│  │  - 각 reasoning step에 점수 부여         │                   │
│  │  - dense supervision signal 제공         │                   │
│  └─────────────────────┬───────────────────┘                   │
│                        │                                        │
│                        ▼                                        │
│              [Best Response Selection]                          │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Best-of-N Sampling

가장 단순한 형태. N개 응답 생성 후 verifier로 최선 선택:

def best_of_n(model, verifier, prompt, n=64):
    """Best-of-N sampling with verifier scoring"""
    responses = []
    scores = []

    for _ in range(n):
        # 다양한 응답 생성 (temperature > 0)
        response = model.generate(prompt, temperature=0.7)
        responses.append(response)

        # Verifier로 품질 평가
        score = verifier.score(prompt, response)
        scores.append(score)

    # 최고 점수 응답 반환
    best_idx = np.argmax(scores)
    return responses[best_idx]

Process Reward Model (PRM)

Outcome Reward Model (ORM)과 달리, 중간 단계별로 점수를 부여:

문제: "234 + 567 = ?"

[Step 1] "먼저 일의 자리를 더합니다: 4 + 7 = 11"
         PRM Score: 0.95 (correct)

[Step 2] "받아올림 1을 기억하고, 십의 자리: 3 + 6 + 1 = 10"
         PRM Score: 0.92 (correct)

[Step 3] "받아올림 1, 백의 자리: 2 + 5 + 1 = 8"
         PRM Score: 0.94 (correct)

[Step 4] "따라서 답은 801입니다."
         PRM Score: 0.98 (correct final answer)

PRM은 어느 단계에서 틀렸는지 localize 가능 → search tree pruning에 효과적.

2.3 Tree Search 방법

┌─────────────────────────────────────────────────────────────────┐
│                  Beam Search with PRM                           │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  [Prompt]                                                       │
│     │                                                           │
│     ▼                                                           │
│  Step 1: ─┬─ "Let's solve step by step..." (0.92)              │
│           ├─ "The answer is 42" (0.31) [pruned]                │
│           └─ "First, we need to..." (0.89)                     │
│                    │                                            │
│     ▼──────────────┘                                            │
│  Step 2: ─┬─ "...calculate the derivative" (0.88)              │
│           ├─ "...find the integral" (0.85)                     │
│           └─ "...apply L'Hopital" (0.91) [selected]            │
│                    │                                            │
│     ▼──────────────┘                                            │
│  Step 3: ─┬─ "Taking the limit..." (0.94)                      │
│           └─ "Therefore the answer is..." (0.96) [final]       │
│                                                                 │
│  Beam Width = 2, 각 단계에서 상위 k개만 유지                    │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

3. Compute-Optimal Scaling Strategy

3.1 문제 난이도에 따른 적응적 할당

핵심 발견: test-time compute 효과는 문제 난이도에 따라 크게 다름

난이도 최적 전략 이유
Easy Greedy (N=1) 추가 compute가 거의 도움 안 됨
Medium Best-of-N 다양한 시도가 정답 확률 높임
Hard Tree Search + PRM step-by-step verification 필요
Very Hard Revision-based search로도 부족, 반복 개선 필요

3.2 Compute-Optimal 전략

def compute_optimal_inference(model, verifier, prompt, compute_budget):
    """
    주어진 compute budget 내에서 최적의 전략 선택
    """
    # 1. 문제 난이도 추정 (lightweight probe)
    difficulty = estimate_difficulty(model, prompt)

    if difficulty < 0.3:  # Easy
        return model.generate(prompt, temperature=0)  # greedy

    elif difficulty < 0.6:  # Medium
        n_samples = compute_budget // cost_per_sample
        return best_of_n(model, verifier, prompt, n=n_samples)

    elif difficulty < 0.85:  # Hard
        # Tree search with PRM
        return beam_search_with_prm(
            model, verifier, prompt,
            beam_width=4,
            max_depth=compute_budget // (4 * cost_per_step)
        )

    else:  # Very Hard
        # Sequential revision
        response = model.generate(prompt)
        for _ in range(compute_budget // cost_per_revision):
            feedback = verifier.get_feedback(prompt, response)
            response = model.revise(prompt, response, feedback)
        return response

3.3 성능 비교

MATH 벤치마크 (Llama-3.1 기준):

┌─────────────────────────────────────────────────────────────────┐
│           Performance vs Compute (MATH Benchmark)               │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Accuracy                                                       │
│     │                                                           │
│ 80% ┼                                          ▲ Compute-Optimal│
│     │                                       ▲                   │
│ 70% ┼                                 ▲                         │
│     │                           ▲ ──────── Tree Search          │
│ 60% ┼                     ▲                                     │
│     │               ▲ ─────────────────── Best-of-N             │
│ 50% ┼         ▲                                                 │
│     │   ▲ ────────────────────────────── Majority Voting        │
│ 40% ┼──▲───────────────────────────────── Greedy                │
│     │                                                           │
│     └───┼───────┼───────┼───────┼───────┼───────┼─────────      │
│         1x      4x     16x     64x    256x   1024x              │
│                    Inference FLOPs (relative)                   │
│                                                                 │
│  Compute-Optimal: 동일 compute에서 Best-of-N 대비 4x 효율       │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

4. Inference Scaling Laws

4.1 Chinchilla-style Laws for Inference

전통적 Chinchilla Law (training):

L(N, D) = A/N^a + B/D^b + E

N: 파라미터 수
D: 학습 토큰 수

Inference Scaling Law:

L(N, G, S) = f(N, G, S)

N: 파라미터 수
G: 생성 토큰 수 (per query)
S: 추론 전략 (greedy, beam, MCTS, etc.)

4.2 핵심 발견

  1. 작은 모델 + 고급 추론 > 큰 모델 + 단순 추론
Llemma-7B + Tree Search > Llemma-34B + Greedy

7B 모델에 16x compute를 투입하면
34B 모델의 greedy 성능을 능가
(동일 FLOPs 기준 더 효율적)
  1. Pareto Frontier
Cost-Performance Trade-off:

       Performance
           │                    * 34B-greedy
           │               *
           │          * 7B-beam-64
           │     *
           │ * 7B-MCTS   <-- Pareto Optimal
           └───────────────────── Cost

5. 실용적 구현

5.1 Self-Consistency (Majority Voting)

from collections import Counter

def self_consistency(model, prompt, n=40, temperature=0.7):
    """
    Self-Consistency: 다수결로 최종 답변 선택
    CoT (Chain-of-Thought)와 결합하여 사용
    """
    answers = []

    for _ in range(n):
        # CoT 프롬프트로 reasoning + answer 생성
        response = model.generate(
            f"{prompt}\nLet's think step by step.",
            temperature=temperature
        )

        # 최종 답변 추출
        answer = extract_final_answer(response)
        answers.append(answer)

    # 다수결
    counter = Counter(answers)
    return counter.most_common(1)[0][0]
import heapq

def beam_search_with_verifier(model, verifier, prompt, beam_width=4, max_steps=10):
    """
    Verifier (PRM) 기반 beam search
    """
    # 초기 상태: (누적 점수, 현재 텍스트, step 수)
    beams = [(0.0, prompt, 0)]

    for step in range(max_steps):
        candidates = []

        for score, text, s in beams:
            if is_complete(text):
                candidates.append((score, text, s))
                continue

            # 다음 step 후보 생성
            continuations = model.generate_continuations(
                text, n=beam_width * 2, max_tokens=50
            )

            for cont in continuations:
                new_text = text + cont
                # PRM으로 이 step 평가
                step_score = verifier.score_step(prompt, new_text, step)
                new_score = score + step_score
                candidates.append((new_score, new_text, s + 1))

        # 상위 beam_width개만 유지
        beams = heapq.nlargest(beam_width, candidates, key=lambda x: x[0])

    # 최고 점수 beam 반환
    return max(beams, key=lambda x: x[0])[1]
import math
import random

class MCTSNode:
    def __init__(self, text, parent=None):
        self.text = text
        self.parent = parent
        self.children = []
        self.visits = 0
        self.value = 0.0

    def ucb1(self, c=1.41):
        if self.visits == 0:
            return float('inf')
        return (self.value / self.visits) + c * math.sqrt(
            math.log(self.parent.visits) / self.visits
        )

def mcts_reasoning(model, verifier, prompt, simulations=100):
    """
    MCTS for LLM reasoning
    """
    root = MCTSNode(prompt)

    for _ in range(simulations):
        node = root

        # 1. Selection: UCB1로 가장 유망한 경로 선택
        while node.children and not is_terminal(node.text):
            node = max(node.children, key=lambda n: n.ucb1())

        # 2. Expansion: 새 자식 노드 생성
        if not is_terminal(node.text):
            continuation = model.generate(
                node.text, max_tokens=50, temperature=0.8
            )
            child = MCTSNode(node.text + continuation, parent=node)
            node.children.append(child)
            node = child

        # 3. Simulation: 끝까지 rollout
        final_text = node.text
        while not is_terminal(final_text):
            final_text += model.generate(
                final_text, max_tokens=50, temperature=1.0
            )

        # 4. Backpropagation: reward 전파
        reward = verifier.evaluate(prompt, final_text)
        while node:
            node.visits += 1
            node.value += reward
            node = node.parent

    # 가장 많이 방문한 자식의 경로 반환
    best_child = max(root.children, key=lambda n: n.visits)
    return best_child.text

6. OpenAI o1/o3 시스템 분석

6.1 추정 아키텍처

┌─────────────────────────────────────────────────────────────────┐
│                  OpenAI o1/o3 추정 구조                         │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  [User Query]                                                   │
│       │                                                         │
│       ▼                                                         │
│  ┌─────────────────────────────────────────┐                   │
│  │        Reasoning Token Generation        │                   │
│  │  - Internal chain-of-thought            │                   │
│  │  - 사용자에게 보이지 않는 "생각" 토큰    │                   │
│  │  - 수백~수천 토큰 생성 가능              │                   │
│  └────────────────────┬────────────────────┘                   │
│                       │                                         │
│                       ▼                                         │
│  ┌─────────────────────────────────────────┐                   │
│  │         Internal Verification            │                   │
│  │  - Self-consistency checks              │                   │
│  │  - Backtracking on errors               │                   │
│  │  - Multiple reasoning paths             │                   │
│  └────────────────────┬────────────────────┘                   │
│                       │                                         │
│                       ▼                                         │
│  ┌─────────────────────────────────────────┐                   │
│  │         Final Answer Synthesis           │                   │
│  │  - Reasoning 결과 종합                   │                   │
│  │  - 사용자에게 보이는 응답 생성           │                   │
│  └─────────────────────────────────────────┘                   │
│                                                                 │
│  특징:                                                          │
│  - Reasoning 토큰에 대해 별도 과금 (더 비쌈)                    │
│  - 어려운 문제 = 더 많은 reasoning 토큰 = 더 높은 비용          │
│  - 사용자가 "thinking time" 조절 가능 (o3-mini: low/medium/high)│
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

6.2 Thinking Effort 설정

o3-mini의 reasoning_effort 파라미터:

설정 추정 동작 사용 사례
low 짧은 CoT, 빠른 응답 간단한 질문, 채팅
medium 중간 길이 reasoning 일반적인 문제 해결
high 긴 CoT, 다중 검증 복잡한 수학/코딩
from openai import OpenAI

client = OpenAI()

# reasoning_effort로 test-time compute 조절
response = client.chat.completions.create(
    model="o3-mini",
    reasoning_effort="high",  # low, medium, high
    messages=[
        {"role": "user", "content": "Prove that sqrt(2) is irrational."}
    ]
)

7. 성능 벤치마크

7.1 MATH 벤치마크 결과

모델/방법 Accuracy Relative Compute
Llama-3.1-8B (greedy) 47.2% 1x
Llama-3.1-8B (maj@64) 58.1% 64x
Llama-3.1-8B (beam+PRM) 62.4% 64x
Llama-3.1-8B (compute-optimal) 66.8% 64x
Llama-3.1-70B (greedy) 64.5% ~9x

핵심: 8B 모델 + compute-optimal이 70B greedy를 능가.

7.2 비용-성능 분석

API 비용 비교 (가상 예시):

Task: 복잡한 수학 문제 1000개 처리

[방법 A] GPT-4-Turbo (greedy)
- 정확도: 72%
- 비용: $50

[방법 B] GPT-3.5-Turbo + Self-Consistency (n=16)
- 정확도: 68%
- 비용: $24

[방법 C] GPT-3.5-Turbo + PRM-guided Search
- 정확도: 74%
- 비용: $35

→ 방법 C가 정확도 높으면서 비용 절감

8. 한계와 연구 방향

8.1 현재 한계

한계 설명
Verifier 의존성 좋은 PRM/ORM 필요, 학습 데이터 비용 큼
Latency 다중 샘플링 → 응답 시간 증가
문제 유형 편향 수학/코딩에서 효과적, 창의적 태스크는 미지수
Compute 상한 무한히 scaling하면 diminishing returns

8.2 미래 연구 방향

  1. Adaptive Compute Allocation
  2. 문제 난이도 자동 추정 개선
  3. 동적 compute budget 조절

  4. Efficient Verifiers

  5. Lightweight PRM 학습
  6. Self-verification (별도 verifier 없이)

  7. Beyond Math/Code

  8. 창의적 글쓰기, 대화에서의 TTS
  9. Multimodal reasoning

  10. Hardware Co-design

  11. TTS 최적화 하드웨어/컴파일러
  12. Speculative decoding과 결합

9. 핵심 요약

┌─────────────────────────────────────────────────────────────────┐
│              Test-Time Compute Scaling 핵심 정리                │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  1. 핵심 원리                                                   │
│     - 모델 크기 대신 추론 시 compute 투입으로 성능 향상         │
│     - 작은 모델 + 많은 추론 > 큰 모델 + 적은 추론 (동일 비용)   │
│                                                                 │
│  2. 주요 방법                                                   │
│     - Search: Best-of-N, Beam Search, MCTS                      │
│     - Revision: Self-Refinement, Sequential Updates             │
│     - Verification: PRM (Process), ORM (Outcome)                │
│                                                                 │
│  3. Compute-Optimal 전략                                        │
│     - 문제 난이도에 따라 다른 방법 적용                         │
│     - Easy → Greedy, Hard → Tree Search                         │
│     - 동일 compute에서 4x 효율 향상                             │
│                                                                 │
│  4. 실제 적용                                                   │
│     - OpenAI o1/o3: reasoning_effort 파라미터                   │
│     - Self-Consistency: 간단하지만 효과적                       │
│     - PRM-guided Search: 정밀한 제어 가능                       │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

참고 문헌

  1. Snell, C., et al. (2024). Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters. ICLR 2025. arXiv:2408.03314
  2. Wu, Y., et al. (2024). Inference Scaling Laws: An Empirical Analysis of Compute-Optimal Inference for Problem-Solving with Language Models. arXiv:2408.00724
  3. Wang, X., et al. (2022). Self-Consistency Improves Chain of Thought Reasoning in Language Models. ICLR 2023. arXiv:2203.11171
  4. Lightman, H., et al. (2023). Let's Verify Step by Step. ICLR 2024. arXiv:2305.20050
  5. Feng, X., et al. (2025). The Art of Scaling Test-Time Compute for Large Language Models. arXiv:2512.02008