Token Classification
Transformers
ONNX
Safetensors
multilingual
bert
autofill
password-manager
form-classification
field-classification
browser-extension
Instructions to use ProCreations/Zap with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ProCreations/Zap with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="ProCreations/Zap")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("ProCreations/Zap") model = AutoModelForTokenClassification.from_pretrained("ProCreations/Zap", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download training/js/bench.mjs from ProCreations/Zap: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/ProCreations/Zap/resolve/main/training/js/bench.mjs
- Command line
-
hf download hf://ProCreations/Zap/training/js/bench.mjs
-
curl -L -o bench.mjs https://huggingface.co/ProCreations/Zap/resolve/main/training/js/bench.mjs
1.5 kB
| // CPU latency benchmark: model-only time per form (extraction excluded), onnxruntime-node via transformers.js | |
| import fs from "fs"; import path from "path"; import { createRequire } from "module"; | |
| const require = createRequire(import.meta.url); | |
| const tf = require("@huggingface/transformers"); | |
| const { JSDOM, VirtualConsole } = require("jsdom"); | |
| const { zapExtract } = require("./zap-extract.js"); | |
| const { ZapModel } = require("./zap-infer.js"); | |
| const [modelDir, dir, dtype] = process.argv.slice(2); | |
| tf.env.allowRemoteModels = false; tf.env.localModelPath = path.dirname(path.resolve(modelDir)) + "/"; | |
| const zap = await ZapModel.load(tf, path.basename(modelDir), { dtype: dtype || "fp32" }); | |
| const pages = JSON.parse(fs.readFileSync(path.join(dir, "py.json"), "utf8")).slice(0, 200); | |
| const vc = new VirtualConsole(); const forms = []; let tx = 0; | |
| for (const p of pages) { const d = new JSDOM(fs.readFileSync(path.join(dir, p.file), "utf8"), { url: p.url, virtualConsole: vc }); | |
| const t = performance.now(); forms.push(...zapExtract(d.window.document, p.url)); tx += performance.now() - t; } | |
| await zap.classify(forms.slice(0, 20)); // warmup | |
| const t0 = performance.now(); const res = await zap.classify(forms); const dt = performance.now() - t0; | |
| const nf = forms.reduce((a, f) => a + f.fields.length, 0); | |
| console.log(JSON.stringify({ dtype: dtype || "fp32", forms: forms.length, fields: nf, ms_per_form: +(dt / forms.length).toFixed(2), extract_ms_per_form: +(tx / forms.length).toFixed(2) })); | |