Understand how PyRel works
PyRel is RelationalAI’s Python library for building semantic models and applying reasoning workflows on top of them. This page gives you a high-level overview of how PyRel works.
What PyRel does
Section titled “What PyRel does”With PyRel, you can:
- Define a semantic model that maps source data to domain meaning.
- Load data from SQL tables, CSV files, or in-memory DataFrames.
- Write definitions that derive new facts and capture business logic.
- Apply advanced reasoning to answer harder questions and support decisions.
Semantic models are evaluated remotely in the RelationalAI Native App in Snowflake. The Native App uses reasoners to evaluate different kinds of logic.
A reasoner is a specialized backend that evaluates a particular reasoning style:
- Logic reasoner: evaluates rules-based logic.
- Solver reasoner: solves optimization and decision problems.
You don’t need to choose or manage reasoners directly. The RAI Native App automatically routes queries to the right reasoner based on the logic you’re using.
What runs where
Section titled “What runs where”PyRel runs in your local Python process, where you author your semantic model using a declarative DSL. When you execute a query, PyRel submits a RelationalAI job to the RelationalAI Native App in Snowflake.
In your Python process, PyRel:
- Loads configuration and connection settings.
- Builds a local representation of your model and query intent.
- Submits jobs to the RelationalAI Native App when you run queries.
In Snowflake, the RelationalAI Native App:
- Evaluates the query using one or more reasoners.
- Returns query results back to your Python process.
Back in Python, you can:
- Inspect results.
- Export results to downstream tools and systems.
The following diagram summarizes this flow visually:
Where to go next
Section titled “Where to go next”The guides in this section are organized by task.