반응형
로컬 LLM 실행 도구 Ollama의 핵심 CLI 명령어를 카테고리별로 정리했습니다.
📦 모델 관리
명령어 설명
| ollama pull <model> | 모델 다운로드 (예: llama3, qwen2.5:72b) |
| ollama list | 설치된 모델 목록 확인 |
| ollama show <model> | 모델 상세 정보 (파라미터, 템플릿 등) |
| ollama cp <src> <dst> | 모델 복사 |
| ollama rm <model> | 모델 삭제 |
💬 실행 및 대화
명령어 설명
| ollama run <model> | 대화형 채팅 시작 |
| ollama run <model> "질문" | 단일 프롬프트 실행 후 종료 |
| ollama run <model> --verbose | 속도(token/s) 등 상세 출력 |
| cat file.txt | ollama run <model> | 파일 내용을 stdin으로 전달 |
| /bye 또는 Ctrl+D | 대화 종료 |
🖥️ 서버 / 프로세스
명령어 설명
| ollama serve | REST API 서버 시작 (기본 포트 11434) |
| ollama ps | 현재 메모리에 로드된 모델 확인 |
| ollama stop <model> | 모델 메모리에서 언로드 |
| ollama --version | 설치된 버전 확인 |
🌐 API 직접 호출
서버가 실행 중이면 curl 또는 HTTP 클라이언트로 직접 호출할 수 있습니다.
단일 응답 (generate)
curl http://localhost:11434/api/generate \
-d '{
"model": "llama3",
"prompt": "안녕하세요",
"stream": false
}'
멀티턴 대화 (chat)
curl http://localhost:11434/api/chat \
-d '{
"model": "llama3",
"messages": [
{ "role": "user", "content": "안녕하세요" }
]
}'
팁: "stream": false 옵션을 주면 응답이 완성된 후 한 번에 반환됩니다.
🛠️ 커스텀 모델 (Modelfile)
나만의 설정을 적용한 커스텀 모델을 만들 수 있습니다.
명령어 설명
| ollama create <name> -f Modelfile | Modelfile로 커스텀 모델 빌드 |
| ollama push <model> | Ollama Hub에 업로드 |
Modelfile 예시
FROM llama3
SYSTEM "당신은 한국어 전문 어시스턴트입니다. 항상 친절하게 답변하세요."
PARAMETER temperature 0.7
PARAMETER top_p 0.9
PARAMETER num_ctx 4096
# 커스텀 모델 생성
ollama create my-assistant -f Modelfile
# 실행
ollama run my-assistant
💡 채팅 중 슬래시(/) 명령어
대화 세션 안에서 사용할 수 있는 내부 명령어입니다.
명령어 설명
| /set system "..." | 시스템 프롬프트 설정 |
| /show info | 현재 모델 정보 출력 |
| /clear | 대화 히스토리 초기화 |
| /save <session> | 세션 저장 |
| /load <session> | 저장된 세션 불러오기 |
| /help | 슬래시 명령 전체 목록 출력 |
⚙️ 유용한 환경변수
# 외부 접근 허용 (OpenClaw, n8n 등 연동 시 필요)
export OLLAMA_HOST=0.0.0.0:11434
# 모델 저장 경로 변경
export OLLAMA_MODELS=~/my-models
# 동시 요청 수 설정
export OLLAMA_NUM_PARALLEL=2
# 모델 언로드 대기 시간 (0이면 즉시 언로드)
export OLLAMA_KEEP_ALIVE=5m
macOS에서는 ~/.zshrc 또는 ~/.bash_profile에 추가하면 영구 적용됩니다.
🔖 자주 쓰는 모델명 예시
모델 명령어
| Llama 3.1 8B | ollama pull llama3.1 |
| Llama 3.3 70B | ollama pull llama3.3 |
| Qwen 2.5 7B | ollama pull qwen2.5 |
| Qwen 2.5 72B | ollama pull qwen2.5:72b |
| Mistral 7B | ollama pull mistral |
| Gemma 3 12B | ollama pull gemma3:12b |
| Phi-4 | ollama pull phi4 |
| Deepseek R2 | ollama pull deepseek-r1 |
| CodeLlama | ollama pull codellama |
| Nomic Embed | ollama pull nomic-embed-text |
전체 모델 목록은 https://ollama.com/library 에서 확인할 수 있습니다.
본 포스트는 Ollama 공식 문서를 기반으로 작성되었습니다.
반응형