Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ pip install -e ".[dev]"
# Classify and extract from a folder of PDFs
python src/pipeline/classify_extract.py path/to/pdfs/

# Extract from pre-classified .txt files (skip XGBoost)
python src/pipeline/classify_extract.py path/to/txts/ --skip-classifier

# Adjust the LLM model or confidence threshold
python src/pipeline/classify_extract.py path/to/pdfs/ --llm-model qwen2.5:7b --confidence-threshold 0.70
```
Expand Down
39 changes: 39 additions & 0 deletions data/processed-text/test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[PAGE 1]
CS 331: Introduction to Artificial
Intelligence
Lecture 2: Agents
Sandhya Saisubramanian
Comment on lines +1 to 5

[PAGE 2]
Announcements
• Quiz 1 will be released on Oct 1 at 2 pm and will be active until Oct 3
11:59pm
Expand All @@ -12,20 +14,23 @@ Announcements
(instead of Thursday)
2

[PAGE 3]
Today’s Agenda
What is an agent?
What does it mean to design an intelligent agent?
3
How can these agents decide what to do/ how to act?
Readings: Chapters 2 and 3 in course textbook

[PAGE 4]
Few Real-World Examples
At a high-level, all these systems perform the following:
1. Sense (perceive)
2. Think (decide what to do)
3. Act (produce some output)
4

[PAGE 5]
Agent-Centric View of AI
Reasoning
Environment
Expand All @@ -38,6 +43,7 @@ sensors and acts on that environment through actuators
Agent
5

[PAGE 6]
Agent-Related Terms
• Percept sequence (P): A complete history of everything the agent
has ever perceived. Think of this as the state of the world from
Expand All @@ -54,13 +60,15 @@ on a machine.
implementation
6

[PAGE 7]
Example: Vacuum Cleaner Agent
Sensors: Camera to detect
obstacles and dirt
Percept Sequence: Cleanliness
status
7

[PAGE 8]
Example: Vacuum Cleaner Agent
Percept Sequence
Action
Expand Down Expand Up @@ -93,6 +101,7 @@ wheels
Agent function
8

[PAGE 9]
Agent Design and Implementation
Before implementing an agent, we need to think carefully about:
1.
Expand All @@ -109,6 +118,7 @@ How should the agent act? How will its behavior or performance
be evaluated?
9

[PAGE 10]
PEAS Descriptions of Task Environments
Performance, Environment, Actuators, Sensors
Performance
Expand Down Expand Up @@ -140,6 +150,7 @@ PEAS is the standard way of specifying an agent task environment before you
even design the agent
10

[PAGE 11]
PEAS Descriptions of Task Environments
Performance, Environment, Actuators, Sensors
Performance
Expand All @@ -166,6 +177,7 @@ answers
Example: Medical Diagnosis Agent
11

[PAGE 12]
Properties of Environments
Fully observable: can access complete state
of environment at each point in time
Expand Down Expand Up @@ -198,6 +210,7 @@ making/executing entities; cooperative or
competitive
12

[PAGE 13]
How Should An Agent Act?
Given:
• A performance measure
Expand All @@ -210,6 +223,7 @@ actions? How should the agent function be constructed?
Intelligence emerges from how agents choose actions
13

[PAGE 14]
How Should An Agent Act?
Given:
• A performance measure
Expand All @@ -223,6 +237,7 @@ Does not consider the agent’s knowledge, its percept
sequence or the environment in which it is operating
14

[PAGE 15]
Rational Agent
Rational agent: for each possible percept sequence, a rational
agent should select an action that is expected to maximize its
Expand All @@ -239,6 +254,7 @@ Actions agent can perform
Agent’s percept sequence to date
15

[PAGE 16]
Types of Agents
• Categorized based on their performance measure
Types of
Expand All @@ -253,6 +269,7 @@ Utility-directed
agents
16

[PAGE 17]
Simple Reflex Agents
17
• Simple if-then: if condition then action; no internal model
Expand All @@ -265,9 +282,11 @@ action ← RULE-ACTION[rule]
return action
Example: if temp < 68 → turn heater on

[PAGE 18]
Simple Reflex Agents
18

[PAGE 19]
Simple Reflex Agents
• Advantages:
• Easy to implement
Expand All @@ -278,6 +297,7 @@ observable
• Infinite loops
19

[PAGE 20]
Model-based Reflex Agents
• Maintain some internal state that keeps track of the part of the world
it can’t see now (partial observability)
Expand All @@ -295,9 +315,11 @@ The internal model (“map of which rooms are clean/dirty”) allows it to act
sensibly despite partial observability.
20

[PAGE 21]
Model-based Reflex Agents
21

[PAGE 22]
Goal-directed Agents
• Goal information guides agent’s actions (looks to the future)
• Sometimes achieving goal is simple e.g. from a single action
Expand All @@ -307,9 +329,11 @@ actions à accounts for future states
Example: Navigation
22

[PAGE 23]
Goal-directed Agents
23

[PAGE 24]
Utility-directed Agents
• What if there are many paths to the goal? à optimize trade-offs
when multiple outcomes are possible
Expand All @@ -324,9 +348,11 @@ Common types of utility definitions:
Example: Self-driving car balancing speed vs. safety vs. comfort
24

[PAGE 25]
Utility-directed Agents
25

[PAGE 26]
Types of Agents
• Categorized based on their performance measure
• Simple reflux agents
Expand All @@ -336,6 +362,7 @@ Types of Agents
• Learning agents
26

[PAGE 27]
Learning Agents
Successful agents split task of computing policy in 3 periods:
1.
Expand All @@ -352,9 +379,11 @@ some emails, but improves by learning from user corrections
(“mark as spam” / “not spam”)
27

[PAGE 28]
Learning Agents
28

[PAGE 29]
Learning Agents
Think of this as outside
the agent since you don’t
Expand All @@ -363,6 +392,7 @@ the agent
Maps percepts to actions
29

[PAGE 30]
Learning Agents
Responsible for improving the
agent’s behavior with experience
Expand All @@ -376,6 +406,7 @@ percepts don’t tell the agent about its
success/failure)
30

[PAGE 31]
In-Class Exercise: Designing Agents
Design an intelligent vacuum cleaner for a house.
To make it more interesting, we will analyze design choices for different
Expand All @@ -388,13 +419,15 @@ At least need a model-based agent, if not more complex designs: must
remember which rooms have been cleaned
31

[PAGE 32]
In-Class Exercise: Designing Agents
Design an intelligent vacuum cleaner for a house.
Scenario 3: Multi-room house with user-specific requests such as ”Clean the
kitchen first and then the living room”
Goal-based agents
32

[PAGE 33]
In-Class Exercise: Designing Agents
Design an intelligent vacuum cleaner for a house.
Scenario 4: Multi-room house and the agent must determine the order of
Expand All @@ -405,6 +438,7 @@ must be cleaned such that the utility is maximized
associated with each room)
33

[PAGE 34]
Designing Modern Agents
34
Example:
Expand All @@ -416,6 +450,7 @@ based (uses an internal model of the environment) + learning
Many of the modern AI agents are designed to learn from
data, to adapt better to the environment and user

[PAGE 35]
From Classical AI to Modern Agents
35
Agent Type
Expand Down Expand Up @@ -451,6 +486,7 @@ AlphaGo, adaptive robots
Improves behavior over time
from data and feedback

[PAGE 36]
Planning Agents
• Need to plan a sequence of actions to reach the goal or complete
a task
Expand All @@ -460,13 +496,15 @@ some level of planning
sequences
36

[PAGE 37]
Search Problem
37
• Perform a search in the solution space intelligently
• Evaluate solutions to identify the best
Solution space: set of all possible solutions to the problem
Solution

[PAGE 38]
Formalizing the Search Problem
• A finite set of states à set of all decision points
• Initial state
Expand All @@ -479,6 +517,7 @@ negative one-step cost of travelling from state s to s’. The
cost function is only defined if s’ is a successor state of s.
38

[PAGE 39]
Formalizing the Search Problem: Example from
Textbook
39
Expand Down
23 changes: 21 additions & 2 deletions documentation/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,25 @@ All contributors must follow the Oregon State University Student Code of Conduct
| `--num-ctx` | `4096` | Ollama context window size (tokens) |
| `--workers` | `1` | Parallel worker processes (`1` = sequential) |

* ### Extracting from pre-classified .txt files
When PDFs have already been classified (or labels come from `labels.json`), skip
XGBoost and run clean → filter → extract on `.txt` files:
```bash
python src/pipeline/classify_extract.py path/to/txts/ --skip-classifier

# Optional: same flags as the former extract_from_txt.py
python src/pipeline/classify_extract.py path/to/txts/ --skip-classifier --chunked
python src/pipeline/classify_extract.py path/to/txts/ --skip-classifier --labels labels.json
```
| Flag | Default | Description |
|------|---------|-------------|
| `--skip-classifier` | off | Process `.txt` files without classification |
| `--labels` | — | `labels.json` path; only stems labelled `useful` are processed |
| `--chunked` | off | Chunked extraction with per-chunk scoring and majority-vote merge |
| `--top-chunks` | `3` | Top chunks to extract (with `--chunked`) |
| `--chunk-size` | `4000` | Chunk size in characters (with `--chunked`) |
| `--chunk-overlap` | `500` | Overlap between chunks (with `--chunked`) |

* ### Sample Output
Each PDF classified as "useful" produces a JSON file in `data/results/metrics/`:
```json
Expand Down Expand Up @@ -389,8 +408,8 @@ Extraction fields are defined in two places:
2. **`src/extraction/llm_client.py`** - the system prompt that instructs the LLM.
Add a description of the new field and its expected format to the prompt string.

3. **`src/pipeline/classify_extract.py`** and **`src/pipeline/extract_from_txt.py`** - update the `row` dict
and `fieldnames` list in the summary CSV writer to include the new column.
3. **`src/pipeline/classify_extract.py`** - update the summary `row` dict and `fieldnames` list
in the summary CSV writer to include the new column.

After adding a field, run `pytest tests/test_llm_text.py` to verify that the prompt changes do not break existing extraction tests.

Expand Down
2 changes: 1 addition & 1 deletion documentation/DESIGN_DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ The `src/` directory was reorganized once near the end of the project (PR #64, M
| `src/llm/` | `src/extraction/` |
| `src/preprocessing/` | `src/io/` |
| `classify_extract.py` (root) | `src/pipeline/classify_extract.py` |
| `extract-from-txt.py` (root) | `src/pipeline/extract_from_txt.py` |
| `extract-from-txt.py` (root) | merged into `src/pipeline/classify_extract.py` (`--skip-classifier`) |

`requirements.txt` was also removed at this point in favor of `pyproject.toml` as the single source of dependency truth.

Expand Down
Loading
Loading