Skip to main content
QUICK REVIEW

[Paper Review] KiloGrams: Very Large N-Grams for Malware Classification

Edward Raff, William Fleming|arXiv (Cornell University)|Aug 1, 2019
Advanced Malware Detection TechniquesComputer Science40 references11 citations
TL;DR

This paper introduces KiloGrams, a highly efficient method to extract the top-k most frequent n-grams even at extremely large n (≥1024), overcoming prior computational and overfitting concerns. Despite the massive n-gram size, the approach yields predictive, interpretable features for malware classification that rival professional human-engineered features when combined with gradient-boosted trees on the EMBER dataset.

ABSTRACT

N-grams have been a common tool for information retrieval and machine learning applications for decades. In nearly all previous works, only a few values of n are tested, with n>6 being exceedingly rare. Larger values of n are not tested due to computational burden or the fear of overfitting. In this work, we present a method to find the top-k most frequent n-grams that is 60× faster for small n, and can tackle large n≥1024. Despite the unprecedented size of n considered, we show how these features still have predictive ability for malware classification tasks. More important, large n-grams provide benefits in producing features that are interpretable by malware analysis, and can be used to create general purpose signatures compatible with industry standard tools like Yara. Furthermore, the counts of common n-grams in a file may be added as features to publicly available human-engineered features that rival efficacy of professionally-developed features when used to train gradient-boosted decision tree models on the EMBER dataset.

Motivation & Objective

  • To address the computational infeasibility and overfitting concerns that have historically limited n-gram analysis to small n values (n≤6).
  • To develop a scalable method capable of efficiently identifying the top-k most frequent n-grams even at very large n (≥1024).
  • To demonstrate that large n-grams retain predictive power for malware classification despite their size.
  • To generate interpretable features that align with malware analysis practices and support integration with industry tools like Yara.
  • To show that n-gram counts can enhance publicly available human-engineered features, matching the performance of professionally developed features.

Proposed method

  • A novel algorithm is proposed that accelerates top-k n-gram extraction by optimizing frequency counting and pruning strategies, achieving 60× speedup for small n.
  • The method scales to n≥1024 by leveraging efficient data structures and streaming techniques to manage memory and computation.
  • It extracts the most frequent n-grams from binary files, treating them as sequences of bytes.
  • The extracted n-grams are used as binary or count-based features in machine learning models.
  • The approach supports integration with existing malware analysis pipelines by generating Yara-compatible signatures from frequent n-grams.
  • The method combines n-gram features with standard human-engineered features (e.g., from EMBER) and trains gradient-boosted decision trees to evaluate performance.

Experimental results

Research questions

  • RQ1Can n-grams of size n≥1024 be efficiently extracted at scale without prohibitive computational cost?
  • RQ2Do large n-grams retain predictive power for malware classification despite their size and potential overfitting risk?
  • RQ3Can large n-grams produce features that are interpretable and usable in real-world malware analysis workflows?
  • RQ4Can n-gram features, when combined with human-engineered features, match the performance of professionally developed features on malware detection?
  • RQ5Can the extracted n-grams be used to generate general-purpose, Yara-compatible signatures?

Key findings

  • The proposed method achieves a 60× speedup in top-k n-gram extraction for small n, enabling scalable processing.
  • The method successfully extracts top-k n-grams even at n=1024 and beyond, which were previously infeasible due to computational constraints.
  • Large n-grams (n≥1024) still provide predictive power for malware classification, demonstrating utility beyond small n.
  • The n-gram features are interpretable and can be used to generate Yara-compatible signatures for practical deployment.
  • When combined with publicly available human-engineered features, the n-gram features achieve performance comparable to professionally-developed features on the EMBER dataset.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.