A multi-head deep learning model trained on Windows application programming interface call sequences achieved 99.21 percent malware detection accuracy, 95.94 percent behavior classification accuracy across seven threat categories, and more than 90 percent early detection within the first five system calls for six of those categories, according to an experimental evaluation published in Machine Learning with Applications. Developed by Wrya Anwar, Saman Mirza, and Akar Hawree, the Pattern-Aware Multi-Head LSTM framework, or PA-MHL, combines malware-exclusive subsequence pretraining with a shared recurrent network to perform binary detection, behavior categorization, and streaming early warning simultaneously. Testing on two public Windows datasets also showed that while the model failed to transfer directly across different collection environments without retraining, fine-tuning recovered performance and boosted behavior classification.
The study addresses a practical divide in behavioral malware analysis. Static inspection examines a program’s binary structure without executing it, making it vulnerable to packing, code obfuscation, and polymorphism. Dynamic analysis instead tracks the sequence of API calls a program issues to the operating system at runtime, which is harder to disguise without altering program behavior, though sandbox-aware malware can still restrict what is observed. Prior machine learning studies on API sequences have largely focused on binary detection accuracy after full execution, leaving interpretability, behavior classification, and early detection separate. In incident response, early detection enables containment before a payload completes, whereas behavior classification tells defenders whether a program is attempting actions such as process injection, registry tampering, or resource extraction.
For their primary experiments, the researchers used the public Oliveira Windows API call dataset, originally collected in Cuckoo Sandbox. After VirusTotal verification and deduplication, the curated dataset contained 43,876 sequences, including 42,297 malware and 1,579 benign programs, each with 100 non-repeated consecutive API calls. The underlying dataset provides only binary malicious-or-benign ground-truth labels and lacks malware family labels; behavior categories were therefore derived heuristically. To prevent data leakage, the team partitioned the sequences randomly with a fixed seed into stratified training (70 percent), validation (15 percent), and test (15 percent) sets before any analysis. Pattern extraction, background-call frequency measurement, and model training used only the training partition, with frozen patterns later applied to validation and test data.
The pipeline begins with coverage-based n-gram extraction to identify short local API subsequences unique to malware. Examining sequence lengths from two to six calls, the authors retained a candidate pattern only if it appeared in at least two training malware samples and in zero training benign programs. Three-call patterns proved central, covering 98 percent of training malware on Oliveira, whereas many four- and five-grams merely extended an already adopted three-gram by one or two surrounding calls. Applying a redundancy rule that discarded longer candidates containing a shorter adopted subsequence, the team selected n equals three as the core length and retained n equals six to capture longer behavioral chains, adding the remaining two percentage points of training malware coverage.
To map these exclusive n-grams to interpretable behaviors without distortion from routine operating system housekeeping, the investigators filtered out ubiquitous API calls. Using training benign programs alone, any API called by more than 50 percent of benign executables was classified as a background call and removed from behavior scoring. Seventeen functions exceeded this cutoff, including LdrGetProcedureAddress at 97 percent, NtClose at 95 percent, LdrLoadDll at 92 percent, NtAllocateVirtualMemory at 89 percent, RegOpenKeyExW at 62 percent, and RegCloseKey at 57 percent. A 30 percent cutoff removed category-defining calls such as GetSystemInfo, whereas 70 percent retained routine registry calls. Remaining patterns were scored against a literature-grounded ontology and assigned to sequences by majority voting. Nine concrete categories met the inclusion threshold of at least 100 training and 30 test malware samples, while unmatched sequences and benign programs were excluded from behavior evaluation.
PA-MHL links these local patterns to full-sequence modeling through a lightweight, two-stage neural architecture containing 196,875 trainable parameters. API tokens are embedded into 128-dimensional vectors and fed into a unidirectional long short-term memory encoder with a 128-unit hidden state. In the first stage, the encoder is pretrained for 10 epochs solely on the behavior-labeled n-grams using the Adam optimizer at a learning rate of 0.001. Those weights then initialize the full model, where three feed-forward heads train jointly for 10 epochs using weighted sampling for class imbalance. The detection and behavior heads read the final hidden state after 100 calls, whereas the early-detection head scores every timestep under a linearly decaying loss weight, decreasing from 1.00 at the first call to 0.96 at the fifth, 0.51 at the fiftieth, and 0.01 at the hundredth, to reward rapid decisions.
On the held-out Oliveira test partition, the detection head reached 99.21 percent accuracy, 99.24 percent precision, 99.21 percent recall, and a Matthews correlation coefficient of 0.8409, while the early-detection head achieved 99.16 percent accuracy and an MCC of 0.8329 at full sequence length. Because 97.5 percent of test samples were malware, meaning a trivial classifier always predicting malicious would score 97.53 percent accuracy, the authors reported MCC and per-class metrics alongside accuracy. Malware precision, recall, and F1-score each reached 0.99, compared with 0.90 precision, 0.93 recall, and 0.92 F1-score for benign programs. Across the seven top-performing behavior categories, namely evasion, exception handling, memory operations, registry operations, resource operations, synchronization, and system information, the behavior head reached 95.94 percent accuracy, with per-category F1-scores between 89.45 percent and 98.02 percent.
Evaluating predictions strictly from the first five API calls showed high malware capture rates alongside important limits on early certainty. Six of the seven behavior categories exceeded 90 percent malware caught within five calls: 100.00 percent for exception handling across 55 test samples, 99.14 percent for evasion, 99.08 percent for synchronization, 95.64 percent for resource operations, 93.71 percent for registry operations, and 91.25 percent for memory operations. System information lagged at 81.60 percent, plausibly because it relies on generic queries like GetSystemInfo and GetSystemTimeAsFileTime that benign programs also invoke. Over the full test set, five-call accuracy was 93.49 percent with an MCC of 0.43, indicating utility as an early warning rather than a final verdict; reliability rose to an MCC of 0.63 around 35 calls and 0.83 from roughly 80 calls onward. The authors attributed early flagging to the early-weighted loss and shared startup routines, including registry probing, unpacking, fingerprinting, and mutex creation, that precede the payload.
Benchmarking on matched hardware against a single-head LSTM baseline with 179,778 parameters showed that PA-MHL’s 9.5 percent parameter increase added negligible latency overhead. At batch size one, PA-MHL averaged 1.546 milliseconds per sequence versus 1.484 milliseconds for the baseline, within measurement noise, staying at 1.48 to 1.56 milliseconds across partial sequences. At batch size 64, PA-MHL was faster and more consistent at 45.744 milliseconds versus 53.282 milliseconds, while peak process memory stayed at 2.30 gigabytes for both models due to fixed runtime overhead. On 6,193 paired test samples, McNemar’s test confirmed PA-MHL’s edge over the baseline (99.21 percent versus 98.64 percent; 45 versus 20 discordant wins, p equals 0.0029), though the comparison did not separate multi-head design from pretraining. Against published Oliveira baselines, PA-MHL matched state-of-the-art binary detection range, slightly below a 2026 GRU baseline, while uniquely reporting all three tasks.
Adversarial stress testing further distinguished the full PA-MHL pipeline from the single-task baseline, while exposing clear failure bounds. Because API calls are discrete tokens, the authors perturbed continuous embedding outputs as an analytical white-box probe rather than a simulation of real-world attackers modifying executable code. Under single-step Fast Gradient Sign Method attacks, PA-MHL retained 94.95 percent accuracy at epsilon equals 0.10 compared with 86.44 percent for the baseline, and 88.32 percent versus 48.26 percent at epsilon equals 0.20. Under stronger 10-iteration Projected Gradient Descent, PA-MHL led by 14.2 percentage points at epsilon equals 0.10 (38.54 percent versus 24.36 percent), but both models collapsed below two percent accuracy at epsilon equals 0.20.
Cross-dataset testing on the newer MalbehavD-V1 benchmark, containing 2,570 balanced Windows sequences with a median length of 37 calls, demonstrated both methodological generality and severe dataset shift. Three-grams still covered 90 percent of MalbehavD-V1 training malware, and every Oliveira background API remained a background call, yet only 0.4 percent of extracted MalbehavD-V1 patterns matched Oliveira patterns. Applied directly without retraining, the Oliveira model performed at chance level: 52.21 percent detection accuracy (MCC 0.04), 51.69 percent early detection, and 24.36 percent behavior accuracy across four qualifying categories, reacting mostly to sequence length. Training the pipeline from scratch on MalbehavD-V1 reached 92.38 percent detection, 90.74 percent early detection, and 81.20 percent behavior accuracy, whereas fine-tuning the Oliveira weights raised those figures to 93.51 percent, 92.47 percent, and 88.46 percent, confirming reusable behavior representations.
The authors note several constraints on real-world deployment. PA-MHL depends heavily on the quality of extracted n-grams, meaning rare, novel, or scattered variable-length attacks without consistent local motifs may be missed. Its vocabulary and behavior ontology are specific to Windows APIs, requiring reconstruction for platforms such as Linux or Android. Direct comparisons against Transformer architectures, evaluations under discrete API-level evasion attacks, and integration of malware family labels remain open work for future studies.
Subject of Research: Deep learning framework for joint malware detection, behavioral categorization, and early API sequence triage
Article Title: PA-MHL: A Pattern-Aware Multi-Head LSTM for joint malware detection, behavior classification, and early detection from API call sequences
Article References: Anwar, W., Mirza, S., & Hawree, A. (2026). PA-MHL: A Pattern-Aware Multi-Head LSTM for joint malware detection, behavior classification, and early detection from API call sequences. Machine Learning with Applications, 26, Article 101069. https://doi.org/10.1016/j.mlwa.2026.101069
Image Credits: AI Generated
DOI: 10.1016/j.mlwa.2026.101069
Keywords: malware detection, API call sequences, long short-term memory, multi-task learning, early threat detection, behavior classification, n-gram pattern mining, cybersecurity, dynamic behavioral analysis, process injection, adversarial robustness, threat triage, Windows security, system call telemetry, machine learning security, reverse engineering
Cite Scienmag News
Blake Davidson. (December 2, 2026). Multi-Head Neural Network Detects Windows Malware Within First Five System Calls. Scienmag. https://scienmag.com/multi-head-neural-network-detects-windows-malware-within-first-five-system-calls/
Blake Davidson. "Multi-Head Neural Network Detects Windows Malware Within First Five System Calls." Scienmag, 2 December 2026, https://scienmag.com/multi-head-neural-network-detects-windows-malware-within-first-five-system-calls/. Accessed 2 December 2026.
Blake Davidson. "Multi-Head Neural Network Detects Windows Malware Within First Five System Calls." Scienmag. December 2, 2026. https://scienmag.com/multi-head-neural-network-detects-windows-malware-within-first-five-system-calls/








