IQL specification
The formal definition of the Isaacus Query Language
This guide formally defines the Isaacus Query Language (IQL), a legal AI query language designed specifically for analyzing legal documents with AI systems.
If you’re interested in learning how to use IQL in practice, check out our introduction to IQL to get started. Otherwise, if you’re looking to understand the complete syntax and semantics of IQL, you’re in the right place.
Statements
The most basic unit of an IQL query () is a statement ().
A statement is formally defined as a sequence of any characters except for curly brackets (\{
and \}
) unless they are prefixed by a backslash (\\{
and \\}
), in which case the backslashes will be removed and treated as raw curly brackets. Backslashes preceding backslashes being used to escape curly brackets can themselves be escaped by adding another backslash (e.g., \\\}
would be interpreted as literally \}
).
Statements must be enclosed in curly brackets (\{
and \}
) unless they are intended to be the entirety of a query and do not contain any curly brackets, in which case the curly brackets are optional (e.g., confidentiality
would be interpreted as {confidentiality}
).
A statement beginning with the word IS
followed by a space is treated as a template invocation, discussed in the next section. This may be avoided by escaping the word IS
with a backslash (\IS
). Backslashes preceding backslashes being used to escape the word IS
can themselves be escaped by adding another backslash (e.g., \\\IS
would be interpreted as literally \IS
).
When run through an AI system (typically alongside a legal document), a statement (excluding template invocations, which will be discussed shortly) will evaluate to , a probability between and , inclusive (). In most cases, the function will be a or function function that converts the raw output (logits) of a model into a probability distribution.
Templates
A template ( ) is a function with a unique case-insensitive name () that takes in any number of arguments () or no arguments at all () and resolves to a query (), which, if arguments are provided, may have those arguments substituted into it.
Templates improve the accessibility and extensibility of queries by allowing for the reuse of common or complex query patterns. They also enable queries to become model-agnostic by abstracting away the need to optimize new idiosyncratic queries for individual models.
A list of currently available built-in templates for Isaacus models may be found here. While it is not currently possible to define one’s own templates, that functionality may be introduced in the future if there is sufficient demand for it (you can express your interest in this feature by contacting us).
A template invocation () is a statement beginning with the word IS
followed by a space followed by the name of a template followed by any number of arguments enclosed in double quotation marks (IS <name> "<argument>"
).
Double quotation marks can be used inside of an argument by simply escaping them with a backslash (\"
). Backslashes preceding backslashes being used to escape double quotation marks can themselves be escaped by adding another backslash (e.g., \\\"
would be interpreted as \"
).
As mentioned earlier, a statement intended to begin literally with the word IS
should escape it with a backslash (\IS
).
A template invocation will evaluate to the of the query that the invocation resolves to ().
Examples
confidentiality
{This is a confidentiality clause.}
{IS confidentiality clause}
{IS clause called "confidentiality"}
Operators
IQL supports the following operators, listed in order of precedence from highest to lowest:
Operator | Syntax | Explanation |
---|---|---|
() | (...) | A group of terms. |
+ | S₁ + S₂ + ... + Sₙ | The average of the scores of the terms. |
> | S₁ > S₂ | The score of the first term if it is greater than the score of the second term; otherwise, . |
< | S₁ < S₂ | The score of the second term if it is less than the score of the first term; otherwise, . |
NOT | NOT S | The complement of the score of the term. |
AND | S₁ AND S₂ AND ... AND Sₙ | The minimum of the scores of the terms. |
OR | S₁ OR S₂ OR ... OR Sₙ | The maximum of the scores of the terms. |
When using a comparison operator (>
or <
) with more than two arguments, the expression will be interpreted as a chain of pairwise comparisons from left to right such that S₁ > S₂ > S₃
will be interpreted as (S₁ > S₂) AND (S₂ > S₃)
.
Examples
{confidentiality} AND {IS confidentiality clause}
{ADR} OR {IS ADR clause} AND NOT {IS clause called "mediation"}