LLM-powered Screening at Scale¶
The everyrow screen() function filters a dataframe by applying LLMs, and LLM research agents, to every row to determine if the criteria are met. This notebook demonstrates how this scales to screening 10,000 rows. Since tricky rows get LLM agents that themselves make dozens of LLM calls, this results in running vastly more LLM calls than is generally feasible without dedicated orchestration or infrastructure. The total cost is ~$0.001 per row.
Example: Filtering 10,000 FDA Recalls¶
This example takes a dataset of FDA product recalls and filters it to find recalls relevant to a specific personal situation: products that might have been used for a child born on a particular date. The screening task requires understanding product types, typical use cases, and timing to determine which recalls matter.
Load Data¶
from dotenv import load_dotenv
import pandas as pd
from everyrow import create_session
from everyrow.ops import screen
pd.set_option("display.max_colwidth", None)
load_dotenv()
fda_product_recalls_df = pd.read_csv("fda_product_recalls.csv")
# Filter to recalls where center_classification_date is after 2021-08-01 to get a dataset with ≈10k rows
fda_product_recalls_df["center_classification_date"] = pd.to_datetime(fda_product_recalls_df["center_classification_date"], errors="coerce")
fda_product_recalls_df = fda_product_recalls_df[fda_product_recalls_df["center_classification_date"] > pd.Timestamp("2021-08-01")]
print(len(fda_product_recalls_df))
fda_product_recalls_df.sample(3)
Define Screen Task¶
The screening criteria specify finding recalls of products that might have been used for a child born on 2021-08-01.
SCREEN_TASK = """Find recalls of products that I might have used for my child born on 2021-08-01."""
Run Screen¶
async def run_screen():
async with create_session(name="FDA Recall Screening Workflow") as session:
print(f"Session URL: {session.get_url()}")
print("\nScreening FDA recalls...\n")
result = await screen(
task=SCREEN_TASK,
input=fda_product_recalls_df, # type: ignore
)
return result.data
results_df = await run_screen()
Cost¶
This run cost $12.10, averaging around $0.001 per row.
Inspecting results¶
results_df = pd.read_csv("Screen child product recalls.csv") # download from https://everyrow.io/sessions/df145a50-2dfd-48c6-97ed-6f82a82bca66
reduced_results_df = results_df[
[
"product_type",
"status",
"reason_for_recall",
"research",
"center_classification_date",
"product_description",
"research",
"screening_result",
]
]
yes_samples = reduced_results_df[
reduced_results_df["screening_result"] == "yes"
].sample(5)
no_samples = reduced_results_df[reduced_results_df["screening_result"] == "no"].sample(
5
)
yes_samples
no_samples