새소식

Project

HuggingFace에서 Llam3.2 한국어 버전 다운로드하고 Ollama로 실행하기

  • -

1. HuggingFace에서 한국어 모델 다운로드하기

https://huggingface.co/Bllossom

Bllossom/llama-3.2-Korean-Blossom-3B 모델은 Bllossom팀에서 개발한 한국어-영어 이중언어 모델입니다.

Bllossom팀은 서울과학기술대학교의 임경태 교수, Teddysum의 함영균 CEO, 연세대학교의 김한샘 교수를 중심으로 구성되어 있으며, 다수의 연구원들이 참여하고 있습니다.

 

 
 

위 이미지에서 Bllossom/llama-3.2-Korean-Bllossom-3B-gguf-Q4_K_M

를 선택해줍니다.

.gguf 확장자 파일 옆에 다운로드 아이콘을 클릭하여 모델을 다운로드 해줍니다.

 

저는 아래 이미지와 같이 해당 파일을 다운로드 폴더에서

khw@khw:~/ollama/gguf 해당 위치로 옮겼습니다.

 

2. Modelfile 파일 만들어주기

해당 위치에서 터미널을 열고 아래 명령어를 입력하세요.

gedit ./Modelfile

또는 .code로 VScode를 열어 Makefile 파일을 만들어줍니다.

그리고 아래 내용을 넣어줍니다.

FROM ./llama-3.2-Korean-Bllossom-3B-gguf-Q4_K_M.gguf

PARAMETER temperature 0.6
PARAMETER top_p 0.9

TEMPLATE """<|start_header_id|>system<|end_header_id|>

Cutting Knowledge Date: December 2023

{{ if .System }}{{ .System }}
{{- end }}
{{- if .Tools }}When you receive a tool call response, use the output to format an answer to the orginal user question.

You are a helpful assistant with tool calling capabilities.
{{- end }}<|eot_id|>
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<|start_header_id|>user<|end_header_id|>
{{- if and $.Tools $last }}

Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.

Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables.

{{ range $.Tools }}
{{- . }}
{{ end }}
{{ .Content }}<|eot_id|>
{{- else }}

{{ .Content }}<|eot_id|>
{{- end }}{{ if $last }}<|start_header_id|>assistant<|end_header_id|>

{{ end }}
{{- else if eq .Role "assistant" }}<|start_header_id|>assistant<|end_header_id|>
{{- if .ToolCalls }}
{{ range .ToolCalls }}
{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}{{ end }}
{{- else }}

{{ .Content }}
{{- end }}{{ if not $last }}<|eot_id|>{{ end }}
{{- else if eq .Role "tool" }}<|start_header_id|>ipython<|end_header_id|>

{{ .Content }}<|eot_id|>{{ if $last }}<|start_header_id|>assistant<|end_header_id|>

{{ end }}
{{- end }}
{{- end }}"""

SYSTEM """You are a helpful AI assistant. Please answer the user's questions kindly. 당신은 유능한 AI 어시스턴트 입니다. 사용자의 질문에 대해 친절하게 답변해주세요."""

2번째 줄과 3번째 줄에 PARAMETER값이 있는데, 이건 모델의 출력을 제어할 수 있는 하이퍼파라미터입니다.

  • temperature는 모델의 응답의 다양성을 조절합니다. 값이 높을수록 답변이 더 창의적이고 예측 불가능하게 되며, 낮을수록 더 보수적인 답변을 생성합니다. 
  • top_p는 누적 확률의 기준을 정해, 가장 유력한 응답을 제한하는 방식으로 제어합니다. 0.9로 설정된 경우, 전체 응답 중 상위 90%의 확률에 해당하는 선택만을 고려합니다.

위 이미지와 같이 준비되어야 합니다.

 

3. Ollama 모델 생성하기

아래 명령어를 통해 Ollama 모델을 생성할 수 있습니다.

ollama create <모델이름> -f Modelfile 

저는 llama3.2-korean이라 이름짓겠습니다.

아래와 같이 입력하였습니다.  

ollama create llama3.2-korean -f Modelfile 

 

4. 모델 확인 

 

ollama list
 

5. 모델 실행

ollama run llama3.2-korean
 
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.