Dynamic evaluation of language model prompts for model selection and output validation and methods and systems of the same
The systems and methods disclosed herein relate to a model validation platform that enables dynamic validation of a user's prompt for a large language model (LLM) in order to evaluate the validity of the prompt and the suitability of a large language model for processing the prompt. For example, the platform enables an estimation of the resource allocation associated with processing the prompt with a given LLM, as well as a modification of the prompt, prior to the processing the prompt with the selected LLM. The platform can further validate the output prior to transmitting the output to a server system for display to the user. By doing so, the platform enables dynamic evaluation of a request to execute an LLM, as well as evaluation of resulting outputs, for accuracy and efficiency improvements in data processing or software development pipelines.
1 . A non-transitory computer-readable storage medium comprising instructions thereon, wherein the instructions when executed by at least one data processor of a system, cause the system to:
receive an output generation request comprising an input for generation of an output using a first artificial intelligence (AI) model;
provide the output generation request to a first input validation model to modify the input,
wherein modifying the input comprises:
determining that the input includes a forbidden token; and
generating the modified input by omitting the forbidden token;
determine a performance metric value associated with the output generation request,
wherein the performance metric value indicates a requirement for the output generation request;
compare the performance metric value of the output generation request with a first performance criterion associated with the first AI model of a plurality of AI models;
in response to determining that the performance metric value satisfies the first performance criterion, provide the modified input to the first AI model to generate the output; and
enable access to the output by a user.
2 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions further cause the system to:
determine a user identifier associated with the user;
determine, from a token database, a stored token associated with the user identifier;
compare the stored token and an authentication token associated with the output generation request; and
in response to determining that the stored token and the authentication token associated with the output generation request match, authenticate the user.
3 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions further cause the system to:
generate, based on the output generation request, an event record including (1) the performance metric value, (2) a user identifier associated with the user, and (3) the input; and
transmit, to a server system, the event record for storage in an event database.
4 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions for modifying the input cause the system to:
determine that the input includes a first alphanumeric token;
determine that one or more records in a sensitive token database include a representation of the first alphanumeric token; and
modify the input to include a second alphanumeric token in lieu of the first alphanumeric token,
wherein the sensitive token database does not include a record representing the second alphanumeric token.
5 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions for modifying the input cause the system to:
generate a trace token comprising a traceable alphanumeric token; and
generate the modified input to include the trace token.
6 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions for comparing the performance metric value with the first performance criterion cause the system to:
generate a cost metric value associated with the requirement for the output generation request;
determine a threshold cost associated with the first AI model; and
determine that the cost metric value satisfies the threshold cost.
7 . The non-transitory computer-readable storage medium of claim 1 , wherein the instructions further cause the system to:
extract a code sample from the output, wherein the code sample includes code for a software routine;
compile, within a virtual machine of the system, the code sample to generate an executable program associated with the software routine;
execute, within the virtual machine, the software routine using the executable program;
detect an anomaly in the execution of the software routine;
in response to detecting the anomaly in the execution of the software routine, generate a validation indicator to include an indication of the anomaly; and
in response to generating the validation indicator, enable access to the output by the user.
8 . A system comprising:
at least one hardware processor; and
at least one non-transitory memory storing instructions, which, when executed by the at least one hardware processor, cause the system to:
receive an output generation request comprising an input for generation of an output using a first AI model;
provide the output generation request to a first input validation model to modify the input,
wherein modifying the input comprises:
generating a traceable token; and
generating the modified input to include the traceable token;
determine a performance metric value associated with the output generation request,
wherein the performance metric value indicates a requirement for the output generation request;
compare the performance metric value of the output generation request with a first performance criterion associated with the first AI model of a plurality of AI models;
in response to determining that the performance metric value satisfies the first performance criterion, provide the modified input to the first AI model to generate the output; and
enable access to the output by a user.
9 . The system of claim 8 , wherein the instructions further cause the system to:
determine a user identifier associated with the user;
determine, from a token database, a stored token associated with the user identifier;
compare the stored token and an authentication token associated with the output generation request; and
in response to determining that the stored token and the authentication token associated with the output generation request match, authenticate the user.
10 . The system of claim 8 , wherein the instructions further cause the system to:
generate, based on the output generation request, an event record including (1) the performance metric value, (2) a user identifier associated with the user, and (3) the input; and
transmit, to a server system, the event record for storage in an event database.
11 . The system of claim 8 , wherein the instructions for modifying the input cause the system to:
determine that the input includes a first alphanumeric token;
determine that one or more records in a sensitive token database include a representation of the first alphanumeric token; and
modify the input to include a second alphanumeric token in lieu of the first alphanumeric token,
wherein the sensitive token database does not include a record representing the second alphanumeric token.
12 . The system of claim 8 , wherein the instructions for modifying the input cause the system to:
determine that the input includes a forbidden token; and
generate the modified input by omitting the forbidden token.
13 . The system of claim 8 , wherein the instructions for comparing the performance metric value with the first performance criterion cause the system to:
generate a cost metric value associated with the requirement for the output generation request;
determine a threshold cost associated with the first AI model; and
determine that the cost metric value satisfies the threshold cost.
14 . The system of claim 8 , wherein the instructions for providing the output generation request to the first input validation model cause the system to:
identify an attribute of the output generation request;
determine, based on the attribute, the first input validation model of a plurality of prompt validation models; and
provide the output generation request to the first input validation model.
15 . A method comprising:
receiving an output generation request comprising an input for generation of an output using a first AI model of a plurality of AI models;
modifying, using a first input validation model, the output generation request by modifying the input to omit a set of forbidden tokens;
determining a performance metric value associated with the modified output generation request,
wherein the performance metric value indicates a requirement for the modified output generation request;
comparing the performance metric value of the modified output generation request with a first performance criterion associated with the first AI model; and
in response to determining that the performance metric value satisfies the first performance criterion, enabling access to the output by a user.
16 . The method of claim 15 , further comprising:
determining a user identifier associated with the user;
determining, from a token database, a stored token associated with the user identifier;
comparing the stored token and an authentication token associated with the output generation request; and
in response to determining that the stored token and the authentication token associated with the output generation request match, authenticating the user.
17 . The method of claim 15 , comprising:
generating, based on the output generation request, an event record including (1) the performance metric value, (2) a user identifier associated with the user, and (3) the input; and
transmitting, to a server system, the event record for storage in an event database.
18 . The method of claim 15 , comprising:
determining that the input includes a first alphanumeric token;
determining that one or more records in a sensitive token database include a representation of the first alphanumeric token; and
modifying the input to include a second alphanumeric token in lieu of the first alphanumeric token,
wherein the sensitive token database does not include a record representing the second alphanumeric token.
19 . The method of claim 15 , wherein comparing the performance metric value with the first performance criterion comprises:
generating a cost metric value associated with the requirement for the output generation request;
determining a threshold cost associated with the first AI model; and
determining that the cost metric value satisfies the threshold cost.
20 . The method of claim 15 , wherein providing the output generation request to the first input validation model comprises:
identifying an attribute of the output generation request;
determining, based on the attribute, the first input validation model of a plurality of prompt validation models; and
providing the output generation request to the first input validation model.