Systems and methods for runtime input and output content moderation for large language models
Systems and methods for runtime input and output content moderation for large language models are disclosed. In one embodiment, a method may include: (1) receiving, by a moderator computer program executed by an electronic device, a query for a large language model-based computer program from a user application; (2) applying, by the moderator computer program, a rule to the query; (3) submitting, by the moderator computer program, the query to the large language model-based computer program; (4) receiving, by the moderator computer program, a response to the query from the large language model-based computer program; and (5) returning, by the moderator computer program, the response to the user application.
1 . A method, comprising:
receiving, by a moderator computer program executed by an electronic device, a query for a large language model-based computer program from a user application;
applying, by the moderator computer program, a query rule to the query, wherein the query rule prohibits queries comprises executable content;
modifying, by the moderator computer program, the query by removing the executable content from the query;
submitting, by the moderator computer program, the modified query to the large language model-based computer program;
receiving, by the moderator computer program, a response to the modified query from the large language model-based computer program;
applying, by the moderator computer program, a response rule to the response, wherein the response rule prevents the response from being returned in response to the response comprising a security risk;
approving, by the moderator computer program, the response from the large language model-based computer program based on the rule applied to the response, wherein if the moderator computer program does not approve the response, the moderator computer program prevents the response from being returned and returns an alternate notification to the user application;
training, by a feedback loop, the large language model-based computer program to predict whether the response should be rejected; and
returning, by the moderator computer program, the response to the user application.
2 . The method of claim 1 , wherein the query rule further prohibits queries comprising sensitive information.
3 . The method of claim 1 , further comprising:
masking, by the moderator computer program, sensitive information in the query before submitting the query to the large language model-based computer program.
4 . A system, comprising:
a user electronic device executing a user application;
a large language model-based computer program; and
an electronic device executing a moderator computer program that is configured to receive a query for the large language model-based computer program from the user application to apply a query rule to the query, wherein the query rule prohibits queries comprises executable content, to modify the query by removing the executable content from the query, to submit the modified query to the large language model-based computer program, to receive a response to the modified query from the large language model-based computer program, to apply a response rule to the response, to approve the response from the large language model-based computer program based on the rule applied to the response, if the moderator computer program does not approve the response, the moderator computer program prevents the response from being returned and returns an alternate notification to the user application, to train the large language model-based computer program by a feedback loop to predict whether the response should be rejected, and to return the response to the user application.
5 . The system of claim 4 , wherein the query rule further prohibits queries comprising sensitive information.
6 . The system of claim 4 , wherein the moderator computer program is configured to mask sensitive information in the query before submitting the query to the large language model-based computer program.
7 . A non-transitory computer readable storage medium, including instructions stored thereon, which when read and executed by one or more computer processors, cause the one or more computer processors to perform steps comprising:
receiving a query for a large language model-based computer program from a user application;
applying a query rule to the query, wherein the query rule prohibits queries comprises executable content;
modifying the query by removing the executable content from the query;
submitting the modified query to the large language model-based computer program;
receiving a response to the modified query from the large language model-based computer program;
applying a response rule to the response, wherein the response rule prevents the response from being returned in response to the response comprising a security risk;
approving the response from the large language model-based computer program based on the rule applied to the response, wherein if the response is not approved, an alternate notification to the user application;
training, by a feedback loop, the large language model-based computer program to predict whether the response should be rejected; and
returning the response to the user application.
8 . The non-transitory computer readable storage medium of claim 7 , wherein the query rule further prohibits queries comprising sensitive information.
9 . The non-transitory computer readable storage medium of claim 7 , further including instructions stored thereon, which when read and executed by the one or more computer processors, cause the one or more computer processors to perform steps comprising:
masking sensitive information in the query before submitting the query to the large language model-based computer program.