Free text queries reminds me of something I could have used at Chegg. Students were entering entire homework questions and we needed to match those against our database of questions. We sanitized the queries by removing or escaping all query syntax, but it would have been nice to have a query “parser” that had no syntax. Just take the text and search.
wunder Walter Underwood [email protected] http://observer.wunderwood.org/ (my blog) > On Nov 23, 2026, at 9:50 AM, Trevor McCulloch <[email protected]> wrote: > > I know there are other models designed specifically to do searching but they > tend to be fine-tunes of much larger LLMs, even the "small" open models are > ~20GB quantized at this point and are very slow unless they are run on a GPU. > > I think there's another interesting topic here is that LLMs tend to generate > long (short paragraph) free text queries, so in addition to the mapping done > here (search these fields, etc) there might be a need to optionalize certain > terms or weight them, and it also might help to extend the input by including > term frequency information, etc. > > On Sun, Nov 22, 2026 at 1:48 PM Dawid Weiss <[email protected] > <mailto:[email protected]>> wrote: >> >> Thanks, Trevor! >> >> I'll be looking at this - very interesting. I assumed somebody had tried >> something like this before but judging from the response so far I guess not! >> >> Dawid >> >> On Sat, Nov 21, 2026 at 11:38 PM Trevor McCulloch <[email protected] >> <mailto:[email protected]>> wrote: >>> I had heard of this tool calling model called Cactus Needle >>> <https://cactuscompute.com/needle> that is designed to be run on a CPU in >>> embedded applications. I used a fancier LLM to generate training data and >>> fine-tuned the model on a local GPU in about 90m. Inference runs in ~50ms >>> on the CPU of an M4 mac which seems like it would be fast enough, and is a >>> relatively small 60M. >>> >>> I put it up on github as needle_lucene >>> <https://github.com/mccullocht/needle_lucene>, with the synthetic training >>> data, model, and a script that runs inference on a basic schema + text >>> query. Word of warning: the README is LLM-generated, it seems pretty >>> intelligible but I haven't had time to clean it up. I tried a few queries >>> beyond the samples and it seems to do alright but it is not very >>> sophisticated and it would need more training to specify system-prompt like >>> things (e.g. "title matches should be weighted more heavily). >>> >>> On Sat, Nov 21, 2026 at 6:02 AM Abhinav <[email protected] >>> <mailto:[email protected]>> wrote: >>>> I don't exactly know LLMs or Lucene but maybe this can be a RAG + Fine >>>> tuning + Parser Validation thing. Basically LLMs are NLP engines so we can >>>> take small LLMs like qwen,ollama etc and basically train them with Claude >>>> like models which know lucene queries (distillation yeah) and that is fine >>>> tuning for us. >>>> >>>> For RAG point LLMs are very good at hallucinating. So if we have a >>>> repository of lucene queries as example then this models can always verify >>>> with previous examples. A simple parser which validates syntax and of >>>> queries so that LLM doesn't over hallucinate. >>>> >>>> >>>> On Sat, Nov 21, 2026, 1:03 PM Dawid Weiss <[email protected] >>>> <mailto:[email protected]>> wrote: >>>>> >>>>> Thanks! >>>>> >>>>> > The idea you can encode and tie together meaningful phrases, vs tokens, >>>>> > changes how search can be done. >>>>> >>>>> >>>>> This sounds good too. My take is I think even more ambitious in that I >>>>> wanted the model to be an "expert" at expressing >>>>> natural language needs into Lucene queries for a given index schema. >>>>> Consider something like this - >>>>> >>>>> "Give me documents mentioning nanotechnology authored by "Weiss", >>>>> possibly mispelled, which were submitted in the last 5 years." >>>>> >>>>> The LLM model would know the data, so something like this would have to >>>>> be given as a system prompt - >>>>> >>>>> fields: >>>>> "title": english text, analyzed; the document title >>>>> "author": english text, analyzed; document's author in "Last, First" >>>>> format >>>>> "date": the date the document was submitted to the system, a numeric >>>>> field. Accepts "yyyy/MM/dd" format and "NOW" as a constant. >>>>> >>>>> I'd like the LLM to produce something like this: >>>>> >>>>> title:nanotechnology AND author:Weiss~2 AND date:[2016 TO NOW] >>>>> >>>>> If the model is smart, it can even do more complex things for you before >>>>> it generates the query. I've vibe-coded something like this and it works >>>>> great - take a look below: >>>>> >>>>> <image.png> >>>>> >>>>> The problem here is that it really needs a very capable model (claude >>>>> sonnet above) to "understand" how Lucene query syntax works and how the >>>>> search works in general to produce reasonable response. I've been >>>>> wondering if fine-tuning a smaller model with just that "understanding of >>>>> how queries work" bit would >>>>> be possible. Training large llms is what I have zero experience with so >>>>> maybe my expectations are too high. >>>>> >>>>> Dawid >>>>>
