esp32kb
Build an on-device knowledge base for the KB ESP32-P4 demo — a MiniLM-L3 embedding search that runs entirely on the board, with no PC attached at runtime.
Point the tool at a folder of markdown/text documents and it emits everything
the firmware flashes: sentence-aware chunks, INT8 embeddings, the packed
kb.img container (vectors + text + file index + WordPiece vocabulary) and
the tiny generated headers the sketch compiles against.
Install
uvx esp32kb --help # or: pip install esp32kb
# from a checkout:
uv run --project esp32kb esp32kb --help
Usage
# 1. documents -> kb.img + generated headers
esp32kb embed --root path/to/documents --sketch-dir path/to/Arduino/project
# 2. print the arduino-cli command that flashes app + model + kb.img
esp32kb flash --sketch-dir path/to/Arduino/project # then answer "y" to run it
Everything defaults relative to --sketch-dir (the current folder by default),
so the demo ships with its MiniLM-L3 model and one flag is enough.
esp32kb embed
| flag | default | meaning |
|---|---|---|
--root / -r |
required | folder with the documents to index (recursively) |
--output-folder / -o |
<sketch-dir>/model/kb |
where the .bin files and kb.img are written |
--sketch-dir / -s |
current folder | holds KB.ino/VectorSearch.h; kb_config.h and kb_queries.h go here |
--onnx |
<sketch-dir>/model/maskseq.onnx if present, else bundled |
float32 MiniLM-L3 the PC embeds with |
--queries / -q |
sampled from the corpus | text file, one demo query per line |
esp32kb flash
| flag | default | meaning |
|---|---|---|
--sketch-dir / -s |
current folder | the sketch to compile |
--model |
<sketch-dir>/model/minilm_l3.espdl |
INT8 model to flash |
--kb |
<sketch-dir>/model/kb/kb.img |
knowledge base to flash |
--port / -p |
$PORT or /dev/ttyUSB0 |
serial port |
--fqbn |
P4 board spec | arduino-cli board spec |
--library |
$ARDUINO_LIBS |
extra Arduino library folder |
--yes / -y |
off | run without asking |
--print-only |
off | print the command and exit |
--port |
$PORT or /dev/ttyUSB0 |
serial port for the printed flash command |
--fqbn |
esp32p4 FQBN | board spec for the printed flash command |
The sequence length and embedding width are read straight from the ONNX model,
so the chunks, the INT8 vectors and the generated kb_config.h the
firmware compiles against can never disagree with the model. No flags to keep
in sync.
Pipeline
documents
-> chunks (<= seq-2 WordPiece tokens each)
-> MiniLM-L3 embeddings (masked mean pool, L2 normalized)
-> symmetric INT8 quantization, one global scale
-> vectors.bin / meta.bin / chunks.bin / files.bin / vocab.txt
-> kb.img single little-endian container with a section table
-> kb_config.h KB_SEQ / KB_DIM / KB_TOPK + container magics (C++ constants)
-> kb_queries.h KB_EXAMPLES[] example query texts for the sketch
The vocabulary travels inside kb.img, so the device tokenizes queries itself.
Additive attention mask
If the ONNX model exposes a second attention_mask input (the variant built
by model/export_onnx_mask.py), esp32kb feeds it the correct per-query
padding bias (0 on real tokens, negative on [PAD]). This preserves retrieval
quality at longer sequence lengths, where the frozen all-ones mask used by the
plain export otherwise collapses query embeddings. With the stock single-input
ONNX the behavior is unchanged.
Outputs
| file | contents |
|---|---|
vectors.bin |
32 B header + N × dim INT8 (16-byte aligned rows) |
meta.bin |
16 B header + N × 16 B records (file id, text offset/length) |
chunks.bin |
16 B header + concatenated UTF-8 chunk text |
files.bin |
16 B header + N × padded filename records |
vocab.txt |
WordPiece vocabulary, one token per line |
kb.img |
container: magic/version/section table + the payloads above |
kb_config.h |
KB_SEQ, KB_DIM, KB_TOPK and the container magics |
kb_queries.h |
KB_EXAMPLES[] example query texts for the sketch |
Metadata
Release files for esp32kb 0.1.2
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 | |
|---|---|---|---|---|
| esp32kb-0.1.2.tar.gz | 63.1 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| esp32kb-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 126.2 MB
Release files / esp32kb-0.1.2.tar.gz
| Download URL | esp32kb-0.1.2.tar.gz |
|---|---|
| Size | 63.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a32bcbb57e4424f24dae41e3508483d27d9defc392aad74e94e992a1065c058e
|
|
BLAKE2b-256 checksum How to use checksums |
2426e2d41e31a3adf1b0306fa58c8243ad6d5fdd46259cd7918453c8510807cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / esp32kb-0.1.2-py3-none-any.whl
| Download URL | esp32kb-0.1.2-py3-none-any.whl |
|---|---|
| Size | 63.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf2676ece7f8781bc26c9c81bc67885fd3472bc9b4c0579a0d4eeb9669c9e58e
|
|
BLAKE2b-256 checksum How to use checksums |
9a9a459b5c0705e3df07bf28d55b7ab94be96319b0e4bbbea6421cce624e297e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for esp32kb 0.1.2
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.