PaliGemma 2 Model Selection and Deployment Checklist
PaliGemma 2 is Google's vision-language model family built from a SigLIP vision encoder and a Gemma 2 language model. This guide provides a practical framework for evaluating, selecting, fine-tuning, quantizing, and deploying PaliGemma 2 variants, with checklists for evaluation sets, resolution routing, structured output, metrics, and risk controls.
PaliGemma 2 is a family of vision-language models released by Google, combining a SigLIP vision encoder and a Gemma 2 language model. It performs well on OCR, document parsing, chart understanding, and table understanding, but these capabilities vary widely across business data. Before selecting a variant, teams should build an evaluation set from their own samples, then decide on model size and resolution.
The structural parameters in this article come from official public materials. Actual accuracy, memory usage, and latency must be measured on your own hardware and data. The thresholds given here are starting points and should be adjusted according to the business cost of errors.
1. Build the Evaluation Set Before Choosing a Model
The evaluation set determines whether all later judgments are reliable. Extract samples from real business data and cover three categories:
- Common samples: the majority, representing daily inputs.
- Hard samples: small text, low contrast, skew, handwriting, cross-page tables, etc., about one third of the set.
- Anomalous samples: blank images, blurry images, and malformed documents, used to check whether the model hallucinates results.
Each category must have ground truth. Before annotation, write an annotation manual that specifies field definitions, formats, and ambiguity handling. Key samples should be independently annotated by two people, and inconsistencies should be arbitrated.
Keep the evaluation set separate from later fine-tuning data. Different pages of the same document or different versions of the same template should be assigned as a whole to the same split to avoid leakage between training and test sets.
2. How to Choose Between 3B, 10B, and 28B
| Variant | Language backbone | Suitable scenarios | Test order | Upgrade condition |
|---|---|---|---|---|
| 3B | Gemma 2 2B | High concurrency, low latency, on-device or edge devices | Test first | Key metrics are not met, and the gap is concentrated in model capability rather than input quality |
| 10B | Gemma 2 9B | General image Q&A, content moderation, medium-complexity documents | Test when 3B is insufficient | Medium-complexity tasks pass, but complex layouts still fail |
| 28B | Gemma 2 27B | Complex layouts, dense charts, multi-step visual reasoning | Test when the first two variants are insufficient | Enable only if memory and latency budgets allow |
Test the three variants sequentially on the same batch of samples. For each run, record accuracy, average time per image, P95 latency, and peak memory.
Memory usage can be roughly estimated first. In bf16, each parameter takes about 2 bytes, so 3B is about 6 GB, 10B about 20 GB, and 28B about 56 GB. This is only a lower bound for model weights. Activations, visual token caches, and inference framework overhead must be added separately, so actual memory requirements will be higher. Use estimates only to rule out clearly infeasible variants; final selection should be based on measurements.
The goal of model selection is to find the smallest variant that meets the metrics with acceptable cost, not the one with the largest parameter count.
3. Resolution Cost and Routing
According to official configurations, the vision encoder divides an image into 14-pixel patches. The table below shows theoretical calculations:
| Resolution | Patch grid | Visual tokens | Token count relative to 224 | Attention relative to 224 (theoretical) |
|---|---|---|---|---|
| 224 | 16×16 | 256 | 1 | 1 |
| 448 | 32×32 | 1024 | 4 | 16 |
| 896 | 64×64 | 4096 | 16 | 256 |
Attention computation scales approximately quadratically with token count, while linear layers and memory usage scale approximately linearly. The two multipliers differ, so theoretical values cannot be used directly as latency predictions.
Resolution measurement steps:
- Fix batch size, image size, and generation length.
- Warm up several times to exclude first-load effects.
- Record peak memory, P50 and P95 latency, and requests per second for each resolution.
- Record accuracy on the same evaluation set to confirm whether the improvement is worth the extra cost.
Routing rules can be implemented with simple methods first and replaced gradually. For example:
- Use 224 when the image content is mostly large graphics and has no recognizable small text.
- Use 448 when many text lines are detected, or when the document type label is receipt, table, or manual.
- Use 896 when the document type label is scanned document or complex chart, or when 448 output confidence is low.
Thresholds such as number of text lines should be calibrated with your own samples; do not copy the example numbers directly.
Routing will misclassify. Design the fallback strategy in advance. A common approach is: when structured output parsing fails at 224, rerun at 448; if 448 still fails, go to 896 or a human queue. Record every fallback and track the fallback ratio. If the fallback ratio remains high, the routing rules need adjustment.
4. Fine-Tuning Data and Workflow
Before fine-tuning, confirm the zero-shot or few-shot performance of 3B or the target variant and record the gap. Fine-tuning is meaningful only when the gap is clear and can be covered by training data.
Data can start with a few hundred examples. After training, observe changes in validation metrics. If adding data no longer clearly improves metrics, stop expanding. Blindly piling up data usually only increases annotation cost.
Try training strategies in the following order:
- Freeze the vision encoder and train only the language side. This is low-cost and suitable for learning text output formats.
- Use parameter-efficient fine-tuning, such as LoRA, to adjust a small number of parameters.
- If the first two approaches are insufficient, consider broader training. Compare each step with the baseline and record gains and signs of overfitting.
Keep a regression test set of general samples for every training run. After fine-tuning, model performance on original tasks may drop; this is called catastrophic forgetting. If general test set metrics drop beyond a set value, pause rollout.
Training data must be de-identified. Samples containing names, ID numbers, phone numbers, or addresses should be redacted before storage. Access to training data should be limited to necessary personnel.
5. Quantization and Deployment Testing
Quantization can reduce memory usage and latency but loses accuracy. Compare quantization options on the same evaluation set:
| Option | Description | Data to record |
|---|---|---|
| bf16 baseline | Unquantized reference version | Accuracy, memory, latency |
| 8-bit quantization | Accuracy loss is usually small | Accuracy, memory, and latency changes relative to baseline |
| 4-bit quantization | Largest gains and largest risk | Same as above, plus changes on small-text and table tasks recorded separately |
Choose quantization tools compatible with the existing inference framework. Calibration data must come from business-domain samples. Using random images for calibration will make quantization parameters deviate from the actual input distribution.
The vision encoder is sensitive to small text and thin lines. Compare two configurations separately: quantizing only the language side, and quantizing both the vision encoder and language side. If the latter shows a clear accuracy drop on hard samples, keep the vision encoder at higher precision.
Write acceptance criteria in advance. For example, if key metrics drop more than 1 percentage point relative to baseline, do not deploy the option. This number is only a starting point; determine it based on the business loss caused by errors.
After a quantized version launches, keep a rollback path. On anomaly, switch back to bf16 or a higher variant and notify relevant people.
6. Structured Output Checklist
Most business use cases need structured results such as JSON, not free text. The checklist below can be reviewed item by item:
- The prompt specifies the JSON structure and field meanings, with fixed field names.
- Fields not found in the image output null consistently; the model must not guess.
- Numeric fields specify units and reasonable ranges; out-of-range results go to review.
- Validate output with a JSON parser and schema. On validation failure, retry at most 2 times; if still failing, go to rule-based parsing or a human queue.
- If the inference framework supports constrained decoding, prefer grammar constraints to reduce format errors.
Acceptance metrics for structured output include JSON parse rate, schema pass rate, field-level accuracy, retry rate, and human review rate. Re-measure these metrics after every model or resolution change.
7. Test Metrics and Acceptance Thresholds
The table below gives evaluation criteria for each task. The thresholds are suggested starting points and should be adjusted before launch according to business requirements.
| Task | Metric | Test set construction | Suggested starting threshold |
|---|---|---|---|
| OCR | Character error rate (CER), word error rate (WER) | Samples covering small text, handwriting, and scans | Set according to business error cost, and report separately on hard samples |
| Table recognition | Cell-level accuracy or structural similarity | Samples with cross-page and merged cells | Deploy after key-field accuracy reaches a business-acceptable level |
| Chart QA | Exact match accuracy plus manual sampling | Same-color multi-line charts and dual-axis charts | Sampling error rate below a set value |
| Image captioning | Human rating: relevance, completeness, hallucination rate | Randomly sample more than 100 items; two independent raters | Set a separate upper limit for hallucination rate; do not deploy if exceeded |
| Structured output | JSON parse rate, schema pass rate | Samples covering abnormal and blank images | Both metrics should be close to 100%; failing samples enter the fallback flow |
The hallucination rate for image captioning must be judged manually: if the description contains an object, text, or number that does not exist in the image, it counts as one hallucination.
Hard samples should be counted separately. Overall accuracy can mask severe failures on small-text and low-contrast samples.
8. Deployment and Risk Control
896-resolution requests have high compute demand and should use a separate queue to avoid slowing other requests. Queue configuration includes:
- Rate limiting: set an upper limit by concurrency or requests per second.
- Timeout: return requests that exceed the set time instead of waiting indefinitely.
- Degradation: when the queue is too long or a timeout occurs, automatically use 448 and record the degradation ratio.
Monitoring should cover P50 and P95 latency, error rate, degradation ratio, peak memory, and structured output validation failure rate. Alerts should be triggered when these metrics are abnormal.
Data privacy requires separate consideration. Images may contain personally identifiable information, financial data, or medical records. When processing such data:
- Process sensitive data locally or in a private environment, not through third-party APIs.
- Do not record raw images or full recognized text in logs; record only necessary metadata.
- Set a data retention period and delete data automatically on expiration.
Model licenses need verification. Read the relevant Gemma license terms before use and confirm that commercial use and distribution comply with the requirements.
Pre-launch checklist:
- The evaluation set covers common, hard, and anomalous samples and has been double-annotated.
- Variant selection is supported by measured data, with accuracy, latency, and memory recorded.
- Resolution routing and fallback rules have been tested, and the fallback ratio is within an acceptable range.
- Fine-tuning results have been compared with the baseline, and regression tests on general tasks pass.
- The accuracy loss of the quantized version is within acceptance thresholds, and a rollback version is retained.
- Structured output validation, retries, and the human queue are integrated.
- Rate limiting, timeouts, and degradation for the 896 queue have been verified.
- Monitoring and alerts are configured, and sensitive data handling has been confirmed.
Completing this checklist item by item helps teams determine whether the model fits their business and quickly locate causes when problems occur.
