In the first article in this series, we explored the design and user experience of “Chiedilo a me”. Now it is time to open the bonnet and show the how: the choices, the challenges and the architecture that make a virtual assistant for the Public Administration work.
Taking a RAG (Retrieval-Augmented Generation) project from an experimental prototype to a public service integrated into the me.toscana.it portal is no simple technical exercise. It represents a “public design” challenge that requires a conscious adoption of artificial intelligence, as promoted by Designers Italia.
Three non-negotiable challenges frame the entire work:
- Security and Privacy: how to manage a service for authenticated citizens (via SPID, CIE, CNS) and ensure GDPR compliance.
- Reliability: responses must come exclusively from official sources. Errors or hallucinated information — tolerable in commercial contexts — would be unacceptable for a public service and would undermine citizens’ trust.
- Pragmatism and Sustainability: the solution must be effective, easy to maintain over time and sustainable, particularly in terms of infrastructure costs and LLM token usage.
Regione Toscana’s requirements could be met through an honest, pragmatic RAG architecture. We did not implement the most complex architecture possible, but the most appropriate and robust one for the specific PA context.
As the core technology stack, three strategic choices were made:
- The adoption of the open-source Cheshire Cat framework, selected for its flexibility and, as we shall see, its capacity for extension via plugins.
- The use of Qdrant as the vector database, which acts as Cheshire Cat’s default vector memory and offers an excellent balance between search speed and efficient memory usage.
- Azure OpenAI models — specifically gpt-4.1-mini for generation and text-embedding-3-large for embeddings. This choice was driven not only by performance, but by stringent contractual guarantees.
By opting for Azure OpenAI’s EU Data Zone deployment type, all data hosting and processing is guaranteed to take place exclusively within European borders (in line with the EU Data Boundary). This is further reinforced by the Zero Training Policy, which contractually ensures that citizens’ data is never used to train the underlying models.
The architecture: a balance between flexibility and security
The system architecture is built on two pillars: a delegated authentication model for user security, and a hybrid hosting model for data sovereignty.
Integration, not identity management
A key point to clarify immediately concerns identity management. “Chiedilo a me” is an embedded React component, integrated within the me.toscana.it portal. It does not manage authentication directly — this is delegated to Regione Toscana’s ARPA system.
The architecture implements a Delegated Authentication pattern. In this model, the me.toscana.it portal (via ARPA) acts as the asserting party: it takes full responsibility for managing the complexity of federated authentication (via SPID, CIE or CNS) and verifying the citizen’s identity.
Once the user is authenticated, the portal passes an authentication token to the React component (the relying party). The chatbot then operates in an already-authenticated context, receiving a verified identity without ever having to manage credentials directly. This architecture creates a clear and robust boundary of responsibility, isolating the conversational component from the complexity of digital identity management, in line with best practices for the integration of secure components.
A hybrid architecture for data sovereignty
A strategic decision was made to physically separate the hosting of components according to their risk profile and need for control.
The “Brain” (LLM): Hosted on Azure EU
The artificial intelligence models (gpt-4.1-mini, text-embedding-3-large) are hosted on Azure infrastructure in a European region (e.g. Germany, Sweden). This choice is sound for GDPR compliance and offers two immovable contractual guarantees:
- EU Data Boundary: Microsoft contractually commits to storing and processing all customer data (including prompts and completions) exclusively within the geographical boundaries of the European Union.
- Zero Training Policy: Azure OpenAI’s official documentation is explicit: customer data (prompts, outputs, embeddings) is NOT available to OpenAI or other third-party providers, is NOT used to train or improve base models, and these models are stateless (they do not retain interactions).
This approach makes it possible to use state-of-the-art models “boxed” within a secure environment that handles citizens’ transient data (their questions) with the highest level of compliance.
The “Core” (Application): Hosted on Controlled Infrastructure
The open-source Cheshire Cat application framework and the Qdrant vector database run on a controlled infrastructure (Hetzner), a European cloud provider based in Germany.
This represents a pragmatic deployment phase that allowed us to accelerate development and time-to-market in a GDPR-compliant environment. It is an intermediate step towards full data sovereignty: as indicated in our roadmap, work is already under way to migrate these components directly onto the regional Sistema Cloud Toscana (SCT) infrastructure, which will consolidate local governance and control.
3. Anatomy of a response: a simple RAG is a robust RAG
The chatbot’s reliability is built on a deliberately simple but robust RAG pipeline that prioritises control over complexity.
Phase 1: Ingestion (the sources)
The first and most important guardrail is grounding. The bot’s knowledge is limited exclusively to a curated corpus from official sources:
- Calls for applications and guides from giovanisi.it and regione.toscana.it.
- Job listings from ARTI.
- The list of digital services from open.toscana.it.
- Content from Regione Toscana’s competenze digitali website.
Automated scripts extract and update this content. Documents are then chunked, transformed into numerical vectors via text-embedding-3-large, and stored in the Qdrant vector database. This process creates the bot’s incontestable “truth” — the fundamental foundation of the RAG.
Cheshire Cat’s tripartite memory

The ingestion process is not monolithic. We exploit Cheshire Cat’s specific memory architecture, which divides knowledge across three distinct collections in Qdrant:
- Declarative Memory: the bot’s “library”. Official documents (calls for applications, guides, etc.) are stored here after chunking and vectorisation. It is the primary source for the RAG.
- Episodic Memory: the conversation memory. It contains an extract of what the user has said in the past, enabling the bot to understand follow-up questions and maintain context, giving the interaction a sense of “memory”.
- Procedural Memory: contains knowledge of “how to do things” — the Tools (Python functions) the bot can choose to execute.
This memory is not merely a theoretical capability — it is already in use for some simple Tools, integrated via plugins. A practical example is the search for Punti Digitali Facili (PDF). If a user asks: “What is the nearest Punto Digitale Facile to Pisa?”, Cheshire Cat recognises the intent and activates the dedicated tool. This plugin makes a specific API call to the regional service to retrieve the information. The API response (for example, the address of the nearest PDF) is then passed contextually to the LLM alongside any sources retrieved from the Declarative Memory, enabling the model to generate a precise, up-to-date response.
Phase 2: The response flow

When a user sends a message, the response flow (the retrieve-then-read pipeline) is linear and controlled:
- Query: the user sends a message via the React component through a websocket connection.
- Embedding: the question is vectorised using the same model used for the documents.
- Retrieval: a semantic search is run on Qdrant to find the most relevant text chunks (from the Declarative Memory) and past conversation fragments (from the Episodic Memory).
- Prompting: a prompt is constructed for gpt-4.1-mini that includes the user’s original question and the retrieved text chunks.
The system prompt as the primary guardrail
Here lies the true challenge of a public service. On one hand, the bot must harness the full power of a frontier LLM (such as gpt-4.1-mini) to be conversational, understand context and demonstrate high linguistic competence. On the other, it must be reliable and sustainable.
The System Prompt is our primary guardrail for balancing these requirements. It is meticulously designed not to limit the LLM’s linguistic capability, but to direct it. The key instructions tell the LLM to:
- Introduce itself correctly as “chiedilo a me”.
- Base its responses primarily on the supplied documents (the chunks retrieved from the Declarative Memory), especially for factual questions.
- Always cite the sources used in the response, ensuring transparency and verifiability for the user.
- Use its general knowledge and conversational capability (drawing also on the Episodic Memory) to manage dialogue, but politely decline to answer out-of-scope questions (e.g. “I don’t have information on this topic”).
This strategy allows us to contain costs (preventing the bot from producing lengthy responses on irrelevant matters) and guarantee reliability, without sacrificing the fluency of the user experience. The bot is grounded, but not limited.
4. The challenges: why “not doing” is a design choice
Many academic or commercial RAG approaches include complex pipelines to marginally improve accuracy. Advanced techniques were analysed, but we consciously chose not to implement them. This counter-current decision is a pillar of the system’s pragmatic design.
Complex RAG pipelines often include additional steps such as:
- Pre-retrieval (Query Expansion): using the LLM (or other methods) to expand or rephrase the user’s query before vector search.
- Post-retrieval (Re-ranking): using a second model (often an SBERT cross-encoder) to reorder the results retrieved from Qdrant, attempting to surface the most relevant result first.
The pragmatic choice: optimising cost and latency
We analysed advanced techniques such as re-ranking — which research demonstrates to be effective in improving retrieval precision in complex scenarios. However, these techniques introduce an inevitable trade-off between accuracy, latency and cost. For a public service serving a broad user base, the increased token consumption and per-query latency required by a re-ranker were deemed an unsustainable cost at this stage.
The high-ROI solution: investing in the datastore
Our strategy was to invest engineering time in ingestion pipelines that prioritise upstream data quality. This decision aligns with an emerging strand of RAG research (e.g. Lyu et al., 2025, “Frustratingly Simple Retrieval“) that has demonstrated how a minimal RAG pipeline, when fed by a very high-quality datastore, can match or outperform complex agentic systems operating on noisy data. Our investment therefore concentrates on the most effective and economical guardrail: ensuring that only clean, incontestable truth enters the vector store.
5. Security and observability: the pillars of trust
A public digital service cannot exist without active security and the ability to learn from its users.
Active defence
Here the strategic value of the open-source choice (Cheshire Cat) becomes clear. A black-box SaaS solution would not have afforded the necessary level of control. The Cheshire Cat framework is designed to be extensible via plugins. Among others, a custom plugin was developed that uses the framework’s hooks to intercept and analyse every user message before it reaches the vector database or LLM. This plugin acts as an application-layer firewall implementing two levels of defence:
- Rate Limiting: a critical best practice for any LLM application. The plugin limits the number of messages a single user can send within a given time interval (e.g. per hour). This protects the service from abuse (such as DDoS attacks) and prevents uncontrolled token consumption, containing costs.
- Jailbreak Detection: this plugin directly addresses a specific vulnerability: Prompt Injection. Jailbreaking attacks attempt to induce the LLM to ignore its safety instructions. The custom plugin intercepts and blocks known attack patterns, preventing them from reaching the model.
Evaluation (The “Golden Dataset”)

To ensure that our pragmatic design choices (such as a simple RAG) were sound from an engineering standpoint, we defined an architecture based on a rigorous evaluation process. The true strategic asset of this phase was the development of a golden evaluation dataset — created not by engineers, but by a domain expert (the editorial curator of competenzedigitali.toscana.it), ensuring that the questions reflect real user needs and that the expected answers are factually correct.
This dataset is the foundation for our automated evaluation scripts. Using frameworks such as ragas, we measure objective metrics at every system change (e.g. change of embedding model, modification of chunking strategy):
- Context Precision and Context Recall: to ensure we retrieve only the right chunks and all the right chunks.
- Faithfulness and Response Relevancy: to measure how faithfully the generated response adheres to its sources and how relevant it is to the question.
This approach enables data-driven decision-making and demonstrates the actual ROI of every intervention, transforming “pragmatism” from a philosophy into a measurable methodology.
We are nevertheless aware of the limitations and potential biases intrinsic to LLM-based evaluation metrics. For this reason, automated quantitative evaluation is always accompanied and validated by rigorous manual review of the golden dataset and qualitative analysis of user feedback, ensuring a holistic and reliable view of system performance.
Observability (Learning from Users)

A chatbot is not a finished product, but a continuously evolving service. Observability is therefore fundamental.
- Feedback: an explicit feedback system (e.g. thumbs up/down) has been integrated for every individual response.
It is important to clarify that this feedback is not automatically fed back to correct the system. This is a conscious design choice: we have observed that negative user feedback is often subjective (linked to a personal interpretation or an unmet expectation) rather than to a factual error.
Each negative signal therefore represents a trigger for manual review. This data is collected and analysed by the team to understand the nature of the problem (an incorrect response, an irrelevant source, a misunderstanding). It is this process of human analysis that enables targeted, safe system correction and improves accuracy over time.
- Tracking: the cornerstone of observability is the anonymous, aggregate recording of all interactions. This process — defined as “chatbot observability” — tracks crucial metrics: questions asked, responses given, sources used, error rates and user feedback.
This tracking is not merely a debugging tool; it is the primary source of user research for a public digital service. It enables answers to critical questions: “What are citizens asking that the bot cannot answer?”, “Which documents produce incorrect responses?”, “Are there emerging new needs that current sources do not cover?”
Observability is the engine of continuous improvement, enabling the service to adapt progressively to the real needs of citizens.
This intensive observability strategy also justifies the current choice of a frontier model such as gpt-4.1-mini. Being in an early phase, and not yet knowing the full spectrum of user needs, a powerful and versatile model is necessary to ensure flexibility.
6. Conclusion: from pragmatic engineering to data-driven evolution
The technical architecture of “Chiedilo a me” is not a stylistic exercise, but the pragmatic engineering act that delivers on the design promises made in Part 1. The flexibility of the open-source Cheshire Cat framework, the contractual security guarantees of Azure EU, and an honest, simplified approach to RAG challenges have made it possible to translate a design vision into a real, secure and evolution-ready service.
This evolution is already under way with the v2 roadmap, which will introduce transformative capabilities: simplified data ingestion, enhanced agentic Tools, multi-chat management and multilingual support.
But this is only the first phase. The true engine of future evolution is the observability infrastructure already in operation. Usage data and feedback being collected represent a strategic asset that will enable the shift from hypothetical to empirical analysis. It will be the evidence emerging from real-world observation that guides data-driven optimisation and motivates the targeted introduction of advanced techniques (such as pre-retrieval, classifiers or re-ranking) — initially excluded for ROI reasons.
This flow of real interactions is, finally, the foundation for the ultimate objective already identified: acquiring the dataset needed for fine-tuning an open-source model, closing the loop on sustainability and data sovereignty. The path marks the planned maturation of the service: from a robust Q&A chatbot to a genuinely agentic conversational assistant, capable of learning and improving not only through our engineering, but through the real needs of citizens.
By Luca Baroncini, AI Specialist