Lets quickly recap we I have discussed in previous blog about Attention Mechanism. Regarding Attention Mechanism, we have seen what is self-attention, drawbacks of legacy systems, Self-attention without trainable weights, Self-attention with trainable weights, Causal attention, Masked multi-headed attention. Inside Self-Attention, we have discussed about : Attention Scores Attention Weights Context Vector Importance of context vector is, it is going to maintain the semantics of all the tokens(not just about a single token). Self-attention with trainable weights : Inputs Weight, Query, Value matrix (Wq, Wk, Wv) and cal Q, K, V Query = Input @ Wq Key = Input @ Wk Value = Input @ Wv Above Query, Key, Value matrix are initially random values and they will be adjusted during training Calculate Attention score Query matrix @ Transpose of Key matrix Attention Weights Scaling = Square root of dimensions of Key matrix Normalization using softmax We are transforming data from Attention Scor...
Prompt engineering defensive techniques are methods used to protect LLM applications from malicious, unsafe, or misleading inputs. These techniques help prevent issues like prompt injection, jailbreaks, data leakage, hallucinations, and unauthorized actions by enforcing input validation, role isolation, output filtering, guardrails, and secure context handling in AI systems. We are going to discuss about two thing in Prompt engineering in this blog. Prompt Defense Prompt Versioning Prompt Defense Following 8 techniques comes under Prompt defense. Please concentrate carefully. Direct Prompt Injection Indirect Prompt Injection Jail Breaking Role-Play & Persona Exploits Token Smuggling Input Sanitization Prompt Firewall Adversarial Hardening Lets go through one by one. 1) Direct Prompt Injection Prompt Injection is a type of attack where a user (or a external data source) tries to manipulate an LLM by inserting malicious or misleading instructions into the input so that the...