Dynamic vocabularies for conditioning a language model for transforming natural language to a logical form
Techniques are disclosed herein for generating dynamic vocabularies for conditioning a language model. A dynamic vocabulary is constructed from an input prompt, database schema information for a database to be queried, and programming language information for a programming language to be used for querying the database to condition the language model to predict an output statement in the programming language. The dynamic vocabulary can be included in prompt information that is provided to the language model. The number of tokens in the dynamic vocabulary can be different than a number of tokens included in a vocabulary of the language model. By utilizing a dynamic vocabulary, the language model can be conditioned to predict tokens for the output statement that are contextually consistent with the tokens included the dynamic vocabulary.
1 . A computer-implemented method comprising:
generating, by a computing system, input information for a machine learning model configured to predict a statement, wherein the input information comprises an input prompt and a dynamic vocabulary derived from the input prompt and separate from the input prompt, wherein the dynamic vocabulary is further derived from a programming language and database schema information, and wherein a set of tokens of the dynamic vocabulary comprises one or more tokens associated with the programming language, one or more tokens associated with the database schema information, and one or more tokens associated with at least one condition of the input prompt;
predicting, by the computing system and using the machine learning model, an output statement for the input prompt based at least in part on the input information, wherein the output statement comprises a plurality of tokens, and wherein at least one token of the plurality of tokens is selected from the set of tokens;
executing, by the computing system and using the output statement, a query on a database associated with the database schema information to retrieve a result for the query; and
providing, by the computing system, the result for the query to a user device.
2 . The computer-implemented method of claim 1 , wherein the input information is first input information, wherein the input prompt is a first input prompt, wherein the set of tokens is a first set of tokens, wherein the database schema information is first database schema information, wherein the output statement is a first output statement, and wherein the plurality of tokens is a first plurality of tokens, the method further comprising:
generating, by the computing system, second input information for the machine learning model, wherein the second input information comprises a second input prompt and a second set of tokens, and wherein the second set of tokens comprises one or more tokens associated with the programming language, one or more tokens associated with second database schema information, and one or more tokens associated with at least one condition of the second input prompt; and
predicting, by the computing system and using the machine learning model, a second output statement for the second input prompt based at least in part on the second input information, wherein the second output statement comprises a second plurality of tokens, and wherein at least one token of the second plurality of tokens is selected from the second set of tokens.
3 . The computer-implemented method of claim 2 , wherein a number of tokens included in the first set of tokens is different from a number of tokens in the second set of tokens.
4 . The computer-implemented method of claim 1 , wherein the machine learning model comprises a vocabulary, and wherein a number of tokens included in the set of tokens is less than a number of tokens included in the vocabulary.
5 . The computer-implemented method of claim 1 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt corresponds to a term included in the input prompt.
6 . The computer-implemented method of claim 1 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt is generated using a rules-based approach and/or a named-entity recognition-based approach.
7 . A system comprising:
one or more processors; and
one or more computer-readable media storing instructions which, when executed by the one or more processors, cause the system to perform operations comprising:
generating input information for a machine learning model configured to predict a statement, wherein the input information comprises an input prompt and a dynamic vocabulary derived from the input prompt and separate from the input prompt, wherein the dynamic vocabulary is further derived from a programming language and database schema information, and wherein a set of tokens of the dynamic vocabulary comprises one or more tokens associated with the programming language, one or more tokens associated with the database schema information, and one or more tokens associated with at least one condition of the input prompt;
predicting, using the machine learning model, an output statement for the input prompt based at least in part on the input information, wherein the output statement comprises a plurality of tokens, and wherein at least one token of the plurality of tokens is selected from the set of tokens;
executing, using the output statement, a query on a database associated with the database schema information to retrieve a result for the query; and
providing the result for the query to a user device.
8 . The system of claim 7 , wherein the input information is first input information, wherein the input prompt is a first input prompt, wherein the set of tokens is a first set of tokens, wherein the database schema information is first database schema information, wherein the output statement is a first output statement, and wherein the plurality of tokens is a first plurality of tokens, the operations further comprising:
generating second input information for the machine learning model, wherein the second input information comprises a second input prompt and a second set of tokens, and wherein the second set of tokens comprises one or more tokens associated with the programming language, one or more tokens associated with second database schema information, and one or more tokens associated with at least one condition of the second input prompt; and
predicting, using the machine learning model, a second output statement for the second input prompt based at least in part on the second input information, wherein the second output statement comprises a second plurality of tokens, and wherein at least one token of the second plurality of tokens is selected from the second set of tokens.
9 . The system of claim 8 , wherein a number of tokens included in the first set of tokens is different from a number of tokens in the second set of tokens.
10 . The system of claim 7 , wherein the machine learning model comprises a vocabulary, and wherein a number of tokens included in the set of tokens is less than a number of tokens included in the vocabulary.
11 . The system of claim 7 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt corresponds to a term included in the input prompt.
12 . The system of claim 7 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt is generated using a rules-based approach and/or a named-entity recognition-based approach.
13 . The system of claim 7 , wherein the providing the result for the query to the user device comprises incorporating the result for the query in a dialog between the user device and a skill bot and presenting the dialog on a display of the user device.
14 . One or more non-transitory computer-readable media storing instructions which, when executed by one or more processors, cause a system to perform operations comprising:
generating input information for a machine learning model configured to predict a statement, wherein the input information comprises an input prompt and a dynamic vocabulary derived from the input prompt and separate from the input prompt, wherein the dynamic vocabulary is further derived from a programming language and database schema information, and wherein a set of tokens of the dynamic vocabulary comprises one or more tokens associated with the programming language, one or more tokens associated with the database schema information, and one or more tokens associated with at least one condition of the input prompt;
predicting, using the machine learning model, an output statement for the input prompt based at least in part on the input information, wherein the output statement comprises a plurality of tokens, and wherein at least one token of the plurality of tokens is selected from the set of tokens;
executing, using the output statement, a query on a database associated with the database schema information to retrieve a result for the query; and
providing the result for the query to a user device.
15 . The one or more non-transitory computer-readable media of claim 14 , wherein the input information is first input information, wherein the input prompt is a first input prompt, wherein the set of tokens is a first set of tokens, wherein the database schema information is first database schema information, wherein the output statement is a first output statement, and wherein the plurality of tokens is a first plurality of tokens, the operations further comprising:
generating second input information for the machine learning model, wherein the second input information comprises a second input prompt and a second set of tokens, and wherein the second set of tokens comprises one or more tokens associated with the programming language, one or more tokens associated with second database schema information, and one or more tokens associated with at least one condition of the second input prompt; and
predicting, using the machine learning model, a second output statement for the second input prompt based at least in part on the second input information, wherein the second output statement comprises a second plurality of tokens, and wherein at least one token of the second plurality of tokens is selected from the second set of tokens.
16 . The one or more non-transitory computer-readable media of claim 15 , wherein a number of tokens included in the first set of tokens is different from a number of tokens in the second set of tokens.
17 . The one or more non-transitory computer-readable media of claim 14 , wherein the machine learning model comprises a vocabulary, and wherein a number of tokens included in the set of tokens is less than a number of tokens included in the vocabulary.
18 . The one or more non-transitory computer-readable media of claim 14 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt corresponds to a term included in the input prompt.
19 . The one or more non-transitory computer-readable media of claim 14 , wherein at least one token of the one or more tokens associated with the at least one condition of the input prompt is generated using a rules-based approach and/or a named-entity recognition-based approach.
20 . The computer-implemented method of claim 1 , wherein the providing the result for the query to the user device comprises incorporating the result for the query in a dialog between the user device and a skill bot and presenting the dialog on a display of the user device.