Vigilantcorp Inc

Interview Questions

Python

1) What is Python?
Python is a high-level, interpreted programming language that is easy to read and write.
It is widely used because of its simple syntax.
Python supports multiple programming paradigms.
It is used in many real-world applications.
2) Why is Python popular?
Python is popular because it is beginner-friendly and easy to learn.
It has a large community and many libraries.
Python is used in AI, web development, and automation.
It works on multiple platforms.
3) What are the features of Python?
Python has simple and readable syntax.
It is platform independent.
It supports object-oriented programming.
It comes with a large standard library.
4) What are Python variables?
Variables are used to store data values in memory.
They allow programs to store and manipulate data.
Python variables do not need type declaration.
The type is assigned automatically.
5) How do you declare a variable in Python?
Variables are declared by assigning a value using the equal sign.
For example, x = 10 creates a variable.
Python determines the type automatically.
No keyword is required.
6) What are Python data types?
Data types define the kind of data a variable holds.
Common data types include int, float, string, and list.
They control allowed operations.
Python is dynamically typed.
7) What is the difference between list and tuple?
A list is a mutable collection of elements.
A tuple is an immutable collection of elements.
Lists use square brackets.
Tuples use parentheses.
8) What is a dictionary in Python?
A dictionary stores data in key and value pairs.
Keys are unique and values can be modified.
It is commonly used for fast lookup.
Dictionaries are unordered.
9) What is a set in Python?
A set is a collection of unique elements.
It does not allow duplicate values.
Sets are unordered.
They are useful for membership testing.
10) What are mutable and immutable data types?
Mutable data types can be changed after creation.
Immutable data types cannot be changed.
Lists are mutable.
Strings and tuples are immutable.
11) What are Python keywords?
Keywords are reserved words in Python.
They have predefined meanings.
Examples include if, else, for, and while.
They cannot be used as variable names.
12) What is indentation in Python?
Indentation is used to define code blocks in Python.
Python uses spaces instead of braces.
It improves code readability.
Incorrect indentation causes errors.
13) What are comments in Python?
Comments are used to explain code.
They improve readability and understanding.
Single-line comments start with #.
Python ignores comments during execution.
14) What is a Python function?
A function is a block of reusable code.
It performs a specific task.
Functions improve modularity.
They reduce repetition.
15) How do you define a function in Python?
Functions are defined using the def keyword.
They can take parameters.
They may return values.
Functions improve code structure.
16) What are function arguments?
Arguments are values passed to a function.
They provide input to the function.
Arguments make functions flexible.
Multiple arguments are allowed.
17) What is a return statement?
The return statement sends a value back to the caller.
It ends function execution.
A function may return multiple values.
Without return, None is returned.
18) What is a loop in Python?
Loops repeat a block of code multiple times.
They reduce code duplication.
Python supports for and while loops.
Loops are used for iteration.
19) What is the difference between for and while loop?
A for loop iterates over sequences.
A while loop runs based on a condition.
For loops are commonly used for counting.
While loops run until condition fails.
20) What is break and continue?
The break statement stops loop execution.
The continue statement skips the current iteration.
They control loop flow.
Used inside loops only.
21) What is conditional statement?
Conditional statements make decisions.
They execute code based on conditions.
The if statement is the basic condition.
They control program logic.
22) What is if–elif–else?
The if statement checks a condition.
elif checks additional conditions.
else executes if all fail.
Used for decision making.
23) What are Python operators?
Operators perform operations on values.
Examples include arithmetic and comparison operators.
They are used in expressions.
Operators help compute results.
24) What is type casting?
Type casting converts one data type to another.
For example, int("10") converts string to integer.
Used to avoid type errors.
Python provides built-in casting functions.
25) What is input() function?
The input() function takes user input.
It returns input as a string.
Used for interactive programs.
Conversion may be required.
26) What is print() function?
The print() function displays output.
It shows values on the screen.
Used for debugging and display.
Supports multiple values.
27) What are Python modules?
Modules are Python files containing code.
They help organize functionality.
Modules promote code reuse.
Example: math module.
28) What is import statement?
The import statement loads modules.
It allows access to module functions.
Improves modularity.
Reduces repetition.
29) What is a package in Python?
A package is a collection of modules.
It organizes related code.
Used in large applications.
Packages use folders.
30) What is exception handling?
Exception handling manages runtime errors.
It prevents program crashes.
Handled using try-except blocks.
Improves robustness.
31) What is try–except block?
The try block contains risky code.
The except block handles errors.
Prevents abnormal termination.
Optional finally block exists.
32) What is an error vs exception?
Errors are syntax or runtime problems.
Exceptions are runtime issues.
Exceptions can be handled.
Errors usually stop execution.
33) What is file handling in Python?
File handling allows reading and writing files.
Used for data storage.
Python provides built-in functions.
Files must be closed.
34) What are read and write modes?
Read mode opens a file for reading.
Write mode opens a file for writing.
Append mode adds data to a file.
Modes control file behavior.
35) What is a string in Python?
Strings store text data.
They are immutable.
Defined using quotes.
Support many methods.
36) What are string methods?
String methods manipulate text.
Examples include upper() and lower().
They return new strings.
Original string remains unchanged.
37) What is list slicing?
List slicing extracts a portion of a list.
It uses start and end indexes.
Returns a new list.
Useful for subsets.
38) What is indexing?
Indexing accesses elements in sequences.
Index starts from zero.
Negative indexing is supported.
Used with lists and strings.
39) What is Python interpreter?
The Python interpreter executes code line by line.
It converts code to bytecode.
Runs Python programs.
Required to run scripts.
40) What is PEP 8?
PEP 8 is the Python style guide.
It defines coding standards.
Improves readability.
Used in professional projects.
41) What is dynamic typing?
Dynamic typing means variable types are assigned at runtime.
No explicit type declaration is needed.
Variables can change type.
Makes Python flexible.
42) What is garbage collection?
Garbage collection removes unused objects.
It frees memory automatically.
Python manages memory internally.
Improves performance.
43) What is None in Python?
None represents absence of a value.
It is a special Python object.
Often used as default return.
Different from zero.
44) What is Boolean data type?
Boolean data type has True or False.
Used in conditions.
Represents logical values.
Important for decision making.
45) What is range() function?
The range() function generates a sequence of numbers.
Commonly used in loops.
It is memory efficient.
Useful for iteration.
46) What is len() function?
The len() function returns length.
Works on strings, lists, and tuples.
Returns an integer.
Used frequently.
47) What is pass statement?
The pass statement does nothing.
Used as a placeholder.
Prevents syntax errors.
Useful in empty blocks.
48) What is global and local variable?
Global variables are declared outside functions.
Local variables are declared inside functions.
Scope defines visibility.
Local variables override global inside functions.
49) What is Python used for?
Python is used for web development.
Used in data science and AI.
Used in automation and scripting.
Used in game development.
50) Why is Python good for beginners?
Python is easy to learn.
Syntax is simple and readable.
Large community support.
Ideal first programming language.
51) What is list comprehension in Python?
List comprehension is a compact way to create lists using a single line of code.
It combines loops and conditional logic together.
It improves readability and performance compared to traditional loops.
52) How does dictionary comprehension work?
Dictionary comprehension allows creating dictionaries dynamically.
It uses key-value pairs inside a loop expression.
This reduces code length and improves clarity.
53) What is a generator in Python?
A generator is a function that returns values one at a time using yield.
It does not store all values in memory.
Generators are memory efficient for large data processing.
54) What is the difference between return and yield?
return sends a value and ends function execution.
yield pauses execution and resumes later.
yield is used in generators for lazy evaluation.
55) What are decorators and why are they used?
Decorators are functions that modify other functions without changing their code.
They are applied using the @ symbol.
Common use cases include logging and authentication.
56) Explain *args in Python functions.
*args allows passing a variable number of positional arguments.
The arguments are received as a tuple.
It makes functions more flexible.
57) Explain **kwargs in Python functions.
**kwargs allows passing a variable number of keyword arguments.
Arguments are received as a dictionary.
Used when function parameters are dynamic.
58) What is a lambda function?
A lambda function is an anonymous function defined using the lambda keyword.
It can have only one expression.
Used for short operations.
59) What is the map() function?
The map() function applies a function to each element of an iterable.
It returns a map object.
Often used with lambda functions.
60) What is the filter() function?
The filter() function selects elements that satisfy a condition.
It returns only True values.
Used to remove unwanted elements.
61) What is the reduce() function?
The reduce() function applies cumulative operations on elements.
It reduces an iterable to a single value.
It is found in the functools module.
62) What is a context manager in Python?
A context manager manages resources efficiently.
It ensures proper setup and cleanup.
Commonly used for file handling.
63) What does the with statement do?
The with statement simplifies resource management.
It automatically closes files or connections.
It reduces error-prone code.
64) How does exception handling work in Python?
Exception handling manages runtime errors using try-except blocks.
It prevents program crashes.
It improves application stability.
65) What is the purpose of the finally block?
The finally block always executes.
It is used for cleanup operations.
It runs regardless of exceptions.
66) What is the difference between shallow copy and deep copy?
Shallow copy duplicates object references.
Deep copy duplicates actual objects.
Deep copy avoids shared references.
67) What is the use of the copy module?
The copy module provides copy and deepcopy functions.
It helps duplicate objects safely.
Used for nested data structures.
68) What is multiple inheritance?
Multiple inheritance allows a class to inherit from multiple parent classes.
It increases flexibility.
Python resolves conflicts using MRO.
69) What is Method Resolution Order (MRO)?
Method Resolution Order defines the order of method execution.
It follows the C3 linearization algorithm.
It avoids ambiguity in inheritance.
70) What is method overriding?
Method overriding allows a child class to redefine parent methods.
It supports polymorphism.
Provides customized behavior.
71) What is the use of super()?
super() calls parent class methods.
It avoids hardcoding parent class names.
Improves maintainability.
72) What are abstract base classes?
Abstract base classes define method structure.
They enforce method implementation.
Used in large-scale applications.
73) What is duck typing?
Duck typing focuses on object behavior instead of type.
If an object behaves correctly, it is accepted.
Improves flexibility.
74) What is an iterator?
An iterator is an object used to traverse elements.
It implements __iter__ and __next__.
Used in loops.
75) What is the difference between iterator and iterable?
An iterable can return an iterator.
An iterator produces values one by one.
All iterators are iterables.
76) What are magic (dunder) methods?
Magic methods customize object behavior.
They start and end with double underscores.
Examples include __len__ and __str__.
77) What is the purpose of the __init__ method?
The __init__ method initializes object attributes.
It runs during object creation.
Acts as a constructor.
78) Difference between __str__ and __repr__?
__str__ is user-friendly output.
__repr__ is developer-focused output.
Used for debugging.
79) What is a closure in Python?
A closure is a nested function that remembers outer variables.
It retains state.
Used in functional programming.
80) What is the global keyword?
The global keyword modifies global variables inside functions.
It allows assignment.
Should be used carefully.
81) What is the nonlocal keyword?
The nonlocal keyword modifies enclosing scope variables.
Used in nested functions.
Helps preserve state.
82) How does multithreading work in Python?
Multithreading allows concurrent execution of threads.
Useful for I/O-bound tasks.
Handled using the threading module.
83) What is the Global Interpreter Lock (GIL)?
The GIL allows only one thread to execute Python bytecode.
It ensures memory safety.
Limits CPU-bound threading.
84) When should multiprocessing be used?
Multiprocessing uses multiple processes.
It bypasses the GIL.
Best for CPU-bound tasks.
85) What is asynchronous programming?
Asynchronous programming handles multiple tasks concurrently.
It improves I/O performance.
Used in network applications.
86) What are async and await keywords?
async defines asynchronous functions.
await pauses execution until completion.
Used with coroutines.
87) What is the asyncio module?
The asyncio module supports async programming.
It manages event loops.
Used in scalable applications.
88) What is serialization in Python?
Serialization converts objects into byte streams.
Used for storage or transfer.
Allows object persistence.
89) What is the pickle module?
The pickle module serializes Python objects.
It converts objects to binary format.
Not safe for untrusted data.
90) What are virtual environments?
Virtual environments isolate project dependencies.
They prevent version conflicts.
Created using venv.
91) Why are virtual environments important?
Virtual environments improve project stability.
They isolate libraries per project.
Essential for deployment.
92) What is pip and how is it used?
Pip is Python’s package manager.
It installs and manages libraries.
Used with PyPI.
93) What is a requirements file?
A requirements file lists project dependencies.
It helps recreate environments.
Used in collaboration.
94) Difference between mutable and immutable objects with example?
Mutable objects can be changed after creation.
Immutable objects cannot be changed.
Lists are mutable, tuples are immutable.
95) How does Python manage memory?
Python manages memory automatically.
It allocates and deallocates objects.
Uses reference counting.
96) What is garbage collection in Python?
Garbage collection removes unused objects.
It frees memory automatically.
Improves performance.
97) What is a Python module?
A module is a Python file with reusable code.
It improves organization.
Imported using import.
98) What is a Python package?
A package is a collection of modules.
It organizes large applications.
Uses directories.
99) How does exception chaining work?
Exception chaining links multiple exceptions.
It preserves error context.
Improves debugging.
100) What are type hints and why are they used?
Type hints specify variable types.
They improve readability.
Used with static analysis tools.

GenAI

1) What is Generative AI?
Generative AI is a branch of artificial intelligence that creates new content instead of just analyzing data. It can generate text, images, audio, video, or code by learning patterns from large datasets. The output is original but based on learned knowledge.
2) How is Generative AI different from traditional AI?
Traditional AI focuses on tasks like classification, prediction, or decision-making based on rules or models. Generative AI, on the other hand, creates new content such as writing text or generating images. It is more creative and flexible in nature.
3) Name some common applications of Generative AI.
Generative AI is used in chatbots, content creation, image and video generation, music composition, and software development. It is also used for summarization, translation, and virtual assistants. Many companies use it to automate creative and repetitive tasks.
4) What is a Large Language Model (LLM)?
A Large Language Model (LLM) is a deep learning model trained on huge amounts of text data. It understands language patterns, grammar, and context. LLMs can answer questions, write content, and generate code.
5) What kind of data is used to train Generative AI models?
Generative AI models are trained on large and diverse datasets such as books, articles, websites, images, audio files, and source code. The quality and diversity of data greatly affect model performance. Clean and unbiased data is very important.
6) What is the difference between discriminative and generative models?
Discriminative models learn to classify input data into predefined categories. Generative models learn how data is distributed and can create new data similar to the training data. For example, one predicts labels, the other creates content.
7) What is a transformer model?
A transformer model is a neural network architecture designed to handle sequential data like text. It uses attention mechanisms to understand relationships between words. Transformers process data in parallel, making them efficient.
8) Why are transformers important in Generative AI?
Transformers are important because they can understand long-range dependencies in text. They scale well for large datasets and perform better than older models like RNNs. Most modern Generative AI models are transformer-based.
9) What is tokenization?
Tokenization is the process of breaking text into smaller pieces called tokens. Tokens can be words, sub-words, or characters. Models use tokens instead of raw text for processing and generation.
10) What is a prompt in Generative AI?
A prompt is the input instruction or question given to a Generative AI model. It guides the model on what kind of output is expected. The clarity of the prompt directly affects response quality.
11) from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)


What is this code doing?
This code sends a request to a language model API.
It provides a user message as input.
The model generates a response based on the input.
The output is printed to the console.
12) prompt = "Explain Python"
print(type(prompt))


Why is prompt used like this in Generative AI?
The prompt stores user input text.
It is sent to the language model for generation.
Prompts guide the model’s response.
They are the main way users interact with LLMs.
13) messages = [
{"role": "system", "content": "You are helpful"},
{"role": "user", "content": "What is AI?"}
]


What is the purpose of role in this structure?
Roles define who is speaking in the conversation.
system sets behavior rules.
user provides questions.
This helps the model understand context.
14) from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o-mini")


What does this code initialize?
This code initializes a language model using LangChain.
It connects Python code to an LLM.
The model name specifies which LLM to use.
This makes interaction easier.
15) response = llm.invoke("What is Python?")
print(response)


What does invoke() do here?
The invoke() method sends a prompt to the model.
It waits for the model’s response.
The response contains generated text.
This is the main execution step.
16) from langchain.prompts import PromptTemplate


Why are prompt templates used?
Prompt templates allow reusable prompts.
They make prompts dynamic.
Variables can be inserted easily.
This improves consistency.
17) template = "Explain {topic}"
prompt = PromptTemplate.from_template(template)


What problem does this solve?
This template creates a reusable prompt structure.
The {topic} placeholder allows dynamic input.
It avoids rewriting prompts.
Useful in large applications.
18) formatted = prompt.format(topic="Machine Learning")


What happens in this line?
The format() method fills the placeholder.
The final prompt becomes complete text.
This text is sent to the LLM.
It customizes the query.
19) from langchain.chains import LLMChain


What is a chain in LangChain?
A chain connects multiple steps together.
It links prompts and models.
Chains simplify execution flow.
They reduce repeated code.
20) chain = LLMChain(llm=llm, prompt=prompt)


Why combine LLM and prompt?
Combining prompt and LLM creates a complete pipeline.
The prompt defines input format.
The LLM generates output.
Together they automate responses.
21) chain.run("Python")


What happens when this line executes?
The chain sends input to the LLM.
It formats the prompt automatically.
The model generates a response.
The result is returned.
22) from llama_index.core import VectorStoreIndex


What is a Vector Store used for?
A vector store stores embeddings.
It enables semantic search.
Used in retrieval-based systems.
Essential for RAG.
23) documents = ["Python is easy", "AI uses data"]


Why are documents stored like this?
Documents are stored as text chunks.
They represent knowledge sources.
These texts are converted into embeddings.
Used for searching later.
24) index = VectorStoreIndex.from_documents(documents)


What does this index represent?
The index converts documents into vectors.
It allows similarity search.
This is the base of retrieval systems.
It stores semantic meaning.
25) query_engine = index.as_query_engine()


What is the purpose of a query engine?
A query engine searches the index.
It retrieves relevant documents.
Then it sends them to the LLM.
This improves answer accuracy.
26) response = query_engine.query("What is Python?")


How is this different from a normal LLM call?
This query searches documents first.
It then generates answers from retrieved data.
Normal LLM calls don’t use external data.
This is Retrieval-Augmented Generation.
27) from langchain.embeddings import OpenAIEmbeddings


What are embeddings?
Embeddings are numerical representations of text.
They capture semantic meaning.
Similar texts have similar vectors.
Used in search and retrieval.
28) embedding = OpenAIEmbeddings()


Why are embeddings needed in RAG?
Embeddings enable document similarity matching.
They allow fast searching.
Used to find relevant context.
Critical for RAG systems.
29) from langchain.vectorstores import FAISS


What does FAISS store?
FAISS stores vector embeddings efficiently.
It allows fast similarity search.
Used for large datasets.
Optimized for performance.
30) vectorstore = FAISS.from_texts(texts, embedding)


What is happening here?
This converts text into embeddings.
The embeddings are stored in FAISS.
It creates a searchable vector database.
Used for retrieval.
31) from langchain.llms import Ollama
llm = Ollama(model="llama2")


What is Ollama used for?
Ollama runs LLMs locally.
No internet is required.
It improves privacy.
Good for testing and development.
32) llm.invoke("Explain AI")


How is this different from cloud APIs?
Local models run on your machine.
Cloud APIs run on remote servers.
Ollama avoids API costs.
Latency may differ.
33) temperature = 0.2


Why is temperature important?
Temperature controls randomness.
Lower values give stable answers.
Higher values give creative answers.
Important for response style.
34) max_tokens = 100


What does this control?
Max tokens limit output length.
It controls response size.
Prevents excessive usage.
Helps manage costs.
35) print("Response received successfully")


Why is logging important in AI apps?
Logging helps track execution flow.
It aids debugging.
Useful for monitoring AI responses.
Essential for production systems.
36) What does “prompt engineering” mean?
Prompt engineering involves crafting well-structured prompts to get accurate and relevant outputs. It includes using instructions, examples, and constraints. Good prompt engineering improves reliability and consistency.
37) What is fine-tuning in Generative AI?
Fine-tuning is the process of training a pre-trained model on task-specific data. It helps the model perform better in a particular domain like healthcare or finance. Fine-tuning requires less data than training from scratch.
38) What is pre-training?
Pre-training is the initial training phase where the model learns general language patterns. It uses massive datasets and takes significant computational resources. Pre-training provides the foundation for later specialization.
39) What is transfer learning?
Transfer learning allows knowledge gained from one task to be reused for another. It reduces training time and improves performance with limited data. Most Generative AI models rely on transfer learning.
40) What is temperature in text generation?
Temperature controls how creative or predictable the model’s output is. A low temperature produces more focused and deterministic answers. A high temperature increases diversity and creativity.
41) What is top-k sampling?
Top-k sampling limits the model to selecting from the top k most probable tokens. This reduces unlikely or random outputs. It helps maintain coherence in generated text.
42) What is top-p (nucleus) sampling?
Top-p sampling selects tokens based on cumulative probability rather than a fixed number. It adapts dynamically depending on the probability distribution. This often results in more natural responses.
43) What are hallucinations in Generative AI?
Hallucinations occur when a model generates false or misleading information confidently. This happens because the model predicts text based on patterns, not facts. Hallucinations are a major reliability concern.
44) How can hallucinations be reduced?
Hallucinations can be reduced by grounding responses in trusted data sources. Techniques like Retrieval-Augmented Generation (RAG) and better prompts help. Human review is also important.
45) What is an embedding?
An embedding is a numerical representation of data that captures semantic meaning. Similar items have similar embeddings. They allow models to compare meaning mathematically.
46) What are embeddings used for?
Embeddings are used in semantic search, recommendation systems, clustering, and document retrieval. They help find related content even if words are different. This improves search accuracy.
47) What is cosine similarity?
Cosine similarity measures how close two vectors are in direction. It is commonly used to compare embeddings. Higher cosine similarity means higher semantic similarity.
48) What is Retrieval-Augmented Generation (RAG)?
Retrieval-Augmented Generation (RAG) combines document retrieval with text generation. The model first retrieves relevant information and then generates a response. This improves factual accuracy.
49) Why is RAG useful?
RAG is useful because it allows models to use up-to-date or private data. It reduces hallucinations and improves trust. It is widely used in enterprise applications.
50) What is context window?
A context window is the maximum amount of text a model can process at one time. It includes both input and output tokens. Larger context windows allow better understanding of long conversations.
51) What happens when the context window limit is exceeded?
When the context limit is exceeded, older information is dropped. This may cause the model to forget earlier instructions. Managing context is important for long interactions.
52) What is reinforcement learning from human feedback (RLHF)?
Reinforcement Learning from Human Feedback (RLHF) improves models using human ratings. Humans evaluate outputs and guide the model toward better behavior. This improves usefulness and safety.
53) Why is RLHF used?
RLHF helps align model outputs with human values. It reduces harmful, biased, or unsafe responses. Most modern LLMs use RLHF.
54) What is overfitting in Generative AI models?
Overfitting occurs when a model performs very well on training data but poorly on new data. It memorizes patterns instead of generalizing. This reduces real-world usefulness.
55) What is underfitting?
Underfitting happens when a model is too simple to learn meaningful patterns. It performs poorly on both training and test data. This usually requires a more complex model or better data.
56) What is bias in Generative AI?
Bias in Generative AI arises from biased training data. It can lead to unfair or inaccurate outputs. Bias is a major ethical and technical challenge.
57) How can bias in Generative AI be reduced?
Bias can be reduced by using diverse datasets and fairness testing. Regular audits and human oversight help. Transparent development practices are important.
58) What is model inference?
Inference is the stage where a trained model generates output based on input. It is used in real-world applications. Inference speed affects user experience.
59) What is latency in AI systems?
Latency is the delay between input submission and response generation. Lower latency improves usability. It is influenced by model size and infrastructure.
60) What is prompt chaining?
Prompt chaining breaks complex tasks into multiple smaller prompts. Each step builds on the previous output. This improves accuracy and control.
61) What is multimodal Generative AI?
Multimodal Generative AI works with more than one type of data. It can process text, images, audio, and video together. This enables richer applications.
62) Give examples of multimodal AI models.
Examples include GPT-4, Gemini, and CLIP. These models can understand and generate across multiple formats. They are used in advanced AI systems.
63) What is zero-shot learning?
Zero-shot learning allows a model to perform tasks without seeing examples. It relies on general knowledge learned during training. This shows model flexibility.
64) What is few-shot learning?
Few-shot learning provides a small number of examples to guide the model. It improves accuracy for specific tasks. It is commonly used in prompts.
65) What is the difference between zero-shot and few-shot learning?
Zero-shot uses no examples, while few-shot uses a few. Few-shot usually produces better results. Both reduce the need for retraining.
66) What is an API in the context of Generative AI?
An API allows applications to communicate with AI models. Developers send requests and receive responses. APIs simplify integration.
67) Why are APIs used to access AI models?
APIs provide scalability, security, and ease of use. They allow teams to use powerful models without managing infrastructure. Most AI services use APIs.
68) What are tokens and why do they matter?
Tokens are the basic units processed by AI models. Token count affects cost, performance, and context size. Efficient token usage is important.
69) What is cost optimization in Generative AI usage?
Cost optimization involves minimizing token usage and selecting appropriate models. Caching responses also helps. This is important for large-scale systems.
70) What is model versioning?
Model versioning tracks changes in models over time. It helps manage updates and rollbacks. This ensures stability in production systems.
71) What is model drift?
Model drift happens when real-world data changes over time. The model becomes less accurate. Regular monitoring and retraining are required.
72) What is explainability in Generative AI?
Explainability helps users understand model behavior. It increases trust and transparency. This is important in regulated industries.
73) What are ethical concerns in Generative AI?
Ethical concerns include bias, privacy, misinformation, and misuse. Responsible AI practices are required. Governance and guidelines help reduce risks.
74) How is Generative AI used in software development?
Generative AI helps developers write code faster. It assists in debugging, testing, and documentation. This improves productivity.
75) What skills are important for a Generative AI engineer?
Important skills include Python, machine learning basics, APIs, prompt engineering, and ethics. Understanding data and system design is also valuable.
76) What is prompt engineering and why is it important?
Prompt engineering is the practice of crafting effective inputs for AI models.
It directly influences accuracy, relevance, and structure of outputs.
Well-designed prompts reduce hallucinations and retries.
They help control tone, format, and reasoning depth.
Prompt engineering is essential for production-grade AI systems.
77) What are system, user, and assistant prompts?
System prompts define overall behavior and rules for the model.
User prompts contain the actual task or question.
Assistant messages form historical context.
Together they control alignment and consistency.
This separation improves predictable behavior.
78) What is a role-based prompt?
Role-based prompting assigns a professional or domain role to the model.
It narrows the response scope and improves expertise.
Examples include “act as a data analyst.”
This improves domain accuracy.
It is widely used in enterprise workflows.
79) What is prompt templating?
Prompt templating uses reusable prompt structures.
Variables are dynamically injected into templates.
This ensures consistency across requests.
It reduces human errors.
Prompt templates are common in LangChain.
80) What are few-shot prompts used for?
Few-shot prompting includes examples inside the prompt.
It teaches the model expected output format.
This improves accuracy without training.
It works well for classification and formatting tasks.
It balances flexibility and control.
81) What is chain-of-thought prompting?
Chain-of-thought prompting forces step-by-step reasoning.
It improves performance on logic-heavy problems.
The model explains how it reaches conclusions.
This increases transparency.
However, it increases token cost.
82) When should chain-of-thought prompting be avoided?
Chain-of-thought should be avoided in short responses.
It increases latency and cost.
It may expose internal reasoning unnecessarily.
Not suitable for real-time systems.
Concise tasks don’t require it.
83) What is instruction-based prompting?
Instruction-based prompting uses direct commands.
Examples include “summarize,” “translate,” or “classify.”
It is simple and beginner-friendly.
Most chatbots rely on it.
It works well for standard tasks.
84) What are common prompt engineering mistakes?
Poor prompts often lack clarity or context.
Overloaded prompts confuse models.
Missing constraints lead to inconsistent output.
Untested prompts fail in production.
Prompt quality directly affects reliability.
85) How do constraints improve prompt quality?
Constraints guide model behavior clearly.
They control length, format, and style.
They reduce unnecessary information.
Constraints increase predictability.
They are critical for automation.
86) What is Text-to-Speech (TTS)?
Text-to-Speech converts written text into spoken audio.
It enables verbal communication from machines.
It improves accessibility for users.
Used in assistants and navigation systems.
Modern TTS sounds natural.
87) How does a TTS system work internally?
TTS systems analyze text linguistically.
They convert text to phonemes.
Neural networks generate speech audio.
Post-processing improves clarity.
Final output is played as sound.
88) What are common use cases of TTS?
TTS is used in voice assistants.
It powers IVR systems.
It helps visually impaired users.
Used in audiobooks and education.
Improves user experience.
89) What is neural TTS?
Neural TTS uses deep learning models.
It generates expressive and natural speech.
It handles emotion and tone.
Requires large voice datasets.
Superior to rule-based TTS.
90) What is voice cloning?
Voice cloning replicates human voice digitally.
It learns tone and style from samples.
Used in personalization.
High misuse risk exists.
Consent is critical.
91) What are ethical concerns in TTS?
Ethical concerns include voice impersonation.
Deepfake audio misuse is a risk.
Privacy violations can occur.
Disclosure is required.
Regulation is increasing.
92) What is LangChain?
LangChain is a framework for LLM applications.
It manages prompts, memory, tools, and chains.
It simplifies complex workflows.
It supports agents and RAG.
Widely used in GenAI apps.
93) What problem does LangChain solve?
LangChain removes manual orchestration complexity.
It standardizes LLM workflows.
It enables tool calling.
It improves scalability.
Speeds up development.
94) What are chains in LangChain?
Chains are sequences of processing steps.
Each step passes output forward.
They create structured pipelines.
They are reusable.
Useful for multi-step tasks.
95) What are agents in LangChain?
Agents can decide actions dynamically.
They choose which tool to use.
They simulate reasoning behavior.
Agents enable autonomy.
Used in complex systems.
96) What is a tool in LangChain?
Tools are external functions.
Examples include calculators or APIs.
Agents call tools when needed.
Tools extend LLM capability.
They improve usefulness.
97) What are memory components in LangChain?
Memory stores past interactions.
It preserves conversation history.
Memory improves continuity.
Different memory types exist.
Essential for chatbots.
98) What is conversational memory?
Conversational memory tracks dialogue.
It remembers user preferences.
It enables personalization.
Improves engagement.
Critical for assistants.
99) What is a LangChain retriever?
Retrievers fetch relevant documents.
They use embeddings.
They power RAG systems.
They ground responses in data.
Accuracy improves significantly.
100) What is LlamaIndex?
LlamaIndex connects LLMs to custom data.
It focuses on indexing and retrieval.
It supports multiple data formats.
It simplifies ingestion.
Often used with RAG.
101) How is LlamaIndex different from LangChain?
LlamaIndex handles data indexing.
LangChain handles orchestration.
They complement each other.
LlamaIndex improves retrieval accuracy.
LangChain manages logic.
102) What is a document loader in LlamaIndex?
Document loaders ingest data.
They support PDFs, DBs, APIs.
They convert data into nodes.
They simplify preprocessing.
They prepare data for indexing.
103) What is an index in LlamaIndex?
Indexes organize data efficiently.
They enable fast retrieval.
They use embeddings.
They improve relevance.
Core of RAG systems.
104) What are nodes in LlamaIndex?
Nodes are data chunks.
They store content and metadata.
Smaller chunks improve precision.
They support semantic search.
They are indexing units.
105) What is query engine in LlamaIndex?
Query engines handle user queries.
They retrieve relevant nodes.
They pass context to LLMs.
They generate final answers.
They power RAG workflows.
106) What is RAG with SQL databases?
RAG with SQL enables natural language queries.
It connects LLMs to structured databases.
The model generates SQL queries.
Results are used in responses.
Improves accessibility.
107) Why use RAG instead of direct SQL queries?
RAG avoids manual SQL writing.
Non-technical users benefit.
It improves flexibility.
Reduces query errors.
Enhances experience.
108) How does SQL-based RAG work step by step?
User asks a natural language question.
Model generates SQL.
Database executes query.
Results are retrieved.
LLM generates final answer.
109) What are common challenges in RAG with SQL?
Schema understanding is difficult.
Complex joins may fail.
Query validation is required.
Security must be enforced.
Performance can degrade.
110) How can embeddings be used with SQL data?
Embeddings convert SQL text data.
They enable semantic search.
Similar rows are matched.
Exact keywords aren’t required.
Improves intelligence.
111) What is Ollama?
Ollama runs LLMs locally.
It simplifies model usage.
No cloud dependency.
Improves privacy.
Great for development.
112) Why is Ollama useful for local LLM development?
Ollama enables offline testing.
It reduces cost.
Supports multiple models.
Easy to experiment.
Developer-friendly.
113) What is MCP (Model Context Protocol)?
MCP standardizes model-tool communication.
It defines context handling.
It improves interoperability.
Reduces integration issues.
Supports scalable systems.
114) Why is MCP important in AI systems?
MCP ensures consistent behavior.
It simplifies tool integration.
It improves reliability.
Supports modular design.
Enterprise-friendly.
115) How does MCP improve tool integration?
MCP standardizes interfaces.
Tools integrate easily.
Context is preserved.
Errors reduce.
System stability improves.
116) What is fine-tuning in LLMs?
Fine-tuning updates model weights.
It uses task-specific data.
It improves specialization.
Consistency increases.
Resource-intensive process.
117) What is the difference between fine-tuning and prompting?
Prompting affects runtime behavior.
Fine-tuning changes model permanently.
Prompting is cheaper.
Fine-tuning is powerful.
Both have use cases.
118) What is parameter-efficient fine-tuning (PEFT)?
PEFT fine-tunes fewer parameters.
It reduces training cost.
It is faster.
Preserves base knowledge.
Widely adopted.
119) When should you fine-tune a model?
Fine-tune when prompts fail.
When accuracy is critical.
When outputs must be consistent.
At scale.
Budget permitting.
120) What is LoRA?
LoRA adds trainable layers.
It is efficient.
Reduces memory usage.
Popular PEFT method.
Used in practice.
121) What is instruction fine-tuning?
Instruction fine-tuning teaches models to follow commands.
It improves alignment.
Enhances usability.
Uses labeled instruction data.
Improves reliability.
122) What is dataset preparation for fine-tuning?
Data must be cleaned.
Formatting must be consistent.
Bias must be minimized.
Labels must be accurate.
Quality is critical.
123) What are risks of fine-tuning?
Overfitting risk exists.
Bias can increase.
Performance may degrade.
Costs rise.
Testing is essential.
124) How do you evaluate a fine-tuned model?
Use evaluation datasets.
Compare with baseline.
Conduct human review.
Monitor metrics.
Validate production behavior.
125) What skills are needed to build production-grade GenAI systems?
Skills include Python and ML basics.
LLM frameworks knowledge.
Data engineering skills.
System design thinking.
Ethics and monitoring awareness.