﻿{"id":3835,"date":"2025-07-09T10:49:20","date_gmt":"2025-07-09T05:19:20","guid":{"rendered":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/?p=3835"},"modified":"2025-07-09T10:49:20","modified_gmt":"2025-07-09T05:19:20","slug":"learning-on-the-fly-user-driven-adaptation-in-small-language-models","status":"publish","type":"post","link":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/artificial-intelligence\/learning-on-the-fly-user-driven-adaptation-in-small-language-models.html","title":{"rendered":"Learning on the Fly : User Driven Adaptation in Small Language models"},"content":{"rendered":"<p>Cybersecurity demands a proactive approach, going beyond simply reacting to threats. It demands proactive, intelligent systems capable of learning from every interaction. Enter Small Language Models (SLMs), fine-tuned for specific domains like cyber defense. These models, when continuously updated, can transform from static tools into dynamic assets that adapt to emerging threats.<\/p>\n<p>In our <a href=\"http:\/\/hyperlink https:\/\/blogs.infosys.com\/emerging-technology-solutions\/artificial-intelligence\/fine-tuning-llama-for-cybersecurity-chatbots-and-agentic-ai-a-comprehensive-approach.html\">previous blog<\/a>, we explored how fine-tuning LLaMA models enables the creation of cybersecurity-specific chatbots and agentic AI systems. Building upon that foundation, this post takes a step further\u2014toward enabling these models to learn from their own mistakes.<\/p>\n<p>The true potential of SLMs is unlocked when they can learn from user interactions, particularly from instances where their responses fall short. By capturing signals of dissatisfaction\u2014such as follow-up questions indicating confusion or frustration\u2014we can create a feedback loop that drives continuous improvement. This approach ensures that the model not only provides accurate information but also aligns with the user&#8217;s expectations and needs.<\/p>\n<p>Large Language Models (LLMs), like GPT-4, offer a unique opportunity to enhance this process. Their generative capabilities can be harnessed to augment training data, creating new question-answer pairs that address gaps identified through user feedback. This synergy between SLMs and LLMs fosters a self-learning memory system, enabling cybersecurity models to evolve in real-time, much like a seasoned analyst refining their expertise with each new challenge.<\/p>\n<p>In this blog, we will explore how to build such a self-learning memory for SLMs from a cybersecurity perspective. We will delve into the steps of capturing user dissatisfaction, suppressing sensitive information, generating enhanced training data, and fine-tuning models to create a continuous learning loop. By the end, you&#8217;ll have a comprehensive understanding of how to transform your SLM into a self-improving cybersecurity assistant.<\/p>\n<h2>When to Use Fine-Tuning vs Retrieval Augmentation (RAG) in Cybersecurity<\/h2>\n<p>Choosing between fine-tuning a Small Language Model (SLM) and using Retrieval-Augmented Generation (RAG) depends heavily on the cybersecurity use case and the nature of the data involved.<\/p>\n<h3>Fine-Tuning: Embedding Domain Expertise Deeply<\/h3>\n<p>Fine-tuning updates the model\u2019s internal weights to incorporate new knowledge, making it an excellent choice when you need the model to intrinsically understand evolving cyber defense tactics, attacker behaviors, and threat intelligence. For example, if a SOC analyst notices recurring patterns of novel phishing attacks or new malware behaviors, fine-tuning the SLM with these examples ensures the model inherently grasps these subtleties and can respond accurately without external context.<\/p>\n<p>Fine-tuning is best when:<\/p>\n<ul>\n<li>The knowledge updates are structured and stable over time.<\/li>\n<li>You want consistent, fast responses without relying on external document retrieval.<\/li>\n<li>The use case demands deep domain reasoning that benefits from the model\u2019s latent understanding.<\/li>\n<\/ul>\n<figure id=\"attachment_3854\" aria-describedby=\"caption-attachment-3854\" style=\"width: 530px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-3854 size-full\" src=\"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-content\/uploads\/2025\/06\/Learning-on-the-fly-2.png\" alt=\"\" width=\"530\" height=\"415\" \/><figcaption id=\"caption-attachment-3854\" class=\"wp-caption-text\">Flow Diagram<\/figcaption><\/figure>\n<h3>Retrieval Augmentation (RAG): Leveraging Dynamic, Growing Corpora<\/h3>\n<p>RAG combines a fixed language model with a retrieval system that pulls in relevant external documents or data at query time. This approach is ideal when the knowledge base is rapidly changing, such as newly released threat reports, vulnerability disclosures, or real-time incident logs.<\/p>\n<p>RAG is preferred when:<\/p>\n<ul>\n<li>The corpus is large, dynamic, and frequently updated.<\/li>\n<li>You want to maintain a lightweight core model without constant retraining.<\/li>\n<\/ul>\n<p>Responses must incorporate the latest information that may not yet be part of the model\u2019s training.<\/p>\n<h3>Prompt Tuning: Lightweight Adaptation for Rapid Adjustments<\/h3>\n<p>Prompt tuning (also known as instruction tuning or prefix tuning) enables targeted behavioural changes in Small Language Models without modifying their core weights. Instead of retraining the entire model, prompt tuning appends learnable embeddings or text prompts that guide the model&#8217;s output in a specific domain or context.<\/p>\n<p>This approach is especially effective in cybersecurity scenarios where:<\/p>\n<ul>\n<li>The team wants rapid updates without large compute resources.<\/li>\n<li>The model is hosted in a restricted environment (e.g., on-prem SOC, air-gapped systems).<\/li>\n<li>You want to experiment with user-intent shifts or temporary guidance without committing to full fine-tuning.<\/li>\n<\/ul>\n<p>For instance, a model can be prompt-tuned to prioritize threat intelligence from a particular vendor or emphasize a zero-trust policy context across all interactions.<\/p>\n<p>Prompt tuning is best when:<\/p>\n<ul>\n<li>You need fast, low-cost iteration over behavior.<\/li>\n<li>You are experimenting with A\/B testing new model styles or tones.<\/li>\n<li>Infrastructure limitations restrict model retraining.<\/li>\n<\/ul>\n<h3>Cybersecurity Example<\/h3>\n<p>Consider a scenario where a SOC chatbot supports analysts by answering questions about attacker Tactics, Techniques, and Procedures (TTPs):<\/p>\n<ul>\n<li>If new TTPs emerge and need to be embedded into the chatbot\u2019s core knowledge, fine-tuning the SLM ensures the model can reason and generalize about these tactics seamlessly.<\/li>\n<li>However, if analysts need quick access to the latest threat intelligence reports or incident data, a RAG approach allows the chatbot to pull in up-to-date documents without retraining.<\/li>\n<\/ul>\n<p>In practice, many cybersecurity solutions combine both\u2014using RAG for fresh data and fine-tuning for stable core knowledge. This blog focuses on advancing the fine-tuning side by building a self-learning memory that continually updates the SLM based on user feedback and dissatisfaction signals.<\/p>\n<h2>Steps to Create Long Term Memory<\/h2>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3855 size-full\" src=\"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-content\/uploads\/2025\/06\/Learning-on-the-fly-3.png\" alt=\"Steps to Create Long Term Memory\" width=\"503\" height=\"755\" \/><\/p>\n<h3>Step 1: Building the Fine-Tuning Pipeline for Cyber SLMs<\/h3>\n<p>To enable a Small Language Model (SLM) to learn continuously from user interactions, we need a modular, auditable, and secure fine-tuning pipeline. The goal is to create a loop where model performance improves based on real-world chat data\u2014particularly on questions that expose limitations in the model\u2019s current knowledge.<\/p>\n<h4>Key Components of the Pipeline:<\/h4>\n<ol>\n<li>Chat Interaction Capture: Capture question-answer pairs from end-user interactions, especially focusing on cases where follow-up questions indicate confusion or dissatisfaction.<\/li>\n<li>Dissatisfaction Detection: Use sentiment analysis and heuristics to identify follow-up questions that imply the previous response was unsatisfactory.<\/li>\n<li>Sensitive Data Redaction: Automatically scrub personally identifiable information (PII), such as emails, IP addresses, names, and organization details, to ensure compliance and data safety.<\/li>\n<li>Augmented Data Generation: Use a secure GPT-4 API backend to create improved or alternate Q&amp;A pairs, based on the gaps identified.<\/li>\n<li>Dataset Curation &amp; Formatting: Structure the collected and cleaned data into instruction-tuning format (e.g., Alpaca-style) for ingestion.<\/li>\n<li>Model Fine-Tuning: Use QLoRA or LoRA-based adapters on top of the LLaMA 3.1 8B base model to reduce compute requirements while achieving high adaptability.<\/li>\n<li>Benchmark &amp; Feedback Loop: After fine-tuning, evaluate the model on both known and new queries to validate learning improvement.<\/li>\n<\/ol>\n<h3>Step 2: Logging User Conversations in a Relational Database<\/h3>\n<p>Capturing real-world interactions between users and your cyber defense chatbot is the foundation of a self-learning system. However, instead of logging entire session histories or user identifiers, the focus should remain on contextually meaningful Q&amp;A pairs\u2014especially those where a user&#8217;s next question reveals ambiguity, confusion, or dissatisfaction with the previous answer.<\/p>\n<h4>What to Log (Minimalist Schema):<\/h4>\n<table style=\"border: 1px solid black\">\n<tbody>\n<tr>\n<td style=\"border: 1px solid white;background-color: #8fb1e8\"><strong>Column<\/strong><\/td>\n<td style=\"border: 1px solid white;background-color: #8fb1e8\"><strong>Type<\/strong><\/td>\n<td style=\"border: 1px solid white;background-color: #8fb1e8\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>question<\/td>\n<td>TEXT<\/td>\n<td>The user\u2019s input query (q1)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>answer<\/td>\n<td>TEXT<\/td>\n<td>The model\u2019s original response (a1)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>next_question<\/td>\n<td>TEXT<\/td>\n<td>The follow-up question (q2 or qs)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>sentiment<\/td>\n<td>FLOAT<\/td>\n<td>Sentiment score of next_question (computed later)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>flagged<\/td>\n<td>BOOLEAN<\/td>\n<td>Whether the conversation should be considered for retraining<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This simple schema, stored in a Relational database, is optimized for identifying improvement areas without compromising user identity.<\/p>\n<h5>Example Conversation:<\/h5>\n<ul>\n<li>q1: &#8220;How does lateral movement work in APT attacks?&#8221;<\/li>\n<li>a1: &#8220;Lateral movement allows attackers to move across systems after initial compromise.&#8221;<\/li>\n<li>qs: &#8220;Can you give an example in a Windows Active Directory environment?&#8221;<\/li>\n<li>Sentiment score: -0.3<\/li>\n<li>Flagged: \u2705<\/li>\n<\/ul>\n<p>Even though a1 isn&#8217;t technically wrong, qs clearly indicates that the answer lacked context or clarity for the user\u2019s specific need. This pair is ideal for re-training.<\/p>\n<h3>Step 3: Capturing User Dissatisfaction Through Sentiment Analysis<\/h3>\n<p>Not all user follow-up questions indicate dissatisfaction\u2014but when they do, it&#8217;s a critical signal for improving the model. Sentiment analysis helps us identify these moments automatically and at scale. In the context of cybersecurity chatbots, we\u2019re especially interested in detecting:<\/p>\n<ul>\n<li>Confusion (\u201cWhat do you mean by\u2026\u201d)<\/li>\n<li>Frustration (\u201cThat\u2019s not helpful, explain more.\u201d)<\/li>\n<li>Ambiguity requests (\u201cIn which scenario would that apply?\u201d)<\/li>\n<\/ul>\n<p>While sentiment analysis is typically used in customer experience contexts, it can be adapted for technical domains using open-source libraries.<\/p>\n<h4>Open-Source Options<\/h4>\n<p>We\u2019ll use Valence Aware Dictionary, for sentiment Reasoning (VADER), is a lexicon-based sentiment analyzer that works well even with follow-up questions. It&#8217;s lightweight, fast, and license friendly. You can also extend this later with Hugging Face models or LLM-assisted critique.<\/p>\n<h4>Python Code Snippet: Sentiment Scoring<\/h4>\n<p>Ref :<\/p>\n<ul>\n<li><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2022\/07\/sentiment-analysis-using-python\/\">sentiment-analysis-using-python<\/a><\/li>\n<li><a href=\"https:\/\/www.kaggle.com\/code\/robikscube\/sentiment-analysis-python-youtube-tutorial\">sentiment-analysis-python-youtube-tutorial<\/a><\/li>\n<li><a href=\"https:\/\/vadersentiment.readthedocs.io\/en\/latest\/pages\/code_and_example.html\">vadersentiment example<\/a><\/li>\n<\/ul>\n<h4>Sample Output:<\/h4>\n<p><span style=\"background-color: #1e1e1e;color: #dcdcaa;font-family: Consolas, monospace;padding: 2px 4px;border-radius: 3px\">Sentiment Score: <span style=\"color: #b5cea8\">0.05<\/span>, Flagged: <span style=\"color: #569cd6\">True<\/span><\/span><\/p>\n<p><strong>NOTE:<\/strong> Over time, you can evolve this logic into a hybrid model using LLMs to classify user follow-ups as &#8220;unclear\/neutral\/clear&#8221;, allowing more nuanced scoring.<\/p>\n<h3>Step 4: Suppressing Sensitive Information in Q&amp;A Data<\/h3>\n<p>Before using chat transcripts for fine-tuning, it\u2019s essential to remove or anonymize any personally identifiable information (PII) or sensitive organizational data. This is not only a security best practice\u2014it also helps ensure compliance with data protection standards like GDPR and enterprise policies.<\/p>\n<p>In cybersecurity chats, the typical sensitive entities to redact include:<\/p>\n<ul>\n<li>Usernames, names of individuals<\/li>\n<li>Email addresses<\/li>\n<li>IP addresses (v4 and v6)<\/li>\n<li>Organization or domain names<\/li>\n<li>File paths, registry keys<\/li>\n<li>Internal project or tool names<\/li>\n<\/ul>\n<h4>Python Code Snippet: Suppressing Sensitive Information<\/h4>\n<p>Ref<\/p>\n<ul>\n<li>https:\/\/spacy.io\/usage\/rule-based-matching<\/li>\n<\/ul>\n<h4>Example<\/h4>\n<div style=\"background-color: #1e1e1e;color: #dcdcdc;font-family: Consolas, monospace;padding: 16px;border-radius: 6px;overflow: auto\">\n<pre style=\"margin: 0\"><code style=\"background-color: #1e1e1e\">\r\n<span style=\"background-color: #1e1e1e;color: #9cdcfe\">sample_qa<\/span><span style=\"color: #dcdcdc\"> = <\/span><span style=\"background-color: #1e1e1e;color: #ce9178\">\"\"\"<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #d4d4d4\">User abc@xyz.com reported suspicious behavior from 192.168.1.12.<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #d4d4d4\">Tool 'NetScanPro.exe' found anomalies on C:\\ \\Program Files\\ \\NetScanPro\\ \\run.exe.<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #d4d4d4\">Escalated to Alice from Infosys Security Response.<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">\"\"\"<\/span>\r\n\r\n<\/code><\/pre>\n<\/div>\n<h3>Step 5: Generating Better Training Data Using GPT-4<\/h3>\n<p>Once you\u2019ve identified unsatisfactory Q&amp;A pairs and redacted sensitive data, the next step is to generate improved responses\u2014or entirely new, well-formed training samples. For this, you can leverage GPT-4 via Azure OpenAI, configured with appropriate prompt engineering to stay within the cyber defense domain.<\/p>\n<p>This process allows your self-learning memory system to bootstrap better responses using a high-performing LLM before retraining your fine-tuned LLaMA 3.1 model.<\/p>\n<h5>Prompt Design: GPT-4 for Cybersecurity Q&amp;A Improvement<\/h5>\n<p>We craft a task-specific prompt that:<\/p>\n<ul>\n<li>Describes the chatbot\u2019s role<\/li>\n<li>Provides the original question and sub-par answer<\/li>\n<li>Requests an improved, red-team\/blue-team aware response<\/li>\n<li>Optionally, asks for 1\u20132 synthetic variations for robustness<\/li>\n<\/ul>\n<h4>Sample Prompt<\/h4>\n<div style=\"background-color: #1e1e1e;color: #dcdcdc;font-family: Consolas, monospace;padding: 16px;border-radius: 6px;line-height: 1.6\">\n<div><span style=\"background-color: #1e1e1e;color: #6a9955\">You are a cybersecurity assistant trained to help SOC analysts understand attacker behavior and defenses.<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #d4d4d4\">Below is a user question and the chatbot&#8217;s earlier response, which the user found unhelpful.<\/span><\/div>\n<p>&nbsp;<\/p>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\">Question<\/span>: <span style=\"background-color: #1e1e1e;color: #ce9178\">&#8220;How does lateral movement happen in an APT attack?&#8221;<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\">Previous Answer<\/span>: <span style=\"background-color: #1e1e1e;color: #ce9178\">&#8220;Attackers move across systems.&#8221;<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #6a9955\">The answer was vague. Please provide a detailed, technically correct explanation for blue-team analysts.<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #6a9955\">Also, suggest one or two alternate question-answer pairs that could be added to improve training coverage.<\/span><\/div>\n<\/div>\n<h4>Format:<\/h4>\n<div style=\"background-color: #1e1e1e;color: #dcdcdc;font-family: Consolas, monospace;padding: 16px;border-radius: 6px;line-height: 1.6\">\n<div><span style=\"background-color: #1e1e1e;color: #569cd6\">&#8211; ImprovedAnswer:<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">&lt;text&gt;<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #569cd6\">&#8211; AlternateQA:<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\">Q1:<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">&lt;text&gt;<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\"> A1:<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">&lt;text&gt;<\/span><\/div>\n<div><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\">Q2:<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">&lt;text&gt;<\/span><\/div>\n<div><span style=\"background-color: #1e1e1e;color: #9cdcfe\"> A2:<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">&lt;text&gt;<\/span><\/div>\n<\/div>\n<h3>Step 6: Fine-Tuning the Model (LLaMA 3.1 8B)<\/h3>\n<p>Now that we\u2019ve captured dissatisfaction signals, redacted sensitive data, and enriched the training set using GPT-4, it\u2019s time to fine-tune your Small Language Model (SLM)\u2014LLaMA 3.1 8B\u2014to better respond in cybersecurity contexts.<\/p>\n<p>Because full fine-tuning of an 8B model is compute-intensive, we recommend using QLoRA (Quantized Low-Rank Adaptation) or LoRA, which enables parameter-efficient tuning by injecting lightweight adapters into selected layers.<\/p>\n<h4>Model Architecture and Training Strategy<\/h4>\n<ul>\n<li>Base Model: meta-llama\/Llama-3-8B<\/li>\n<li>Technique: QLoRA (recommended) or LoRA<\/li>\n<\/ul>\n<h3>Step 7: Testing and Benchmarking the Fine-Tuned Cyber Model<\/h3>\n<p>Fine-tuning is only useful when it leads to measurable improvement. To validate the effectiveness of your enhanced LLaMA 3.1 8B model, it&#8217;s important to define metrics, collect test data, and compare results against baselines (e.g., the base model or GPT-4 outputs).<\/p>\n<h4>Evaluation Strategy<\/h4>\n<p>You can use a mix of automatic and manual methods:<\/p>\n<table style=\"border: 1px solid black\">\n<tbody>\n<tr>\n<td style=\"border: 1px solid white;background-color: #8fb1e8;text-align: center\"><strong>Evaluation Type<\/strong><\/td>\n<td style=\"border: 1px solid white;background-color: #8fb1e8;text-align: center\"><strong>Approach<\/strong><\/td>\n<td style=\"border: 1px solid white;background-color: #8fb1e8;text-align: center\"><strong>Tools<\/strong><\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>Accuracy \/ Correctness<\/td>\n<td>TEXT<\/td>\n<td>The user\u2019s input query (q1)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>Helpfulness \/ Clarity<\/td>\n<td>TEXT<\/td>\n<td>The model\u2019s original response (a1)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>Response Diversity<\/td>\n<td>TEXT<\/td>\n<td>The follow-up question (q2 or qs)<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>Token-Level Metrics<\/td>\n<td>FLOAT<\/td>\n<td>Sentiment score of next_question (computed later)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5>Sample Test Questions<\/h5>\n<table style=\"border: 1px solid black\">\n<tbody>\n<tr>\n<td style=\"border: 1px solid white;background-color: #8fb1e8;text-align: center\">Question<\/td>\n<td style=\"border: 1px solid white;background-color: #8fb1e8;text-align: center\">Expected Trait<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>&#8220;How can I detect Kerberoasting?&#8221;<\/td>\n<td>Technical depth<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>&#8220;What does the MITRE T1548 technique involve?&#8221;<\/td>\n<td>Correct classification<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>&#8220;Explain persistence mechanisms in Linux.&#8221;<\/td>\n<td>System-specific clarity<\/td>\n<\/tr>\n<tr style=\"border: 1px solid black\">\n<td>&#8220;Why is DNS tunneling dangerous?&#8221;<\/td>\n<td>Conceptual precision<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4>Python Snippet: GPT-4 as Judge<\/h4>\n<p>Here\u2019s a quick tool to score responses using GPT-4 as a judge (yes, your model can now be critiqued by GPT-4 itself):<\/p>\n<h5>Prompt:<\/h5>\n<div style=\"background-color: #1e1e1e;color: #dcdcdc;font-family: Consolas, monospace;padding: 16px;border-radius: 6px;overflow: auto\">\n<pre style=\"margin: 0\"><code style=\"background-color: #1e1e1e\">\r\n\r\n<span style=\"background-color: #1e1e1e;color: #9cdcfe\">system_prompt<\/span><span style=\"color: #ffffff\"> =<\/span> (\r\n        <span style=\"background-color: #1e1e1e;color: #ce9178\">\"You are a cybersecurity expert and evaluator. Score the candidate response for its technical accuracy, clarity, and usefulness \"<\/span>\r\n        <span style=\"background-color: #1e1e1e;color: #ce9178\">\"on a scale of 1 to 10. Explain the rating briefly.\"<\/span>\r\n    )\r\n<span style=\"background-color: #1e1e1e;color: #9cdcfe\">user_prompt<\/span> <span style=\"color: #ffffff\">=<\/span> <span style=\"background-color: #1e1e1e;color: #ce9178\">f\"\"\"<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">         Question: {question}<\/span>\r\n\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">         Reference Answer: {reference_answer}<\/span>\r\n\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">         Candidate Answer: {candidate_answer}<\/span>\r\n\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">         Score the candidate out of 10 and provide reasoning.<\/span>\r\n<span style=\"background-color: #1e1e1e;color: #ce9178\">             \"\"\"<\/span>\r\n\r\n\r\n<\/code><\/pre>\n<\/div>\n<h5>Python Snippet: BLEU \/ ROUGE<\/h5>\n<p>Ref:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.geeksforgeeks.org\/nlp\/understanding-bleu-and-rouge-score-for-nlp-evaluation\/\">understanding-bleu-and-rouge-score-for-nlp-evaluation<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/@sthanikamsanthosh1994\/understanding-bleu-and-rouge-score-for-nlp-evaluation-1ab334ecadcb\">understanding-bleu-and-rouge-score-for-nlp-evaluation-1ab334ecadcb<\/a><\/li>\n<\/ul>\n<h4>Tips for Cyber Evaluations<\/h4>\n<ul>\n<li>Evaluate per MITRE tactic (e.g., Discovery, Lateral Movement) for targeted fine-tuning impact.<\/li>\n<li>Include new synthetic questions to check generalization.<\/li>\n<li>Track follow-up satisfaction signals again post-deployment for feedback loop validation.<\/li>\n<\/ul>\n<h2>Conclusion: Toward Continual Learning in Cyber Defense AI<\/h2>\n<p>In today\u2019s rapidly evolving threat landscape, a static cybersecurity assistant is quickly outpaced by attacker innovation. This is where self-learning memory becomes transformative. By capturing dissatisfaction signals from real user interactions, redacting sensitive content, and generating better training samples with GPT-4, we unlock a sustainable path for improving Small Language Models (SLMs) like LLaMA 3.1 8B.<\/p>\n<p>This feedback-driven architecture enables a closed-loop system that fine-tunes itself over time\u2014learning from missed context, ambiguous responses, and edge-case scenarios. By augmenting traditional datasets with real-world usage and failure patterns, we build more resilient, context-aware, and cost-efficient cyber defenders.<\/p>\n<p>Fine-tuning is not a silver bullet. It complements but does not replace retrieval-based architectures like RAG. Together, they form a continuum\u2014from long-term memory to dynamic context grounding. Organizations can strategically adopt both, guided by operational needs, latency budgets, and model governance policies.<\/p>\n<p>As the cyber domain becomes increasingly agentic, enabling our models to learn from their own missteps is not just an optimization\u2014it&#8217;s a necessity.<\/p>\n<pre style=\"margin: 0\"><code><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Cybersecurity demands a proactive approach, going beyond simply reacting to threats. It demands proactive, [&hellip;]<\/p>\n","protected":false},"author":504,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[4,9,10],"tags":[60,381,186,382,324],"coauthors":[181],"class_list":["post-3835","post","type-post","status-publish","format-standard","hentry","category-artificial-intelligence","category-intelligent-automation","category-predictive-cyber-security","tag-artificial-intelligence","tag-cybernext","tag-generative-ai","tag-memory","tag-rag"],"acf":[],"_links":{"self":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/users\/504"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/comments?post=3835"}],"version-history":[{"count":18,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3835\/revisions"}],"predecessor-version":[{"id":4006,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/posts\/3835\/revisions\/4006"}],"wp:attachment":[{"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/media?parent=3835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/categories?post=3835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/tags?post=3835"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.infosys.com\/emerging-technology-solutions\/wp-json\/wp\/v2\/coauthors?post=3835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}