Role of Python Flashcards

(63 cards)

1
Q

Why is Python considered a glue machine for agentic systems?

A

Because it dominates the AI & LLM ecosystem and facilitates integration

Python is used to connect various components and libraries in agentic systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the major ML/LLM libraries that are Python-first?

A
  • PyTorch
  • JAX
  • TensorFlow
  • Hugging Face transformers
  • diffusers

These libraries are essential for building and deploying machine learning models.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the typical agent workloads that Python excels at orchestrating?

A
  • Call an LLM
  • Call a tool/API
  • Hit a database/vector store
  • Read/write files
  • Loop until a goal is met
  • Hand off to another agent

Python’s capabilities make it suitable for managing these tasks effectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false: Python is primarily used for heavy number crunching in agentic systems.

A

FALSE

Agents mostly perform I/O and coordination rather than intensive computations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What features of Python’s async stack align with agent behavior?

A
  • asyncio
  • Libraries like httpx, aiohttp, anyio

These features allow for efficient handling of I/O-bound tasks and concurrent operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some capabilities of Python that support dynamic and introspective programming?

A
  • Dynamic imports (importlib)
  • Reflection (inspect)
  • Metaprogramming
  • First-class functions and decorators

These capabilities allow for flexible and adaptive agentic systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Name some Python-centric agent frameworks.

A
  • LangChain
  • LlamaIndex
  • AutoGen
  • CrewAI

These frameworks are designed to facilitate the development of agentic systems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What tools does Python provide for outer loop experimentation in agentic systems?

A
  • Jupyter/VS Code notebooks
  • Simple CLI scripts
  • Rich ecosystem for metrics, logging, and dashboards

These tools support rapid prototyping and testing of agent behaviors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a common pattern in serious agentic systems regarding language use?

A
  • Python for orchestration
  • Rust/C++/Go/Java for performance-critical tools

This allows for a balance between ease of development and performance optimization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a significant non-technical reason for using Python in agentic systems?

A
  • High familiarity among data scientists and ML engineers

This makes it easier to build and grow teams around Python-based projects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When might you choose a language other than Python for agentic systems?

A
  • Node/TypeScript for web frontends
  • Go for high-throughput services
  • Rust/C++ for safety-critical tools
  • Java/Kotlin/C# in enterprise environments

These languages may be better suited for specific use cases or environments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Python notebook most commonly known as?

A

Jupyter Notebook or .ipynb file

A Python notebook is an interactive lab notebook for code, combining code, text, and results.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the two main types of cells in a Python notebook?

A
  • Code cells
  • Markdown cells

Code cells are for writing Python, while Markdown cells are for explanations and notes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the kernel in a Python notebook do?

A
  • Executes code
  • Keeps variables in memory
  • Returns output

The kernel is a Python process running behind the scenes that handles code execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

True or false: The order in which you run cells in a Python notebook does not matter.

A

FALSE

Running cells out of order can lead to a state that doesn’t match the notebook’s top-to-bottom view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the typical workflow steps in a Python notebook?

A
  • Setup cell
  • Exploration cells
  • Analysis / modeling cells
  • Documentation cells
  • Export / save

Each step serves a specific purpose in the coding and analysis process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are the strengths of using Python notebooks?

A
  • Fast feedback
  • Exploration and experimentation
  • Rich documentation
  • Sharing

These strengths make notebooks ideal for data analysis, prototyping, and reporting.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are some weaknesses or challenges associated with Python notebooks?

A
  • Hidden state problems
  • Not ideal for large, production systems
  • Testing & CI challenges

These issues can complicate debugging and reproducibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the best use case for a Notebook (.ipynb)?

A
  • Prototypes
  • Experiments
  • Learning
  • Analysis / reports

Notebooks are executed by clicking cells or using Shift+Enter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the best use case for a Script (.py)?

A
  • Command-line tools
  • Simple ETL jobs
  • Repeatable tasks

Scripts are executed with the command python my_script.py.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the best use case for a Package / library (structured project)?

A
  • Production systems
  • Shared utilities
  • Code that multiple services rely on

This typically includes modules, tests, CI, and documentation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

In an agentic / LLM-heavy world, notebooks are used to prototype ________.

A

agent behavior

This includes trying different prompting strategies and testing tool-calling patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a Python notebook best described as?

A

An interactive coding diary

You write code, run it in small chunks, see results in-line, and annotate your thinking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a Python notebook file essentially composed of?

A

JSON

The top-level structure includes cells, metadata, and format version information.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the three types of **cell types** in a notebook?
* code * markdown * raw ## Footnote Each cell type serves a different purpose in the notebook.
26
What does the **execution_count** represent in a code cell?
The “In [3]” number you see in the UI ## Footnote It indicates how many times the cell has been executed.
27
What is the purpose of the **outputs** field in a notebook cell?
A list of result objects (print output, rich displays, errors) ## Footnote This allows the notebook to remember what happened the last time it was run.
28
What does the **metadata** field at the top level of a notebook contain?
* Kernel info (language, display name) * Extensions config, authors, etc. ## Footnote Metadata is crucial for tools and pipelines that rely on these fields.
29
What are the three main components that participate when you open a notebook?
* Frontend * Jupyter server * Kernel ## Footnote Each component plays a vital role in rendering and executing the notebook.
30
True or false: All code cells in a notebook talk to different kernel instances.
FALSE ## Footnote All code cells communicate with the same kernel instance, leading to a shared global state.
31
What happens when you hit **Run** on a cell in a notebook?
* Frontend sends code to the kernel * Kernel executes code * Outputs are delivered back to frontend * Frontend renders outputs ## Footnote This process updates the cell’s execution count and outputs in memory.
32
What is the role of the **kernel** in a notebook?
* Executes code * Keeps variables in memory * Serves as the single source of truth for all variables ## Footnote The kernel provides a REPL-like loop for executing and inspecting code.
33
What functional role do **cells** serve in a notebook?
* Chunked experimentation * Re-runnable sections * Narrative structure ## Footnote Cells allow for organized and efficient coding and documentation.
34
What do **outputs** turn the notebook into?
* A lab notebook * A shareable artifact ## Footnote Outputs allow the notebook to retain and display results from previous runs.
35
What does **metadata** enable in a notebook?
* Parameterization / automation * Selective execution * Presentation changes ## Footnote Metadata enhances the functionality and usability of notebooks.
36
What are some higher-level functions that notebooks serve?
* Exploratory playground * Narrative analysis / reports * Experiment harness * Bridge to production code ## Footnote These functions illustrate the versatility of notebooks in data science and programming.
37
Fill in the blank: Notebooks serve as **inner-loop experiment rigs** for _______.
[Prompt templates and system prompts] ## Footnote This highlights how notebooks can be utilized for rapid experimentation.
38
What does the **execution model** of a notebook allow for?
Sequential execution per kernel while allowing user control over the sequence ## Footnote This model gives notebooks their hybrid feel of REPL and document.
39
What is LangChain primarily known as?
**LLM wiring framework** ## Footnote It provides standard building blocks to connect models, prompts, tools, and memory into reusable chains and agents.
40
List the **key pieces** of LangChain's structure.
* LLMs and Chat Models * Prompts and Templates * Chains * Memory * Tools * Agents * Document loaders, text splitters, and vector stores * Callbacks / tracing / observability ## Footnote These components work together to facilitate the orchestration of LLM workflows.
41
What does the **LLM** component in LangChain represent?
* Abstractions around model providers * Unified interface for invoking models ## Footnote Examples include OpenAI, Anthropic, and local models like Ollama.
42
What is the function of **Prompts and Templates** in LangChain?
* Separate prompt design from execution code * Reuse templates across different chains or models * Make prompts programmable ## Footnote This allows for conditionals, few-shot examples, and multi-message chat prompts.
43
Define a **Chain** in the context of LangChain.
A **Chain** is a pipeline that takes inputs, calls components, and returns outputs ## Footnote It encapsulates multistep LLM workflows into reusable objects.
44
What does **Memory** allow in LangChain?
* Store conversation history or other state * Enable stateful chains/agents ## Footnote It helps agents remember previous user turns and recall facts from earlier in a session.
45
What is the purpose of **Tools** in LangChain?
* Allow LLMs to act in the world * Call APIs, run code, query databases ## Footnote Tools are what agents choose between when deciding what to do next.
46
Describe the structure of **Agents** in LangChain.
* Built on one or more LLMs * A set of tools ## Footnote Agents implement tool-augmented reasoning and can be composed into larger systems.
47
What are **Document loaders** and **text splitters** used for in LangChain?
* Pull text from various sources * Break content into chunks ## Footnote They are part of the RAG stack for Retrieval-Augmented Generation.
48
What is the function of **Callbacks** in LangChain?
* Log prompts and responses * Send traces to dashboards * Measure tokens, latency, cost ## Footnote They are crucial for debugging and improving agent behavior.
49
True or false: LangChain provides a **standard, pluggable interface** for each step in the agentic flow.
TRUE ## Footnote This helps avoid a ball of custom scripts and facilitates easier orchestration.
50
What does the **agent loop** in LangChain consist of?
* See user input + current state * Ask the model what to do next * Execute the tool * Feed the result back into the model ## Footnote This process repeats until termination.
51
In a larger agentic system, how does LangChain fit in?
* Handles local orchestration for a single app or service * Encapsulates prompt logic, tools, RAG, and agent loops ## Footnote It can be integrated with other services for broader coordination.
52
What are the **main components** of LangChain?
* LLM / ChatModel * PromptTemplate * Chain * Memory * Tool * Agent * RAG stack (Loader → Splitter → Embeddings → VectorStore) * Callbacks / Tracing ## Footnote These components work together to create a structured system for interacting with language models.
53
What is the **function** of the **LLM / ChatModel** in LangChain?
* Provide a uniform way to talk to different models * Encapsulate provider-specific details * Allow higher-level components to treat model calls as nodes in a graph ## Footnote The LLM acts as a driver around an external model API.
54
What does a **PromptTemplate** consist of?
* Static parts: system instructions, role, examples * Slots / variables: `{question}`, `{context}`, `{tools}` * Optional structure: multi-message representation ## Footnote It translates structured inputs into model-ready text/messages.
55
What is the **structure** of a **Chain** in LangChain?
* Directed graph / pipeline of steps * Input schema (expected keys) * Output schema * May have sub-chains ## Footnote Chains encapsulate multi-step procedures into a single callable unit.
56
What is the purpose of **Memory** in LangChain?
* Inject context into new prompts * Store conversation history, summaries, key entities * Act as a black-box store for context ## Footnote Memory allows chains/agents to access previous interactions.
57
What are the key components of a **Tool** in LangChain?
* Name * Description * Input schema * Callable that implements the action ## Footnote Tools expose non-LLM capabilities to an LLM in a structured way.
58
What is the **function** of an **Agent** in LangChain?
* Implement reason–act–observe cycle * Read current state and ask LLM for next action * Execute tool calls and manage state ## Footnote Agents control the flow of operations based on user input and history.
59
What does the **RAG stack** consist of?
* Document Loaders * Text Splitters * Embeddings * Vector Store ## Footnote The RAG stack is used for knowledge retrieval and semantic search.
60
What is the role of **Document Loaders** in the RAG stack?
* Read from various sources (PDFs, APIs) * Output a standard Document object ## Footnote They normalize heterogeneous sources into a common document abstraction.
61
What do **Text Splitters** do?
* Break documents into retrieval-friendly chunks * Control recall vs precision tradeoffs ## Footnote They ensure chunks are meaningful and fit into context windows.
62
What is the purpose of **Callbacks / Tracing** in LangChain?
* Provide observability * Feed data to debugging tools and evaluation systems ## Footnote Callbacks allow monitoring of operations like model calls and tool calls.
63
How does data flow in a **LangChain-based app or agent**?
* External input → Agent → Memory loading → (Optional RAG call) → Build prompt → Call LLM → Tool execution → Final answer ## Footnote This flow illustrates how components interact to process requests.