neural-formmap
v0.1.2
Published
A tiny local model that maps messy form fields to standard autocomplete names.
Maintainers
Readme
neural-formmap
A tiny local model that maps messy form labels and attributes to standard HTML autocomplete field names.
import { mapField } from "neural-formmap";
mapField({
label: "Where should we send updates?",
name: "contactEmail",
placeholder: "[email protected]",
});
// { type: "email", autocomplete: "email", source: "model", ... }CLI
Pass a plain label:
npx neural-formmap "Work email"Or pass a JSON field descriptor:
npx neural-formmap '{"label":"Apt / Suite","name":"unit"}'Piped input is read as JSON Lines. A JSON array maps a complete form.
How it works
The mapper follows a strict evidence order:
- A valid
autocompleteattribute wins. - Unambiguous HTML types such as
email,tel,url, andsearchwin. - A dependency-free
128 → 24 → 22neural network classifies hashed features from the label, name, id, placeholder, input type, and nearby context.
The model has 3,646 parameters and runs locally. There is no server, telemetry, inference framework, or runtime dependency.
API
mapField(field | label)maps one field and returns the best type, confidence, evidence source, and three alternatives.mapForm(fields)maps a list while preserving its order.FIELD_KINDSexposes the supported vocabulary.
The vocabulary covers names, credentials, contact information, addresses, payment fields, search, and unknown. It follows HTML autocomplete names where an equivalent exists.
Scope
This package classifies field purpose. It does not read the DOM, fill values, store personal data, or bypass form validation. Integrations should gather accessible labels and attributes, then decide whether a confidence threshold is sufficient for their use case.
The checked-in model is trained and evaluated on deterministic synthetic variations. The proof is reproducible, but it does not establish accuracy on arbitrary production forms, languages, or adversarial markup. See MODEL_CARD.md.
Development
Requires Bun 1.3 or newer.
bun run train
bun run check
bun run benchmarkCI retrains the model and verifies that src/weights.ts is byte-for-byte reproducible. See docs/prior-art.md for the project boundary.
License
MIT
