Generative artificial intelligence-based information retrieval
A technique for generative artificial intelligence-based information retrieval is disclosed. The system receives a natural language query for information to be retrieved from a knowledge base, that includes a structured data source and an unstructured data source. Further, contextual information for the natural language query is extracted from the knowledge base by domain-based chunking and tagging of relevant documents in the unstructured data source, and/or executing an automatically generated Structured Query Language (SQL) query, on the structured data source. Following, the system inputs the contextual information along with the natural language query to at least a Large Language Model (LLM). The system provides an output of the LLM as a response to the natural language query.
1 . A system, comprising:
at least one hardware processor; and
at least one non-transitory processor-readable medium storing instructions to be executed by the at least one hardware processor to:
receive a natural language query for information to be retrieved from a knowledge base,
wherein the knowledge base includes a structured data source and an unstructured data source;
apply a Responsible Artificial Intelligence (RAI) filter for detecting non-compliance with predefined standards in the natural language query;
extract contextual information for the filtered natural language query from the knowledge base by at least one of:
domain-based chunking and tagging of relevant documents in the unstructured data source; and
executing an automatically generated Structured Query Language (SQL) query, on the structured data source;
input the contextual information along with the natural language query to a large language model (LLM); and
provide an output of the LLM as a response to the natural language query.
2 . The system of claim 1 , wherein the at least one non-transitory processor-readable medium storing further instructions that cause the at least one hardware processor to:
apply the RAI filter that analyzes the output of the LLM for detecting non-compliance with predefined standards; and
provide the filtered output as the response to the natural language query.
3 . The system of claim 1 , wherein to extract the contextual information from the structured data source the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
input the natural language query to an SQL generating Large Language Model (LLM); and
obtain the automatically generated SQL query as an output from the SQL generating LLM in response to the natural language query.
4 . The system of claim 1 , wherein to extract the contextual information from the structured data source the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
determine an intent of the natural language query; and
select an agent to execute the automatically generated SQL query on the structured data source based on the intent.
5 . The system of claim 3 , wherein to extract the contextual information from the unstructured data source, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
classify the natural language query into a category, wherein the category includes at least one of a use-case based type, and an exploratory type.
6 . The system of claim 1 , wherein to extract the contextual information from the unstructured data source the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
further optimize the natural language query by performing one or more of stop word removal, synonym expansion, and dynamic query rewriting.
7 . The system of claim 6 , wherein to input the contextual information, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
determine a quantum of the contextual information to be input to the LLM based on the type of the natural language query.
8 . The system of claim 5 , wherein to input the contextual information the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
determine that the quantum of contextual information to be input to the LLM is based on corresponding percentages of the contextual information extracted from the structured data source and the unstructured data source.
9 . The system of claim 5 , wherein to execute the domain-based chunking, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
create chunks from the relevant documents based on the type of the natural language query.
10 . The system of claim 9 , wherein to create the chunks based on the type of the natural language prompt, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
create fine-grained chunks when the natural language query is of the use-case based type; and
create larger, context-preserving chunks when the natural language query is of the exploratory type.
11 . The system of claim 10 , wherein to execute the domain-based chunking, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
create chunks from the relevant documents based on document structures.
12 . The system of claim 1 , wherein to execute the tagging of the relevant documents, the at least one non-transitory processor-readable medium stores further instructions that cause the at least one hardware processor to:
attach domain-specific metadata to chunks of the relevant documents.
13 . A processor-executable method comprising:
receiving, by the processor, a natural language query for information to be retrieved from a knowledge base that includes a structured data source and an unstructured data source;
applying a Responsible Artificial Intelligence (RAI) filter for detecting non-compliance with predefined standards in the natural language query;
extracting, by the processor, contextual information for the filtered query from the knowledge base by at least one of:
domain-based chunking and tagging of relevant documents in the unstructured data source; and
executing an automatically generated Structured Query Language (SQL) query on the structured data source;
inputting, by the processor, the contextual information along with the natural language prompt to at least a large language model (LLM); and
providing, by the processor, an output of the LLM as a response to the natural language prompt.
14 . The processor-executable method of claim 13 , wherein inputting the contextual information further comprises:
combining, by the processor, the contextual information including structured data from the structured data source and unstructured data from the unstructured data source;
adjusting, by the processor, a proportion of the structured data and the unstructured data based on the category of the natural language query selected from at least one of the use-case based type, and the exploratory type; and
inputting, by the processor to the LLM, the contextual information formatted based on a prompt template.
15 . The processor-executable method of claim 13 , further comprises:
adding, by the processor, the natural language prompt issued to a log of issued requests, wherein the log includes a time of a request including the natural language prompt, a type of the request, resources accessed, and a user or an application making the request, a response time and computational resources used.
16 . The processor-executable method of claim 15 , further comprises:
determining, by the processor from the log of issued requests, a number of tokens processed by the LLM for a user account issuing the natural language prompt; and
selecting, by the processor via a rules engine, the LLM from a plurality of LLMs based on the number of processed tokens.
17 . A non-transitory processor-readable storage medium comprising machine-readable instructions that cause a processor to:
receive a natural language query for information to be retrieved from a knowledge base that includes a structured data source and an unstructured data source;
apply a Responsible Artificial Intelligence (RAI) filter for detecting non-compliance with predefined standards in the natural language query;
extract contextual information for the filtered query from the knowledge base by at least one of:
domain-based chunking and tagging of relevant documents in the unstructured data source; and
executing an automatically generated Structured Query Language (SQL) query on the structured data source;
input the contextual information along with the natural language prompt to at least a large language model (LLM); and
provide an output of the LLM as a response to the natural language prompt.
18 . The non-transitory processor-readable storage medium of claim 17 , comprising further machine-readable instructions that cause the processor to:
apply the RAI filter that analyzes the output of the LLM for detecting non-compliance with predefined standards to be applied to the LLM.
19 . The non-transitory processor-readable storage medium of claim 17 , wherein the output of the LLM includes at least one of metric data, tabular data including rows and columns, chart data, and summary.