Natural language query for Search UI?

Hello Enterprise Search Team :wave:!

Do you have any examples for how to use natural language queries with Search UI?

For example, I want to search "Show me all movies with Tom Hanks in the last year."

I plan to run this query through some LLM (e.g. ChatGPT) along with my available search UI field names to generate some structured JSON output like:

filters: [
  {
    field: "actorName",
    operator: "contains",
    value: "Tom Hanks"
  }
  {
    field: "releaseDate",
    operator: ">"
    value: "2021"
  }
]

Which I would then convert into the correct Search UI facets/filters.

Do you have any suggestions for LLMs that would work well for this use case?

Thanks!
Rich

Hello Rich! Good to see you! Hope you're well :wave:

Not elegantly but I can think of one potential way with a custom search box component. What you could do is:

  1. extend the search box component to perform a separate API call to LLM for the user's query into the query and filters object that you mention.
  2. Invoke a search UI request with the query (possibly in this example it would be an empty string as all features of the query have been converted into filters) and transforming your filters object into Search UI filters.

Does that sound reasonable? I can try give an example via codesandbox if that sounds right.

Just dropping in to say hi @Rich_Kuzsma2 :slight_smile:

Thanks Joe! Your approach makes sense to me for the UI side of this. :+1:

Any suggestions for LLMs to use/train that are good at converting natural language queries into a structured format for this use case? Admittedly, this question is beyond the scope of Search UI. But it would be a really powerful way to extend Search UI's capabilities.

Thanks again, and Hi Serena! :wave:

Any suggestions for LLMs to use/train that are good at converting natural language queries into a structured format for this use case? Admittedly, this question is beyond the scope of Search UI. But it would be a really powerful way to extend Search UI's capabilities.

I dont have any recommendations unfortunately. There is a project that might help converting text into Elasticsearch filters Introduction — 😼 Kor 0.13.0

Definitely getting this part right is the hardest. Let me know if you have any success in this, and i will try follow up with a search ui integration example.

Joe

Hi @Rich_Kuzsma2, I'm working on something similar and wanted to know if you found a good LLM that you would recommend?

Thanks,
Adi

I've not found an LLM that works well for this use case out-of-the-box.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.