Query Symbolically or Retrieve Semantically? A Dataset and Method for Semi-Structured Question Answering

Mateusz Czyżnikiewicz, Ryszard Tuora, Adam Kozakiewicz, Tomasz Ziętkiewicz, Mateusz Galiński, Michał Godziszewski, Michał Karpowicz, Timothy Hospedales, Cristina CornelioarXiv 2026

TL;DR

Standard Retrieval-Augmented Generation (RAG) struggles with complex, specification-heavy questions that require exact filtering or exhaustive listing. To solve this, DualGraph combines the flexibility of semantic vector search with the precision of symbolic querying by maintaining parallel Textual and Symbolic Knowledge Graphs. Evaluated on a new real-world e-commerce dataset (SpecsQA), DualGraph significantly outperforms state-of-the-art dense retrieval and GraphRAG baselines.

What Problem Does This Paper Address?

Most modern RAG systems rely on semantic similarity in an embedding space to retrieve relevant document chunks. While this works beautifully for open-ended queries over unstructured text, it falls flat on semi-structured data (like product catalogs, enterprise documentation, or user manuals).

If you ask a standard RAG system, "List all Samsung phones under £300 that support 5G and have an AMOLED display," it will likely struggle. It cannot guarantee an exhaustive list, nor can it reliably perform exact arithmetic filtering or multi-hop aggregation across multiple documents. Conversely, purely symbolic approaches (like converting natural language directly to SQL or SPARQL) can handle exact filtering but are notoriously brittle when faced with noisy natural language or unstructured text.

This paper introduces a framework that bridges this gap, combining the best of both worlds.

Methods

The authors propose DualGraph, a RAG framework that processes a corpus into two complementary graph views:

  1. Textual Knowledge Graph (TKG): An undirected graph optimized for semantic retrieval. It uses an LLM to map text chunks to entity mentions and aggregates their descriptions, preserving linguistic context and ambiguity.
  2. Symbolic Knowledge Graph (SKG): A directed graph that extracts structured facts into ontology-consistent subject-predicate-object triples. It supports exact logical operations (filtering, aggregation, arithmetic constraints) by translating natural language queries into formal SPARQL queries.

The overall indexing pipeline is illustrated below:

Figure 1: Overview of Dualgraph indexing process. Legend: Blue - TKG processing; Orange - SKG processing.

To answer a question, DualGraph evaluates several orchestration strategies to combine these views. The most successful variant, SKG+TKG fallback, attempts a precise symbolic SPARQL query first; if the graph returns no context, it falls back to the robust semantic TKG retriever.

Datasets

To evaluate the framework, the authors introduced SpecsQA, a challenging benchmark built from a snapshot of the Samsung UK online shop (comprising 2,162 webpages across 26 product categories).

The dataset includes 117 manually written, highly specific consumer queries. As shown in the distribution table below, these questions are split into four categories: Inverse (attribute lookup), Multi-condition (compositional constraints), Group Comparison (contrasting product families), and Reasoning (open-ended recommendations).

Table 1: Distribution of SpecsQA questions by category, and percentage of objective and list-based answers.

Key Insights and Ideas

  • The Power of Duality: Text-only RAG methods retrieve locally relevant passages but fail at global, corpus-level enumeration. Purely symbolic methods excel at constraints but fail when queries are underspecified. Combining them provides a safety net.
  • Schema-Based Patterns are Critical: For the symbolic engine to generate accurate SPARQL queries, it needs question-specific context. The authors found that retrieving and linearizing specific graph patterns (especially "Spec patterns" describing product attributes) into the LLM prompt was the single most critical factor for successful symbolic retrieval.

Key Results

DualGraph consistently outperformed all baselines—including standard Vector RAG, Microsoft GraphRAG, RAPTOR, and table-oriented methods (TableRAG)—across multiple metrics like Factual Correctness (FC) and List Matching (LM).

As shown in the performance breakdown, DualGraph's edge is most pronounced in Inverse and Multi-Condition queries, where exact filtering and exhaustive listing are mandatory:

Figure 2: List matching (F1) results by question category for DualGraph and baseline retrieval methods.

Quantitatively, the SKG+TKG fallback strategy achieved a List Matching F1-score of 0.372, vastly outperforming standard Vector RAG (0.118) and Microsoft GraphRAG (0.203), while maintaining a highly efficient query-time token cost compared to heavy symbolic baselines like Wikontic.

Limitations and Future Work

Despite its strong performance, the authors note a few areas for improvement:

  • Lightweight Alignment: Currently, the TKG and SKG are aligned primarily through simple name-matching heuristics (stemming and stop-word removal). Developing a richer, learned cross-graph alignment could enable joint retrieval strategies.
  • Manual Engineering: Key symbolic components, such as the initial lightweight ontology and Datalog reasoning rules, were manually designed by domain experts. Future work will focus on automatically inducing these schemas and rules directly from data.
  • Tabular Constraints: The SKG is currently populated only from explicit specification tables. Extending symbolic extraction to unstructured text sections (like marketing copy or FAQs) would expand DualGraph's coverage.

Summary updated

BibTeX
@misc{czyznikiewicz2026query,
  author = {Mateusz Czyżnikiewicz and Ryszard Tuora and Adam Kozakiewicz and Tomasz Ziętkiewicz and Mateusz Galiński and Michał Godziszewski and Michał Karpowicz and Timothy Hospedales and Cristina Cornelio},
  title = {{Query Symbolically or Retrieve Semantically? A Dataset and Method for Semi-Structured Question Answering}},
  year = {2026},
  eprint = {2605.27164},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.27164},
}
Figure