Skip to content
Question Answering Architecture

How Countrydle Answers Questions

Rather than trusting raw LLM hallucinations, Countrydle uses a hybrid engine: sub-millisecond deterministic template compilers, Gemini 2.5 Flash Lite as a formal AST parser, curated local SQLite relational fact tables, and verifiable semantic vector RAG.

Templates
< 1 ms

Zero LLM overhead

AST Planner
~1.1 s

Structured query plan

Hallucination
0.0%

SQLite verifies truth

Local Entities
642

Countries, states, counties

Question Flow Graph & Anti-Hallucination Shield

Click any step in the pipeline flow to inspect the exact code, queries, and anti-hallucination defense applied.

8 Defensive Layers
PIPELINE STAGE 02•< 1 ms (No LLM Call)

Sub-millisecond Template Compiler

What Happens at This Stage?

Fast-path in-memory compiler executing compiled regex trees across 672 country forms, 50 states, Polish counties, borders, seas, license plates, and population ranges. Intercepts ~50% of all player questions.

Anti-Hallucination Defense

Zero hallucination probability. The question completely bypasses generative language models and translates deterministically into an AST node directly in RAM.

Core Engine Logic
def compile_template(q: str):
    if re.search(r"\b(landlocked|srodladow\w*)\b", q):
        return [_node("exists", "water_access"), {"operator": "not", "args": [0]}]

Interactive Pipeline Inspector

Select a real query from the uniform grid to inspect its wire AST plan, SQLite queries, and ground truth proof.

Verified Case Bank
< 1 ms Fast-PathCountrydle (World)•0.4 ms

"Is it landlocked?"

Truth VerdictFALSE
Formal Abstract Syntax Tree (AST)Operator: not(exists(water_access))
[
  {
    "entity": "target_country",
    "relation": "water_access",
    "operator": "exists"
  },
  {
    "operator": "not",
    "args": [
      0
    ]
  }
]

Common natural language templates (landlocked, island, borders, driving side) compile into abstract syntax trees in sub-millisecond memory without invoking any LLM, costing zero tokens.

Formal AST Operator Specification

The intermediate representation executed against our offline facts databases.

equalscomparison
equals(left: Reference, right: Literal)

Tests strict equality between a scalar property and an expected value.

Example

"Is it an island?" → equals(is_island, True)

greater_than / less_thancomparison
greater_than(left: Reference, right: Literal)

Evaluates numeric thresholds for population, square area, admission order, or year.

Example

"Does it have more than 50 million people?"

contains / contains_exactcollection
contains_exact(left: Reference, right: Literal)

Checks membership in one-to-many sets: water bodies, border neighbors, or international organizations.

Example

"Does it border France?"

existscollection
exists(left: Reference)

Unary operator checking if a relation contains at least one record (e.g. has coastline or mountain ranges).

Example

"Does this state have mountain ranges?"

north_of / east_ofspatial
east_of(left: Reference, right: Reference)

Geographic coordinate comparison across longitudes or latitudes against reference entities.

Example

"Is it east of Germany?"

starts_with / ends_withstring
starts_with(left: Reference, right: Literal)

Case-insensitive prefix or suffix matching on entity names or license plate codes.

Example

"Does the country name start with B?"

char_count_equalsstring
char_count_equals(left: Reference, right: Literal)

Compares the exact letter count of the name, ignoring spaces and hyphens.

Example

"Does the name have 6 letters?"

and / or / notlogic
and(args: [nodeIndex1, nodeIndex2])

Topological node combinators chaining sub-conditions with strict boolean algebra.

Example

"Is it in Europe and landlocked?"

Offline Relational Facts Catalog

Every game mode operates on dedicated, curated relational SQLite tables with indexed foreign keys.

196 countries

country_facts.sqlite

16 relational tables: continents, borders, water bodies, capitals, currencies, languages, historical unions (USSR, Yugoslavia), driving sides.

Source: CIA Factbook & RestCountries
50 states

us_state_facts.sqlite

8 tables: state/international borders, ocean access (Pacific, Atlantic, Great Lakes), mountain ranges, interstates, 13 colonies, Civil War side.

Source: US Census Bureau & USGS
16 voivodeships

voivodeship_facts.sqlite

7 tables: neighboring country borders, Baltic coastline, dual capital seats, river courses (Wisła, Odra), macro-regional geographic tags.

Source: Główny Urząd Statystyczny (GUS)
380 counties

powiat_facts.sqlite

6 tables: city vs land county flags, registration plate codes, neighboring voivodeship borders, international frontiers, seat cities.

Source: Rejestr TERYT & MSWiA

Why Zero Hallucinations? The Architecture

The architectural contrast between conversational chatbots and Countrydle’s query engine.

Standard Generative Chatbot

The Model Generates the Truth

  • High hallucination rate: answers are guessed probabilistically via stochastic token sampling.
  • Non-deterministic: identical questions can yield contradictory answers across sessions.
  • Zero auditability: players have no guarantee whether the AI remembered facts correctly.
Unreliable for trivia deduction games
Countrydle Hybrid Pipeline

The Model is Only a Parser; Database Computes Truth

  • 0.0% local hallucination: ground truth is evaluated mathematically by relational SQLite queries.
  • Sub-millisecond latency: regex compilers resolve common templates instantly in RAM.
  • Complete audit trail: every answer provides an exact human proof and audit relation tag.
Deterministic • Verifiable • Zero Hallucination

Ready to Test the Engine in Practice?

Return to the game, ask any geographic question, and observe the instant factual feedback.

Advertisement
v1.23.1