onpanda: The Companion Python Package for onPanda
Python package for onPanda: Efficient Annotation of On-Policy Alignment Data for LLMs and Agents via Token-Level Correction [project page]
Contents: Features | Install | Example Data | Quick Start | Main Modules | Iterative Correction API | Data Assumptions
▮ Features
- Parse
.panda.jsoninto SFT and preference-pair data (build_legacy_data_v1) - Build token-level supervision data (
build_token_level_supervision_data_v1/v2) - Build Find-and-Replace correction training data (
build_far_correction_data_v1) - Token-level correcting on the reasoning and tool call channels, not only content
- Verify and score Find-and-Replace outputs (
FindAndReplaceVerifier) - Benchmark Panda-CVL dataset
- Run iterative correction as a Proxy API (
onpanda.server.iterative_correction_api) - Build
panda battledata from two arena result sets (build_panda_battle)
▮ Install
pip install onpanda -U
# Or want to run demos.
git clone https://github.com/on-panda/on-panda-python.git
pip install -e ./on-panda-python
# Example Data for demo
git clone https://github.com/on-panda/on-panda-example-data.git
ls on-panda-example-data/panda_json/
If you want to use tokenizers, install transformers separately.
▮ Quick Start
import onpanda
panda_path = (
"../on-panda-example-data/panda_json/"
"2025-08-19_how-many-1s_tokenizer-Qwen2.5.panda.json"
)
tokenizer=onpanda.utf8_tokenizer
# Use built-in utf8_tokenizer for a minimal runnable flow.
tree = onpanda.PandaTree(panda_path, tokenizer)
# 1) SFT + preference pairs
legacy = tree.build_legacy_data_v1()
print("sfts:", len(legacy["sfts"]))
print("preferences:", len(legacy["preferences"]))
# 2) Token-level supervision
token_level_v1 = tree.build_token_level_supervision_data_v1(
tokenizer
)
print("token_level_v1:", len(token_level_v1))
# 3) Find-and-Replace correction data
adapter = onpanda.FindAndReplaceCorrectionAdapter(
tokenizer
)
correction_data = tree.build_far_correction_data_v1(adapter)
print("correction_data:", len(correction_data))
Build from plain chat messages:
import onpanda
messages = [
{"role": "user", "content": "5+7=?"},
{"role": "assistant", "content": "12"},
]
panda_json = onpanda.messages_to_panda_tree(messages, uuid="demo")
# dump to xxx.panda.json
▮ Main Modules
onpanda/parser.py:PandaTreeand data conversion entrypointsonpanda/response_templates/:apply/parsebetween an assistant message and the model's own response text, so correcting reaches the reasoning and tool call channelsonpanda/token_level_supervision_utils.py: token-level patch extraction and masksonpanda/correcting_model/far_correction_utils.py: FAR data builder and apply logiconpanda/correcting_model/verifier.py: FAR parser/locator/reward computationonpanda/correcting_model/panda_score_mixin.py: evaluation correction ability on Panda JSONonpanda/correcting_model/correcting_model.py: iterative correction workflowonpanda/server/iterative_correction_api.py: Flask wrapper for correction serviceonpanda/arena/panda_battle.py: build battle-style comparison data
▮ Iterative Correction API
Launch a proxy API server that return response using iterative_correction
python -m onpanda.server.iterative_correction_api --help
▮ Data Assumptions
PandaTreeis a parser for qualified, annotated Panda JSON.PandaTreepreprocessing currently assumes:- Top-level field
dialogsexists - Top-level field
update_timeexists - At least one dialog ends with an
assistantmessage - If
annotate.is_goodis missing, latest dialog is treated as default good
- Top-level field
Metadata
Release files for onpanda 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onpanda-0.1.7.tar.gz | 84.8 kB | Without provenance | Details for onpanda-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onpanda-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for onpanda-0.1.7-py3-none-any.whl |
Total release size: 171.8 kB
Release files / onpanda-0.1.7.tar.gz
| Download URL | onpanda-0.1.7.tar.gz |
|---|---|
| Size | 84.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fb3e6d45afd71e81b96f92b50e9e2dd4664747b1a11562b0481671bde06d732
|
|
BLAKE2b-256 checksum How to use checksums |
4293b1021ef8ae96e8ed913f8d10d6c84b3875b536ff15b8f8642b26c16db62a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / onpanda-0.1.7-py3-none-any.whl
| Download URL | onpanda-0.1.7-py3-none-any.whl |
|---|---|
| Size | 87.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cf0b53251d46b73064975f0a376b55f244cfdfb5fc9fd5ff07e29be5079f25d
|
|
BLAKE2b-256 checksum How to use checksums |
646f61edfb50f7a84b8c5eb5a6a4c21dc6d91d548506d18938eaa0d17545f5b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for onpanda 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.