Skip to content

Rhyme

Rhyme is a declarative query language designed for querying and transforming nested data structures like JSON or tensors (nested arrays). It is designed to be easy to use, and to express complex queries in a simple way, while also achieving high performance by constructing an IR which gets optimized and translated to efficient JS or C code.

Rhyme takes inspiration from existing approaches like GraphQL, Datalog, JQ, XQuery, and similar query languages, as well as from functional logic and array languages.

Rhyme can represent all the usual query operators like aggregations, joins, group-by, etc., but also supports tensor computations in the style of einops. Rhyme also profits from integration with the JS ecosystem, e.g., for producing visualizations as DOM trees, React components, etc.

Quick Examples

Below is an example that computes a group-by aggregation based on keys:

js
let data = [
    {"key": "A", "value": 30},
    {"key": "B", "value": 20},
    {"key": "A", "value": 45},
]
// rhyme query
let query = rh`{ data.*.key: sum(data.*.value) }`
// compile 
let func = api.compile(query)
// run the compiled query
let result = func({data})

Likewise, we can also express other types of workloads like tensor computations:

js
let A = [[1, 2], [3, 4]]
let B = [[5, 6], [7, 8]]

// rhyme query
let matmul = rh`{ *i: { *j: sum(A.*i.*k * B.*k.*j) } }`
// compile
let func = api.compile(matmul)
// run the compiled query
let result = func({A, B})

To learn more about the different ways of using Rhyme, including different APIs, check out the documentation.

Presentations

Papers

Development

Rhyme is developed by members of Prof. Tiark Rompf's'research group at Purdue University and is available for use under a permissive MIT license. Before using Rhyme for anything critical, please consider the usual caveats around research-oriented software developed by a small team.