Back to Case Studies

Natural-Language ETF Screening

From a Plain-Language Request to a Ranked Fund List

ProductionFinancial Services & FinTechJun 2025 – Aug 2025NLP, Knowledge Systems & Generative AI
~0.95
Accuracy of request-to-filter mapping
< 5 s
From a request to a ranked fund list
0
SQL written by the LLM
Delivered
Built and handed to the client

My Role

Role
Architect & tech lead
At Dataforest
Team
Me + 1–2 engineers
Stage reached
Built and delivered to the client
Key decisions
  • LLM maps requests onto a fixed filter schema
  • Filters held as finite-state-machine states
  • Rules compile SQL; the LLM never writes it

Approach at a Glance

Details
  1. 1Natural or Structured Input
  2. 2LLM Mapping onto a Fixed Filter Schema
  3. 3Filters as a Finite State Machine
  4. 4Rule-Based SQL Compilation
  5. 5Multi-Criteria Ranking

Executive Summary

An ETF screener that takes a request in plain language, such as "technology funds in Europe with low fees", and returns a ranked list of ETFs that meet it. Investors don't have to know the screener's filter names or click through dozens of dropdowns: they say what they want, and the system turns it into a precise query.

The key design decision was to keep the LLM away from the database. The LLM's only job is to map the request onto a fixed set of filter types and values ("technology" → industry = TECH, "Europe" → region = EU). From there, the filters are held as states in a finite state machine, rule-based logic compiles them into SQL, and a weighted ranking sorts the results by expense ratio, AUM and performance. The request was mapped to the right filters with about 0.95 accuracy, and a ranked list came back in under 5 seconds.

I was the architect and tech lead, working with one or two engineers, from June to August 2025. The system was built and delivered to the client.


Client Profile

The client needed a simpler way for users to screen ETFs. A classic screener has many filters, including sector, region, fees, fund size and performance, and users have to know which ones to set and how they're named. Most people think about funds in plain words instead: "cheap", "European tech", "large, established funds".

Letting an LLM loose on this is risky:

  • Wrong numbers are expensive. A screener that silently drops a constraint, or invents one, shows funds the user didn't ask for, and in investing that's a trust problem.
  • Generated SQL is hard to trust. SQL written freely by a model can be wrong in subtle ways, hard to audit and unsafe to run on production data.
  • Results must be explainable. The user should see why a fund made the list and why it ranks where it does.

Technical Approach

  1. Natural or Structured Input – Users can describe what they want in plain language or set criteria directly, such as sector focus, region or a fee threshold. Both paths end up in the same representation, so the rest of the pipeline doesn't care how the request was made.

  2. LLM Mapping onto a Fixed Filter Schema – The LLM translates the request into a predefined schema of filter types, each with a discrete set of allowed values: "technology" becomes industry = TECH, "Europe" becomes region = EU. Because the model can only choose from known filters and values, it can't invent a field or a value the database doesn't have. Requests were mapped to the right filters with about 0.95 accuracy.

  3. Filters as a Finite State Machine – Internally, each filter is a defined state or transition in a finite state machine. Adding, changing or removing a criterion is an explicit, valid transition, so the set of active filters is always consistent and easy to inspect.

  4. Rule-Based SQL Compilation – The active filter states are compiled into SQL by rule-based translation logic, with one WHERE clause for each active filter. The LLM never writes SQL. Queries are deterministic, auditable and safe to run, and the same request always produces the same query.

  5. Multi-Criteria Ranking – After the query, a ranking layer orders the matching ETFs by weighted scoring or multi-criteria sorting on expense ratio, AUM and performance. The output is a ranked list designed to be easy to interpret, so users can see why each fund is where it is.


Business Outcome

Users can screen ETFs by describing what they want instead of learning the screener's filters. The system maps requests to the right filters with about 0.95 accuracy and returns a ranked list they can understand in under 5 seconds.

The architecture keeps each part doing what it's good at. The LLM understands language. The state machine keeps the criteria consistent. The rules produce correct, auditable SQL. The ranking layer makes the result easy to act on.

Technologies

LLMsStructured OutputFinite State MachineRule-Based SQL GenerationMulti-Criteria RankingSQL

Planning something similar?

Tell me about it on a short call. New projects can start within 2 weeks