Creating "ask a question" functionality in Shiny using NLP

Hello RStudio Community!

I've been thinking about the "ask a question" functionality seen in some enterprise analytical applications such as AnswerRocket, where users can type something like "How were sales of grape soda last quarter?" and this generates a query that then generates content in the application for them to consume. From the business user's perspective, they just type a normal question and then see a plot or table that answers it. That's an awesome user experience.

I think I understand what it would take to code this out with R/python in a shiny application, but I assume I'm not the first to be curious about this or the first to try it, hence this pot. I'm not seeing any posts about it in google searches, so I thought I'd ask here!

Has anyone tried to build this type of functionality before? If so, did it work? Do you have any suggestions or pointers (even if you haven't tried it)? Would love a discussion on this topic!


1 Like

What you're talking about is usually called a "natural language interface" to data visualization, and for example Tableau has this as a feature (Ask Data is its name, I think). There is an R package that builds out some of this type of functionality for ggplot2 called ggx, although I haven't played with it that much.

I think a lot of the best systems that implement natural language interfaces for data visualization are based on large sets of training data (queries from users as input, with the outcome being the intended plot) but I bet some also are more manually crafted. I know of a couple nice papers on this:

Those are just ones I have looked at but there are lots more out there!

1 Like

Thanks for all the work you do - I've use walkthroughs from you to learn a lot :slight_smile:.

I had never heard of ggx - I'll check it out. Also appreciate the papers, I'll give them a look.

I assumed the same about building this out from a lot of queries and the intended code. I've seen people who have done this with GPT-3 and building out web apps, for example.

Thank you!

1 Like

This may also be of use:

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.