Build2SPARQL: A Large-Scale Text-to-SPARQL Benchmark Dataset for Building Knowledge Graph Querying
Organizations: Assistant Professor, Dept. of Civil and Architectural Engineering and Mechanics, Univ. of Arizona, Tucson, AZ 85719.
Abstract
Building automation systems are increasingly represented as semantic knowledge graphs (KGs) using ontologies such as Brick and ASHRAE 223P, creating a machine-readable substrate for artificial-intelligence applications. One promising application is translating natural-language questions into SPARQL (text-to-SPARQL), which would let building operators query these graphs through language agents, but progress is limited by the scarcity of large natural-language/SPARQL benchmarks. This paper presents Build2SPARQL, a large-scale benchmark for building KGs generated by a KG-grounded pipeline: SPARQL queries are produced and validated entirely by graph-traversal code, while large language models generate only the natural-language questions, keeping query correctness independent of model behavior. The pipeline mines six query-pattern families -- linear chains, branching, UNION, aggregation, OPTIONAL, and attribute-filtered -- and phrases each query across five vocabulary registers. Applied to 201 building KGs (180 Brick, 21 ASHRAE 223P), it yields 6,136 executable SPARQL queries and 30,680 questions. A two-rater human validation of 300 questions found 98.8% semantic fidelity, 98.8% naturalness, and 84.0% operational plausibility. A retrieval-augmented evaluation across three open-weight language models raised exact-match accuracy from 0.2-20% (zero-shot) to 56-65% (three-shot retrieved).
Figures & tables
| Small scale | Large scale | |
|---|---|---|
| Broad patterns | BuildingQA [ Mulayim et al. 2025a ] | – |
| Narrow patterns | DA-KGQA [ Mulayim et al. 2025b ] | BuildingGPT [ Li and Wang 2026 ] , BuildingGPT2 [ Li et al. 2026 ] , OntoSage [ Devmane et al. 2026 ] |
| Q | Register label | Key instruction |
|---|---|---|
| 1 | Technical | Name the equipment types and relationships in the query directly. Use ontology class names and property identifiers where natural. |
| 2 | Systems-engineering | Use building domain terminology. Paraphrase ontology class names into engineering language but keep them recognizable as specific equipment types. |
| 3 | Operational | Describe what information is needed without naming specific ontology classes or data model terms. |
| 4 | Instance-grounded | When named entity examples are listed, use one verbatim in the question (e.g. “Is AHU-3 reporting…” rather than “Is the AHU reporting…”, where AHU denotes an Air Handling Unit). Describe a practical task or check, not a data query. |
| 5 | Plain English | Write a plain English question using no ontology terms, no SPARQL vocabulary, no class names, and no equipment identifiers. Paraphrase the information need in everyday language accessible to any building occupant. |
| Pipeline stage | Model | Temperature | Max output tokens |
|---|---|---|---|
| Semantic filtering | Gemma 4 4B ( gemma4:e4b ) | 0.3 | 512 |
| Query refinement | Gemma 4 4B ( gemma4:e4b ) | 0.3 | 800 |
| NL question generation | Gemma 4 31B ( gemma4:31b ) | 0.7 | 150 |
| Metric | Count |
|---|---|
| Buildings | 201 |
| Real | 81 |
| Mortar testbed (Brick) | 47 |
| Brick reference models | 13 |
| ASHRAE 223P example models | 21 |
| Synthetic (BuildGraph, Brick) | 120 |
| Pattern type | Queries | Share (%) |
|---|---|---|
| Linear chain | 5,009 | 81.6 |
| Branching (Y-shape) | 815 | 13.3 |
| Aggregation (COUNT) | 120 | 2.0 |
| Attribute-filtered | 100 | 1.6 |
| UNION disjunction | 51 | 0.8 |
| Optional (OPTIONAL) | 41 | 0.7 |
| Q | Register | Question |
|---|---|---|
| 1 | Technical | Which brick:Start_Stop_Command instances are linked via brick:isPointOf to brick:Supply_Fan entities? |
| 2 | Systems-engineering | Which supply fans are associated with which start/stop command points? |
| 3 | Operational | Which supply fans have corresponding start and stop controls? |
| 4 | Instance-grounded | Which start/stop command is mapped to SupplyFan_AHU01 ? |
| 5 | Plain English | Which control command is used to turn the supply fan on and off? |
| Pattern type | Lex. sim. | Dist. open. | Q4 inst. (%) | |
|---|---|---|---|---|
| Linear chain | 5,009 | 0.170 | 0.714 | 81 |
| Branching (Y-shape) | 815 | 0.156 | 0.910 | 82 |
| Aggregation (COUNT) | 120 | 0.176 | 0.753 | 52 |
| UNION disjunction | 51 | 0.243 | 0.600 | 22 |
| Optional (OPTIONAL) | 41 | 0.176 | 0.883 | 17 |
| Attribute-filtered | 100 | 0.198 | 0.677 | 56 |
| Model | Condition | Arity F1 (%) | Exec (%) | Exact Match F1 (%) | Row F1 | Ent. Set F1 |
|---|---|---|---|---|---|---|
| Gemma 4 4B | Zero-shot | 68.1 | 91.0 | 3.8 | 0.039 | 0.390 |
| Gemma 4 4B | 3-shot (random) | 74.1 | 93.2 | 25.2 | 0.257 | 0.754 |
| Gemma 4 4B | 3-shot (retrieved) | 87.4 | 89.4 | 60.9 | 0.615 | 0.958 |
| Llama 3.1 8B | Zero-shot | 66.7 | 90.6 | 0.2 | 0.016 | 0.214 |
| Llama 3.1 8B | 3-shot (random) | 71.5 | 88.1 | 22.0 | 0.229 | 0.797 |
| Llama 3.1 8B | 3-shot (retrieved) | 91.7 | 88.1 | 56.0 | 0.575 | 0.907 |
| Model | Condition | Q1 | Q2 | Q3 | Q4 | Q5 |
|---|---|---|---|---|---|---|
| Gemma 4 4B | Zero-shot | 15.8 | 3.1 | 0.8 | 0.0 | 0.0 |
| Gemma 4 4B | 3-shot (random) | 32.7 | 26.4 | 26.7 | 9.0 | 27.6 |
| Gemma 4 4B | 3-shot (retrieved) | 81.2 | 74.4 | 66.7 | 17.0 | 60.0 |
| Llama 3.1 8B | Zero-shot | 0.0 | 0.0 | 0.0 | 1.0 | 0.0 |
| Llama 3.1 8B | 3-shot (random) | 27.7 | 22.5 | 21.7 | 14.0 | 27.6 |
| Llama 3.1 8B | 3-shot (retrieved) | 78.2 | 63.6 | 57.5 | 21.0 | 57.1 |
| Model | Lin. | Brnch. | Union | Aggr. | Opt. | Filt. |
|---|---|---|---|---|---|---|
| Gemma 4 4B | 63.5 | 40.0 | 9.1 | 33.3 | 50.0 | 20.0 |
| Llama 3.1 8B | 58.5 | 40.0 | 18.2 | 26.7 | 33.3 | 20.0 |
| Qwen 2.5 32B | 67.6 | 40.0 | 18.2 | 26.7 | 66.7 | 60.0 |
| Exact Match F1 | Row F1 | |||
|---|---|---|---|---|
| Model | Realistic | Oracle | Realistic | Oracle |
| Gemma 4 4B ( ) | 0.592 | 0.558 | 0.598 | 0.566 |
| Llama 3.1 8B ( ) | 0.667 | 0.511 | 0.682 | 0.519 |
| Metric | Build2SPARQL | BuildingQA |
|---|---|---|
| Scale and coverage | ||
| Buildings | 201 | 4 |
| Queries | 6,136 | 27 |
| NL questions | 30,680 | 188 |
| Pattern types | 6 | 3 |
| Mean BGP triples | 3.9 | 5.7 |
| Resource | Construction | Bldg. | Ontology | Queries | NL q. | Br | Un | Op | Ag | Fi |
|---|---|---|---|---|---|---|---|---|---|---|
| BuildingQA a | expert | 4 | Brick, 223P | 27 | 188 | Y | Y | n.r. | N | n.r. |
| DA-KGQA | method eval | 1 | Brick | 19 | 19 | N | N | N | N | N |
| OntoSage b | synthesis+FT | 3 | Brick | 120,000 pairs | n.r. | n.r. | n.r. | P | n.r. | |
| BuildingGPT | 6 templates | 45 | Brick | 18,555 | 18,555 | N | N | N | P | N |
| BuildingGPT2 c | templates+FT | 45 | Brick | 18,555 | 18,555 | N | N | N | P | N |
| Build2SPARQL | KG-mined | 201 | Brick, 223P | 6,136 | 30,680 | Y | Y | Y | Y | Y |
| Pool | Test building identifiers | |
| BuildGraph hospital | BG_hospital_{2004, 2013, pre1980} _0000--0004 | 15 |
| Mortar | bldg6, bldg10, bldg15, bldg16, bldg17, bldg22, bldg23, bldg25 | 8 |
| Brick / 223P reference | apartment, IBAL, NIST-HPL, pnnl-bdg2-1, soda_brick | 5 |
| Total test | 28 | |
| Retrieval pool (all other) | 173 | |
| Criterion | Question the rater answers | Scale |
|---|---|---|
| C1 Semantic fidelity | Does the question ask for what the paired SPARQL query actually returns—same entities, relationship, and conditions? | Y/B/N |
| C2 Naturalness | Does it read as fluent, grammatical English a practitioner might say? (For the Technical register, verbatim ontology tokens are expected and not penalized.) | Y/B/N |
| C3 Operational plausibility | Could a building operator, energy manager, or commissioning engineer realistically ask this in practice? | Y/N |
| Group | C1 Sem. fidelity | C2 Naturalness | C3 Oper. plaus. |
|---|---|---|---|
| By register | |||
| Q1 Technical | 100.0 | 99.2 | 80.0 |
| Q2 Systems-engineering | 100.0 | 100.0 | 80.0 |
| Q3 Operational | 99.2 | 98.3 | 80.0 |
| Q4 Instance-grounded | 97.5 | 99.2 | 98.3 |
| Q5 Plain English | 97.5 | 97.5 | 81.7 |
Benchmark Construction
Benchmark construction develops tasks, datasets, environments, and protocols that make AI capabilities measurable and comparisons reliable.
See all 68 papers