# Hugging Face Hub의 모든 GGUF 모델과 Ollama 사용

![cover](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/ollama/cover.png)

Hugging Face Hub에서 비공개 GGUF도 실행할 수 있습니다.

Ollama는 llama.cpp 기반의 애플리케이션으로, 컴퓨터를 통해 LLM과 직접 상호작용할 수 있습니다. Hugging Face에서 커뮤니티가 생성한 모든 GGUF quants([bartowski](https://huggingface.co/bartowski), [MaziyarPanahi](https://huggingface.co/MaziyarPanahi) 및 [많은 기타](https://huggingface.co/models?pipeline_tag=text-generation&library=gguf&sort=trending))를 새로운 `Modelfile`을 생성하지 않고 Ollama에서 바로 사용할 수 있습니다. 작성 시점 기준 Hub에는 45K개의 공개 GGUF checkpoints가 있으며, 이 중 어떤 것이든 단일 `ollama run` 명령어로 실행할 수 있습니다. 또한 전체적인 경험을 개선하기 위해 양자화 유형, 시스템 프롬프트 선택 등 다양한 커스터마이징 옵션을 제공합니다.

시작하는 방법은 다음과 같이 간단합니다:

1. `ollama`를 [로컬 앱 설정](https://huggingface.co/settings/local-apps)에서 활성화하세요.
2. 모델 페이지에서 `Use this model` 드롭다운에서 `ollama`를 선택합니다. 예를 들어: [bartowski/Llama-3.2-1B-Instruct-GGUF](https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF).

snippet은 다음과 같은 형식입니다:

```sh
ollama run hf.co/{username}/{repository}
```

`hf.co`와 `huggingface.co` 두 도메인 이름을 모두 사용할 수 있습니다.

다음은 시도해 볼 수 있는 모델들입니다:

```sh
ollama run hf.co/bartowski/Llama-3.2-1B-Instruct-GGUF
ollama run hf.co/mlabonne/Meta-Llama-3.1-8B-Instruct-abliterated-GGUF
ollama run hf.co/arcee-ai/SuperNova-Medius-GGUF
ollama run hf.co/bartowski/Humanish-LLama3-8B-Instruct-GGUF
```

## 사용자 정의 양자화

기본적으로 모델 저장소에 `Q4_K_M` 양자화 스킴이 포함된 경우 해당 스킴이 사용됩니다. 그렇지 않으면 저장소 내에 존재하는 합리적인 양자화 유형 중 하나를 기본으로 선택합니다.

다른 스킴을 선택하려면 다음을 수행합니다:

1. 모델 페이지의 `Files and versions` 탭에서 특정 GGUF 파일의 GGUF 뷰어를 엽니다.
2. `Use this model` 드롭다운에서 `ollama`를 선택합니다.

다음 스니펫은 (양자화 태그가 추가된) 형식입니다:

```sh
ollama run hf.co/{username}/{repository}:{quantization}
```

예를 들어:

```sh
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:IQ3_M
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0

# the quantization name is case-insensitive, this will also work
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:iq3_m

# you can also directly use the full filename as a tag
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Llama-3.2-3B-Instruct-IQ3_M.gguf
```

## 사용자 지정 Chat Template 및 매개변수

기본적으로 일반적으로 사용되는 템플릿 목록에서 템플릿이 자동으로 선택됩니다. GGUF 파일 내부에 저장된 내장 `tokenizer.chat_template` 메타데이터를 기반으로 선택됩니다.

GGUF 파일에 내장된 템플릿이 없거나 채팅 템플릿을 사용자 지정하려면 저장소에 `template`이라는 새 파일을 만들 수 있습니다. 템플릿은 Jinja 템플릿이 아닌 Go 템플릿이어야 합니다. 예시는 다음과 같습니다:

```
{{ if .System }}<|system|>
{{ .System }}<|end|>
{{ end }}{{ if .Prompt }}<|user|>
{{ .Prompt }}<|end|>
{{ end }}<|assistant|>
{{ .Response }}<|end|>
```

Go 템플릿 형식에 대해 자세히 알아보려면 [이 문서](https://github.com/ollama/ollama/blob/main/docs/template.mdx)를 참조하세요.

저장소에 `system`이라는 이름의 새 파일을 추가하여 시스템 프롬프트를 선택적으로 구성할 수 있습니다.

샘플링 매개변수를 변경하려면 저장소에 `params`라는 이름의 파일을 생성하세요. 파일은 JSON 형식이어야 합니다. 사용 가능한 모든 매개변수 목록은 [이 문서](https://github.com/ollama/ollama/blob/main/docs/modelfile.mdx#parameter)를 참고하세요.

## Hugging Face Hub에서 Private GGUF 실행

개인 계정 또는 연결된 조직 계정에서 개인용 GGUF를 두 단계로 실행할 수 있습니다:

1. Ollama SSH 키를 복사하세요. 다음 명령을 통해 수행할 수 있습니다: `cat ~/.ollama/id_ed25519.pub | pbcopy`
2. [계정 설정](https://huggingface.co/settings/keys)으로 이동하여 `Add new SSH key`를 클릭하고 Hugging Face 계정에 해당 키를 추가하세요.
3. 이것으로 끝입니다! 이제 Hugging Face Hub에서 개인 GGUF를 실행할 수 있습니다: `ollama run hf.co/{username}/{repository}`.

## 참고

- https://github.com/ollama/ollama/blob/main/docs/README.md
- https://huggingface.co/docs/hub/ko/gguf

