Request it for the seed queue, or get it now with pf download playforgecoding/LFM2-350M-Extract-facts-ONNX (CLI guide).
The ONNX export of playforgecoding/LFM2-350M-Extract-facts for Transformers.js, made with the onnxruntime-genai model builder and laid out the way the onnx-community LFM2 files are.
Experimental. Not used by Spelling Creator yet: it still names the subject of a fact wrong half the time. The training, the results and what it does are on the merged model's card.
| file | for |
|---|---|
onnx/model_q4f16.onnx |
WebGPU (device: "webgpu", dtype: "q4f16") |
onnx/model_int8.onnx |
CPU: Node and the wasm backend (dtype: "int8") |
On the 24 held-out passages the int8 export finds 50 percent of the labelled claims, 42 percent of what it lists matches a label, and it takes about 3 seconds a passage on an M4's CPU.
import { AutoModelForCausalLM, AutoTokenizer } from "@huggingface/transformers";
import { passageClaimsMessages, parseClaimsReply } from "./factClaims.js"; // from Spelling Creator's core package
const repo = "playforgecoding/LFM2-350M-Extract-facts-ONNX";
const tokenizer = await AutoTokenizer.from_pretrained(repo);
const model = await AutoModelForCausalLM.from_pretrained(repo, {
dtype: "q4f16",
device: "webgpu",
});
const inputs = tokenizer.apply_chat_template(
passageClaimsMessages(passage, lessonTitle),
{ add_generation_prompt: true, return_dict: true },
);
const output = await model.generate({
...inputs,
max_new_tokens: 1000,
do_sample: false,
});
const claims = parseClaimsReply(
tokenizer.batch_decode(output.slice(null, [inputs.input_ids.dims[1], null]), {
skip_special_tokens: true,
})[0],
);
Drop any claim whose quote is not in the passage before looking it up.
python -m onnxruntime_genai.models.builder -i merged -p int4 -e webgpu for
q4f16 and -p int8 -e cpu for int8, then relayout-onnx.py from the
Spelling Creator repo, which renames the convolution caches to past_conv.N,
makes the KV cache's head dimension concrete, moves the chat template into
tokenizer_config.json, adds the transformers.js_config block, and puts the
graphs under onnx/. The route is written up at
spellingcreator.org/docs/monorepo/document-import-experiment.
Derived from LFM2-350M-Extract and released under the same LFM Open License v1.0 (see LICENSE).
Have the files? Publish a torrent.
Publish a torrentHave the complete files and permission to share them? Replace the example folder path. The script checks the files, makes a torrent and submits its magnet and checksums. Keep your torrent client seeding. Get your community key from your settings, and read the script before running it.
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo playforgecoding/LFM2-350M-Extract-facts-ONNX ./model-folderonnx/model_int8.onnx 148.7 KiBonnx/model_q4f16.onnx 136.8 KiBplayforgecoding/LFM2-350M-Extract-facts