Next-Generation Cyber Defense: Transformer-Based AI for Threat Detection and Autonomous Response in Dynamic Environments | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article Next-Generation Cyber Defense: Transformer-Based AI for Threat Detection and Autonomous Response in Dynamic Environments Godfrey OIse This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-7961869/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract The escalating sophistication of cyber threats in dynamic digital ecosystems demands the deployment of intelligent and adaptive defense mechanisms capable of real-time detection, interpretation, and mitigation. This research presents a Transformer-Based Threat Detection and Response Framework, an advanced AI-driven cybersecurity architecture designed to autonomously identify and counter malicious activities in large-scale networked environments. Utilizing the comprehensive UNSW-NB15 dataset, the proposed model adopts a customized encoder-only Transformer architecture that effectively captures long-range contextual dependencies among network traffic features such as packet rates, flow duration, and protocol behavior. The model incorporates multi-head self-attention, layer normalization, and global pooling to extract discriminative representations crucial for attack identification, while a reinforcement learning module enables adaptive and context-aware response selection. Experimental results demonstrate an impressive 96.78% classification accuracy, underscoring the framework’s superior performance and generalization across multiple attack vectors, including Denial of Service (DoS), reconnaissance, and infiltration attempts. Comparative evaluations confirm that the attention-based mechanism enhances sensitivity to subtle threat patterns that traditional sequential and convolutional models often overlook. Furthermore, attention-weight visualization contributes to interpretability and transparency, supporting human trust and explainable AI in cybersecurity. Overall, this study establishes the viability of Transformer-based architectures as a cornerstone for next-generation, autonomous, and interpretable cyber defense systems applicable to cloud, IoT, and industrial control environments. Transformer-based Intrusion Detection Reinforcement Learning (RL) Cybersecurity Automation Self-Attention Mechanism Adaptive Threat Response Full Text Additional Declarations No competing interests reported. Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-7961869","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":541820154,"identity":"7a5b1bf5-5a85-48e9-9b14-0ca8e2906e3d","order_by":0,"name":"Godfrey OIse","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABOklEQVRIiWNgGAWjYHACgw9gihmIPzAcAJKMDUBCIgEsyoNVi+EMmBbGGaRpAeniAWuBAJxa5N2bNzZXVBxm4Gdnf/jYdsedxPnthxuYeXdY5PFLNzA+eNuGacWZY4WNZ84cZpBs5jE2zj3zLHHDmUSgljMSxZJzDjAbzsWiZUaO+cPGtsMMBod52KRz2w4nbpBgBGppk0jccCOBTZoXqxbDxsZ/IC3sz39bArXMnwHVsv9GAvtvLFrkJUBaGkBaGMyYGYFaGm7AbJFIYGPGosWAB+iXhmPpPCC/SPaeOWwM8svBuW0SxRI3Epsl55zDtKW9eWNjQ421HD//8Ycffu44LDu//fhDYEDV5fHPSD744U0Zpi0HwFQzJPyBkejYAKQhgpA4xbQFIloHV2OPTdUoGAWjYBSMbAAAFdN1GU+TaWgAAAAASUVORK5CYII=","orcid":"","institution":"University of Benin","correspondingAuthor":true,"prefix":"","firstName":"Godfrey","middleName":"","lastName":"OIse","suffix":""}],"badges":[],"createdAt":"2025-10-27 15:37:39","currentVersionCode":1,"declarations":"","doi":"10.21203/rs.3.rs-7961869/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-7961869/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":95537908,"identity":"f36cbe39-9257-4a64-a6b7-7ee5c333beb0","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"docx","order_by":0,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":797444,"visible":true,"origin":"","legend":"","description":"","filename":"Next.docx","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/3cfff71c78da84e7dd7e52d9.docx"},{"id":95537909,"identity":"fd9e42fb-8258-45ec-a501-4bc896c4230e","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"json","order_by":1,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":3619,"visible":true,"origin":"","legend":"","description":"","filename":"b2eee6a688644a389d2451c9c7dc1766.json","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/c81fdd42ef3080e47b9c5eb3.json"},{"id":95537910,"identity":"ce65057b-9b37-485c-bfa3-a546b3f522c5","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"xml","order_by":2,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":95291,"visible":true,"origin":"","legend":"","description":"","filename":"b2eee6a688644a389d2451c9c7dc17661enriched.xml","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/124e238d66797bcdc39abe74.xml"},{"id":95537907,"identity":"c18a44e5-1f2b-48c9-a898-951ef2ea7c84","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":3,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":573705,"visible":true,"origin":"","legend":"","description":"","filename":"floatimage1.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/ca0e11cf31f9e464c9dffd8d.png"},{"id":95537916,"identity":"7e1f3ef5-aa87-4f8f-a201-25401e11e143","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":4,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":37452,"visible":true,"origin":"","legend":"","description":"","filename":"floatimage2.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/dd910b158a76d4c913a8a064.png"},{"id":95654167,"identity":"be4f5853-f947-4f96-a560-10c32b419d46","added_by":"auto","created_at":"2025-11-11 16:10:08","extension":"png","order_by":5,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":29965,"visible":true,"origin":"","legend":"","description":"","filename":"floatimage3.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/6e288d19a40e6cf112aee6ea.png"},{"id":95537906,"identity":"315c8718-c1e3-4179-9870-0f5537b5372c","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":6,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":8442,"visible":true,"origin":"","legend":"","description":"","filename":"floatimage4.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/bfa842b382e0905fe793e7ce.png"},{"id":95537912,"identity":"5f1e6943-45de-40f1-a621-941ea45a0e2e","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":7,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":15442,"visible":true,"origin":"","legend":"","description":"","filename":"floatimage5.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/d02f1ae34048942f0e8108c6.png"},{"id":95537914,"identity":"6825ef1e-2d0b-4aaa-bf1e-5bcbe09c8179","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":8,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":32899,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage1.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/6076ef7a49627fa54bf18742.png"},{"id":95654191,"identity":"5774eb55-7b2c-4cc4-bcf3-bb96989e8dcc","added_by":"auto","created_at":"2025-11-11 16:10:19","extension":"png","order_by":9,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":10998,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage2.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/db302b8cfa2789ddc662b661.png"},{"id":95654157,"identity":"6f6bd964-572c-4463-a4d8-8fc67dbe4b09","added_by":"auto","created_at":"2025-11-11 16:10:05","extension":"png","order_by":10,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":8841,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage3.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/f08a482f98de5c580e9e4a76.png"},{"id":95537917,"identity":"bfcd7bf0-87bf-4729-acf3-8c79a331ad84","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"png","order_by":11,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":3506,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage4.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/22a966d866e410bbf3d31bdc.png"},{"id":95653990,"identity":"9d08abfd-da2f-4e28-84b6-4804358e988a","added_by":"auto","created_at":"2025-11-11 16:07:41","extension":"png","order_by":12,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":4599,"visible":true,"origin":"","legend":"","description":"","filename":"Onlinefloatimage5.png","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/37e885d71e9a59c334878868.png"},{"id":95537918,"identity":"90783984-05a4-43ee-b50d-60ac424e927c","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"xml","order_by":13,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":94285,"visible":true,"origin":"","legend":"","description":"","filename":"b2eee6a688644a389d2451c9c7dc17661structuring.xml","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/4699ef5fce15820e85987809.xml"},{"id":95537920,"identity":"0061e636-ceb5-4d8f-9bed-d272dc6646cf","added_by":"auto","created_at":"2025-11-10 10:54:12","extension":"html","order_by":14,"title":"","display":"","copyAsset":false,"role":"acdc-reference","size":103154,"visible":true,"origin":"","legend":"","description":"","filename":"earlyproof.html","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1/985ee91eb3f26f1eaf916ba1.html"},{"id":107918384,"identity":"ebcbd8ab-60c3-43ec-affa-53c6f93216a9","added_by":"auto","created_at":"2026-04-27 14:27:54","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":409011,"visible":true,"origin":"","legend":"","description":"","filename":"Next.pdf","url":"https://assets-eu.researchsquare.com/files/rs-7961869/v1_covered_71266937-812e-46f9-9ad6-db3f26df313b.pdf"}],"financialInterests":"No competing interests reported.","formattedTitle":"\u003cp\u003eNext-Generation Cyber Defense: Transformer-Based AI for Threat Detection and Autonomous Response in Dynamic Environments\u003c/p\u003e","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":false,"hideJournal":true,"highlight":"","institution":"","isAcceptedByJournal":false,"isAuthorSuppliedPdf":true,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":true,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"Transformer-based Intrusion Detection, Reinforcement Learning (RL), Cybersecurity Automation, Self-Attention Mechanism, Adaptive Threat Response","lastPublishedDoi":"10.21203/rs.3.rs-7961869/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-7961869/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eThe escalating sophistication of cyber threats in dynamic digital ecosystems demands the deployment of intelligent and adaptive defense mechanisms capable of real-time detection, interpretation, and mitigation. This research presents a Transformer-Based Threat Detection and Response Framework, an advanced AI-driven cybersecurity architecture designed to autonomously identify and counter malicious activities in large-scale networked environments. Utilizing the comprehensive UNSW-NB15 dataset, the proposed model adopts a customized encoder-only Transformer architecture that effectively captures long-range contextual dependencies among network traffic features such as packet rates, flow duration, and protocol behavior. The model incorporates multi-head self-attention, layer normalization, and global pooling to extract discriminative representations crucial for attack identification, while a reinforcement learning module enables adaptive and context-aware response selection. Experimental results demonstrate an impressive 96.78% classification accuracy, underscoring the framework\u0026rsquo;s superior performance and generalization across multiple attack vectors, including Denial of Service (DoS), reconnaissance, and infiltration attempts. Comparative evaluations confirm that the attention-based mechanism enhances sensitivity to subtle threat patterns that traditional sequential and convolutional models often overlook. Furthermore, attention-weight visualization contributes to interpretability and transparency, supporting human trust and explainable AI in cybersecurity. Overall, this study establishes the viability of Transformer-based architectures as a cornerstone for next-generation, autonomous, and interpretable cyber defense systems applicable to cloud, IoT, and industrial control environments.\u003c/p\u003e","manuscriptTitle":"Next-Generation Cyber Defense: Transformer-Based AI for Threat Detection and Autonomous Response in Dynamic Environments","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2025-11-10 10:54:07","doi":"10.21203/rs.3.rs-7961869/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"
[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"750b9206-1b8a-47b3-b3ab-df823c68ecee","owner":[],"postedDate":"November 10th, 2025","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[],"tags":[],"updatedAt":"2026-04-27T14:27:26+00:00","versionOfRecord":[],"versionCreatedAt":"2025-11-10 10:54:07","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-7961869","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-7961869","identity":"rs-7961869","version":["v1"]},"buildId":"8U1c8b4HqxoKbykW_rLl7","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}
Text is read by the "Ask this paper" AI Q&A widget below.
Extraction quality varies by source — PMC NXML preserves structure
cleanly, OA-HTML may include some navigation residue, and OA-PDF can
have broken hyphenation. The publisher copy
(via DOI)
is the canonical version.