The landscape
Statistics Denmark is the national provider of statistics in Denmark. As part of their platform, they provide a statistics bank which holds thousands of tables of statistics about Denmark and the people in it. A steady stream of people, from journalists and students to curious citizens, use the statistics bank’s search page every day to find a statistic.
But increasingly, search users are relying less on keywords and concrete terminology, opting instead to formulate sentences or ask questions of the data directly. This makes searching the data a different problem; rather than pure text matching, the user’s intent needs to be matched to table data based on meaning and intent.
Statistics Denmark wanted to know whether AI could help these searches reach the right statistics, and had already been experimenting with various AI-driven solutions of their own, but had run into a number of challenges.
Semantic search has its own shortcomings, and the table data itself is not very well suited for it either, as many tables look almost identical, covering the same topic for different periods or sharing similar descriptions.
When it comes to keyword search, there are also several challenges:
- People search for specific things, like a town or a country, which are buried inside a table’s data rather than its description
- Search users use colloquialisms which differ from internal terminology in the data
This all gets even more challenging once you start introducing other difficulties in search, such as typos or misunderstandings of what is even possible to search for.
An example question which hits most of these challenges could be something like “how many ppl got hitched in denmrak last yr” - which may be somewhat possible for a human to translate into a particular statistic which might provide the answer, but is very difficult for a system.
Furthermore, the search had to be fast, and had to be owned, moved and replicated by Statistics Denmark themselves, which is especially important as Statistics Denmark is part of an international tech stack for statistics banks across the world, which could potentially also benefit from such a search solution.
What we did
PineGrove started by getting to know the source data and existing search, then explored and tested different ways of using AI to improve it:
Along the way, we restructured the table data so that similar tables were easier to tell apart, and so specific words like place names could still be found. We then built a working prototype and tested it against a set of real questions with known correct answers. Finally, we looked at what it would take to run the solution in production, from hardware and hosting to keeping the search up to date as new statistics are published.
Everything ran on our own hardware, using open-weight AI models rather than an external AI service.
An example search
An illustration of the kind of question the search has to handle, and how the AI step turns it into something the search can find.
The results
- Test questions, filled with typos and vague phrasing, now found a correct table among the top results in the vast majority of cases
- The model could generate accurately answers for a list of real user queries, to be used in further validation and training
- Results came back in seconds, supporting a satisfying search experience
All of this was achieved with an open-weight Qwen3.8 model running on a single consumer graphics card (RTX 5090), at a load that could easily handle the search page’s traffic as it is today, even with local peaks.
It was also clear that better data beats bigger models; clear semantic table descriptions matter more for good results than raw AI power. Throwing the biggest frontier model like Claude or ChatGPT at the problem would not have helped much - and perhaps an even smaller model than the one we used could have produced similar results.
What’s next
Together with Statistics Denmark, we are now working towards taking the search from prototype to a live part of their site, so anyone can find the statistics they need by asking in their own words.
The aim is a solution that runs on Statistics Denmark’s own infrastructure, letting them own everything from source to AI infrastructure. Further ahead, we see the potential to share it as an open-source module to be used by other statistics sites built on the same platform.
Key Takeaways
The above results were identified in working with Statistics Denmark towards better search results, but the solution identified works for pretty much any problem with a similar shape; finding a specific piece of information in a large dataset, which wasn’t necessarily made for it.
A fast but effective solution to such problems can be built with:
- Simple semantic improvement of the source data
- A small AI agent converts user queries to an enriched search intent
- A fast embedded index-search capable of handling both semantic and keyword searches
And none of this rests on model intelligence or external capabilities, making it a very attractive (and affordable!) solution with self-hosted AI.