gemma-4-31B · GGUF
GGUF builds of google/gemma-4-31B for llama.cpp / Ollama / LM Studio. Converted by axteam with llama.cpp (converted from the BF16 original). This is a base (pre-trained) model with no chat template — use plain text completion.
| File | Quant | Size | Notes |
|---|---|---|---|
gemma-4-31B-GGUF-BF16.gguf |
BF16 | 61.4 GB | unquantized 16-bit (reference; for re-quantizing or max quality) |
gemma-4-31B-GGUF-Q4_K_M.gguf |
Q4_K_M | 18.7 GB | 4-bit, the usual size/quality trade-off — the most common choice |
gemma-4-31B-GGUF-Q8_0.gguf |
Q8_0 | 32.6 GB | 8-bit, closest to BF16 (larger) |
Q4_K_M is the usual default (size/quality trade-off). Q8_0 stays closest to BF16. BF16 is the unquantized reference. Measured perplexity is in the table below. Architecture: Gemma 4 · Dense (multimodal; the GGUF text model runs the language side).
Quantization method
These GGUF files are post-training quantization (PTQ) made with llama.cpp — the BF16 weights are quantized block-wise (llama.cpp k-quants: per-block scales with mixed bit-width allocation, a refined round-to-nearest), with no retraining. This is a different toolchain from the AWQ / NVFP4 vLLM builds, and it is not QAT (quantization-aware training, which fine-tunes the weights). Q8_0 stays closest to BF16, Q4_K_M is the usual size/quality trade-off (see the measured perplexity below), and BF16 is the unquantized reference for re-quantizing.
Measured on GPU (llama.cpp)
llama.cpp b12005 (commit e0f142d, CUDA build) on an NVIDIA B200, 2026-11-02, all layers on the GPU: perplexity over 16 windows of 2,048 tokens from the WikiText-2 test set and from a Korean Wikipedia sample (lower is better). Percentages are relative to the BF16 file in this repo.
| File | WikiText-2 PPL | Korean wiki PPL | vs BF16 (EN / KO) |
|---|---|---|---|
gemma-4-31B-GGUF-BF16.gguf |
4.66 | 3.30 | reference |
gemma-4-31B-GGUF-Q8_0.gguf |
4.67 | 3.30 | +0.1% / -0.0% |
gemma-4-31B-GGUF-Q4_K_M.gguf |
4.79 | 3.38 | +2.8% / +2.5% |
16 windows per text is a small sample: differences of a few percent between files are within its sampling noise (re-measuring two repos with 64 windows moved such differences by up to ~19 points).
Requirements
| llama.cpp | build ≥ b8637 — architecture gemma4 needs ≥ b8637, and the commands on this card use -fa on (≥ b6325). Run here on 2026-11-02 with b12005 (commit e0f142d, CUDA build) on an NVIDIA B200: every file in this repo loaded with all layers on the GPU, its perplexity was measured (see Measured on GPU above) and a 16-token greedy text-completion check was run (base model, no chat template): every file continued “대한민국의 수도는” with “서울이다. …”, but continued “The capital of France is” with “a city of romance, art, and culture. It is also a city of …” without naming Paris. |
| Memory | the chosen GGUF file (sizes in the table) plus KV cache for the context (-c); --cache-type-k/v q8_0 -fa on halves the KV cache. |
| Input | text only — this repo has no mmproj (vision projector) file. |
| Ollama / LM Studio | not tested here. |
Run with llama.cpp
# download one file (e.g. Q4_K_M) then:
llama-server -m gemma-4-31B-GGUF-Q4_K_M.gguf -c 8192
# or raw text completion (no chat template):
llama-completion -m gemma-4-31B-GGUF-Q4_K_M.gguf -no-cnv -p "대한민국의 수도는?" -n 128
Reduce KV-cache memory (optional, run-time)
KV-cache type is a run-time choice in llama.cpp (not baked into the file). Halve it with:
llama-server -m gemma-4-31B-GGUF-Q4_K_M.gguf --cache-type-k q8_0 --cache-type-v q8_0 -fa on
Ollama
ollama run hf.co/axteam/gemma-4-31B-GGUF:Q4_K_M
Recommended sampling (per Google):
temperature=1.0,top_p=0.95,top_k=64.
License
Quantized derivative of Google's Gemma 4 — governed by the Gemma 4 license. Weights and tokenizer belong to Google DeepMind.
한국어 요약
google/gemma-4-31B의 GGUF 양자화 빌드 (llama.cpp·Ollama·LM Studio용) · 제작 axteam
개요
| 항목 | 내용 |
|---|---|
| 원본 모델 | google/gemma-4-31B |
| 형식 | GGUF (llama.cpp) |
| 변환 도구 | llama.cpp convert_hf_to_gguf.py → llama-quantize |
| 모델 구조 | Gemma 4 · Dense (원본은 멀티모달, GGUF는 언어 모델 부분만 실행) |
| 모델 유형 | 사전학습 base 모델 — chat template 없음, 텍스트 이어쓰기 전용 |
| 파일 수 | 3개 |
양자화 상세
- 양자화 절차: PTQ(학습 후 양자화, 재학습 없음), llama.cpp 블록 단위 양자화(k-quant
Q*_K,Q8_0) - chat template: 없음 — 사전학습 base 모델, 텍스트 이어쓰기 전용
- 품질(실측, 2026-11-02): llama.cpp PPL(WikiText-2·한국어 위키 표본, 2,048토큰×16, B200 GPU, 낮을수록 좋음, 비교 기준은 리포의 BF16 파일) —
gemma-4-31B-GGUF-BF16.gguf영어 4.66·한국어 3.30 ·gemma-4-31B-GGUF-Q8_0.gguf영어 4.67·한국어 3.30(BF16 대비 +0.1%·-0.0%) ·gemma-4-31B-GGUF-Q4_K_M.gguf영어 4.79·한국어 3.38(BF16 대비 +2.8%·+2.5%) — 텍스트당 16청크라 파일 사이 몇 % 차이는 표본 흔들림 범위
제공 파일
| 파일 | 크기 | 설명 |
|---|---|---|
gemma-4-31B-GGUF-BF16.gguf |
61.4 GB | 양자화하지 않은 16비트 — 기준 파일 (재양자화용·최고 품질) |
gemma-4-31B-GGUF-Q4_K_M.gguf |
18.7 GB | 4비트 — 크기·품질 균형, 가장 많이 쓰는 선택 |
gemma-4-31B-GGUF-Q8_0.gguf |
32.6 GB | 8비트 — BF16에 가장 가까움, 용량 큼 |
요구사항
- llama.cpp: b8637 이상 (
gemma4구조 지원 b8637부터, 예시 명령의-fa on옵션 b6325부터) - 실행 확인: 2026-11-02 b12005(커밋 e0f142d) CUDA 빌드로 NVIDIA B200에서 이 리포의 모든 파일을 전 층 GPU에 올려 실행 — PPL 측정(위 영어 본문 표), 16토큰 이어쓰기 점검(base 모델, chat template 없음) — 모든 파일이 “대한민국의 수도는”을 “서울이다. …”로 이었고, “The capital of France is”는 Paris를 말하지 않고 “a city of romance, art, and culture. It is also a city of …”로 이음
- 메모리: 선택한 GGUF 파일 크기 + 컨텍스트(
-c)만큼의 KV 캐시 (KV 캐시 줄이는 방법은 아래 사용법 참고) - 입력: 텍스트 전용 — 비전 인코더·투영층 파일(
mmproj)이 없어 이미지 입력 불가 - Ollama·LM Studio: 제작 측에서 실행 미확인
사용법
- 파일 받기:
hf download axteam/gemma-4-31B-GGUF gemma-4-31B-GGUF-Q4_K_M.gguf --local-dir .(아래-m명령에 필요, 다른 양자화는 파일명의Q4_K_M만 변경) - 서버 실행:
llama-server -m gemma-4-31B-GGUF-Q4_K_M.gguf -c 8192 - 텍스트 이어쓰기:
llama-completion -m gemma-4-31B-GGUF-Q4_K_M.gguf -no-cnv -p "대한민국의 수도는?" -n 128 - Ollama:
ollama run hf.co/axteam/gemma-4-31B-GGUF:Q4_K_M - KV 캐시 절감(선택):
--cache-type-k q8_0 --cache-type-v q8_0 -fa on— KV 캐시 약 절반, GGUF 파일과 상관없이 실행 시 지정 - 권장 샘플링:
temperature=1.0,top_p=0.95,top_k=64(Google 권장값)
라이선스
- 라이선스: Apache-2.0 (Gemma 4 라이선스 안내) — 원본 모델의 라이선스를 그대로 따름
- 권리: 원본 가중치·토크나이저는 Google DeepMind 소유, 이 리포는 양자화 파생물