Granite 추론 모드 — thinking 파라미터와 사용

Granite 추론 모드

Granite 4.2는 모델 하나로 추론 깊이를 상황에 맞게 조절할 수 있어요. 채팅 템플릿 파라미터로 세 가지 모드를 선택해요.

세 가지 모드

모드 템플릿 파라미터 동작
Thinking(기본) enable_thinking=True thinking... 태그 안에서 전체 체인오브소트 수행
Low-effort enable_thinking=True, low_effort=True 더 단순한 질문에 짧은 추론
Non-thinking enable_thinking=False 추론 없이 바로 답 생성

이렇게 같은 모델로 깊이 vs 지연 간 트레이드오프를 쿼리마다 조절할 수 있어요.

추론 예시 (30B)

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_path = "ibm-granite/granite-4.2-30b"
tokenizer = AutoTokenizer.from_pretrained(model_path)
# CPU에서는 device_map 을 빼세요
model = AutoModelForCausalLM.from_pretrained(model_path,
    device_map="cuda", torch_dtype=torch.bfloat16)

생성 파라미터 권장값

모든 태스크·모든 서빙 백엔드에서 temperature=1.0, top_p=0.95를 쓰는 것을 권장해요. 일반 채팅·추론·도구 호출 모두 동일해요.

더 알아보기