Skip to content

TypeSeg

See which content types are inside a text file, and where. TypeSeg labels regions of code, markup, data, and encodings across 35 textual content types. It shows where each type starts and ends, including in mixed or malformed text.

The TypeSeg paper appeared in the ACM AISec ’26 proceedings. TypeSeg is based on research by Martin Dallinger, Yanick Fratantonio, and Luca Invernizzi at Google. The project began as a master’s thesis at JKU Linz under the supervision of Prof. Stefan Rass. This is not an officially supported Google product.

TypeSeg uses deep learning sequence modeling to predict a content type for each character. Its lightweight U-Net and Mamba models have 1.52 million and 1.36 million parameters, respectively, and run on local hardware. U-Net processes short overlapping sections; Mamba uses context from the whole file. About the models.

U-Net labels 4.83 million input characters per second on an RTX 5070 laptop GPU in the paper’s warmed benchmark before output post-processing. That is 4.83 MB/s for ASCII text. The same research runtime reaches about 292,000 characters per second on a Ryzen AI 7 350 laptop CPU. Full Python package calls also post-process labels and build the segmentation result. Model and package speed

A file detector such as Magika can identify textual files before TypeSeg labels their internal regions.

PowerShell and Base64 inside a batch script.Shortened excerpt · 211 shown bytes
0105211 bytes

Hover to unfold the file. Select a region to inspect its text.

From MalwareBazaar, ID 626f2311154e7a07136f4d8d45fa218a359874d0d805c22c52544385bbd1290d. Hover to inspect the annotated regions. Ranges refer to this shortened excerpt, not the original file. Gray ellipses mark omissions; these labels are illustrative, not live model predictions.

Select a region to inspect its source. Use cases include text inspection, content-specific analysis, and dataset review.

Category Content types
Programming and scripting (17) Python, JavaScript / TypeScript, Java, C / C++ / Objective-C, C#, Go, Rust, Ruby, PHP, Swift, Kotlin, Scala, Dart, Visual Basic, Shell, PowerShell, SQL
Markup and documentation (7) HTML, XML, SVG, CSS, Markdown, reStructuredText, TeX
Data and configuration (6) JSON, YAML, CSV, Plain text, Dockerfile, Gettext catalogs
Text encodings (5) Hexadecimal, Base64, Base32, Base58, Base85

JavaScript and TypeScript share a label, as do C, C++, and Objective-C. See Models & Content Types for exact API labels and how uncertain text is handled.

Inspect mixed text directly from the command line:

Terminal window
pip install typeseg
typeseg --model fast file.txt
Terminal output showing colored CSS, JavaScript, HTML, SQL, and shell regions, with a table of character ranges and confidence.
Recorded Mamba output from TypeSeg on PyPI. The historical screenshot’s banner reads textseg.precise; the current API call is typeseg.precise. Colors mark content types; the table shows ranges and confidence.

The CLI guide covers models, piped input, and output formats.

  • Mixed and malformed text. Labels content types even when tags are missing or syntax is incomplete.
  • 35 content types. U-Net achieved 94.9% F1 for character labels on 875 human-labeled files covering all 35 types. How the score is measured.
  • Small models, local inference. U-Net has 1.52M parameters and runs on CPU or GPU.
  • Character-level locations. Each segment includes a content type, start and end offsets, and confidence. Output format.
  • Python, CLI, and browser. Try the Python package, command-line tool, or browser demo. Demo text stays in your browser.
  • Open source. Code and model checkpoints are available under Apache 2.0. Research and citation.