GPT-4
GPT-4
OpenAI의 최신 대규모 언어 모델. 멀티모달 기능, 향상된 추론 능력이 특징.
GPT-4
OpenAI의 최신 대규모 언어 모델. 멀티모달 기능, 향상된 추론 능력이 특징.
GPT-4는 2023년 3월 OpenAI가 공개한 대규모 멀티모달 언어 모델로, 텍스트와 이미지를 모두 입력받아 처리할 수 있습니다. 정확한 파라미터 수는 공개되지 않았으나, 1.7조 파라미터의 MoE(Mixture of Experts) 구조로 추정되며, 한 번에 8개 전문가 중 2개가 활성화됩니다.
GPT-4는 GPT-3.5 대비 다양한 벤치마크에서 크게 향상된 성능을 보입니다. 미국 변호사 시험에서 상위 10%(GPT-3.5는 하위 10%), SAT 수학에서 700점(GPT-3.5는 590점), 코딩 능력에서 HumanEval 67%(GPT-3.5는 48%)를 달성했습니다.
GPT-4 Turbo는 128K 컨텍스트 윈도우를 지원하여 약 300페이지 분량의 텍스트를 한 번에 처리할 수 있습니다. 또한 JSON 모드, 함수 호출(Function Calling), 시드 기반 재현성(Reproducible outputs) 등 개발자 친화적 기능을 제공합니다. 비용은 GPT-4 대비 3배 저렴합니다.
실무에서 GPT-4는 복잡한 추론, 코드 생성, 문서 분석, 멀티모달 작업에 주로 사용됩니다. Vision 기능을 활용한 차트 분석, UI 설계 리뷰, 이미지 기반 QA가 가능하며, Assistants API와 결합하면 RAG, Code Interpreter 등 고급 에이전트 기능을 구현할 수 있습니다.
from openai import OpenAI
import base64
client = OpenAI(api_key="your-api-key")
# GPT-4 Turbo with Vision (이미지 분석)
def analyze_image(image_path: str, question: str) -> str:
with open(image_path, "rb") as f:
image_data = base64.standard_b64encode(f.read()).decode("utf-8")
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": question},
{"type": "image_url", "image_url": {
"url": f"data:image/jpeg;base64,{image_data}",
"detail": "high" # low, high, auto
}}
]
}],
max_tokens=1000
)
return response.choices[0].message.content
# 재현 가능한 출력 (seed 사용)
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[{"role": "user", "content": "Generate a haiku about coding."}],
seed=42,
temperature=1
)
print(f"System fingerprint: {response.system_fingerprint}")
# JSON 모드 활용
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[
{"role": "system", "content": "Extract entities as JSON with keys: persons, organizations, locations"},
{"role": "user", "content": "Apple CEO Tim Cook announced new products in Cupertino."}
],
response_format={"type": "json_object"}
)
import json
entities = json.loads(response.choices[0].message.content)
# Assistants API with Code Interpreter
assistant = client.beta.assistants.create(
name="Data Analyst",
instructions="You analyze data and create visualizations.",
model="gpt-4-turbo",
tools=[{"type": "code_interpreter"}]
)
thread = client.beta.threads.create()
client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="Analyze the attached CSV and plot sales trends."
)
run = client.beta.threads.runs.create_and_poll(
thread_id=thread.id,
assistant_id=assistant.id
)
# 긴 문서 처리 (128K 컨텍스트)
with open("long_document.txt", "r") as f:
long_text = f.read() # 최대 ~300페이지
response = client.chat.completions.create(
model="gpt-4-turbo",
messages=[
{"role": "system", "content": "Summarize the key points of this document."},
{"role": "user", "content": long_text}
],
max_tokens=2000
)
2025년 1월 기준 OpenAI GPT-4 계열 모델 API 가격 정보입니다.
| 모델 | 입력 (1M tokens) | 출력 (1M tokens) | 컨텍스트 |
|---|---|---|---|
| GPT-4o | $2.50 ~ $5.00 | $10.00 ~ $15.00 | 128K tokens |
| GPT-4o-mini | $0.15 | $0.60 | 128K tokens |
| GPT-4 Turbo | $10.00 | $30.00 | 128K tokens |
비용 최적화: GPT-4o-mini는 GPT-3.5 Turbo 대비 60% 저렴하면서 성능은 향상. 단순 작업은 mini, 복잡한 추론은 GPT-4o로 라우팅 권장.
"GPT-4와 Claude 3를 비교하면 어떤 차이가 있나요?" - "GPT-4는 멀티모달과 함수 호출이 강점이고, Claude 3는 200K 컨텍스트와 문서 분석에서 우수합니다. 코딩 벤치마크는 비슷하지만, GPT-4가 OpenAI 생태계(DALL-E, Whisper) 연동이 쉽고, Claude는 헌법 AI 기반 안전성이 높습니다. 용도에 따라 선택해야 합니다."
"GPT-4 Vision으로 UI 스크린샷 분석이 가능한가요?" - "네, detail을 high로 설정하면 UI 요소를 정확히 인식합니다. 저희 프로젝트에서 앱 스크린샷을 분석해 접근성 이슈를 찾는 데 사용했는데, 버튼 대비 문제나 터치 영역 크기 등을 잘 잡아냈어요. 다만 이미지당 토큰 비용이 높으니 필요한 곳에만 선택적으로 사용하세요."
"seed를 42로 고정했는데 왜 결과가 다르게 나오죠?" - "seed는 동일 system_fingerprint에서만 재현성이 보장됩니다. OpenAI가 모델을 업데이트하면 fingerprint가 바뀌어 결과도 달라질 수 있어요. 프로덕션에서는 fingerprint를 로깅하고, 중요한 출력은 캐싱하는 것을 권장합니다."
이미지 분석 시 해상도에 따라 85~1,105 토큰이 소비됩니다. detail=high는 4배 이상 토큰을 사용하므로, 대량 처리 시 detail=low나 이미지 리사이징을 고려하세요.
128K 컨텍스트라도 너무 긴 입력은 성능이 저하됩니다. Lost in the Middle 현상으로 중간 정보가 무시될 수 있으니, 중요한 정보는 시작이나 끝에 배치하세요.
gpt-4-turbo는 최신 버전을 자동으로 가리키며 변경될 수 있습니다. 프로덕션에서는 gpt-4-turbo-2024-04-09 같은 고정 버전을 사용해 일관성을 유지하세요.