Function calling to enable muti-source data retrieval in generative artificial intelligence systems
Abstract
A generative artificial intelligence system includes a retrieval augmented generation (RAG) assistant that utilizes function calling to facilitate multi-source data retrieval to enhance user queries transmitted to a large language model (LLM). The RAG assistant Transmits, to the LLM, a function selection instruction prompt that includes conversation history data, a function list including function definitions that each correspond to a data source, and instructions directing the LLM to return a function call to at least one function defined on the function list identified as relevant to the conversation history data based on a corresponding function descriptor. In response to receiving a function selection response from the LLM that includes the function call, the RAG assistant selects and executes a conditional operation based on a name of the at least one function.
Claims
exact text as granted — not AI-modifiedwhat is claimed is:
1 . A method comprising:
receiving, from a user compute system, conversation history data including a query; generating, by a retrieval augmented generative (RAG) assistant, a function selection instruction prompt for a large language model (LLM), the function selection instruction prompt including:
the conversation history data;
a function list including function definitions that each correspond to a data source and include a function descriptor that describes content of the data source; and
instructions directing the LLM to return a function call to at least one function on the function list identified as relevant to the conversation history data based on the corresponding function descriptor; and
receiving, at the RAG assistant, a function selection response from the LLM including the function call; based on the least one function identified within the function selection response, selecting a conditional operation from multiple defined conditional operations; and executing, by the RAG assistant, the conditional operation.
2 . The method of claim 1 , wherein the function list includes an out-of-domain function with a function descriptor that instructs the LLM to select the out-of-domain function in response to determining that no other function on the function list is relevant to the conversation history data.
3 . The method of claim 2 , wherein the conditional operation includes:
transmitting a response to the user compute system in response to determining that the function selection response identifies the out-of-domain function, wherein the response indicates that the query could not be answered using available data sources.
4 . The method of claim 3 , wherein the function selection instruction prompt further includes potentially-relevant data chunks mined from one or more data sources and the function list includes a particular function with a function descriptor that instructs the LLM to select the particular function in response to determining that the potentially-relevant data chunks are usable to answer the query.
5 . The method of claim 1 , wherein the method further comprises:
receiving, from a user compute system, identification of a group of approved data sources, wherein each data source of the group of approved data sources corresponds to a function on the function list.
6 . The method of claim 1 , further comprising:
determining that the function call identifies a function corresponding to a select data source; retrieving, from the select data source, potentially-relevant data chunks satisfying similarity criteria with the conversation history data; transmitting, to the LLM, a context-enhanced query that includes:
the query;
context data that includes the potentially-relevant data chunks; and
an instruction directing the LLM to answer the context-enhanced query based on the context data; and
receiving, from the LLM, an answer to the context-enhanced query; and displaying, on a user display, a response that is based on the answer.
7 . The method of claim 1 , wherein the instructions direct the LLM to return a function call to one or multiple functions that the LLM identifies as relevant to the conversation history data, and wherein the method further comprises:
in response to determining that the function selection response includes multiple function calls identifying multiple different data sources:
retrieving, from each of the multiple different data sources, potentially-relevant data chunks satisfying similarity criteria with the query;
defining, based on the potentially-relevant data chunks retrieved with respect to each of the multiple different data sources, a set of most relevant data chunks; and
generating a context-enhanced query that includes the set of most relevant data chunks, the query, and an instruction to answer the query using the set of most relevant data chunks;
receiving, from the LLM, an answer to the context-enhanced query; and
displaying, on a user display, a response that is based on the answer.
8 . The method of claim 7 , wherein generating the set of most relevant data chunks further comprises:
ranking the potentially-relevant data chunks retrieved with respect to each of the multiple different data sources based on respective similarity to the conversation history data; selecting a number N of highest-ranked data chunks.
9 . The method of claim 7 , wherein generating the set of most relevant data chunks further comprises:
generating, via a trained summarization model, summaries of the potentially-relevant data chunks; generating one or more combined data chunks that each includes two or more of the summaries concatenated together, wherein the set of most relevant data chunks includes the one or more combined data chunks.
10 . A system comprising:
a retrieval augmented generative (RAG) assistant stored in memory and executable to: transmit a function selection instruction prompt to a large language model (LLM) in response to receiving, from a user compute system, conversation history data including a query, the function selection instruction prompt including:
the conversation history data;
a function list including function definitions that each correspond to a data source and include a function descriptor that describes content of the data source; and ; and
instructions directing the LLM to return a function call to at least one function on the function list identified as relevant to the conversation history data based on the corresponding function descriptor; and
receive, in response to transmission of the function selection instruction prompt, a function selection response from the LLM that includes the function call; select, based on the least one function identified within the function selection response, a conditional operation from multiple defined conditional operations; and execute, by the RAG assistant, the conditional operation.
11 . The system of claim 10 , wherein the function list includes an out-of-domain function with a function descriptor that instructs the LLM to select the out-of-domain function in response to determining that no other function on the function list is relevant to the conversation history data.
12 . The system of claim 11 , wherein the at least one function identified within the function selection instruction prompt identifies the out-of-domain function and the conditional operation provides for transmitting a response, to the user compute system, that indicates the query could not be answered using available data sources.
13 . The system of claim 11 , wherein the function selection instruction prompt further includes potentially-relevant data chunks mined from one or more data sources and the function list includes a particular function with a function descriptor that instructs the LLM to select the particular function in response to determining that the potentially-relevant data chunks are usable to answer the query.
14 . The system of claim 10 , wherein the RAG assistant is further executable to:
determine that the function call corresponds to a select data source: retrieve, from the select data source, potentially-relevant data chunks satisfying similarity criteria with the conversation history data; transmit a context-enhanced query to the LLM, the context-enhanced query including:
the query;
context data including the potentially-relevant data chunks; and
an instruction directing the LLM to answer the context-enhanced query based on the context data; and
receive, from the LLM, an answer to the context-enhanced query; and display, on a user display, a response that is based on the answer.
15 . The system of claim 10 , wherein the instructions in the function selection instruction prompt direct the LLM to return function calls to one or multiple functions that the LLM identifies as relevant to the conversation history data, and wherein the RAG assistant is further executable to:
determine that the function selection response includes multiple function calls corresponding to multiple different data sources: retrieve, from each of the multiple different data sources, potentially-relevant data chunks satisfying similarity criteria with the conversation history data; define, based on the potentially-relevant data chunks retrieved with respect to each of the multiple different data sources, a set of most relevant data chunks; and generate a context-enhanced query that includes the set of most relevant data chunks, the query, and a final instruction directing the LLM to answer the query using the set of most relevant data chunks; receive from the LLM, an answer to the context-enhanced query; and display, on a user display, a response that is based on the answer.
16 . The system of claim 15 , wherein the RAG assistant is further executable to:
generate the set of most relevant data chunks at least in part by:
ranking the potentially-relevant data chunks retrieved with respect to each of the multiple different data sources based on respective similarity to the conversation history data; and
selecting a number N of highest-ranked data chunks.
17 . The system of claim 15 , wherein the RAG assistant is further executable to:
generate the set of most relevant data chunks at least in part by:
generating, via a trained summarization model, summaries of the potentially-relevant data chunks; and
generate one or more combined data chunks that each includes two or more of the summaries concatenated together, wherein the set of most relevant data chunks includes the one or more combined data chunks.
18 . One or more tangible computer-readable storage media encoding instructions for executing a computer process, the computer process comprising:
receiving, from a user compute system, conversation history data including a query; generating, by a retrieval augmented generative (RAG) assistant, a function selection instruction prompt for a large language model (LLM), the function selection instruction prompt including:
the conversation history data;
a function list defining:
a first set of function definitions, each function definition in the first set corresponding to a data source and including a function descriptor that describes content of the data source; and
an out-of-domain function with a function descriptor that instructs the LLM to select the out-of-domain function in response to determining that no other function on the function list is relevant to the conversation history data;
instructions directing the LLM to return a function call to at least one function on the function list identified as relevant to the conversation history data based on the corresponding function descriptor; and
receiving, at the RAG assistant, a function selection response from the LLM including a call to the out-of-domain function; transmitting a response to the user compute system in response to determining that the function selection response identifies the out-of-domain function, the response indicating that the query could not be answered using available data sources.
19 . The one or more tangible computer-readable storage media of claim 18 , wherein the function selection instruction prompt further includes potentially-relevant data chunks mined from one or more data sources and the function list includes a particular function with a function descriptor that instructs the LLM to select the particular function in response to determining that the potentially-relevant data chunks are usable to answer the query.
20 . The one or more tangible computer-readable storage media of claim 19 ,
transmitting, to the LLM, a context-enhanced query in response to determining that the function selection response identifies the particular function, the context-enhanced query including: the query, context data including the potentially-relevant data chunks, and an instruction directing the LLM to answer the context-enhanced query based on the context data.Join the waitlist — get patent alerts
Track US2025384064A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.