Skip to main content
Home  /  Knowledge Hub  /  Interview Questions

Interview Questions& Model Answers

Real questions. Real answers. Built from 20 years of actual hiring and being hired.

54
Total Questions
3
Technologies
3
Levels
✕ Clear filters

Showing 5 questions · Advanced · AI Integration

Clear all filters
AI-ADV-004 What is the difference between zero-shot few-shot and fine-tuned models in production?
AI Integration AI Integration Advanced
7/10
Answer

Zero-shot uses the base model with only instructions (no examples). Few-shot includes examples in the prompt. Fine-tuned models are retrained on domain data. The tradeoff is cost and flexibility versus consistency and performance.

Deep Explanation

Zero-shot: just the task description in the prompt. Relies entirely on the model's pretraining. Fast to deploy requires no labeled data. Performance varies by task complexity. Best for: common well-defined tasks (summarization translation sentiment). Few-shot: include 3-10 task examples in the prompt. Dramatically improves consistency and format adherence. Cost: larger prompts = more tokens per call. Performance ceiling limited by context window and what can be communicated via examples. Best for: uncommon tasks new formats specific style requirements. Fine-tuned: domain-specific retraining. Bakes behavior into model weights instead of prompt tokens. Shorter prompts lower inference cost better consistency on trained tasks. Requires labeled data (minimum 100-1000 high-quality examples) compute for training. Not updatable without retraining. Best for: consistent structured output domain-specific terminology and behaviors classification with specific categories.

Real-World Example

A legal clause extraction system evolution: zero-shot (78% accuracy) → few-shot with 5 examples (86% accuracy) → few-shot with 20 examples (89% accuracy) → fine-tuned on 3000 examples (96% accuracy lower latency lower cost per call). Each step required more investment but delivered better ROI at the production volume they were operating at.

⚠ Common Mistakes

Jumping to fine-tuning before exhausting prompt engineering (expensive and inflexible). Using few-shot examples that are low quality or inconsistent — few-shot examples teach the model a behavior; bad examples teach bad behavior. Not measuring whether the performance gain justifies the cost of fine-tuning. Fine-tuning on a narrow task and breaking general capabilities (catastrophic forgetting).

🏭 Production Scenario

A startup building a document AI product started with zero-shot (fast prototype) discovered insufficient performance moved to few-shot (8 examples in prompt fixed 70% of failures) then fine-tuned only their highest-volume document type (processing 100K documents/month — fine-tuning ROI was clear) while keeping few-shot for lower-volume types. This staged approach minimized cost while maximizing quality where it mattered.

Follow-up Questions
How do you measure whether fine-tuning improved over few-shot? What is instruction tuning and how is it different from task-specific fine-tuning? What is RLHF and how does it relate to fine-tuning??
ID: AI-ADV-004  ·  Difficulty: 7/10  ·  Level: Advanced
AI-ADV-001 How does Retrieval-Augmented Generation (RAG) work and what are its main failure modes?
AI Integration AI Integration Advanced
8/10
Answer

RAG retrieves relevant documents from a vector database using semantic similarity search injects them into the LLM context and generates a response grounded in the retrieved content. Main failure modes are retrieval failures context window overflow and hallucinations about retrieved content.

Deep Explanation

RAG has three main components: indexing (documents are chunked embedded using an embedding model and stored in a vector database like Pinecone Weaviate or pgvector) retrieval (the user query is embedded and semantically similar chunks are retrieved using approximate nearest neighbor search) and generation (retrieved chunks are inserted into the LLM prompt as context and the model generates a response). Key design decisions: chunk size (too small loses context too large wastes context window and dilutes relevance) embedding model choice number of retrieved chunks (k) whether to use reranking to improve retrieved chunk ordering and metadata filtering to constrain retrieval. Advanced patterns include hybrid search (semantic + keyword/BM25) HyDE (hypothetical document embeddings) and multi-hop retrieval for complex questions.

Real-World Example

A legal research assistant RAG system at a law firm used chunk sizes of 512 tokens for case documents. Attorneys complained answers lacked context. Investigation showed important legal reasoning spanned across chunk boundaries. Implementing larger overlapping chunks (1024 tokens with 200 token overlap) and a reranker (Cohere Rerank) improved answer quality significantly.

⚠ Common Mistakes

Chunking documents arbitrarily without considering semantic boundaries (splitting mid-paragraph). Using cosine similarity retrieval without reranking causing less relevant chunks to appear in context and confuse the model. Not handling the case where no relevant documents are retrieved — the model hallucinates instead of saying it does not know. Embedding the entire document instead of chunking exceeding context limits.

🏭 Production Scenario

A production customer support RAG system was giving confidently wrong answers about product return policies. Investigation revealed the retrieval was returning chunks from old policy documents because they had higher semantic similarity scores than newer updates. Implementing date-based metadata filtering to prefer recent documents and adding a retrieval confidence threshold solved the problem.

Follow-up Questions
What is the difference between RAG and fine-tuning — when do you use each? What is a vector database and how does HNSW indexing work? What is RAGAS and how do you evaluate a RAG system??
ID: AI-ADV-001  ·  Difficulty: 8/10  ·  Level: Advanced
AI-ADV-002 What is an AI agent and how is it architecturally different from a simple LLM API call?
AI Integration AI Integration Advanced
8/10
Answer

An AI agent uses an LLM as a reasoning engine to autonomously plan use tools and complete multi-step tasks. Unlike a single LLM call that maps input to output an agent operates in a loop: observe think act observe again — until the task is complete.

Deep Explanation

The ReAct pattern (Reason + Act) describes the core agent loop: the LLM receives a task and available tools generates a thought (reasoning about what to do) selects an action (a tool call) receives the observation (tool output) and repeats until producing a final answer. Tools are functions the LLM can invoke: web search code execution database queries API calls file operations. Agent architectures range from simple (single LLM with tools) to complex (multi-agent systems where specialized agents collaborate with a planner/orchestrator agent routing tasks). Key engineering challenges: tool design (tools must have clear descriptions for the LLM to select them correctly) error handling (agents can get stuck in loops or make wrong tool calls) context management (the agent's action history grows and fills the context window) and cost control (multi-step agents can make many API calls).

Real-World Example

A customer onboarding agent at a SaaS company replaces a 12-step manual process: it receives a new customer email calls the CRM API to create a contact queries the provisioning API to set up an account generates and sends a personalized welcome email creates a Jira ticket for account review and posts a Slack notification to the account manager — all autonomously from a single trigger.

⚠ Common Mistakes

Building agents without observability — impossible to debug why an agent made wrong decisions without logging the full thought-action-observation trace. Not implementing maximum step limits — agents can loop indefinitely on ambiguous tasks. Giving agents too many tools — LLMs struggle to select from large tool sets. Not handling tool failures gracefully in the agent loop.

🏭 Production Scenario

A document processing agent for an insurance company was processing claims autonomously. Without a step limit it entered an infinite loop trying to resolve a document parsing error making 10000 API calls in 8 minutes and generating a $400 API bill before being detected. Implementing a 20-step maximum and exponential backoff on tool errors fixed the runaway behavior.

Follow-up Questions
What is the difference between ReAct Plan-and-Execute and Reflexion agent patterns? How do you implement agent memory (short-term vs long-term)? What is LangGraph and how does it implement agent state machines??
ID: AI-ADV-002  ·  Difficulty: 8/10  ·  Level: Advanced
AI-ADV-003 What is fine-tuning an LLM and when should you fine-tune versus use RAG or prompt engineering?
AI Integration AI Integration Advanced
8/10
Answer

Fine-tuning adjusts the model weights on domain-specific data to internalize knowledge or style. Use it when the task requires consistent behavior style or format the base model cannot achieve through prompting alone. RAG is better for factual grounding; prompt engineering first for most tasks.

Deep Explanation

Fine-tuning: continue training a pretrained LLM on a curated dataset of examples in your target format/domain. Changes the model weights permanently for that task. Types: full fine-tuning (expensive updates all parameters) parameter-efficient fine-tuning (PEFT — LoRA QLORA update a small fraction of parameters cheaply). When to fine-tune: consistent output format the base model keeps breaking (code generation with specific conventions) domain-specific style or tone (legal writing medical reports) task-specific behavior patterns (classification schema extraction) or reducing prompt length at inference (baking instructions into the model). When NOT to fine-tune: you need up-to-date information (use RAG) you are still exploring requirements (use prompting first) you have less than 1000 high-quality examples (insufficient for fine-tuning) or the base model already performs the task well with prompting.

Real-World Example

A financial services company needed an LLM to consistently extract structured data from loan applications into a specific JSON schema. Prompt engineering achieved 78% schema compliance. RAG did not help (the schema was fixed not document-dependent). Fine-tuning with 5000 labeled examples achieved 97% schema compliance with shorter prompts reducing inference cost.

⚠ Common Mistakes

Fine-tuning with low-quality or insufficient examples — produces a model worse than the base model. Fine-tuning when prompt engineering would suffice — expensive and inflexible. Forgetting that fine-tuned models still hallucinate and still need RAG for factual grounding. Not evaluating catastrophic forgetting — fine-tuning on a narrow dataset can degrade performance on general tasks.

🏭 Production Scenario

A customer service company fine-tuned an LLM on 2000 examples of customer conversations expecting it to handle all intents. In production the model lost general language capabilities and failed on intents not well-represented in the training data. Rebuilding with a larger curated dataset (15000 examples across all intents) with proper evaluation resolved the regression.

Follow-up Questions
What is LoRA and how does it make fine-tuning parameter-efficient? What is catastrophic forgetting in fine-tuning? How do you create a high-quality fine-tuning dataset??
ID: AI-ADV-003  ·  Difficulty: 8/10  ·  Level: Advanced
AI-MLO-001 How do you evaluate the quality of an LLM-powered application in production?
AI Integration AI Integration Advanced
8/10
Answer

LLM application quality requires a multi-layered evaluation strategy: offline evals (automated benchmarks using LLM-as-judge) online monitoring (latency cost error rates) and human evaluation for quality calibration. There is no single metric — you need task-specific criteria.

Deep Explanation

Evaluation layers: automated offline evals (run test cases through the system compare outputs against reference answers using another LLM as judge — e.g. GPT-4 scoring responses on accuracy relevance groundedness and format compliance) human evaluation (sample of outputs reviewed by domain experts to calibrate the LLM judge and catch systematic failures) production monitoring (latency per-call cost API error rates user feedback signals like thumbs up/down) and A/B testing (compare system versions on real user traffic). RAGAS framework evaluates RAG systems specifically: faithfulness (is the answer grounded in retrieved context?) answer relevancy (does the answer address the question?) context recall and context precision. For agents: task completion rate steps per completion tool error rate and cost per successful task completion.

Real-World Example

At a legal document AI company: automated evals used a curated set of 500 document-question pairs with reference answers GPT-4 as judge scored faithfulness and accuracy monthly human review by paralegals calibrated the automated judge real-time dashboards showed per-endpoint latency and cost and a thumbs-down button collected user feedback that triggered human review for systematic issues.

⚠ Common Mistakes

Using only automated LLM-as-judge evaluation without human calibration — the judge model has its own biases and blind spots. Not evaluating on adversarial cases (edge cases failure modes). Measuring only technical metrics (latency cost) and not quality metrics. Not separating evaluation of the retrieval step from the generation step in RAG systems.

🏭 Production Scenario

A customer service AI showed consistently positive automated evaluation scores but had a growing volume of user complaints. The disconnect was because the LLM judge was evaluating response quality in isolation while users were frustrated by the system's failure to resolve their issues (task completion rate was not measured). Adding task completion as a primary metric revealed the real problem.

Follow-up Questions
What is LLM-as-judge and what are its limitations? What is RAGAS and how do you set it up? How do you A/B test prompt changes safely in production??
ID: AI-MLO-001  ·  Difficulty: 8/10  ·  Level: Advanced