[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,92 +2,259 @@
|
||||
id: wiki-2026-0508-foundation-models
|
||||
title: Foundation Models
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-FOMO-001]
|
||||
aliases: [foundation model, FM, large pretrained, LLM, VLM, multimodal foundation, GPT, Claude, Gemini, Llama]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.98
|
||||
tags: [auto-reinforced, foundation-models, llm, multimodal, Generative-AI, scaling-laws]
|
||||
verification_status: applied
|
||||
tags: [ai, foundation-model, llm, vlm, multimodal, scaling-laws, pretraining]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: Python
|
||||
framework: PyTorch / Transformers / vLLM
|
||||
---
|
||||
|
||||
# [[Foundation-Models|Foundation-Models]]
|
||||
# Foundation Models
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> "지능의 새로운 지층: 거대한 데이터셋에서 학습되어 언어, 이미지, 코딩 등 수많은 하위 작업을 동시에 수행할 수 있는 범용적인 능력을 갖춘 기본 모델로, 그 위에 다양한 앱이 건축([[Fine-tuning|Fine-tuning]])되는 현대 AI 생태계의 단단한 지반."
|
||||
## 매 한 줄
|
||||
> **"매 large-scale 의 의 의 self-supervised pretrained 의 의 의 다양한 task 의 의 의 adapt"**. Bommasani 2021 Stanford term. 매 LLM (GPT, Claude, Gemini, Llama), VLM (GPT-4V, Claude 3, Gemini), 매 audio (Whisper), 매 protein (ESM, AlphaFold), 매 robot (RT-2, π0).
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
파운데이션 모델(Foundation-Models)은 방대한 데이터에서 자기지도 학습(Self-supervised learning)을 통해 훈련되어 광범위한 하위 작업에 적응할 수 있는 모델입니다. (스탠포드 HAI 명명)
|
||||
## 매 핵심
|
||||
|
||||
1. **특징**:
|
||||
* **Generality**: 특정 용도가 아닌 범용적 지능 제공.
|
||||
* **Scale**: 수천억 개의 파라미터와 테라바이트급 데이터로 학습.
|
||||
* **[[Emergence|Emergence]]**: 학습하지 않은 능력(추론 등)이 규모가 커지며 갑자기 나타남. (Emergence와 연결)
|
||||
* **Multimodality**: 최근에는 텍스트를 넘어 시각, 청각을 동시에 처리.
|
||||
2. **왜 중요한가?**:
|
||||
* 누구나 바닥부터 모델을 만들 필요 없이, 강력한 파운데이션 모델을 API나 오픈소스로 가져와 비즈니스 아이디어만 얹으면 되는 'AI 민주화'의 핵심임.
|
||||
### 매 traits
|
||||
- **Scale**: 매 billions of parameter.
|
||||
- **Pretrain**: 매 vast unsupervised data.
|
||||
- **Emergence** (debated).
|
||||
- **Adaptable**: 매 prompt / fine-tune / RAG.
|
||||
- **Foundation 효과**: 매 downstream 의 ↑.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌**: 과거에는 각 도메인별로 전용 모델을 만드는 '개별 최적화 정책'이었으나, 현대 정책은 하나의 거대 모델이 모든 것을 더 잘한다는 '범용 엔진 정책(One-model-to-rule-them-all)'으로 시장이 재편됨(RL Update).
|
||||
- **정책 변화(RL Update)**: 단일 거대 모델의 효율 정책 한계를 극복하기 위해, 특정 영역에 특화된 여러 소형 모델을 연결하는 '에이전틱 워크플로우 정책'이나 'Mixture of Experts(MoE) 정책'으로 기술이 분화 중임.
|
||||
### 매 modality
|
||||
- **Text**: GPT, Claude, Gemini, Llama, Mistral.
|
||||
- **Vision-Language**: GPT-4V, Claude 3, Gemini, LLaVA.
|
||||
- **Audio**: Whisper, AudioLM.
|
||||
- **Code**: Codex, CodeLlama.
|
||||
- **Protein**: ESM-2, AlphaFold-3.
|
||||
- **Robot**: RT-2, OpenVLA, π0.
|
||||
- **Time-series** (TimeGPT).
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- [[Gen-AI|Gen-AI]], [[Emergence|Emergence]], [[Fine-tuning|Fine-tuning]], Multi-modal (멀티모달), Scaling-Laws
|
||||
- **Modern Tech/Tools**: GPT-4, Llama-3, Claude 3, Gemini, ViT (Vision Transformer).
|
||||
---
|
||||
### 매 scaling laws
|
||||
- **Kaplan 2020**: 매 power law (loss vs params/data/compute).
|
||||
- **Chinchilla** (Hoffmann 2022): 매 D ≈ 20·N optimal.
|
||||
- **Modern (2024+)**: 매 over-train (Llama 3 매 15T tokens).
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
### 매 modern (2025-2026)
|
||||
- **Frontier**: Claude Opus 4.7, GPT-5, Gemini 2 Ultra.
|
||||
- **Open**: Llama 3.x, Qwen 2.5, Mistral, DeepSeek-V3.
|
||||
- **Multimodal**: Gemini 1.5 1M context, Claude 3.5.
|
||||
- **MoE**: Mixtral, DeepSeek MoE.
|
||||
- **Reasoning**: o1, o3, DeepSeek-R1.
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
### 매 응용
|
||||
1. **General assistant**.
|
||||
2. **Code**.
|
||||
3. **Domain expert** (medical, legal).
|
||||
4. **Multimodal analysis**.
|
||||
5. **Agent**.
|
||||
6. **Embedding** (retrieval, clustering).
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
## 💻 패턴
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### LLM call (Anthropic)
|
||||
```python
|
||||
from anthropic import Anthropic
|
||||
client = Anthropic()
|
||||
response = client.messages.create(
|
||||
model='claude-opus-4-7',
|
||||
max_tokens=1024,
|
||||
messages=[{'role': 'user', 'content': 'Hi'}],
|
||||
)
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Streaming
|
||||
```python
|
||||
with client.messages.stream(
|
||||
model='claude-opus-4-7',
|
||||
max_tokens=1024,
|
||||
messages=[{'role': 'user', 'content': prompt}],
|
||||
) as stream:
|
||||
for text in stream.text_stream:
|
||||
print(text, end='', flush=True)
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Tool use (function calling)
|
||||
```python
|
||||
tools = [{
|
||||
'name': 'get_weather',
|
||||
'description': 'Get weather for a location',
|
||||
'input_schema': {'type': 'object', 'properties': {'location': {'type': 'string'}}},
|
||||
}]
|
||||
r = client.messages.create(model='claude-opus-4-7', tools=tools, messages=[...])
|
||||
if r.stop_reason == 'tool_use':
|
||||
tool = next(b for b in r.content if b.type == 'tool_use')
|
||||
result = execute_tool(tool.name, tool.input)
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Vision (multimodal)
|
||||
```python
|
||||
import base64
|
||||
img_b64 = base64.b64encode(open('img.jpg', 'rb').read()).decode()
|
||||
client.messages.create(model='claude-opus-4-7', max_tokens=1024, messages=[{
|
||||
'role': 'user',
|
||||
'content': [
|
||||
{'type': 'image', 'source': {'type': 'base64', 'media_type': 'image/jpeg', 'data': img_b64}},
|
||||
{'type': 'text', 'text': 'What do you see?'},
|
||||
],
|
||||
}])
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Open-source (Hugging Face)
|
||||
```python
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
model = AutoModelForCausalLM.from_pretrained('meta-llama/Llama-3.1-70B-Instruct', torch_dtype='bfloat16', device_map='auto')
|
||||
tokenizer = AutoTokenizer.from_pretrained('meta-llama/Llama-3.1-70B-Instruct')
|
||||
inputs = tokenizer.apply_chat_template([{'role': 'user', 'content': 'Hi'}], return_tensors='pt')
|
||||
outputs = model.generate(inputs, max_new_tokens=200)
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Embedding (text)
|
||||
```python
|
||||
from sentence_transformers import SentenceTransformer
|
||||
m = SentenceTransformer('all-mpnet-base-v2')
|
||||
vecs = m.encode(['hello', 'world'])
|
||||
|
||||
# 매 production
|
||||
from openai import OpenAI
|
||||
client = OpenAI()
|
||||
emb = client.embeddings.create(input='hello', model='text-embedding-3-large').data[0].embedding
|
||||
```
|
||||
|
||||
### CLIP (vision-text)
|
||||
```python
|
||||
from transformers import CLIPModel, CLIPProcessor
|
||||
model = CLIPModel.from_pretrained('openai/clip-vit-large-patch14')
|
||||
processor = CLIPProcessor.from_pretrained('openai/clip-vit-large-patch14')
|
||||
inputs = processor(text=['cat', 'dog'], images=image, return_tensors='pt')
|
||||
outputs = model(**inputs)
|
||||
similarities = outputs.logits_per_image.softmax(dim=-1)
|
||||
```
|
||||
|
||||
### Foundation model for robotics (OpenVLA)
|
||||
```python
|
||||
# 매 example concept
|
||||
from transformers import AutoProcessor, AutoModelForVision2Seq
|
||||
processor = AutoProcessor.from_pretrained('openvla/openvla-7b')
|
||||
model = AutoModelForVision2Seq.from_pretrained('openvla/openvla-7b', torch_dtype=torch.bfloat16)
|
||||
inputs = processor('In: What action?\nOut:', image, return_tensors='pt')
|
||||
action = model.predict_action(**inputs, unnorm_key='bridge_orig')
|
||||
```
|
||||
|
||||
### vLLM serving
|
||||
```python
|
||||
from vllm import LLM, SamplingParams
|
||||
llm = LLM(model='meta-llama/Llama-3.1-8B-Instruct', tensor_parallel_size=2)
|
||||
outputs = llm.generate(prompts, SamplingParams(max_tokens=100, temperature=0.7))
|
||||
```
|
||||
|
||||
### Fine-tune (LoRA)
|
||||
```python
|
||||
from peft import LoraConfig, get_peft_model
|
||||
config = LoraConfig(r=16, lora_alpha=32, target_modules=['q_proj', 'v_proj'])
|
||||
model = get_peft_model(model, config)
|
||||
# 매 train on task data
|
||||
```
|
||||
|
||||
### Adapter via prompt
|
||||
```python
|
||||
def domain_assistant(question, system_prompt):
|
||||
return client.messages.create(
|
||||
model='claude-opus-4-7',
|
||||
max_tokens=1024,
|
||||
system=system_prompt,
|
||||
messages=[{'role': 'user', 'content': question}],
|
||||
)
|
||||
|
||||
medical_system = 'You are a medical expert. Always recommend consulting a physician.'
|
||||
```
|
||||
|
||||
### Caching (prompt cache)
|
||||
```python
|
||||
# 매 Anthropic prompt caching
|
||||
client.messages.create(
|
||||
model='claude-opus-4-7',
|
||||
max_tokens=1024,
|
||||
system=[
|
||||
{'type': 'text', 'text': 'You are an expert.', 'cache_control': {'type': 'ephemeral'}},
|
||||
{'type': 'text', 'text': long_context, 'cache_control': {'type': 'ephemeral'}},
|
||||
],
|
||||
messages=[{'role': 'user', 'content': question}],
|
||||
)
|
||||
```
|
||||
|
||||
### Agent loop
|
||||
```python
|
||||
def agent(goal, tools, max_steps=10):
|
||||
history = [{'role': 'user', 'content': goal}]
|
||||
for _ in range(max_steps):
|
||||
r = client.messages.create(model='claude-opus-4-7', tools=tools, messages=history)
|
||||
if r.stop_reason == 'end_turn': return r
|
||||
if r.stop_reason == 'tool_use':
|
||||
tool_block = next(b for b in r.content if b.type == 'tool_use')
|
||||
result = execute(tool_block.name, tool_block.input)
|
||||
history.extend([{'role': 'assistant', 'content': r.content}, {'role': 'user', 'content': [{'type': 'tool_result', 'tool_use_id': tool_block.id, 'content': result}]}])
|
||||
```
|
||||
|
||||
### Evaluate (LLM judge)
|
||||
```python
|
||||
def llm_judge(response, criteria):
|
||||
judge_prompt = f"""Rate this response on {criteria}.
|
||||
Response: {response}
|
||||
Output JSON: {{"score": 0-10, "rationale": "..."}}"""
|
||||
return json.loads(client.messages.create(model='claude-opus-4-7', max_tokens=200, messages=[{'role': 'user', 'content': judge_prompt}]).content[0].text)
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Model |
|
||||
|---|---|
|
||||
| Top quality | Claude Opus 4.7 / GPT-5 |
|
||||
| Cost-aware | Claude Sonnet / GPT-4o-mini |
|
||||
| Open-source | Llama 3.x / Qwen 2.5 |
|
||||
| Code | Claude / DeepSeek-Coder |
|
||||
| Vision | Claude 3.5 / Gemini |
|
||||
| Embedding | text-embedding-3-large / mpnet |
|
||||
| On-device | Llama 3.2 1B/3B / Phi-3 |
|
||||
| Reasoning | o1 / DeepSeek-R1 |
|
||||
|
||||
**기본값**: 매 Frontier API for quality + 매 OSS for cost / control + 매 multimodal where needed + 매 RAG + 매 prompt caching.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[AI]] · [[Deep-Learning]]
|
||||
- 변형: [[LLM]] · [[VLM]] · [[Multimodal-LLM]] · [[Embodied-AI]]
|
||||
- 응용: [[Fine-tuning]] · [[RAG]] · [[Prompt-Engineering]] · [[Agent]]
|
||||
- Adjacent: [[Scaling-Laws]] · [[Mixture-of-Experts]] · [[Flash Attention]] · [[Edge-AI-and-Computing]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 modern AI 의 default. 매 NLP, multimodal, agent, code.
|
||||
**언제 X**: 매 strict latency / cost / privacy → smaller / on-device.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Largest model always**: 매 cost.
|
||||
- **Fine-tune for facts**: 매 RAG 의 better.
|
||||
- **No eval**: 매 quality 의 invisible.
|
||||
- **Single API lock-in**: 매 fallback 의 X.
|
||||
- **No prompt cache**: 매 cost ↑.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Bommasani 2021, Kaplan 2020, Hoffmann 2022, Anthropic / OpenAI / Google docs).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-04-20 | Auto-reinforced |
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — modalities + 매 Anthropic / HF / vLLM / agent / cache code |
|
||||
|
||||
Reference in New Issue
Block a user