AI Assistant & AI Agents - Part 1
Mastering AI System Prompts for Cyber Security ; Enhancing AI Accuracy with Retrieval Augmented Generation
Hello Cyber Builders 🖖,
I'm particularly excited about the future evolution of AI Assistants into AI Agents. These Agents are expected to be the next significant stride in AI, offering substantial productivity enhancements and ultimately transforming our interactions with technology.
This week, we’re diving into the fascinating world of AI Assistants and how they can transform our daily interactions with technology. Next week, we’ll explore the next significant stride in AI—intelligent Agents—and how they can further enhance productivity and efficiency.
There seems to be a lot of confusion around Chatbots, Assistants, and Agents terminology. Therefore, I will dedicate this post to providing clear explanations, ensuring you feel well-informed.
In this Post
What Are AI Assistants?
Effective System Prompts for AI Assistants
Example of AI Assistants in Cyber Security
Better AI Assistants - Using Retrieval Augmented Generation (RAG)
AI Assistants - What Are They?
We are all familiar with AI Assistants, as many use technologies like ChatGPT daily. The process is simple: you provide an input (prompt) and receive an answer.
This straightforward interaction is known as zero-shot learning. Zero-shot means you provided nothing but your query and are not helping the assistant focus on a specific role.
However, a better System prompt can obtain more refined and accurate responses. A System prompt is a persistent instruction that guides the AI model throughout the interaction. A good System prompt is clear, specific, and aligned with the desired outcome.
Here are a few characteristics of an effective System prompt:
Objective-Oriented: Clearly defines the role or task of the AI. For example, “You are a cybersecurity specialist, acting as a penetration tester and ethical hacker for your customer.”
Contextual: Provides relevant background information to guide the AI’s responses. For example, “You are assisting your users to understand if they have security weaknesses in their corporate network and Active Directory.”
Directive: Includes specific instructions on how the AI should respond, such as “Provide step-by-step instructions and ask clarifying questions if needed.”
Formatting Guidance: Specifies the desired format of the output, such as “Please format your response as a numbered list” or “JSON file.”
Tone and Style: Defines the tone and style of the response. For example, “Respond as you are talking to a peer network engineer.”
For more guidelines, please refer to the great “Prompt Engineering Guide” (HERE).
Assistants are based on Generative AI and large language models (LLMs), which can create new content based on their training data. LLMs can understand and generate human-like text, excelling in translation, summarization, and conversation. But they need your guidance via Prompting.
AI Assistant & CyberSecurity - Threat Intelligence “summarization”
Noteworthy system prompts examples come from Daniel Miesler Fabric’s project (HERE). As you will see below, it could be a VERY long prompt 😁
I am quoting one of them here (source)
IDENTITY and PURPOSE
You are an expert at creating concise security updates for newsletters according to the STEPS below.
Take a deep breath and think step by step about how to best accomplish this goal using the following steps.
STEPS Read all the content and think deeply about it. Organize all the content on a virtual whiteboard in your mind.
OUTPUT SECTIONS
Output a section called Threats, Advisories, and Vulnerabilities with the following structure of content.
Stories: (interesting cybersecurity developments)
A 15-word or less description of the story. $MORE$
Next one $MORE$
Next one $MORE$
Up to 10 stories
Threats & Advisories: (things people should be worried about)
A 10-word or less description of the situation. $MORE$
Next one $MORE$
Next one $MORE$
Up to 10 of them
New Vulnerabilities: (the highest criticality new vulnerabilities)
A 10-word or less description of the vulnerability. | $CVE NUMBER$ | $CVSS SCORE$ | $MORE$
Next one $CVE NUMBER$ | $CVSS SCORE$ | $MORE$
Next one $CVE NUMBER$ | $CVSS SCORE$ | $MORE$
Up to 10 vulnerabilities
A 1-3 sentence summary of the most important issues talked about in the output above. Do not give analysis, just give an overview of the top items.
OUTPUT INSTRUCTIONS
Each $MORE$ item above should be replaced with a MORE link like so: <a href="https://www.example.com">MORE</a> with the best link for that item from the input.
For sections like $CVE NUMBER$ and $CVSS SCORE$, if they aren't included in the input, don't output anything, and remove the extra | symbol.
Do not create fake links for the $MORE$ links. If you can't create a full URL just link to a placeholder or the top level domain.
Do not output warnings or notes—just the requested sections.
Do not repeat items in the output sections.
Do not start items with the same opening words.
INPUT:
AI Assistant & CyberSecurity - Write and Review Security Policies
Another example comes from Alex Haynes (here), who highlights the use of Google Bard (now Gemini), the Google (LLM), to simplify and enhance the readability of security policies. Haynes chose Bard because it can rewrite and streamline complex documentation, making it more accessible and less time-consuming than manual efforts.
What does he achieve?
Efficiency Gains: Using AI Assistant reduced the time required to proofread, remove excess verbiage, and tidy up grammar from hours to minutes. This efficiency gain translated into significant resource savings when updating 300 pages of security documentation.
Readability Improvements: AI Assistant’s ability to produce clearer, more concise security policies resulted in documents that were easier for laypersons to understand. The LLM could simplify terminology, remove redundancies, and maintain an authoritative tone necessary for security documentation.
Drafting Flexibility: Google Gemini offers a feature that generates multiple drafts for each input, allowing users to choose the best-suited version and modify it further. This feature ensures that the final output aligns closely with user expectations without extensive manual editing.
Prompts Used:
“Rewrite the following security policy, removing duplicates and being as succinct as possible. Structure the response in bullet-point format.”
“Using as few words as possible, rewrite the following security policy. Remove any redundant phrases and structure them in an easy-to-read format.”
“Make the following security policy easier to read. Remove any legal-sounding words and simplify terminology where possible.”
Going further with better Assistants - Using Retrieval Augmented Generation (RAG)
Retrieval Augmented Generation (RAG) is an advanced approach designed to enhance the accuracy of AI-generated content by integrating relevant, trusted documents into the generation process. This method mitigates the risk of AI hallucination—where the AI invents facts or information—by grounding responses in verifiable data.
When using Retrieval Augmented Generation (RAG), you can also leverage your data and documents to enhance the accuracy and relevance of the AI-generated content. By integrating your data into the generation process, RAG can provide personalized and contextually appropriate outputs, making the information more tailored to your needs and requirements.
This approach mitigates the risk of AI hallucination and ensures that the generated content aligns closely with your individual knowledge and experience.
How RAG Works
Document Indexing with Embeddings:
Documents are pre-processed and indexed using embeddings, a method that maps text to a vector space.
Similar concepts are placed close together in this vector space. For instance, “Penetration Testing” and “Red Teaming” would be positioned near each other, reflecting their conceptual similarity.
Query Processing:
When a user asks a question, the AI searches the database for the most relevant documents or chunks of knowledge.
This search uses the embeddings to find documents conceptually aligned with the query.
Generating Responses:
The AI then uses the retrieved documents to generate a response.
A specific prompt guides the AI, stating: “You are provided chunks of knowledge; you must answer using this data; if you don’t find the answer, say ‘I don’t know.’”
Example Use Case
Let’s say a user wants to know more about the differences between Penetration Testing and Red Teaming:
Query: “What are the differences between Penetration Testing and Red Teaming?”
Retrieval: The AI searches the database for documents related to Penetration Testing and Red Teaming. It finds articles, tutorials, and news pieces that explain these concepts and their distinctions.
Generation: Using the retrieved documents, the AI constructs a response that accurately reflects the information found. If the documents do not clearly distinguish, the AI will respond with “I don’t know” to maintain accuracy.
Benefits of RAG
Enhanced Accuracy: By anchoring responses in trusted documents, the AI reduces the likelihood of fabricating information.
Contextual Relevance: Using embeddings ensures that the AI retrieves conceptually relevant documents, providing more contextually appropriate answers.
Transparency: Users can trust the information provided, knowing it is based on actual data rather than generated from potentially inaccurate training sets.
Retrieval-augmented generation (RAG) is a powerful tool for improving the reliability of AI-generated content.
Conclusion
Thank you for joining me on this exploration of AI Assistants. I hope you found this introduction to their capabilities and the importance of effective prompting enlightening. Stay tuned for next week’s post, where we’ll delve into the world of AI Agents and their potential to revolutionize our interactions with technology.
If you enjoyed this post, please share it with your network to help spread the knowledge. Let’s continue to build a more informed and secure cyber community together!