Work

Contract Driven RAG Backend for Finnish Railway Traffic Using GTFS and GTFS Real-time

Year: 2026
Type: dissertation
Abstract: Public transport information services must provide correct and time sensitive facts about departures, delays, cancellations, and service disruptions. At the same time, large language models enable natural language interaction with complex transport datasets, but their outputs are unreliable for knowledge intensive and time dependent tasks when they are not grounded in authoritative sources. This product-based thesis designs and implements a retriever first, contract driven backend for Finnish railway question answering using GTFS schedule data and GTFS Realtime operational updates. The scope focuses on a production-oriented RAG pipeline for stop, route, and train queries, including optional real-time enrichment, and excludes point to point routing, user authentication, and large-scale benchmarking. The theoretical framework covers large language model limitations, retrieval augmented generation grounding, dense semantic retrieval with sentence transformer embeddings, GTFS and GTFS Realtime data constraints, and responsible deployment concerns in transport information systems. The implementation follows a two-layer architecture. In the offline layer, a Python ingestion pipeline transforms fragmented GTFS schedule tables into canonical Stop, Route, and Trip Pattern documents, generates multilingual embeddings using paraphrase-multilingual-MiniLM-L12 -v2, and stores documents and vectors in MongoDB Atlas. In the online layer, Express/Node service performs intent detection and routes each query to an intent specific retriever. Retrievers execute vector search with metadata filtering, and when real-time is required, the backend fetches GTFS Realtime Protocol Buffers, normalizes TripUpdates into a universal fact schema, interprets the facts into a structured contract, and then invokes Gemini to generate a user-facing response constrained to the prepared context and a strict JSON response contract. The prototype was developed and refined iteratively through incremental implementation and local testing of ingestion, retrieval, real-time processing, and generation guardrails. The evaluation combines automated functional tests for the Python ingestion and backend modules with a manual dataset of 50 queries executed through the API. All automated tests passed, and the manual test set achieved a 92 percent success rate, with failures concentrated on regular expression parsing rigidity, vector score threshold settings, and time-based grounding in live status questions. The results support that a retriever first, contract driven RAG backend can improve traceability and safe failure behavior for railway queries, while the discussion identifies high impact improvements in retriever stage aware score thresholds, document type routing beyond trip patterns, deterministic service window checks for real-time queries, and clearer real-time availability signaling.
Author: Che, Un Kuan
Language: English
Open Access status: green
OpenAlex ID: W7162155857
Cites: 4
Cited by:
Related to: 10