I'm interested in using Foundation Models to act as an AI support agent for our extensive in-app documentation. We have many pages of in-app documents, which the user can currently search, but it would be great to use Foundation Models to let the user get answers to arbitrary questions.
Is this possible with the current version of Foundation Models? It seems like the way to add new context to the model is with the instructions
parameter on LanguageModelSession
. As I understand it, the combined instructions and prompt need to consume less than 4096 tokens.
That definitely wouldn't be enough for the amount of documentation I want the agent to be able to refer to. Is there another way of doing this, maybe as a series of recursive queries? If there is a solution based on multiple queries, should I expect this to be fast enough for interactive use?
Hi @interferon,
You are correct, adding your entire documentation to the prompt will likely exceed the context window size and is probably not the right approach here. One option could be to find just the relevant information in your documentation and then include that information in the prompt.
This approach is sometimes called retrieval augmented generation (RAG). It's up to you as the developer, however, to choose how you set up your data to retrieve the most relevant chunks of information.
Just keep in mind that Foundation Models gives access to powerful but comparatively small on-device models that are optimized for a subset of tasks like summarization. Unexpected results may occur if relied on for tasks which require a large amount of context or advanced reasoning.
Best,
-J