ONE is preparing: 01 / INITIALIZING MODEL ROUTER. Evaluating routing across providers.
Current state
01 / INITIALIZING MODEL ROUTER.

Evaluating routing across providers.

Start learning
← Huấn luyện & Alignment

AI Researcher

Tính toán lúc suy luận — Nghĩ thêm khi cần

Vietnamese onlyThe learning content is available in Vietnamese only. The surrounding interface follows your language.

Chiến lược sử dụng nhiều tài nguyên tính toán hơn tại thời điểm suy luận để cải thiện chất lượng câu trả lời.

lesson98 minHuấn luyện & AlignmentAI Researcher

Dự đoán

Model 8B (nhỏ) trả lời bài toán IMO đúng 10%. Model 70B (lớn) đúng 30%. Nhưng nếu cho model 8B 'suy nghĩ' gấp 100 lần (test-time compute), kết quả sẽ thế nào?

Nghiên cứu cho thấy: model nhỏ + test-time compute scaling có thể VƯỢT model lớn hơn 14x dùng 1-pass! Giống sinh viên trung bình được suy nghĩ 3 tiếng vs thiên tài chỉ có 5 phút — thời gian suy nghĩ bù đắp cho năng lực nền.

Khoảnh khắc Aha

Hai cách làm AI giỏi hơn: train lâu hơn (1 lần, fix) hoặc nghĩ lâu hơn (mỗi query, linh hoạt). Test-time compute giống cho thí sinh thêm thời gian làm bài — câu dễ xong nhanh, câu khó nghĩ kỹ. Linh hoạt hơn nhiều so với tăng kích thước model!

Thử thách

Majority voting N = 32 cho mọi câu thì quá đắt với budget. Cách hợp lý nhất?

Adaptive test-time compute: classifier nhẹ phân loại câu hỏi → 80% câu dễ dùng 1-pass ($0.01), 15% trung bình dùng N=4 ($0.04), 5% khó dùng N=32 ($0.32). Chi phí trung bình: $0.027/req → 100K req = $2700 < budget. Tiết kiệm 10x so với voting cho mọi câu!

Test-time compute là gì

Test-Time Compute là paradigm mới cho phép model sử dụng nhiều compute hơn tại INFERENCE để cải thiện chất lượng từng câu trả lời. Đây là nền tảng của reasoning models thế hệ mới, mở rộng scaling laws từ training sang inference.

Model nhỏ + test-time compute cao có thể vượt model lớn + 1-pass inference!

Scaling law mới

Scaling law mới:

Performance∝log⁡(Ctrain)+α⋅log⁡(Ctest-time)\text{Performance} \propto \log(C_{\text{train}}) + \alpha \cdot \log(C_{\text{test-time}})

5 chiến lược chính

5 chiến lược chính:

  • Best-of-N: Sinh N answers, reward model chọn cái tốt nhất
  • Majority Voting: Sinh N answers, chọn đáp án phổ biến nhất (self-consistency)
  • Iterative Refinement: Generate → Critique → Revise, lặp K vòng
  • Tree Search: Khám phá cây suy luận, PRM tỉa nhánh kém (MCTS style)
  • Adaptive Compute: Phân loại độ khó → allocate compute tương ứng

Compute-optimal allocation

Verifier và Best-of-N

Verifier / Reward Models:

Best-of-N: y^=arg⁡max⁡yi∈{y1,...,yN}R(x,yi)\text{Best-of-N: } \hat{y} = \arg\max_{y_i \in \{y_1, ..., y_N\}} R(x, y_i)
Majority Vote: y^=arg⁡max⁡a∑i=1N1[yi=a]\text{Majority Vote: } \hat{y} = \arg\max_{a} \sum_{i=1}^{N} \mathbb{1}[y_i = a]

Test-time compute: Best-of-N + Reward Model

import anthropic
import numpy as np

client = anthropic.Anthropic()

def best_of_n(prompt: str, n: int = 8) -> str:
    """Sinh N answers, reward model chọn cái tốt nhất."""
    # Sinh N diverse answers (temperature > 0)
    answers = []
    for _ in range(n):
        resp = client.messages.create(
            model="claude-sonnet-4-20250514",
            max_tokens=1024,
            temperature=0.8,  # Đa dạng hoá
            messages=[{"role": "user", "content": prompt}],
        )
        answers.append(resp.content[0].text)

    # Reward model đánh giá chất lượng
    scores = []
    for ans in answers:
        score_resp = client.messages.create(
            model="claude-sonnet-4-20250514",
            max_tokens=10,
            messages=[
                {"role": "user", "content": f"""Rate answer quality 0-10.
Question: {prompt}
Answer: {ans}
Score (number only):"""}
            ],
        )
        scores.append(float(score_resp.content[0].text.strip()))

    # Chọn answer có score cao nhất
    best_idx = int(np.argmax(scores))
    return answers[best_idx]

# Chi phí: N=8 → 8x inference + 8x scoring = ~16x
# Accuracy: +15-25% trên bài toán khó

AlphaProof và AlphaGeometry

Tóm tắt

  • Test-time compute: tăng compute PER QUERY thay vì tăng model size — linh hoạt, chỉ tốn khi cần.
  • Model 8B + 100x test-time compute có thể VƯỢT model 70B dùng 1-pass.
  • 5 chiến lược: Best-of-N, Majority Vote, Iterative Refine, Tree Search, Adaptive Compute.
  • Adaptive allocation: phân loại độ khó → câu dễ 1-pass, câu khó tree search. Hiệu quả 5-10x.
  • Trade-off: accuracy tăng nhưng latency và chi phí tăng theo. Diminishing returns sau một ngưỡng.

Continue the module

Lesson 7 of 11