Ollama는 로컬 환경에서 LLM(대형 언어 모델)을 손쉽게 실행할 수 있는 오픈소스 도구입니다.
공식 사이트에서 Windows 설치 파일을 받습니다.
https://ollama.com/download/windows
OllamaSetup.exe 실행 → Install 클릭
💡 Windows Defender 경고가 뜨면 "추가 정보" → "실행" 클릭
설치 완료 후 시스템 트레이(우측 하단)에 라마 아이콘이 생성됩니다.
PowerShell 또는 명령 프롬프트(cmd)를 열고 확인합니다.
ollama --version
| 모델 | 크기 | 특징 |
|---|---|---|
gemma3:4b | 3.3GB | 입문 추천, 성능 균형 |
llama3.2:3b | 2.0GB | 경량, 빠른 응답 |
qwen2.5:7b | 4.7GB | 한국어 성능 강점 |
mistral:7b | 4.1GB | 영어 성능 강점 |
ollama run gemma3:4b
다운로드 완료 후 >>> 프롬프트가 나타나면 바로 대화할 수 있습니다.
>>> 안녕하세요! 파이썬 리스트 컴프리헨션을 설명해줘
종료하려면 /bye 또는 Ctrl+D를 입력합니다.
# 설치된 모델 목록 확인
ollama list
# 모델 다운로드만 (실행 없이)
ollama pull llama3.2:3b
# 모델 삭제
ollama rm gemma3:4b
# 현재 실행 중인 모델 확인
ollama ps
# 모델 상세 정보
ollama show gemma3:4b
# API 서버 수동 실행
ollama serve
Ollama를 설치하면 백그라운드에서 자동으로 API 서버가 실행됩니다.
http://localhost:11434curl http://localhost:11434/api/generate \
-d '{
"model": "gemma3:4b",
"prompt": "하늘은 왜 파란가요?",
"stream": false
}'
curl http://localhost:11434/api/chat \
-d '{
"model": "gemma3:4b",
"messages": [
{"role": "user", "content": "안녕하세요!"}
],
"stream": false
}'
{
"model": "gemma3:4b",
"message": {
"role": "assistant",
"content": "안녕하세요! 무엇을 도와드릴까요?"
}
}
pip install ollama
import ollama
response = ollama.chat(
model="gemma3:4b",
messages=[
{"role": "system", "content": "당신은 친절한 AI 도우미입니다."},
{"role": "user", "content": "파이썬 리스트 컴프리헨션을 설명해줘"}
]
)
print(response["message"]["content"])
이전 메시지를 messages 리스트에 누적해서 넘기면 맥락이 유지됩니다.
import ollama
messages = []
def chat(user_input):
messages.append({"role": "user", "content": user_input})
response = ollama.chat(model="gemma3:4b", messages=messages)
assistant_msg = response["message"]["content"]
messages.append({"role": "assistant", "content": assistant_msg})
return assistant_msg
print(chat("내 이름은 홍길동이야"))
print(chat("내 이름이 뭐라고 했지?")) # 맥락 유지됨
import ollama
stream = ollama.chat(
model="gemma3:4b",
messages=[{"role": "user", "content": "파이썬의 장점 5가지"}],
stream=True
)
for chunk in stream:
print(chunk["message"]["content"], end="", flush=True)
print()
response = ollama.generate(
model="gemma3:4b",
prompt="하늘이 파란 이유를 한 문장으로 설명해줘",
system="간결하게 답변하세요",
options={"temperature": 0.7}
)
print(response["response"])
RAG, 유사도 검색, 문서 분류 등에 활용합니다.
# 임베딩 전용 모델 먼저 설치 필요
# ollama pull nomic-embed-text
result = ollama.embeddings(
model="nomic-embed-text",
prompt="안녕하세요"
)
vector = result["embedding"]
print(f"벡터 차원 수: {len(vector)}")
FastAPI, aiohttp 등 비동기 웹 프레임워크에서 사용합니다.
import asyncio
import ollama
async def main():
client = ollama.AsyncClient()
response = await client.chat(
model="gemma3:4b",
messages=[{"role": "user", "content": "안녕!"}]
)
print(response["message"]["content"])
asyncio.run(main())
import ollama
# 설치된 모델 목록
models = ollama.list()
for m in models["models"]:
print(m["name"], m["size"])
# 모델 다운로드
ollama.pull("llama3.2:3b")
# 모델 정보 조회
info = ollama.show("gemma3:4b")
print(info["modelfile"])
# 모델 삭제
ollama.delete("gemma3:4b")
import ollama
# 기본값은 http://localhost:11434
client = ollama.Client(host="http://192.168.1.100:11434")
response = client.chat(
model="gemma3:4b",
messages=[{"role": "user", "content": "테스트"}]
)
print(response["message"]["content"])
ChatGPT와 유사한 웹 인터페이스를 제공합니다. Docker가 필요합니다.
docker run -d -p 3000:8080 `
--add-host=host.docker.internal:host-gateway `
-v open-webui:/app/backend/data `
ghcr.io/open-webui/open-webui:main
설치 후 브라우저에서 http://localhost:3000 접속
config.json에서 Ollama 모델 지정| 항목 | 최소 | 권장 |
|---|---|---|
| RAM | 8GB | 16GB (7B 모델 기준) |
| 저장소 | 모델당 2~8GB | SSD 권장 |
| OS | Windows 10 64-bit | Windows 11 |
| GPU | 없어도 동작 (CPU) | NVIDIA GPU (CUDA) |
NVIDIA GPU가 있으면 설치 즉시 CUDA 가속이 자동 적용됩니다. 별도 설정이 필요 없습니다.
💡 CPU 대비 5~20배 빠른 응답 속도를 경험할 수 있습니다.
GPU 사용 여부를 확인하려면:
ollama ps
실행 중인 모델 옆에 GPU 사용량이 표시됩니다.
Ollama는 로컬 AI 환경을 구성하는 가장 빠른 방법입니다. Python 라이브러리와 REST API를 통해 다양한 애플리케이션에 LLM을 손쉽게 연동할 수 있고, Open WebUI를 통해 ChatGPT와 동일한 사용 경험도 얻을 수 있습니다.
참고: Ollama 공식 문서 | Ollama GitHub