Skip to main content

CNBE-32: Chinese Native Binary Encoding — Structured 32-bit CJK encoding for AI and hardware

Project description

CNBE-32
Chinese Native Binary Encoding

English · 简体中文 · English mirror

Project status Python SDK Basic CJK DB Extended scope

A 32-bit structural fingerprint for CJK characters — built for people who wonder what Chinese text would look like if it were designed closer to the metal.

CNBE-32 is a research prototype. The packaged Python SDK currently targets 20,902 Basic CJK entries. The broader 97,686 CJK figure is an intended / experimental extended scope, not current packaged SDK coverage.


Why this is interesting

Unicode tells computers which character this is.

CNBE-32 asks a different question:

Can part of a CJK character's visual and structural logic be carried directly in a compact binary form?

That makes CNBE-32 interesting for experiments in CJK-aware embeddings, low-level lookup tables, hardware-friendly text features, and language-specific model inputs.


The idea in one picture

31              24 23        19 18     15 14                 4 3        0
┌────────────────┬────────────┬─────────┬─────────────────────┬──────────┐
│ Radical/Radix  │  Stroke    │ Struct  │     Glyph Index     │   Ext    │
│     8 bits     │  5 bits    │ 4 bits  │       11 bits       │  4 bits  │
└────────────────┴────────────┴─────────┴─────────────────────┴──────────┘

Think of it as a compact structural fingerprint, not a replacement for Unicode.


Quick start

python -m pip install .
from cnbe32 import encode_cnbe, decode_cnbe, bit_hamming_distance

a = encode_cnbe(radix=72, stroke=8, struct=1, index=123, ext=0)
b = encode_cnbe(radix=72, stroke=9, struct=1, index=124, ext=0)

print(decode_cnbe(a))
print(bit_hamming_distance(a, b))

What is stable today

  • CNBE-32 field encoding and decoding
  • strict validation of all bitfield ranges
  • true bit-level Hamming distance and legacy field-weighted distance
  • optional SQLite database lookup
  • explicit SkillTable construction for experiments
  • wheel build, pip install, pytest, ruff, GitHub Actions CI

What is experimental

  • LLM prompting and feature experiments
  • JEPA-style representation learning
  • RISC-V and hardware instruction prototypes
  • OS and kernel-level experiments
  • finance, biology, physics, and social-science-style experiments

These should be interpreted as preliminary research prototypes unless the corresponding directory includes fixed datasets, reproducible scripts, baseline comparisons, random seeds, and clear train/test separation.


Coverage terminology

Term Meaning
Packaged Python SDK database 20,902 Basic CJK entries (shipped in the wheel)
Experimental extended scope 97,686 CJK characters as a design / research target
Experiment-specific coverage depends on the dataset and reproduction script for each experiment

Claims about collision rate, full coverage, or extended CJK breadth should be interpreted only within the scope of the specific dataset and script used for that experiment.


Evidence level

This repository contains research prototypes and early experiments. Results should be interpreted as preliminary unless the corresponding experiment includes:

  • fixed dataset versions,
  • reproducible scripts,
  • baseline comparisons,
  • random seeds or deterministic settings,
  • raw outputs or result artifacts,
  • and clear train/test separation where applicable.

Bitfield layout

Field Bits Description
Radical / Radix 8 Radical or structural root field
Stroke 5 Stroke-count field
Structure 4 Character structure field
Glyph Index 11 Basic CJK glyph index field
Extension 4 Experimental extension field

Python SDK example

from cnbe32 import (
    encode_cnbe, decode_cnbe,
    bit_hamming_distance, field_weighted_distance,
)

a = encode_cnbe(radix=72, stroke=8, struct=1, index=123, ext=0)
b = encode_cnbe(radix=72, stroke=9, struct=1, index=124, ext=0)

print(decode_cnbe(a))
print(bit_hamming_distance(a, b))
print(field_weighted_distance(a, b))

For geeks

If you like... CNBE-32 gives you...
bitfields a fixed 32-bit CJK structure layout
language internals radical, stroke, structure, glyph-index fields
ML features compact CJK-aware feature inputs
hardware experiments a layout testable near RISC-V / instruction prototypes
weird text encoding ideas a research sandbox for Chinese-native representation

For Chinese language enthusiasts

Chinese characters are not just arbitrary symbols. Many carry visible structure: components, strokes, layout, and historical form.

CNBE-32 does not claim to fully understand characters. It simply asks whether some of that visible structure can be encoded in a way computers can use directly.


Roadmap

  1. Keep the Python SDK build, install, test, and lint pipeline green.
  2. Add reproducible scripts for each experiment.
  3. Separate stable SDK claims from experiment-specific claims.
  4. Publish dataset provenance and coverage validation scripts.
  5. Add golden vectors shared across Python, C, Rust, and hardware prototypes.
  6. Add benchmark baselines (Unicode codepoint, one-hot, IDS, learned embeddings).

Implementation consistency

CNBE-32 includes machine-readable golden vectors in spec/golden_vectors.json. These vectors define canonical bitfield encode/decode examples for Python, C, Rust, and hardware-oriented implementations. The same vector set is now exercised by Python tests, a minimal C consistency test, and a minimal Rust consistency test.

Project maintenance

License

MulanPSL-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cnbe32-1.0.3.tar.gz (889.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cnbe32-1.0.3-py3-none-any.whl (875.8 kB view details)

Uploaded Python 3

File details

Details for the file cnbe32-1.0.3.tar.gz.

File metadata

  • Download URL: cnbe32-1.0.3.tar.gz
  • Upload date:
  • Size: 889.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cnbe32-1.0.3.tar.gz
Algorithm Hash digest
SHA256 47e1c5c717e87dcbf2a49bbc886f3b6390c4e34b31315d9474162e62ed6d99bf
MD5 98441921c8a0cbd5defbb7e8df15abd6
BLAKE2b-256 9fd93642a1e0b44867d9b2c9f30b7434a0d39571806c42ab555bea1a337db113

See more details on using hashes here.

File details

Details for the file cnbe32-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: cnbe32-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 875.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cnbe32-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fd112548f102a6b1a771c88a5c38683a8c06c3c4d2ff3840402079b3df2bf7e0
MD5 f970d2e4e1b690bad995595cca952111
BLAKE2b-256 ec2201c5f74e9e9b3c8239ccaf2c857109a33a99ff15714b1c890ed52f3ce72a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page