본 포스팅은 테디님의 Git을 참고하여 작성되었습니다.
https://github.com/teddylee777/langserve_ollama/tree/main
0. Ollama
LLM을 로컬 PC에서 쉽게 실행할 수 있게 해주는 도구입니다.
Ollama를 이용하여 LLM을 직접 다운로드 받고 프롬프트로 실행하는 방법을 소개합니다.
1. WSL 설치(windows 기준)
WSL(Windows Subsystem for Linux)으로 Windows에 리눅스 운영체제를 설치하여 사용할 수 있습니다.
1) 커맨드 관리자 권한 실행 후 다음 입력
wsl --install
2) 재부팅 후 ID, PW 설정
2. Ollama 설치
Ollama는 로컬 컴퓨터에서 개인 LLM 서버를 구성할 수 있게 도움을 주는 도구입니다.
1) Ubuntu 콘솔 실행 후 다음 입력
curl -fsSL https://ollama.com/install.sh | sh
2) ollama --version 실행 후 버전 확인
3. LLM 모델(EEVE) 가져오기
EEVE 모델은 야놀자에서 Solar 모델을 한국어 어휘로 확장하여 만든 모델입니다.
먼저 기본적인 ubuntu 설정 후 모델을 다운로드 하겠습니다.
pip로 python 패키지를 다운로드 받기 위해서는 가상환경 설정이 필요합니다.
1) python, pip 설치
sudo apt update & sudo apt upgrade
sudo apt install python3-pip
sudo apt install python3-venv
2) python3, pip3를 python, pip로 실행할 수 있도록 alias를 붙여줍니다.
vi ~/.bashrc 실행 후 아래 두 줄 추가 후 source ~/.bashrc 를 실행하여 적용
alias python='python3'
alias pip='pip3'
3) 가상환경 활성화
python -m venv .venv
source .venv/bin/activate
deactivate(비활성화)
4) huggingface 설치
pip install huggingface-hub
5) EEVE 모델 다운로드
huggingface-cli download \
heegyu/EEVE-Korean-Instruct-10.8B-v1.0-GGUF \
ggml-model-Q5_K_M.gguf \
--local-dir [다운로드받을경로] \
--local-dir-use-symlinks False
4. 모델 파일 설정
다운로드 받은 경로로 이동해서(ggml-model-Q5_K_M.gguf 파일과 같은 경로) Modelfile을 생성하고 다음과 같이 작성하여 저장합니다.
FROM ggml-model-Q5_K_M.gguf
TEMPLATE """{{- if .System }}
<s>{{ .System }}</s>
{{- end }}
<s>Human:
{{ .Prompt }}</s>
<s>Assistant:
"""
SYSTEM """A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions."""
PARAMETER stop <s>
PARAMETER stop </s>
5. Ollama 실행
1) 모델 생성
ollama create EEVE-Korean-10.8B -f [Modelfile경로]
2) 모델 실행
ollama run EEVE-Korean-10.8B:latest
'AI > LLM' 카테고리의 다른 글
[LLM] Ngrok (3) | 2024.10.06 |
---|---|
[LLM] LangServe (8) | 2024.10.06 |