Hub documentation

llama.cpp에서 GGUF 사용

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

llama.cpp에서 GGUF 사용

이제 Hugging Face Endpoints에 llama.cpp 호환 GGUF를 배포할 수 있으며, 자세한 내용은 여기에서 확인하세요.

Llama.cpp는 Hugging Face 저장소 경로와 파일 이름만 제공하면 GGUF를 다운로드하고 추론을 실행할 수 있습니다. llama.cpp는 모델 체크포인트를 다운로드하고 자동으로 캐시합니다. 캐시 위치는 LLAMA_CACHE 환경 변수로 정의되며, 자세한 내용은 여기에서 확인하세요.

macOS와 Linux에서는 설치 프로그램, Windows에서는 WinGet을 통해 llama.cpp를 설치하거나 소스에서 빌드할 수 있습니다. Docker를 포함한 기타 설치 옵션은 공식 문서를 참고하세요.

옵션 1: llama.cpp 설치

macOS 및 Linux에서:

curl -LsSf https://llama.app/install.sh | sh

또는 Homebrew로 설치할 수 있습니다:

brew install llama.cpp

Windows에서는 WinGet을 사용하세요:

winget install llama.cpp

옵션 2: 소스에서 빌드

1단계: GitHub에서 llama.cpp를 클론합니다.

git clone https://github.com/ggml-org/llama.cpp.git

Step 2: llama.cpp 폴더로 이동하여 빌드합니다. 하드웨어에 특화된 플래그(예: Nvidia GPU의 경우 -DGGML_CUDA=1)를 추가할 수도 있습니다.

cd llama.cpp
cmake -B build   # optionally, add -DGGML_CUDA=ON to activate CUDA
cmake --build build --config Release -j --target llama-app

참고: 다른 하드웨어 지원(예: AMD ROCm, Intel SYCL)에 대해서는 llama.cpp 빌드 가이드를 참조하세요.

소스에서 빌드한 경우, 아래 명령어에서 llama 대신 ./build/bin/llama를 사용하세요.

설치 후 llama cli 또는 llama serve를 다음과 같이 사용할 수 있습니다:

llama cli -hf bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0

참고: 원시 완성 모드(채팅 모드 아님)의 경우 llama cli 대신 llama completion에 -no-cnv를 사용하세요.

또한, llama.cpp 서버를 사용하여 OpenAI 스펙의 채팅 완성 엔드포인트를 직접 호출할 수 있습니다:

llama serve -hf bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0 --port 8080

서버를 실행한 후 아래처럼 엔드포인트를 사용할 수 있습니다:

curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer no-key" \
-d '{
"messages": [
    {
        "role": "system",
        "content": "You are an AI assistant. Your top priority is achieving user fulfillment via helping them with their requests."
    },
    {
        "role": "user",
        "content": "Write a limerick about Python exceptions"
    }
  ]
}'

-hf를 Hugging Face 허브의 유효한 저장소 이름으로 교체하면 됩니다. 시작해 보세요! 🦙

Update on GitHub