CoolFace
Modelpublic

Arm/ernie-4-5-0-3b-pt-q4-k-m-llamacpp-raspberrypi5

sourceHugging Faceapache-2.0updated 19d agoView on Hugging Face
0likes161downloads
Model Card

ERNIE-4.5-0.3B-PT optimized for Arm-based Edge Linux

ERNIE-4.5-0.3B-PT optimized for text generation in GGUF format with the llama.cpp runtime, targeting Arm-based Edge Linux systems.

Summary

This repository contains an Arm-optimized version of baidu/ERNIE-4.5-0.3B-PT for text generation. The model is provided as a GGUF file for the llama.cpp runtime, targeting Edge Linux systems.

The weights are quantized to Q4KM (K-quant, 4-bit weights with per-block scales) using llama.cpp's post-training quantization pipeline, guided by a llama-imatrix importance matrix calibrated on WikiText-2. Inference runs on CPU through llama.cpp.

This version is intended to demonstrate efficient inference on Arm-based platforms while preserving the original model's intended behavior. Arm has evaluated this model on MMLU and measured performance on a representative evaluation target.

Key results

AreaResult
Model formatGGUF (llama.cpp)
Target device classEdge Linux
Reference deviceRaspberry Pi 5 (Cortex-A76, Debian GNU/Linux 13 (trixie))
Primary performance result43.32 tokens/sec, 2068.29 ms time-to-first-token
Accuracy resultMMLU 5-shot 35.97%
Size / memory result229.50 MB model size, 515.28 MB peak memory

Original model

FieldValue
Original modelbaidu/ERNIE-4.5-0.3B-PT
Original sourceHugging Face
Original developerBaidu
Original model cardbaidu/ERNIE-4.5-0.3B-PT
Original licenseApache-2.0

Model files

FileDescription
baidu__ERNIE-4.5-0.3B-PT_llamacpp_optimized.ggufArm-optimized model for deployment
example.pyMinimal inference example
pyproject.tomlPinned runtime dependencies for example.py, resolved with uv
uv.lockLocked dependency resolution for pyproject.toml
config.yamlModel I/O contract used by the example
benchmarks/FP32 baseline and Arm-optimized benchmark records

Performance

Performance was measured on the reference configuration below. Results are intended to make the optimization reproducible but do not guarantee identical performance on every Arm-based system.

Reference configuration

FieldValue
Device / platformRaspberry Pi 5
CPU / acceleratorCortex-A76, 4 cores at 2.4 GHz, 8 GB system memory, cpu execution backend
OSLinux Raspberry Pi OS Trixie
Runtimellama.cpp
Backend / delegateKleidiAI
Batch size1
PrecisionQ4KM, K-quant
Runs100 measured runs, 512-token prompt, 128-token generation

Performance results

MetricOriginal / baselineArm-optimizedImprovement
Tokens per second14.0943.323.07 x
Time to first token5008.46 ms2068.29 ms2.42 x faster
p50 latency14092.42 ms5022.88 ms2.81 x faster
Model size690.42 MB229.50 MB3.01 x smaller
Peak memory748.91 MB515.28 MB1.45 x less

Accuracy

Accuracy was evaluated using the same preprocessing, input resolution, and evaluation protocol described below. Where possible, the optimized model is compared against the original model under the same evaluation conditions.

Evaluation setup

FieldValue
DatasetMMLU (cais/mmlu)
Splittest, 5-shot MCF, stratified across 57 subjects (seed 42)
Number of samples4498, stratified with a per-subject cap of 200 samples
Metric(s)MMLU 5-shot accuracy
Evaluation runtimellama.cpp

Accuracy results

MetricOriginal / baselineArm-optimizedChange
MMLU 5-shot accuracy38.02%35.97%-2.05 pp

Accuracy was measured using the evaluation setup described above. Users should re-evaluate the model on their own data before production use.

Arm optimization approach

Arm optimized this model for efficient inference on Arm-based platforms using a hardware-aware conversion and validation flow.

For this release, Arm used:

Optimization areaApplied?Notes
Model conversionYesConverted to GGUF via llama.cpp's converthfto_gguf.py
QuantizationYesK-quant post-training quantization, Q4KM variant (4-bit weights with per-block scaling), calibrated with a llama-imatrix importance matrix on WikiText-2 (200 samples, 800 imatrix chunks)
Runtime/backend selectionYesllama.cpp CPU backend with Arm KleidiAI kernels, 4 threads
Graph/runtime compatibility updatesYesPerformed as part of the llama.cpp GGUF conversion pipeline (converthfto_gguf.py + llama-quantize)
Accuracy validationYesCompared against the original model or published baseline
Performance validationYesMeasured on the reference Arm platform

The goal of this process is to improve deployment characteristics such as latency, memory use, model size, and runtime compatibility while preserving the model's intended behavior. Detailed conversion scripts, calibration configuration, or backend-specific implementation details may be provided separately where appropriate.

Using this model

Install dependencies

Dependencies are declared in pyproject.toml, which ships with this repository. Resolve and install them into a local virtual environment with uv:

bash
uv python install
uv sync --frozen

Run the example

bash
uv run example.py

The example prints its response without modifying the included expected result. To also save the result as JSON, pass an explicit output path:

bash
uv run example.py --output result.json

Expected input

PropertyValue
Input shape[1, T], where T is the runtime sequence length bounded by n_ctx
Input typeint32 token ids
Input rangeToken ids from the tokenizer embedded in the .gguf (vocabulary size 103424)
PreprocessingApply the model's chat template (embedded in the GGUF from chat_template.jinja), then tokenize with the embedded tokenizer; no extra BOS token is added because the template emits its own (`<\beginofsentence\>`)

Expected output

PropertyValue
Output shapeNext-token logits over the 103424-token vocabulary
Output typeLogits; the runtime samples one token id per decode step
PostprocessingDecode token ids with the embedded tokenizer; stop on the eos token (id 2) or the max_tokens budget

This pre/postprocessing is handled internally by create_chat_completion in example.py; the script itself only passes a prompt in and reads text out.

Intended use

This model is intended for developers evaluating text generation workloads on Arm-based platforms. It is suitable as a reference implementation for benchmarking, prototyping, and integration exploration.

Limitations

  • —Performance depends on the target device, runtime version, backend/delegate support, memory configuration, and system load.
  • —Accuracy was evaluated on the MMLU test split subset described above and may not generalize to all domains.
  • —This release preserves the original model's intended task and behavior, but users should validate it for their own application, data, and deployment environment.
  • —This repository is not a replacement for the original model documentation.

Additional notes

  • —The p50 latency is derived, not directly measured: llama-bench reports per-phase averages only, so the p50 is the sum of the prefill and decode averages standing in for one request. No p90 or p99 is available; the per-phase throughputs are the primary numbers.
  • —Prefill throughput was also measured: 102.23 tokens/sec for the f16 reference and 247.55 tokens/sec for the Q4KM build.
  • —MMLU was evaluated on a stratified subset of the test split rather than the full test set.
  • —Prefill gains less than decode: decode at this model size is memory-bandwidth-bound and scales with bytes-per-weight, while prefill is compute-bound, and Cortex-A76 has dotprod but not i8mm, so KleidiAI's INT8 GEMM kernels fall back to dotprod-only paths. Devices with i8mm should see a larger prefill gain.
  • —GGUF quantizes the graph uniformly — there is no per-module skip list. ERNIE-4.5-0.3B ties its input and output embeddings, so no separate embedding or LM-head precision promotion was applied.
  • —Benchmarks were run at 4 threads on a 4-core Raspberry Pi 5 with a 512-token prompt and 128-token generation. Other thread counts, prompt lengths, and context sizes are not measured here.

About this version

Original Model: baidu/ERNIE-4.5-0.3B-PT by Baidu - Repository

Optimization/conversion: Arm-Optimized version for execution on Arm-based platforms.

Converted/optimized by: Arm

License: The Original Model and the Optimized Model are subject to Apache-2.0.

This repository contains a converted or optimized version of the Original Model (the “Optimized Model”). The Original Model has been converted or optimized as described above for execution on Arm-based platforms.

No retraining or fine-tuning of the Original Model was performed as part of the conversion or optimization. The conversion or optimization was not intended to change the Original Model’s behavior or intended use.

Original Model and Documentation

For information about the Original Model, including its development, training data, intended uses, limitations and other relevant information, please refer to the Original Model repository. Information in that repository was provided by the original developer or other third parties and, unless expressly stated otherwise, has not been independently verified by Arm.

Licenses and Third-Party Terms

Use of the Original Model and the Optimized Model is subject to the applicable licenses, usage restrictions and other terms identified above and in the relevant repositories. Publication of the Optimized Model does not grant any rights beyond those provided under the applicable license terms.

You are responsible for reviewing those terms and ensuring that your use of the Original Model and the Optimized Model is permitted.

Purpose of this Release

The Optimized Model is provided as a reference implementation to demonstrate and evaluate execution and performance on Arm-based systems. It is not a production-ready or supported solution.

Arm’s publication of the Optimized Model does not constitute an endorsement or certification of the Original Model or a representation that the Optimized Model is suitable for production use or any particular purpose.

To the fullest extent permitted by applicable law (i) the Optimized Model is provided “as is.” Arm makes no representations or warranties that the Original Model, the Optimized Model or their outputs are accurate, safe, secure, non-infringing, legally compliant, suitable for production use or fit for any particular purpose; and (ii) Arm will not be liable for any loss or damage arising from or in connection with the Optimized Model, its use or its outputs.

You are responsible for independently evaluating the Optimized Model, its outputs and its suitability for your intended use, including compliance with applicable legal, regulatory, safety and security requirements.

Arm does not commit to provide ongoing support, maintenance or updates for the Optimized Model. Any use of or reliance on the Optimized Model or its outputs is at your own risk.