Specification for tensor literals in RDF & SPARQL
See the website for more information.
This is an extension to RDF and SPARQL that introduces 2 new datatypes, dozens of SPARQL functions, and new aggregates to allow for processing of data tensors within RDF graphs. A data tensor is a multi-dimensional array of values, which can be numeric or boolean, commonly used for example in machine learning embeddings.
- New datatypes:
tensor:DataTensor– represents tensors containing numeric or boolean valuestensor:Range– represents the range of numbers, either concrete (e.g., 0 to 1) or fully open (e.g., all numbers)
- New SPARQL functions:
- Tensor manipulations (addition, multiplication, reshaping, etc.)
- Algebraic computations
- New aggregates:
- Generalized aggregation functions for numerical tensors
- Sum, average, variance, and standard deviation computations
See the website for more details.
The vocabulary (datatypes, functions, aggregates) is authored in LinkML YAML files in the ontology/ directory. The published RDF artifacts (RDFS in Turtle, N-Triples, JSON-LD, RDF/XML, and Jelly) are generated from these sources.
To regenerate the published files locally you need two tools in your PATH:
linkml-scala– generates RDFS from the LinkML sources.jelly-cli– converts between RDF serializations.
Then run, from the root of the repository:
bin/build_ontology.shThe generated files are written to the publish/ directory. CI runs the same script.
- Clone the repository:
git clone git@github.com:NeverBlink-OSS/rdf-tensor.git - Create a new Python virtual environment using your favorite tool (e.g.,
venv). - Install the dependencies:
pip install -r requirements.txt - Generate the ontology files so the docs can embed them:
bin/build_ontology.sh(see above). - Compile the docs and host them locally for testing:
mkdocs serve - Whenever you make changes to the documentation pages (they reside in the
docsdirectory), the docs will be automatically recompiled.
This repository is maintained and developed by NeverBlink.
The original SPARQL extension and implementation for Jena were done by Piotr Marciniak – see the original repository.
This repository is licensed under Apache License 2.0.
If you use this work in an academic context, please cite it as follows:
Marciniak, P., Sowiński, P., & Ganzha, M. (2025). Representing and Querying Data Tensors in RDF and SPARQL [Conference paper]. Curry, E., et al. The Semantic Web: ESWC 2025 Satellite Events. ESWC 2025. Lecture Notes in Computer Science, 15832. https://doi.org/10.1007/978-3-031-99554-5_12
@inproceedings{rdftensor_2025,
author = {Marciniak, Piotr and Sowiński, Piotr and Ganzha, Maria},
booktitle = {Curry, E., et al. The Semantic Web: ESWC 2025 Satellite Events. ESWC 2025. Lecture Notes in Computer Science},
publisher = {Springer, Cham},
title = {{Representing and Querying Data Tensors in RDF and SPARQL}},
url = {https://doi.org/10.1007/978-3-031-99554-5_12},
year = {2025}
}