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 환경 변수로 정의되며, 자세한 내용은 여기에서 확인하세요.

llama.cpp는 brew(Mac 및 Linux에서 작동)를 통해 설치하거나 소스에서 빌드할 수 있습니다. 공식 문서에서 확인할 수 있는 사전 빌드된 바이너리와 Docker 이미지도 있습니다.

옵션 1: brew/ winget로 설치

brew install llama.cpp

또는 Windows에서 winget을 통해

winget install llama.cpp

옵션 2: 소스에서 빌드

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

git clone https://github.com/ggerganov/llama.cpp

Step 2: Move into the llama.cpp folder and build it. You can also add hardware-specific flags (for ex: -DGGML_CUDA=1 for Nvidia GPUs).

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

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

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

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

참고: -no-cnv를 명시적으로 추가하여 CLI를 원시 완성 모드(채팅 모드 아님)로 실행할 수 있습니다.

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

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

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

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