NCA-GENLNVIDIA Certified Associate - Generative AI with LLMsNVIDIACheat SheetLLMQuick Reference
NCA-GENL Cheat Sheet 2026: Quick Reference for Exam Day
Preporato TeamSeptember 7, 202610 min readNCA-GENL
This comprehensive cheat sheet covers all 5 exam domains with formulas, comparison tables, and code snippets. Based on official NVIDIA exam guide (30/24/22/14/10 weighting).
Find out where you stand first
Take the free NCA-GENL sample questions cold (no signup, real exam style), then read on with your gaps in mind. When you are ready for full rehearsal, Preporato's NCA-GENL practice tests include 6 full-length exams (360 questions in total, domain-proportional, every answer explained) for a one-time $19.99 with lifetime access.
Watch how Query (Q), Key (K), and Value (V) matrices interact through the attention mechanism. The animation shows the step-by-step process: creating Q/K/V from inputs, computing attention scores (Q×Kᵀ), applying softmax normalization, and multiplying by values to produce the final output.
Multi-Head Attention
MultiHead(Q,K,V) = Concat(head₁,...,headₕ)W^O
Copy
Multi-Head Attention Visualization
See how multi-head attention processes information in parallel. The animation shows the input being split into 4 attention heads (each with different colors), each head computing attention independently, then concatenating the results and applying the final projection matrix (W^O) to produce the output.
Component Comparison Table
Component
Purpose
Key Details
Positional Encoding
Preserve sequence order
Sinusoidal: PE(pos,2i) = sin(pos/10000^(2i/d))
Self-Attention
Model token relationships
Computes Q, K, V projections
Multi-Head Attention
Different representation subspaces
Typically 8-16 heads, d_model/h per head
Feed-Forward Network
Position-wise transformation
2 layers: d_model → 4×d_model → d_model
Layer Normalization
Stabilize training
Normalizes across features (not batch)
Residual Connections
Enable deep networks
x + Sublayer(x) pattern
Model Architecture Types
Type
Attention
Use Cases
Examples
Encoder-Only
Bidirectional (no masking)
Classification, NER, embeddings
BERT, RoBERTa
Decoder-Only
Causal/masked (autoregressive)
Text generation, completion
GPT-3/4, Llama 2/3
Encoder-Decoder
Both types + cross-attention
Translation, summarization
T5, BART, mT5
Key Differences:
Encoder: Can see full context (bidirectional), outputs contextualized representations
Decoder: Causal masking (can't see future), generates text token-by-token
Cross-Attention: Decoder queries encoder outputs (K, V from encoder, Q from decoder)
Attention Mechanism Steps
Compute Scores: QK^T (query-key similarity)
Scale: Divide by √d_k (stabilize gradients)
Apply Mask (decoder only): Set future positions to -∞
RLHF (Optional): Reinforcement Learning from Human Feedback for alignment
Scaling Laws
Loss ∝ (N_params)^(-α) × (N_data)^(-β) × (Compute)^(-γ)
Copy
Parameter Count Estimation
Params ≈ 12 × n_layers × d_model²
Copy
Memory Requirements (Inference)
Memory (GB) = Params × Bytes_per_param / 1e9
Copy
Model Memory Calculator
Required GPU Memory
14.00 GB
For 7B parameter model at FP16
Context Window:
Maximum sequence length model can process
GPT-3: 2,048 tokens
GPT-4: 8K-128K tokens
Claude 3: 200K tokens
Llama 3: 8K tokens (32K with extension)
Test yourself before you memorise anything. These three questions come from the free NCA-GENL sampler and use the real exam format.
Three quick NCA-GENL questions
Question 1 of 3Core Machine Learning and AI Knowledge
What is the key difference between the encoder and decoder components in an encoder-decoder transformer architecture?
Pick one answer
AThe encoder exclusively uses self-attention while the decoder relies solely on cross-attention to encoder outputs for all token interactions
BThe decoder uses masked self-attention to prevent attending to future tokens during training, while the encoder uses bidirectional attention
CThe decoder uses larger embedding dimensions and wider feed-forward layers than the encoder to improve generation quality and fluency
DThe encoder typically has more layers than the decoder to better process and encode input representations before passing them to generation
Answer: B
In an encoder-decoder transformer (the original 'Attention is All You Need' design), the encoder uses bidirectional self-attention, every input token can attend to every other input token, including those to its right. This is fine for understanding tasks because the entire input is known up front. The decoder, however, generates output autoregressively: token by token, left to right. During training we use teacher forcing (feed the entire ground-truth output sequence in parallel for efficiency), but the decoder must NOT see future tokens, otherwise the model would learn to copy them rather than predict them. The fix is the causal mask: before softmax, set attention scores at positions (i, j) where j > i to -inf, so softmax assigns them zero probability. This is the SAME mechanism that GPT-style decoder-only models use during training, which is why they're sometimes called 'causal' or 'autoregressive' transformers. The decoder also uses a second attention block, cross-attention, where Queries come from the decoder and Keys/Values come from the encoder output, letting the decoder consult the input. Encoder-only models like BERT use bidirectional attention; decoder-only models like GPT use causal masked attention; encoder-decoder models like T5 use both.
Question 2 of 3Core Machine Learning and AI Knowledge
In the attention mechanism, what mathematical operation is performed on the Query (Q) and Key (K) matrices to compute attention scores?
Pick one answer
AElement-wise multiplication of query and key vectors followed by summation across the feature dimension to produce position-wise similarity scores
BA convolution operation applied across query and key matrices to capture local positional patterns and short-range dependencies between tokens
CConcatenation of the query and key vectors for each position pair followed by a learned linear transformation to compute compatibility scores
DMatrix multiplication (dot product) followed by scaling and softmax
Answer: D
The scaled dot-product attention formula is Attention(Q, K, V) = softmax(QKᵀ/√d_k)V. Step by step: (1) compute QKᵀ, a matrix multiplication where Q is shape (n, d_k) and K is (m, d_k), giving an (n, m) matrix of raw similarity scores between every Query position and every Key position. The dot product measures alignment: large positive values mean the Query and Key vectors point in similar directions. (2) Divide by √d_k. This scaling is critical: without it, for large d_k the dot products grow large in magnitude, pushing softmax into regions where gradients are extremely small and training becomes unstable. The √d_k correction keeps the variance of the dot products at unit scale. (3) Apply softmax row-wise, converting raw scores into a probability distribution per Query: each row sums to 1.0, so attention weights are nonnegative and normalized. (4) Multiply by V to produce the output, a weighted sum of Value vectors. NOT element-wise products, NOT cosine similarity (no L2 normalization), NOT addition. Matrix multiply, scale, softmax, weight-and-sum. This is what every attention block in every transformer computes.
Question 3 of 3Core Machine Learning and AI Knowledge
What is the primary advantage of FlashAttention in modern transformer implementations?
Pick one answer
AIt reduces memory usage by computing attention incrementally using tiling and recomputation techniques
BIt replaces multi-head attention with a single consolidated attention head, reducing the total number of learnable parameters across the model's layers significantly
CIt applies post-training quantization to compress attention weight matrices to 8-bit integer precision, reducing memory bandwidth requirements during computation
DIt eliminates the need for softmax normalization in the attention mechanism by using a linear approximation that scales more efficiently with sequence length
Answer: A
Standard attention materializes the full (n × n) attention matrix in GPU HBM (high-bandwidth memory), making it the bottleneck for long contexts: HBM accesses dominate the wall-clock cost, not FLOPs. FlashAttention (Dao et al., NeurIPS 2022) is an IO-aware exact attention algorithm that restructures the computation to minimize HBM reads and writes. Its two techniques: TILING, split Q, K, V into blocks that fit in fast SRAM, then compute attention block-by-block, accumulating softmax statistics (running max and running sum-of-exp) so the per-block softmax can be combined into a globally correct softmax without ever materializing the full n×n matrix; RECOMPUTATION, during the backward pass, instead of storing the attention matrix, FlashAttention re-derives it on the fly from saved softmax normalizers, paying extra FLOPs to save memory traffic. The result is exact attention (not approximate) with much lower HBM bandwidth use: ~15% end-to-end speedup on BERT-large, ~3× on GPT-2 (seq 1K), 2.4× on long-range arena. Memory drops from O(n²) to O(n), enabling much longer contexts. Note that FlashAttention is NOT sparse, NOT lossy, and does NOT change the model architecture, it's a kernel-level reimplementation of exact attention.
Full NCA-GENL set: 6 timed exams, every answer explained, $19.99 one-time.
[System Role]
You are an expert data analyst.
[Context]
Dataset: {data_description}
[Task]
Analyze trends and provide insights on {specific_aspect}.
[Constraints]
- Use only provided data
- Cite sources with [Source: X]
[Format]
Respond in JSON: {"trends": [], "insights": []}
Dynamic batching (combine requests for efficiency)
Model ensembles (chain multiple models)
LangChain Essentials
Basic Chain:
from langchain import PromptTemplate, LLMChain
from langchain.llms import HuggingFacePipeline
template = "Summarize in 3 sentences: {text}"
prompt = PromptTemplate(template=template, input_variables=["text"])
chain = LLMChain(llm=llm, prompt=prompt)
result = chain.run(text="Long document...")
Common Chain Types:
Chain
Purpose
Example
LLMChain
Single LLM call with prompt
Q&A, classification
SequentialChain
Chain multiple LLM calls
Multi-step reasoning
RetrievalQA
RAG pipeline
Knowledge-grounded QA
ConversationalRetrievalChain
RAG with chat history
Chatbots
AgentExecutor
Dynamic tool selection
Task automation
Agent with Tools:
from langchain.agents import initialize_agent, Tool
tools = [
Tool(name="Search", func=search_fn, description="Search the web"),
Tool(name="Calculator", func=calc_fn, description="Do math")
]
agent = initialize_agent(
tools, llm, agent="zero-shot-react-description", verbose=True
)
agent.run("What is 25% of the GDP of France?")
Hugging Face Transformers
Load and Generate:
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load model
model = AutoModelForCausalLM.from_pretrained("gpt2")
tokenizer = AutoTokenizer.from_pretrained("gpt2")
# Generate
inputs = tokenizer("Once upon a time", return_tensors="pt")
outputs = model.generate(
**inputs,
max_length=100,
temperature=0.7,
top_p=0.9,
do_sample=True
)
text = tokenizer.decode(outputs[0], skip_special_tokens=True)
import re
pii_patterns = {
'email': r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b',
'phone': r'\b\d{3}[-.]?\d{3}[-.]?\d{4}\b',
'ssn': r'\b\d{3}-\d{2}-\d{4}\b',
'credit_card': r'\b\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}\b'
}
defdetect_pii(text):
found = {}
for pii_type, pattern in pii_patterns.items():
matches = re.findall(pattern, text)
if matches:
found[pii_type] = matches
return found
Toxicity Detection:
from transformers import pipeline
classifier = pipeline("text-classification",
model="unitary/toxic-bert")
result = classifier("Your text here")
# Output: [{'label': 'toxic', 'score': 0.02}]# Filter if score > 0.7if result[0]['score'] > 0.7:
return"Content filtered due to toxicity"
Bias Detection
Fairness Metrics:
Demographic Parity: P(Ŷ=1|A=0) = P(Ŷ=1|A=1)
Equal Opportunity: TPR equal across groups
Equalized Odds: TPR and FPR equal across groups
Testing Approach:
# 1. Create test sets for each demographic
test_sets = {
'male': male_examples,
'female': female_examples,
'non_binary': nb_examples
}
# 2. Measure metrics per group
metrics = {}
for group, examples in test_sets.items():
metrics[group] = {
'accuracy': calculate_accuracy(model, examples),
'f1': calculate_f1(model, examples)
}
# 3. Flag if disparity > 5%
max_disparity = max(metrics.values()) - min(metrics.values())
if max_disparity > 0.05:
print(f"⚠️ Bias detected: {max_disparity:.1%} disparity")
Hallucination Prevention
Strategies:
RAG: Ground responses in retrieved documents
Citations: Require model to cite sources
Confidence Scores: Filter low-confidence outputs
Verification: Cross-check facts with knowledge base
Temperature: Lower temperature (0.3-0.5) reduces creativity/hallucination
Citation Enforcement:
prompt = """
Use ONLY the provided context to answer.
If unsure, say "I don't have enough information."
ALWAYS cite sources: [Source: document_name]
Context:
{retrieved_docs}
Question: {question}
"""
Quick Command Reference
Model Loading & Optimization
Flash Attention 2 (2-4x faster):
model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-2-7b-hf",
attn_implementation="flash_attention_2",
torch_dtype=torch.bfloat16,
device_map="auto"
)
Gradient Checkpointing (reduce memory):
model.gradient_checkpointing_enable()
# Trades compute for memory (20-30% slower, 30-40% less memory)
8-bit Quantization:
model = AutoModelForCausalLM.from_pretrained(
"model_name",
load_in_8bit=True,
device_map="auto"
)
# Reduces memory by ~50% with minimal accuracy loss
Tokenizer Operations
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("gpt2")
# Encode
token_ids = tokenizer.encode("Hello world", add_special_tokens=True)
# [15496, 995] + special tokens# Decode
text = tokenizer.decode(token_ids, skip_special_tokens=True)
# "Hello world"# Get vocab size
vocab_size = len(tokenizer) # 50,257 for GPT-2