Modifying a user query to prevent hallucinations
A user query that includes a natural language description is received. It is determined that the user query is an improper request for information. In response to a determination that the user query is the improper request for information, a proper request for information is generated.
1 . A method, comprising:
receiving a user query that includes a natural language description, wherein the natural language description includes one or more words corresponding to one or more known parameters associated with a particular schema and one or more words corresponding to an unknown parameter associated with the particular schema;
determining that the user query is an improper request for information including by determining the user query includes the unknown parameter associated with the particular schema;
in response to determining that the user query is the improper request for information, generating a proper request for information, wherein generating the proper request for information includes generating a prompt that utilizes a Pydantic style schema for the one or more known parameters and providing in the prompt an instruction for the unknown parameter;
providing the prompt to a large language model;
receiving a user query response from the large language model;
filtering the user query response based on the unknown parameter; and
providing the filtered user query response.
2 . The method of claim 1 , wherein filtering the user query response from the large language model includes determining data included in the user query response from the large language model to satisfy the request for information and removing a subset of the data included in the user query response from the large language model that does not satisfy the request for information.
3 . A system, comprising:
a processor configured to:
receive a user query that includes a natural language description, wherein the natural language description includes one or more words corresponding to one or more known parameters associated with a particular schema and one or more words corresponding to an unknown parameter associated with the particular schema;
determine that the user query is an improper request for information including by determining the user query includes the unknown parameter associated with the particular schema;
in response to determining that the user query is the improper request for information, generate a proper request for information, wherein to generate the proper request for information, the processor is configured to generate a prompt that utilizes a Pydantic style schema for the one or more known parameters and providing in the prompt an instruction for the unknown parameter;
provide the prompt to a large language model;
receive a user query response from the large language model;
filter the user query response based on the unknown parameter; and
provide the filtered user query response; and
a memory coupled to the processor and configured to provide the processor with instructions.
4 . The system of claim 3 , wherein to filter user query response from the large language model, the processor is configured to determine data included in the user query response from the large language model to satisfy the request for information and remove a subset of the data included in the user query response from the large language model that does not satisfy the request for information.
5 . A non-transitory computer readable medium and comprising computer instructions for:
receiving a user query that includes a natural language description, wherein the natural language description includes one or more words corresponding to one or more known parameters associated with a particular schema and one or more words corresponding to an unknown parameter associated with the particular schema;
determining that the user query is an improper request for information including by determining the user query includes the unknown parameter associated with the particular schema;
in response to determining that the user query is the improper request for information, generating a proper request for information, wherein generating the proper request for information includes generating a prompt that utilizes a Pydantic style schema for the one or more known parameters and providing in the prompt an instruction for the unknown parameter;
providing the prompt to a large language model;
receiving a user query response from the large language model;
filtering the user query response based on the unknown parameter; and
providing the filtered user query response.
6 . The computer program product of claim 5 , wherein filtering the user query response from the large language model includes determining data included in the user query response from the large language model to satisfy the request for information and removing a subset of the data included in the user query response from the large language model that does not satisfy the request for information.