Fuente:
PubMed "apis"
Sci Rep. 2026 Mar 7. doi: 10.1038/s41598-026-43111-9. Online ahead of print.ABSTRACTAccurate prediction of user actions is essential for optimizing digital platform workflows, enabling proactive recommendations, resource prefetching, and intelligent user assistance. Traditional Markov chain-based methods, though widely used for modeling sequential behavior, are fundamentally limited in capturing the complexity, long-range dependencies, and multi-objective nature of real-world user interactions. This paper introduces a multi-task attention-based transformer architecture for sequential API recommendation that addresses these gaps in robustness and generalizability. The core insight is that user behavior on enterprise platforms is driven by latent intent: users with different goals-such as executing a machine learning pipeline, conducting data analysis, managing user accounts, or generating quick visualizations-exhibit systematically different sequential patterns across functional API categories. Our framework exploits this structure through a shared transformer encoder backbone that produces a unified representation of the user's action history, which is then decoded by three task-specific prediction heads operating simultaneously. The primary head predicts the next API action from a probability distribution over all available endpoints; an auxiliary goal classification head infers the user's underlying session objective from the observed action sequence alone; and a session boundary detection head estimates the probability that the user is about to conclude their session. During inference, only the sequence of prior API calls is required as input-the model jointly infers what the user will do next, what they are trying to accomplish, and whether they are about to leave, all from the observed behavioral trace. Leveraging a large-scale simulated behavioral dataset encompassing 2, 000 user sessions and 20, 000 API calls across 100 APIs organized into 10 functional categories, with 4 distinct session goal types governing workflow-specific transition patterns, our model demonstrates strong performance across all tasks. The primary API prediction task achieves [Formula: see text] top-1 accuracy and [Formula: see text] top-5 hit rate, representing a [Formula: see text] improvement over a first-order Markov chain baseline. Auxiliary tasks further validate the framework's effectiveness, with goal prediction reaching [Formula: see text] accuracy and session-end detection achieving [Formula: see text] accuracy. To ensure full reproducibility, we release an open-source Python package, context-engineer, available on PyPI, that enables researchers and practitioners to regenerate the experimental dataset, reproduce all reported results, and-critically-apply the same multi-task transformer pipeline to their own user log data by mapping proprietary action sequences and session labels into the framework's integer-encoded input format. Our approach not only advances prediction accuracy over conventional sequential methods but also establishes a new, reproducible benchmark for modeling multi-objective sequential user behavior on digital platforms, with direct applicability to any enterprise environment where user actions can be represented as ordered sequences of discrete events.PMID:41794914 | DOI:10.1038/s41598-026-43111-9