Module 20: Practice & Interview Q&A
Test your understanding of modern AI engineering, APIs, secrets security, chatbots, and RAG architectures.
20.5.1 Practice Exercises
- Environment Setup:
Create a script
config_check.pythat loads variables from.envand checks for the presence ofGEMINI_API_KEY. If the key is present, print"Key is loaded safely!". If not, print"Setup failed". - API Call:
Write a short script to make a prompt request to the Gemini model asking:
"Give me a 5-step roadmap to learn machine learning."Print the response. - Chatbot Exit Logging:
Extend the chatbot script from Module 20.3 to write the user's exit timestamp to a log file
exit_log.txtwhen the user types'exit'.
20.5.2 Placement Q&A (Interview Prep)
Click on the questions below to reveal the answers:
Q1. What is the difference between an AI Engineer and a Machine Learning Engineer?
- Machine Learning Engineer: Focuses on designing, training, tuning, and evaluating models from scratch using math, statistics, and libraries like PyTorch or TensorFlow.
- AI Engineer: Focuses on building end-to-end applications by orchestrating pre-trained models (via APIs), managing data pipelines, context databases (Vector DBs), and deploying software systems.
Q2. Why is POST used for AI generation APIs instead of GET?
POST requests are used because:
- Prompts can be very long, and GET requests have character length limits on URLs.
- Query parameters in a GET request URL are logged in browser history and server logs, exposing API keys or private data. POST request bodies are transmitted securely.
- AI generation parameters require structured, nested configurations (JSON) which are easily sent in a POST body.
Q3. How does RAG solve the context window and hallucination problems?
RAG solves these problems by:
- Preventing hallucinations: Instead of relying on the model's memory (which can generate false facts), RAG forces the model to base its answers strictly on retrieved factual documents.
- Context window limits: By chunking long documents and retrieving only the most relevant sections, RAG avoids exceeding the maximum token input limits of the LLM API.
Q4. What is a Vector Embedding?
A Vector Embedding is a list of floating-point numbers generated by a neural network model that represents the semantic meaning of a word, sentence, or document. Words or sentences with similar meanings will have vectors that are numerically close in multi-dimensional space, enabling semantic search.