3B–14B Open-Source LLMs: Selection and Deployment on a Single GPU

    A practical guide to evaluating and deploying 3B, 7B, and 14B open-source models on a single GPU with 12–24 GB of VRAM. Learn how to set task-specific acceptance thresholds, estimate memory requirements, compare quantization formats, run a local evaluation script, and manage deployment risks and rollback.

    1. Scope and Limitations

    Strong model capabilities were once widely associated with large parameter counts and multi-GPU clusters. Over the past year or two, open-source models in the 3B–14B range have made substantial progress in reasoning, coding, and tool calling. They can run on a single GPU, keep data on the local machine, and make per-request inference costs easier to predict.

    Comparable capabilities do not make a model a drop-in replacement for an existing solution. Before choosing one, answer three questions: Which tasks can it handle adequately? Is the deployment cost acceptable? How serious are the consequences of failure?

    This guide applies only to:

    • Hardware: A single consumer or professional GPU with 12–24 GB of VRAM.
    • Models: Parameter sizes of 3B, 7B, and 14B.
    • Deployment: Single-machine inference services, without multi-GPU tensor parallelism or multi-node clusters.

    The memory estimates and thresholds below should not be applied directly outside these boundaries.

    2. Four-Dimensional Evaluation: Define Tasks Before Thresholds

    2.1 Can an Aggregate Benchmark Score Determine Model Selection?

    No. An aggregate score combines results from multiple public benchmarks using weighted averages. It is useful for initial screening, not final selection.

    Common benchmarks include MMLU, C-Eval, HumanEval, GSM8K, and the Berkeley Function Calling Leaderboard. Their weights are chosen by the evaluator and may not reflect your workload.

    Before evaluating candidates, record the benchmark names, versions, sampling methods, and evaluation date. Make the final decision using samples from your own use cases.

    2.2 Calibrating Acceptance Thresholds

    Dimension Samples and sources Initial threshold Cost of an incorrect assessment Controls
    General capability 50 samples from public benchmarks plus 50 internal samples At least 80% accuracy on internal samples Selecting a model that does not fit the workload Prioritize internal samples; use public benchmarks only as a reference
    Agent tasks 100 cases from a custom tool-calling test set At least 95% argument-format accuracy and 80% task completion Incorrect calls may trigger real business operations Require human approval before write operations and validate tool arguments against allowlists
    Knowledge accuracy 200 samples from the business knowledge base At least 90% accuracy on critical facts; abstain when uncertain Hallucinated conclusions that appear credible Route high-risk conclusions to human review and require supporting sources
    Multimodal understanding 100 images from the target workload At least 90% recognition accuracy for key fields Text-only models cannot process image inputs Confirm image support first; otherwise skip this dimension or choose another model

    These thresholds are starting points. Raise them when errors could directly cause financial loss or compliance problems. If a human reviewer can catch errors, lower thresholds may be acceptable in exchange for lower deployment costs.

    Sample size determines how much confidence to place in the results. A normal approximation gives a rough 95% confidence interval with a half-width of:

    1. 1.96 × √(p(1 − p) / n)

    With 50 samples and 80% accuracy, the half-width is approximately 11 percentage points, giving an estimated interval of 69%–91%. This can distinguish clearly weaker models, but not models with similar performance.

    With 200 samples and 90% accuracy, the half-width is approximately four percentage points. If two models’ intervals overlap substantially, do not treat the results as clear evidence that one is better.

    3. Estimating VRAM and Comparing Quantization Formats

    GPU memory consumption has three main components:

    1. VRAM ≈ model weights + KV cache + framework and CUDA runtime overhead

    Weight memory can be estimated as:

    1. Weight memory ≈ parameter count × bytes per parameter

    FP16 uses two bytes per parameter, INT8 uses one byte, and INT4 uses approximately half a byte. Quantized formats also include metadata such as scaling factors, so actual memory usage is slightly higher than the theoretical estimate.

    KV cache memory can be estimated as:

    1. KV cache memory ≈ 2 × number of layers × number of KV heads
    2. × head dimension × context length × batch size
    3. × bytes per element

    The number of layers, KV heads, and head dimension can be found in the model directory’s config.json. Longer contexts and larger batches increase KV cache usage. Long-text workloads are particularly likely to exhaust VRAM here.

    The following table provides rough weight-only estimates in decimal GB. It excludes the KV cache and framework overhead. “Headroom” means the memory remaining after loading the weights, which must accommodate those additional components.

    Model size Precision Estimated weight memory 12 GB GPU 24 GB GPU
    3B FP16 About 6 GB Weights fit; about 6 GB headroom Weights fit; ample headroom
    3B INT8 About 3 GB Weights fit Weights fit
    3B INT4 About 1.5 GB Weights fit Weights fit
    7B FP16 About 14 GB Weights do not fit Weights fit; about 10 GB headroom
    7B INT8 About 7 GB Weights fit; about 5 GB headroom Weights fit
    7B INT4 About 3.5 GB Weights fit Weights fit
    14B FP16 About 28 GB Weights do not fit Weights do not fit
    14B INT8 About 14 GB Weights do not fit Weights fit; about 10 GB headroom
    14B INT4 About 7 GB Weights fit; about 5 GB headroom Weights fit

    Use these figures only to narrow the candidate list. Measure actual memory consumption before deployment.

    For each measurement, record:

    • GPU model and driver version.
    • Inference framework and version.
    • Quantization method and source.
    • Context length.
    • Batch size and concurrency.

    Sample GPU memory usage with:

    1. nvidia-smi --query-gpu=name,memory.used,memory.total --format=csv -l 1

    Compare quantization formats using the same workload samples. Evaluate both FP16 and the target quantized version. If the accuracy loss exceeds the acceptable tolerance for an evaluation dimension, do not use that quantized version.

    This guide does not provide throughput or per-request inference cost figures because they depend heavily on hardware, framework, and concurrency. Before launch, load-test candidates under the same workload and record generated tokens per second and time to first token.

    4. Local Evaluation Script and Execution Steps

    4.1 Prepare the Environment

    The inference service must expose an OpenAI-compatible API, such as one provided by vLLM or llama.cpp server. Once the service is running, the script uses this endpoint by default:

    1. http://127.0.0.1:8000/v1/chat/completions

    The script requires only the Python standard library and runs on Python 3.8 or later.

    1. python -m venv .venv
    2. source .venv/bin/activate # On Windows, use .venv\Scripts\activate

    4.2 Input Format

    Store test cases in a JSONL file, with one case per line:

    1. {"id":"q001","prompt":"What is the main difference between lists and tuples in Python?","expected":"mutable","rule":"contains"}

    The supported matching rules are:

    • contains: The output contains expected.
    • exact: The output matches expected exactly after leading and trailing whitespace is removed.

    The default rule is contains.

    4.3 Evaluation Script

    Save the following code as eval.py. Set MODEL to the model name loaded by the server.

    1. import csv
    2. import json
    3. import sys
    4. import time
    5. import urllib.request
    6. ENDPOINT = "http://127.0.0.1:8000/v1/chat/completions"
    7. MODEL = "your-model-name"
    8. TIMEOUT = 120
    9. def ask(prompt):
    10. body = json.dumps({
    11. "model": MODEL,
    12. "messages": [{"role": "user", "content": prompt}],
    13. "temperature": 0,
    14. "max_tokens": 256,
    15. }).encode("utf-8")
    16. req = urllib.request.Request(
    17. ENDPOINT, data=body, headers={"Content-Type": "application/json"}
    18. )
    19. with urllib.request.urlopen(req, timeout=TIMEOUT) as resp:
    20. data = json.load(resp)
    21. return data["choices"][0]["message"]["content"]
    22. def judge(output, expected, rule):
    23. if rule == "exact":
    24. return output.strip() == expected.strip()
    25. if rule == "contains":
    26. return expected.strip() in output
    27. raise ValueError(f"unknown rule: {rule}")
    28. def main():
    29. if len(sys.argv) != 4:
    30. print("Usage: python eval.py cases.jsonl result.csv 0.80", file=sys.stderr)
    31. return 2
    32. cases_path, out_path = sys.argv[1], sys.argv[2]
    33. threshold = float(sys.argv[3])
    34. try:
    35. with open(cases_path, encoding="utf-8") as f:
    36. cases = [json.loads(line) for line in f if line.strip()]
    37. except (OSError, json.JSONDecodeError) as e:
    38. print(f"Failed to read test cases: {e}", file=sys.stderr)
    39. return 2
    40. passed = 0
    41. rows = []
    42. for case in cases:
    43. rule = case.get("rule", "contains")
    44. start = time.time()
    45. try:
    46. output = ask(case["prompt"])
    47. except OSError as e:
    48. print(f"Inference endpoint unreachable or request timed out: {e}",
    49. file=sys.stderr)
    50. return 3
    51. latency = time.time() - start
    52. ok = judge(output, case["expected"], rule)
    53. passed += int(ok)
    54. rows.append([case["id"], rule, int(ok), round(latency, 2), output[:200]])
    55. with open(out_path, "w", encoding="utf-8", newline="") as f:
    56. writer = csv.writer(f)
    57. writer.writerow(["id", "rule", "passed", "latency_s", "output_head"])
    58. writer.writerows(rows)
    59. rate = passed / len(cases) if cases else 0.0
    60. print(f"Samples={len(cases)} Passed={passed} Accuracy={rate:.2%} "
    61. f"Threshold={threshold:.2%}")
    62. return 0 if rate >= threshold else 1
    63. if __name__ == "__main__":
    64. sys.exit(main())

    4.4 Run the Evaluation and Interpret Exit Codes

    1. python eval.py cases.jsonl result.csv 0.80

    The third argument specifies the required pass rate. The result file contains each sample’s ID, matching rule, pass/fail result, elapsed time, and the first 200 characters of the output.

    Exit codes are defined as follows:

    Exit code Meaning
    0 Accuracy meets or exceeds the threshold
    1 Accuracy is below the threshold
    2 Invalid arguments or a problem with the sample file
    3 The inference endpoint is unreachable or the request times out

    4.5 Data Handling and Compliance

    • Follow the original dataset licenses when using public benchmark samples. Do not copy them directly into public-facing documents.
    • De-identify business samples before storing them. Replace phone numbers, government-issued ID numbers, customer names, and similar information with placeholders.
    • Store result.csv in an access-controlled directory. Do not upload complete model outputs to logging platforms.

    5. Troubleshooting and Pre-Deployment Risk Checks

    5.1 Common Problems and Diagnostic Steps

    • Out of memory (OOM): First reduce context length and max_tokens, then reduce concurrency and batch size. If memory is still insufficient, use a lower-precision version or a smaller model.
    • Tokenizer or chat-template mismatch: Compare the chat_template in the local tokenizer_config.json with the template actually used by the server. A mismatch can substantially reduce output quality for the same question. Align the templates and rerun the evaluation.
    • Accuracy loss after quantization: Compare FP16 and quantized versions using the same samples. Do not deploy a version whose accuracy loss exceeds the acceptable tolerance.
    • Invalid tool-call format: Parse model outputs as JSON and validate them against a schema. Count invalid outputs as failures and do not execute them. One retry may be allowed, but retry outcomes must be included in the statistics rather than retaining only the successful attempt.
    • VRAM fragmentation: If memory usage keeps rising during long-running operation, a PyTorch backend can use PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True. Periodically restart the service and perform health checks.

    5.2 Pre-Deployment Risk Checklist

    Risk Check Control
    Incorrect tool calls trigger real business operations Do all write operations require human approval? Require approval before writes and validate tool arguments against allowlists
    Hallucinated outputs appear credible Do high-risk conclusions include supporting sources? Route high-risk conclusions to human review; abstain when sources are unavailable
    Quality declines after deployment Does the production input distribution match the evaluation samples? Continue sampled evaluations in production and update the test set regularly
    Rollback fails Are the previous model and configuration retained? Keep the previous model files and configuration; make switching possible through a single change
    Data leakage Do logs or result files contain sensitive information? De-identify logs and restrict access to result files

    5.3 Rollback and Human Approval

    Before deployment, retain the previous model and service configuration. Roll back if accuracy declines, requests time out, or output formats become invalid.

    After switching back, rerun the same evaluation samples to confirm that the metrics have recovered. Automated actions involving deletion, sending, deployment, or permission changes must receive human approval before execution.

    The figures in this guide are starting points for model selection, not guarantees that any model will work for your workload. Validate candidates against your own samples before deployment, and record the sample size and consequences of failure behind each conclusion.