Skip to content

v0.3.0

Choose a tag to compare

@koivualeksi koivualeksi released this 26 Nov 17:17
· 4 commits to main since this release
2e19dfe

Added

  • dedup=True (CLI --dedup): leaves out each selected line of 100 or more characters that repeats an earlier selected line, keeping the first copy, in text, html and markdown. Lines are compared ignoring case, punctuation and markers. Lines in a <pre> are never deduped. Off by default; with_blocks=True, the model input and the predictions are unchanged.
  • threshold= (CLI --threshold): a line is kept when its probability is above it, 0 to 1, default 0.5. Lower keeps more, higher keeps less. Only 0.5 is benchmarked. with_blocks=True still returns every probability.

Changed

  • New mini model: the embedding table is int8 rank-128 (34.6 MB, was 768 wide and 202 MB). The release pin moves to Hub commit a86f08a; base/ is unchanged apart from its added tokenizer.json.gz. The first mini download is ~43 MB, and base fetches the 5.4 MB gzipped tokenizer instead of the 33 MB plain one.
  • Dependencies now have tested bounds: lxml>=6.0.4,<7, tokenizers>=0.21,<0.24, onnxruntime>=1.20.1, numpy>=1.26.4, huggingface-hub>=0.26.5, w3lib>=2.3.1,<3 (was >=2.5,<3), and for [full] torch>=2.7.1, transformers>=5.1,<6. Tested on Linux: across these ranges the mini model gives the same text, html and markdown on 2,040 test pages (onnxruntime before 1.30 shifts probabilities by at most 2.4e-6). The base model gives the same line selection on a 13-page sample, except that torch 2.7-2.12 shifts probabilities by up to 0.014 and can flip a line that sits right at the 0.5 threshold. lxml 5.x is excluded: its older libxml2 renders some pages differently from the libxml2 2.14 the models were trained on. CI now also runs the suite with the lowest allowed versions.
  • The mini model now mean-pools each block's token embeddings with one vectorized segment sum, in batches of 32,768 tokens, instead of a Python loop over blocks. Probabilities can differ from before by about 1e-6; on 2,040 test pages no block changed side of the 0.5 threshold.
  • The mini model's per-page memory estimate is sized for the rank-128 table: 1 KB per distinct token id and 12 KB per block (was 12 and 21, sized at 768 wide). Pages estimated above 100 MB still give onnxruntime's arena back after they run; with the new sizes that is pages with about 8,500 or more blocks. Output is unchanged.
  • The tokenizer is read from tokenizer.json.gz when the bundle has one, and from tokenizer.json otherwise, both from the Hub and from a local bundle folder. Pinned bundles without the gzipped file load as before.

Fixed

  • A document that parses to no element (only comments, a doctype, an <?xml?> declaration or other processing instructions; with libxml2 2.11, as in lxml's Windows wheels, also a lone BOM or leading NUL bytes) raised lxml.etree.ParserError: Document is empty. It now returns "" in every output, and ([], []) with with_blocks=True, as an empty string does.
  • An unknown output (e.g. output="md") raised ValueError only after the model had run on the page, and not at all with with_blocks=True. It now raises before any inference, in every case.
  • output="html" and output="markdown" no longer contain text from lines the model rejected. They kept whole elements, so the text of a parent element, the text right after a kept element and the children of a kept element came back with it. They now keep exactly the text of the selected lines, as output="text" does. A code block (a <pre> with no block elements inside) stays whole when any of its lines is selected. text output, the model input and the predictions are unchanged.
  • output="html" and output="markdown" no longer glue separate lines together (Personal incomePopulation) when the <br> or block element between them was not kept; a <br> takes its place.
  • With base_url= (or an absolute <base href>), a relative SVG xlink:href stayed relative in output="html" on lxml < 6.1. It is now made absolute on every lxml version, as on 6.1+.
  • With libxml2 2.14 (lxml's Linux wheels), output="html" and output="markdown" raised ValueError: All strings must be XML compatible on pages with C0 control characters (such as \x03 or &#3;) in text or attributes. The parser now removes them, as libxml2 2.11 (lxml's Windows wheels) already did. Pages without them, and every page on Windows, give the same output as before; on Linux, the text output and the model input of affected pages lose the characters too. None of the 7,825 WebMainBench training and test pages contain them.

Security

  • output="html" and output="markdown" are now cleaned of active content. Kept elements could carry <script>, <style>, event handlers (onclick=), srcdoc and javascript: links, and markdown wrote [text](javascript:...). Now the elements the model never reads (script, style, title, meta, link, base) and SVG <animate> / <set> are dropped, on* and srcdoc attributes are removed, and a link or source whose scheme is not http, https, mailto, tel, ftp or relative loses its target (its text stays); data:image/ in <img src> is kept. SVG xlink:href is checked the same way on every lxml version (lxml < 6.1 does not list it as a link attribute). A basic cleanup, not a guarantee. text output, the model input and the predictions are unchanged.

Full changelog: v0.2.1...v0.3.0