Hermes

Hermes

Overview

Hermes is named for the Greek messenger and interpreter. A question, a Turtle ontology, and optional context go in. One SPARQL query comes out. Each approach is a system behind one interface, so systems can be swapped and compared.

The public entry is hermes.ask(question, ontology, system=...). A system is any callable registered by name, and Systems shows how to add one. The one that ships today is training-free. It loads a compact vocabulary, asks a model for a draft, walks a fixed list of stages, and checks that the result parses. The stages are the place later techniques plug in. Today each of them returns the draft unchanged.

The pieces

One call

  1. load_vocabulary reads the Turtle file.
  2. build_prompt lists prefixes, classes, properties, context, and examples.
  3. complete asks the model for one query.
  4. prepare_draft extracts the query and lifts solution modifiers.
  5. apply_stages walks guardrails, query guided, context guided, then chase and backchase.
  6. parse_error checks the query. On failure, one repair call runs, then the same stages and the same check.

The return value is a dict with sparql, model, and provider.

Install

git clone https://github.com/lamng3/hermes.git
cd hermes
pip install -e .

The install name is hermes-sparql and the import name is hermes. Python 3.11 or newer. Dependencies are rdflib and httpx. Tests use the dev extra: pip install -e ".[dev]", then pytest.