# EXAONE-3.0-7.8B-Instruct Ollama 설치 가이드 Hugging Face의 EXAONE-3.0-7.8B-Instruct 모델을 Ollama에 추가하는 방법입니다. ## 사전 준비 ### 1. Hugging Face 계정 및 액세스 권한 1. [Hugging Face 계정 생성](https://huggingface.co/join) (없는 경우) 2. [EXAONE-3.0-7.8B-Instruct 모델 페이지](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct) 방문 3. 사용 조건에 동의하고 액세스 권한 요청 ### 2. Hugging Face 토큰 설정 ```bash # Hugging Face CLI로 로그인 huggingface-cli login # 또는 환경 변수로 토큰 설정 export HUGGINGFACE_HUB_TOKEN=your_token_here ``` Windows PowerShell: ```powershell $env:HUGGINGFACE_HUB_TOKEN="your_token_here" ``` ### 3. 필요한 패키지 설치 ```bash pip install huggingface_hub transformers torch ``` ## 설치 방법 ### 방법 1: Ollama의 --from 옵션 사용 (가장 간단) ```bash ollama create EXAONE-3.0-7.8B-Instruct --from huggingface:LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct ``` **주의사항:** - Ollama 최신 버전이 필요합니다 (0.1.0 이상) - 모델이 GGUF 형식으로 변환되어 있어야 합니다 - Hugging Face에 GGUF 버전이 없으면 이 방법은 작동하지 않을 수 있습니다 ### 방법 2: Modelfile 사용 (권장) 1. `add_exaone_model.py` 스크립트 실행: ```bash python add_exaone_model.py ``` 2. 생성된 Modelfile로 모델 생성: ```bash ollama create EXAONE-3.0-7.8B-Instruct -f EXAONE-3.0-7.8B-Instruct.modelfile ``` ### 방법 3: 수동 Modelfile 생성 1. `EXAONE-3.0-7.8B-Instruct.modelfile` 파일 생성: ```modelfile FROM huggingface:LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct PARAMETER temperature 0.7 PARAMETER top_p 0.9 PARAMETER top_k 40 PARAMETER num_ctx 4096 SYSTEM """You are EXAONE, a helpful AI assistant developed by LG AI Research.""" TEMPLATE """{{ if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant {{ .Response }}<|im_end|> """ ``` 2. 모델 생성: ```bash ollama create EXAONE-3.0-7.8B-Instruct -f EXAONE-3.0-7.8B-Instruct.modelfile ``` ### 방법 4: GGUF 변환 후 추가 (고급) Hugging Face 모델이 GGUF 형식이 아닌 경우, llama.cpp를 사용하여 변환해야 합니다. 1. llama.cpp 설치 및 빌드 2. 모델을 GGUF 형식으로 변환 3. 변환된 모델을 Ollama에 추가 자세한 내용은 [llama.cpp 문서](https://github.com/ggerganov/llama.cpp)를 참고하세요. ## 설치 확인 ```bash # 모델 목록 확인 ollama list # 모델 테스트 ollama run EXAONE-3.0-7.8B-Instruct "안녕하세요" ``` ## 문제 해결 ### 1. "file does not exist" 오류 - Hugging Face 토큰이 올바르게 설정되었는지 확인 - 모델 액세스 권한이 승인되었는지 확인 - Ollama 버전이 최신인지 확인 ### 2. 모델이 너무 큼 - 모델 크기는 약 15GB입니다 - 충분한 디스크 공간과 메모리가 필요합니다 - GPU 메모리 최소 16GB 권장 ### 3. 변환 오류 - 모델이 GGUF 형식이 아닌 경우, llama.cpp로 변환 필요 - 또는 Ollama의 최신 버전에서 Hugging Face 모델 직접 지원 여부 확인 ## 참고 자료 - [EXAONE-3.0-7.8B-Instruct 모델 페이지](https://huggingface.co/LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct) - [Ollama 공식 문서](https://github.com/ollama/ollama) - [EXAONE 기술 보고서](https://www.lgresearch.ai/data/upload/tech_report/ko/EXAONE_3.0_Technical_Report.pdf) ## 대안: 직접 Hugging Face 모델 사용 Ollama에 추가하는 것이 어려운 경우, Python에서 직접 Hugging Face 모델을 사용할 수도 있습니다: ```python from transformers import AutoModelForCausalLM, AutoTokenizer model = AutoModelForCausalLM.from_pretrained( "LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto" ) tokenizer = AutoTokenizer.from_pretrained("LGAI-EXAONE/EXAONE-3.0-7.8B-Instruct") ``` 하지만 이 경우 Ollama API와 통합하려면 추가 작업이 필요합니다.