Skip to content

Understand how PyRel works

PyRel is RelationalAI’s Python library for building semantic models and applying reasoning workflows on top of them. This overview gives you a high-level picture of how PyRel works, and links to guides that show you how to use it.

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.

PyRel executes in two places:

  • In your local Python process, PyRel loads configuration, builds the local model and query intent, and submits jobs when you run queries.
  • In Snowflake, the RelationalAI Native App evaluates those jobs with one or more reasoners and returns results for you to inspect in Python or pass to downstream tools.

Here’s a picture of how these pieces fit together:

Local Python processRAI Native App in Snowflakeraiconfig.yamlPyRel semanticmodelRAI jobLogicreasonerSolverreasoner query results

You can think of PyRel as the client that prepares and sends work to the RAI Native App, and the Native App as the remote engine that evaluates that work with reasoners and sends results back. The following flow chart describes that execution workflow in more detail:

1. Load and validateconfiguration2. Build modeland query3. SubmitRelationalAI job4. Run job withreasoners5. Materializeresults

Here’s a quick summary of what happens at each stage:

  • Load and validate configuration: PyRel reads the settings it needs and checks that they’re usable before submitting work.
  • Build model and query: PyRel prepares your model definitions and query intent for submission.
  • Submit RelationalAI job: PyRel sends that job to the RAI Native App in Snowflake.
  • Run job with reasoners: The Native App evaluates the job with one or more reasoners, depending on the logic involved.
  • Materialize results: The results come back in a form you can inspect in Python or pass to downstream tools.