Ollama로 Qwen 로컬 실행하기
Ollama로 Qwen 로컬 실행하기
Ollama는 몇 가지 명령만으로 LLM을 로컬에서 실행할 수 있게 도와주는 도구예요. macOS, Linux, Windows에서 사용할 수 있어요. 이제 Qwen2.5가 Ollama에 공식 등록되어 있어서 한 줄의 명령으로 바로 실행할 수 있답니다.
출처: 문서
본문
⚠️ 주의: 이 페이지는 Qwen3 기준으로 업데이트 예정이에요.
Ollama는 몇 개의 명령만으로 LLM을 로컬에서 실행할 수 있게 해줘요. macOS, Linux, Windows에서 사용할 수 있어요. 이제 Qwen2.5가 Ollama에 공식 지원되며, 다음 한 줄의 명령으로 실행할 수 있어요:
ollama run qwen2.5
다음으로 Ollama로 Qwen2.5 모델을 실행하는 더 자세한 사용법을 소개할게요.
퀵스타트
공식 웹사이트 Ollama를 방문해 다운로드를 클릭하면 기기에 Ollama를 설치할 수 있어요. 웹사이트에서 모델을 검색할 수도 있는데, 거기서 Qwen2.5 모델을 찾을 수 있어요. 기본 모델 외에도 다음 명령으로 다양한 크기의 Qwen2.5-Instruct 모델을 실행할 수 있어요:
ollama run qwen2.5:0.5bollama run qwen2.5:1.5bollama run qwen2.5:3bollama run qwen2.5:7bollama run qwen2.5:14bollama run qwen2.5:32bollama run qwen2.5:72b
📝 참고:
ollama는 base 모델을 호스팅하지 않아요. 태그에 instruct 접미사가 없더라도 모두 instruct 모델이에요.
나만의 GGUF 파일로 Ollama 실행하기
때로는 모델을 가져오지 않고 나만의 GGUF 파일로 Ollama를 사용하고 싶을 때가 있어요. Qwen2.5의 GGUF 파일 qwen2.5-7b-instruct-q5_0.gguf가 있다고 가정해 볼게요.
먼저 Modelfile이라는 파일을 만들어야 해요. 파일 내용은 다음과 같아요:
FROM qwen2.5-7b-instruct-q5_0.gguf
# set the temperature to 1 [higher is more creative, lower is more coherent]
PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER repeat_penalty 1.05
PARAMETER top_k 20
TEMPLATE """{{ if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{ .System }}
{{- if .Tools }}
# Tools
You are provided with function signatures within <tools></tools> XML tags:
<tools>{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}{{- end }}
</tools>
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}"""
# set the system message
SYSTEM """You are Qwen, created by Alibaba Cloud. You are a helpful assistant."""
그 다음 아래 명령으로 Ollama 모델을 생성하세요:
ollama create qwen2.5_7b -f Modelfile
완료되면 다음 명령으로 Ollama 모델을 실행할 수 있어요:
ollama run qwen2.5_7b
도구 사용 (Tool Use)
이제 Ollama에서 도구 사용(Tool use)을 지원하며, Qwen2.5 모델을 그 기능과 함께 실행할 수 있어요. 자세한 내용은 함수 호출 가이드를 참고하세요.