기술과 산업/AI

macOS에서 Ollama 사용하기

B컷개발자 2024. 9. 27. 18:25
728x90

아래 링크에 너무 잘 나와 있다.

 

https://www.llama.com/docs/llama-everywhere/running-meta-llama-on-mac/

 

Running Meta Llama on Mac | Llama Everywhere

For this demo, we are using a Macbook Pro running Sonoma 14.4.1 with 64GB memory. Since we will be using Ollamap, this setup can also be used on other operating systems that are supported such as Linux or Windows using similar steps as the ones shown here.

www.llama.com

 

 

2024년 4월 18일 Llama 3가 발표되었다. 8B와 70B 모델이 있는데, 성능이 많이 올라온 듯 하고 70B 모델은 상용 LLM에도 비견할 수 있는 성능을 가진 모양이다.

 

설치는 brew로 아래 처럼

 

brew install ollama

 

구동은 아래 명령어로...

 

ollama serve  # 서버 구동
ollama run llama3  # llama3 latest를 실행하고, 없으면 다운로드 함

 

CLI보다 웹을 선호한다면 web ui를 설치한다.

https://github.com/open-webui/open-webui

 

GitHub - open-webui/open-webui: User-friendly WebUI for AI (Formerly Ollama WebUI)

User-friendly WebUI for AI (Formerly Ollama WebUI) - open-webui/open-webui

github.com

 

Docker 쓰는건 즐긴다면 아래 명령어로

docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main

 

 

한국어 모델은 아래 링크에서...

 

https://huggingface.co/Bllossom/llama-3-Korean-Bllossom-70B

 

Bllossom/llama-3-Korean-Bllossom-70B · Hugging Face

NEWS [2024.08.30] 사전학습량을 250GB까지 늘린 Bllossom ELO모델로 업데이트 되었습니다. 다만 단어확장은 하지 않았습니다. 기존 단어확장된 long-context 모델을 활용하고 싶으신분은 개인연락주세요! [20

huggingface.co

 

https://huggingface.co/teddylee777/Llama-3-Open-Ko-8B-gguf/tree/main

 

teddylee777/Llama-3-Open-Ko-8B-gguf at main

Upload Llama-3-Open-Ko-8B-Q5_0.gguf with huggingface_hub 872a508 verified 4 months ago

huggingface.co

 

모델을 적용하려면 아래와 같이 해당 모델 정보를 반영하여 Modelfile을 하나 만들어준다.

 

FROM llama-3-Korean-Bllossom-8B-Q4_K_M.gguf

SYSTEM """당신은 유용한 AI 어시스턴트입니다. 사용자의 질의에 대해 친절하고 정확하게 답변해야 합니다. You are a helpful AI assistant, you'll need to answer users' queries in a friendly and accurate manner. 모든 대답은 한국어(Korean)으로 대답해주세요."""


TEMPLATE """{{- if .System }}
<s>{{ .System }}</s>
{{- end }}
<s>Human:
{{ .Prompt }}</s>
<s>Assistant:
"""

PARAMETER temperature 0.6
PARAMETER num_predict 3000
PARAMETER num_ctx 4096
PARAMETER stop <s>
PARAMETER stop </s>
PARAMETER stop <|eot_id|>

 

ollama create ollama-ko-0710 -f Modelfile

 

web ui에서 질의를 해보면 한국어로 응답을 잘 주는것을 확인 할수 있다.

 

728x90