posa-bench / benchmark /README.md
Baker-UAI's picture
Publish POSA Bench preview-v0.1.0
2f49b29 verified
|
Raw History Blame Contribute Delete
6.59 kB
# POSA Bench
POSA Bench is an open, app-specific benchmark for small language models running
inside the Portable Offline Survival Assistant. It measures whether a model can
turn fixed, cited safety guidance into a useful answer and whether the complete
offline Android stack is practical on constrained devices.
The benchmark is deliberately vendor-neutral. A model or runtime partner may
sponsor testing, but sponsorship never changes prompts, scoring, eligibility,
or result ordering. The primary result is a metric card/Pareto view; the
opinionated `posa_fit_score` is secondary and publishes all of its weights.
## What is measured
Quality:
- required-claim recall and exact critical-fact recall
- unsafe or contradicted claims
- citation presence and citation-ID validity
- appropriate uncertainty/abstention
- instruction following, concision, and actionability (human-review fields)
- retrieval claim recall and context precision in the end-to-end track
On-device behavior:
- cold and warm time to first token (TTFT)
- end-to-end latency, prefill latency, and decode tokens/second
- model load time and success/failure/OOM rate
- model artifact size, installed size, and peak proportional set size (PSS)
- battery energy per answer when measured with an approved power method
- battery-temperature rise, Android thermal throttling, and sustained speed
- determinism across three runs and output truncation rate
- offline integrity (no network fallback) and minimum-API compatibility
## Tracks
1. **Fixed Context / Common Runtime** compares model quality with the exact
evidence in `data/questions.v1.jsonl`, the same prompt, quantization class,
and inference-engine revision. This isolates the generator as much as
practical.
2. **POSA End-to-End / Best Available Stack** runs the Android Ask pipeline,
including BGE retrieval, prompt packing, the model's supported on-device
runtime, citation verification, and fallbacks. Runtime differences are part
of the product result and must be disclosed.
Never combine the two tracks into one ranking. Likewise, only compare
performance rows with the same physical-device fingerprint and run protocol.
## Quick start
The scorer uses only Python's standard library (Python 3.10+):
```sh
python3 -m unittest discover -s benchmark/tests -v
python3 benchmark/posa_bench.py validate
python3 benchmark/posa_bench.py score \
--responses path/to/android-or-portable-results.jsonl \
--metadata path/to/run-metadata.json \
--output benchmark/results/my-run.json
python3 benchmark/posa_bench.py leaderboard \
--results benchmark/results \
--output benchmark/huggingface/space/leaderboard.csv
```
Structured semantic labels can be regenerated without rerunning inference:
```sh
python3 benchmark/posa_bench.py score-reviewed \
--automatic-result benchmark/results/my-run.json \
--audit benchmark/review/my-audit.json \
--run-key my_run \
--output benchmark/review/results/my-run.reviewed.json
python3 benchmark/posa_bench.py reviewed-leaderboard
```
To exercise an OpenAI-compatible local server with the fixed contexts:
```sh
python3 benchmark/posa_bench.py run-openai \
--base-url http://127.0.0.1:8080/v1 \
--model LiquidAI/LFM2.5-1.2B-Instruct-GGUF:Q4_K_M \
--output /tmp/posa-responses.jsonl
```
This portable runner is useful for quality development. Its timing is official
only when the endpoint is local, its engine/build and physical device are
declared, and the run follows `METHODOLOGY.md`.
## Android run
The existing instrumented test exercises the actual app pipeline:
```sh
./gradlew :app:connectedDebugAndroidTest \
-Pandroid.testInstrumentationRunnerArguments.class=ai.unplugged.posa.data.local.LocalLfmAnswerEvalInstrumentedTest
adb shell run-as ai.unplugged.posa cat \
files/local_lfm_answer_eval_25.jsonl > /tmp/posa-android.jsonl
```
Record run metadata using `schemas/run-metadata.example.json`, then score the
JSONL. Official submissions also include raw rows, logs, checksums, and the
metadata file.
## Candidate slate
Start with four similarly deployable instruction models, using exact artifacts
that the chosen Android runtime actually supports:
- LiquidAI LFM2.5 1.2B Instruct
- Meta Llama 3.2 1B Instruct
- Google Gemma 3 1B IT
- Qwen3 0.6B or 1.7B (choose the variant that fits the declared device tier)
The final manifest must pin repository revision, artifact SHA-256,
quantization, tokenizer/chat template, license, runtime commit, context size,
thread count, and generation parameters. Do not describe community GGUF
conversions as publisher-verified unless they are.
The pinned slate is in `data/models.v1.json`. Gemma remains declared but
blocked until its terms are accepted with an authenticated Hugging Face
account; publisher-built SmolLM2 is the ungated fourth-run fallback.
## Reproducing the Android common runtime
The scripts in `scripts/` download the pinned artifacts, verify that the
checked-out llama.cpp revision matches the manifest, build its Android server,
and push the server plus shared libraries to a connected device. They do not
accept licenses or silently obtain gated artifacts.
```sh
benchmark/scripts/download_models.sh /private/tmp/posa-models
benchmark/scripts/build_android_llama_cpp.sh /path/to/llama.cpp "$ANDROID_NDK_HOME"
ADB=/path/to/adb benchmark/scripts/push_android_runtime.sh /path/to/llama.cpp/build-android/bin
```
After the instrumented end-to-end test, retain its output without relying on
shell redirection:
```sh
python3 benchmark/posa_bench.py collect-android --limit 25 \
--output benchmark/raw/my-run/responses.jsonl
```
## Repository layout
- `data/questions.v1.jsonl` — 25 public benchmark cases and fixed evidence
- `data/device-profiles.v1.json` — compatibility/performance gates
- `data/models.v1.json` — exact candidate and common-runtime revisions
- `METHODOLOGY.md` — run protocol, ranking, and anti-bias rules
- `schemas/` — submission contract and example run metadata
- `results/` — one immutable scored JSON file per submitted run
- `review/` — structured semantic labels and reproducibly derived reviewed results
- `releases/` — checksum-pinned baseline snapshots and release notes
- `huggingface/` — dataset card and leaderboard Space scaffold
- `posa_bench.py` — validation, portable execution, scoring, and aggregation
The code and benchmark-authored text inherit the repository's Apache-2.0
license. Linked source material retains its original terms; URLs and publisher
names are provenance, not a claim that third-party content is relicensed.