← Lab /AI/ML

Hamm-grams improve robustness of malware detection features

Hamm-grams provide more robust static features for malware classification than traditional n-grams

AI/ML arXiv 1 Jul 2026 Method Prototype evidence

Published as “Hamm-Grams: An Algorithm for Mining Regular Expressions of Bytes”

Why it matters

Hamm-grams enable more robust, lightweight malware detectors that can run on constrained endpoints while improving detection rates.

Summary

Hamm-grams-regular expressions with single-character wildcards-significantly improve malware detection accuracy compared to plain n-grams, achieving balanced accuracies >95% on Drebin and higher partial AUCs on Ember and PDF datasets. The paper presents a new locality-sensitive hash for Hamming distance and an efficient extraction pipeline, and evaluates on public benchmarks. The evidence is strong: multiple experiments show consistent gains, though for larger gram sizes the advantage narrows.

What they found 2

  1. Both n-gram and hamm-gram features achieve balanced accuracies greater than 95% on the Drebin family classification task when using the top-5 000 features.

    “both n-gram and hamm-gram features achieving balanced accuracies of greater than 95%.”

  2. On Ember 2018 with k=105, hamm-grams of length 8 obtain a partial AUC (FPR < 0.001) of 0.746 versus 0.684 for n-grams.

    “h-gram 0.746 0.893”

Caveats 2

  • For gram size 16 the hamm-gram model performs similarly to the best n-gram model, offering no clear advantage.
  • the hamm-grams of size 16 perform as well as the best n-gram model (n=8).

What’s new here 4

  • A rolling complex hash that is locality-sensitive to Hamming distance
  • An efficient three-pass algorithm (based on KiloGrams) to extract frequent hamm-grams with wildcards
  • Use of agglomerative clustering within hash buckets to place wildcards
  • Demonstration of improved detection on large public malware datasets