Assignment 6 Solve Questions
Q1. What is an API?
API stands for Application Programming Interface. In simple words, an API is a bridge that allows one software system to talk to another software system in a structured way.
We can think of it like a waiter in a restaurant. You do not go inside the kitchen and cook your own food. You give your order to the waiter, the waiter takes it to the kitchen, and then the kitchen sends the food back through the waiter. In the same way, when one app wants something from another app, it sends a request through an API, and the other system sends back a response.
For example, when a website shows a weather report, the website usually does not calculate the weather itself. It calls a weather API. When a payment app confirms a transaction, it often uses a banking API. When we use ChatGPT inside a project, we usually connect to the model through an API.
An API is important because it creates rules for communication. It defines:
- what request should be sent
- what data format should be used
- what response will come back
- who is allowed to access it
Without APIs, every software system would need direct manual integration, which would be messy, insecure, and hard to scale.
So the real idea is this: an API is not the intelligence itself, not the database itself, and not the app itself. It is the communication contract between systems.
2. What is RAG?
RAG stands for Retrieval-Augmented Generation.
This means the AI does not answer only from what it learned during training. Before answering, it first retrieves useful information from an outside source such as notes, PDFs, company documents, websites, or a database. Then it uses that retrieved information to generate a better answer.
This is powerful because normal AI models have limited memory about your personal or company-specific data. They may know general things about programming, business, or history, but they do not automatically know your class notes, your private files, your research papers, or your company SOPs. RAG solves that problem by giving the model relevant context at the time of answering.
A simple flow of RAG is:
- User asks a question.
- System searches the knowledge base.
- Most relevant chunks of information are found.
- Those chunks are sent to the LLM.
- The LLM writes an answer using that context.
So RAG is not a separate AI brain. It is a system design pattern that improves an LLM by attaching retrieval to it.
The big benefit of RAG is that it helps the model become:
- more grounded
- more up to date
- more useful for private knowledge
- less likely to hallucinate blindly
But RAG is only as good as the data quality, chunking quality, retrieval quality, and prompt quality behind it.
3. What is the difference between RAG and Agentic AI and Machine Learning?
These three things belong to different levels of the AI stack, so comparing them properly is very important.
RAG
RAG is a method for improving answers by retrieving relevant information before generation. It is mainly about giving better context to an LLM.
Agentic AI
Agentic AI is when AI does not just answer once, but works toward a goal. It may plan steps, use tools, call APIs, search documents, write code, check outputs, and decide what to do next. In other words, it behaves more like a worker handling a task than a chatbot giving a one-shot reply.
Machine Learning
Machine Learning is the broader field where systems learn patterns from data instead of relying only on fixed rules written by humans. It includes many techniques such as regression, classification, clustering, recommendation systems, and deep learning.
Core difference
Machine Learning is the broad learning field.
RAG is a retrieval architecture usually used with LLM systems.
Agentic AI is a goal-oriented behavior layer built on top of models and tools.
A simple analogy
- Machine Learning is like teaching a person how to recognize patterns from past examples.
- RAG is like giving that person access to a notebook before they answer.
- Agentic AI is like giving that person a task, tools, memory, and permission to take multiple steps until the work is done.
So they are not competitors. They operate at different levels.
4. As a student, where can I use RAG?
As a student, RAG can be extremely useful because most of your important knowledge is not general internet knowledge. It lives inside your own notes, textbooks, PDFs, teacher handouts, lecture slides, past question papers, and personal summaries.
You can use RAG in many practical ways:
Study assistant from your own notes
You can upload your class notes and ask questions in simple language. Instead of getting a generic answer, the system can answer from your exact material.
Exam revision
You can ask:
- what are the most repeated concepts in my notes
- explain chapter 3 in easy language
- give me viva questions from this material
- create MCQs from these documents
Weak-topic detection
If your documents are uploaded properly, you can ask the system to identify which concepts are connected, where you are likely to get confused, and what you should revise first.
Assignment support
RAG can help you refer to your actual syllabus or source material while writing answers, instead of randomly generating unrelated content.
Career preparation
You can build a RAG system from:
- interview notes
- resume drafts
- company research
- coding notes
- system design notes
Then you can ask focused questions from your own preparation material.
The biggest value for students is this: RAG turns scattered notes into a searchable brain.
5. As a non-technical person, explain how a RAG works behind the scenes.
Let us explain this very simply.
Imagine you have 500 pages of notes. You ask the system, "Explain recursion from my class material."
If the AI reads all 500 pages every single time, it will be too slow and expensive. So instead, the system prepares your data in advance.
Step 1. Your documents are collected
Your notes, PDFs, files, or web pages are uploaded into the system.
Step 2. The documents are broken into smaller parts
Instead of storing one giant note, the system splits the content into smaller chunks. For example, one paragraph, one section, or one concept at a time.
Step 3. Each chunk is converted into meaning form
The text is converted into embeddings. Embeddings are numerical representations of meaning. This allows the computer to compare ideas based on similarity, not just exact words.
Step 4. Those embeddings are stored
They are stored in a database, often a vector database.
Step 5. You ask a question
When you type a question, the question is also converted into an embedding.
Step 6. The system searches for similar chunks
It compares your question embedding with stored embeddings and finds the most relevant note sections.
Step 7. The relevant text is sent to the AI model
Now the model receives:
- your question
- the relevant retrieved chunks
- instructions about how to answer
Step 8. The AI writes the final answer
The answer is generated using both the model's language ability and the retrieved knowledge from your notes.
So behind the scenes, RAG is doing two jobs:
- search for the right information
- generate a useful answer from that information
That is why it is called Retrieval-Augmented Generation.
6. What is a database?
A database is a structured system used to store, organize, update, and retrieve data.
It is more than just a random file. A database is designed so that data can be managed properly, searched quickly, and used safely by applications.
For example:
- student names and marks can be stored in a database
- login details can be stored in a database
- product lists can be stored in a database
- chat history can be stored in a database
If data were stored only in normal text files, handling large amounts of information would become slow and confusing. A database solves that by providing structure.
Common things a database helps with:
- storing data
- updating data
- deleting data
- searching data
- controlling access
- maintaining consistency
A database is important because modern software needs memory. If the frontend is the visible face of an app, then the database is one part of the app's memory system.
7. How should I use AI for decision making? Should I fully rely on AI for every task?
AI should support your decision making, not replace your responsibility.
This is one of the most important mindset lessons. AI is excellent at:
- summarizing information
- comparing options
- generating possibilities
- spotting patterns
- helping you think faster
But AI is not truly responsible for the consequences of your life, career, money, health, or relationships. You are.
So the correct way to use AI for decision making is:
Use AI for clarity
Ask it to structure your thoughts, compare pros and cons, create decision frameworks, or show possible risks.
Use AI for research support
Ask it what factors you should consider before making a decision. This helps widen your thinking.
Use AI for simulation
You can ask:
- what are possible outcomes
- what questions should I ask before deciding
- what hidden risks am I missing
But do not blindly obey it
AI can sound confident even when wrong. It may miss real-world context, emotions, personal values, legal realities, or recent information.
You should never fully rely on AI for every task because:
- it can hallucinate
- it may not know your full context
- it may oversimplify complex human situations
- it does not own the consequences
The best model is:
AI for support, human for judgment.
Especially in serious decisions, AI should act like a smart assistant, not like the final authority.
8. Why does AI make mistakes? What is human in the loop?
AI makes mistakes for many reasons.
It predicts, it does not truly understand like a human
Most generative AI systems are pattern prediction engines. They generate the most likely next sequence based on training and context. That means they can produce fluent language without true grounding.
Training data is incomplete
If the model has never seen enough good examples, or if the data had noise, bias, or gaps, the output can also be weak.
Context can be poor
If the prompt is vague, missing details, or misleading, the output can also become wrong.
Retrieval can fail
In RAG systems, sometimes the wrong chunks are retrieved. Then even a good model may answer from the wrong evidence.
Real world changes
AI may not know the latest laws, prices, events, or company-specific facts unless connected to fresh sources.
Overconfidence problem
One dangerous thing about AI is that it often presents wrong answers very confidently. This creates false trust.
What is human in the loop?
Human in the loop means a human is involved in checking, guiding, correcting, approving, or supervising the AI system.
This is important because AI should not always run independently in sensitive tasks.
Examples of human in the loop:
- a doctor reviewing an AI-generated medical suggestion
- a teacher checking AI-generated study material
- a developer reviewing AI-written code
- a recruiter verifying AI-based candidate screening
So human in the loop means AI assists, but a human still controls quality and final accountability.
This is one of the safest and smartest ways to use AI in the real world.
9. What is frontend and backend? In software why is backend needed? Why can we not do everything in frontend?
Frontend is the part of software that users can directly see and interact with.
Examples:
- buttons
- forms
- pages
- layout
- colors
- input boxes
If you open a website and click, type, scroll, or view content, that visible experience is the frontend.
Backend is the hidden logic running behind the application.
It handles things like:
- business logic
- authentication
- database operations
- API calls
- permissions
- storing and processing data
Why is backend needed?
Because frontend alone is not enough for real applications.
If you put everything in the frontend:
- secret keys become exposed
- anyone can inspect your code
- there is no secure control of data
- database access becomes unsafe
- business logic can be manipulated
For example, if a payment rule, admin permission rule, or user verification rule is placed only in the frontend, a user may bypass it by modifying browser-side code.
Backend acts like the secure control room of the software. It decides what is allowed, talks to the database safely, protects secrets, and processes operations reliably.
Simple analogy
- Frontend is the shop counter.
- Backend is the staff room and operations system behind the shop.
Customers see the counter, but the real control happens behind it.
10. What is the difference between database and backend?
Many beginners mix these two, but they are not the same thing.
Database
The database stores data.
Backend
The backend controls logic and operations.
The backend usually talks to the database, but it does many more things than just storage.
For example, suppose you have a notes app.
The database stores:
- user accounts
- note titles
- note content
- timestamps
The backend handles:
- login validation
- checking which user owns which note
- saving a new note
- editing a note
- deleting a note
- deciding whether a user has permission
- sending note data to the frontend
So the database is like storage memory, while the backend is like the manager operating that memory.
The database does not usually decide business logic on its own. The backend sits in the middle between frontend and database and makes the system work properly.
11. As a non-tech person, explain: if I want to create a project where I upload my notes, how will frontend, backend, and database connect? How will the AI connect using API? If I want to create my own RAG, how will it work?
Let us walk through this as a complete project flow.
Suppose you want to build a website where students upload notes and then ask questions from those notes.
Step 1. Frontend
The frontend is the website interface. This is where the user:
- signs in
- uploads notes
- sees a chat box
- types questions
- reads the answers
So the frontend collects user actions and displays results.
Step 2. Backend
When the user uploads a file, the frontend sends that file to the backend.
The backend is responsible for:
- receiving the file
- processing the content
- extracting text
- splitting text into chunks
- creating embeddings
- storing the data
- later receiving user questions
- calling the AI API
So the backend is the main coordinator.
Step 3. Database
The database stores normal application data such as:
- user information
- file names
- note metadata
- upload history
- chat history
If you are using RAG, then you may also use a vector database to store embeddings for semantic search.
Step 4. AI API connection
Your backend talks to the AI provider using an API.
For example, when a user asks a question, the backend may send a request like:
- here is the user question
- here are the relevant retrieved note chunks
- now generate an answer based on this context
The AI model returns the answer through the API, and the backend sends that answer back to the frontend.
Step 5. Full RAG flow
If you want your own RAG system, the full flow is:
- User uploads notes from frontend.
- Frontend sends files to backend.
- Backend extracts text from files.
- Backend breaks text into chunks.
- Backend generates embeddings for each chunk.
- Embeddings are stored in a vector database.
- User asks a question in chat.
- Backend converts the question into an embedding.
- System searches the vector database for similar chunks.
- Relevant chunks are collected.
- Backend sends question plus chunks to the LLM API.
- LLM generates the answer.
- Backend sends final answer to frontend.
- Frontend displays the answer to the user.
What is the main insight here?
Frontend shows.
Backend controls.
Database stores.
API connects.
LLM generates.
RAG grounds the answer using your own knowledge.
That is the full flow in simple language.
12. As a non-tech person, explain why I need to use a vector database over a normal database. What is a normal database and how does a vector database work? Give a simple example.
This is a very important concept for anyone building AI products.
What is a normal database?
A normal database stores structured information in a traditional way.
For example:
- name = Monish
- subject = AI
- marks = 92
- city = Mumbai
This is excellent for exact data lookup.
If you ask:
- show me all students from Mumbai
- show me notes uploaded on Monday
- show me users with marks above 80
a normal database works very well.
But what is the limitation?
A normal database is not naturally built for meaning-based search.
Suppose your notes say:
"Large language models predict the next token based on context."
Now you search:
"How do AI models generate the next word?"
The wording is different, but the meaning is similar. A normal database mainly works well with exact matching or structured query rules. It may not understand that both sentences are conceptually related.
What is a vector database?
A vector database stores embeddings.
Embeddings are numerical representations of meaning. When text is converted into embeddings, similar ideas are placed closer together in a mathematical space.
So instead of searching by exact word match, a vector database searches by semantic similarity.
Simple example
Let us say your notes contain these three lines:
- "Neural networks learn patterns from data."
- "Photosynthesis happens in plants."
- "Deep learning uses many layered neural networks."
Now suppose you ask:
"Which parts of my notes talk about AI learning systems?"
A vector database can understand that sentence 1 and sentence 3 are related to your query, even if the exact words are different. It will retrieve those lines because their meaning is close.
Why use vector database in RAG?
Because RAG needs relevant chunks based on meaning, not just exact keyword match.
If a student asks:
"Explain how the model predicts output"
the system should still find notes that say:
"The language model generates the next token from prior context."
That is semantic similarity, and vector databases are designed for that.
Final difference
Normal database:
- best for structured records
- exact filters
- IDs, names, dates, marks, users, payments
Vector database:
- best for semantic search
- similar meaning matching
- notes, documents, PDFs, knowledge retrieval
Best practice in real products
In many AI systems, both are used together.
- normal database stores app data
- vector database stores embeddings for retrieval
So the real answer is not that vector databases replace normal databases. They solve a different problem. You use a vector database when you want the system to search by meaning instead of only exact text matching.