Refusal system
Certain aspects of the disclosure provide techniques for selecting functions. An example method includes receiving, as input, a user query; obtaining a plurality of function schemas that include function descriptions and examples for a plurality of functions; generating, for the user query and based on the plurality of function schemas, a plurality of similarity scores, the plurality of similarity scores including a respective set of similarity scores for each function of the plurality of functions; selecting, based on the plurality of similarity scores and a plurality of function-specific thresholds corresponding to the plurality of functions, a subset of the functions as relevant functions for the user query; generating a function plan that comprises one or more function definitions for one or more functions of the subset of the functions; and executing the function plan.
1 . A computer-implemented method for selecting functions, comprising:
receiving, as input, a user query;
obtaining a plurality of function schemas that include function descriptions and examples for a plurality of functions;
generating, for the user query and based on the plurality of function schemas, a plurality of similarity scores, the plurality of similarity scores including a respective set of similarity scores for each function of the plurality of functions;
selecting, based on the plurality of similarity scores and a plurality of function-specific thresholds corresponding to the plurality of functions, a subset of the functions as relevant functions for the user query;
generating, based on the user query and the plurality of function schemas, a function plan that comprises one or more function definitions for one or more functions of the subset of the functions; and
executing the function plan.
2 . The method of claim 1 , wherein generating the plurality of similarity scores comprises generating, for a function of the plurality of functions, multiple similarity scores; and
determining a similarity score, of the plurality of similarity scores, for the function using the multiple similarity scores.
3 . The method of claim 2 , where a first similarity score of the multiple similarity scores is for a function description of the function and a second similarity score of the multiple similarity scores is for an example of the function.
4 . The method of claim 1 , wherein the plurality of function-specific thresholds comprises a function-specific threshold for a function of the plurality of functions, wherein the function-specific threshold is based on historical data regarding user queries, similarity scores corresponding to the user queries, or selected functions corresponding to the user queries.
5 . The method of claim 1 , wherein the plurality of similarity scores are based on embeddings of the user query and embeddings of information included in the plurality of function schemas.
6 . The method of claim 5 , wherein the plurality of similarity scores comprise cosine similarity scores for the embeddings of the user query and the embeddings of the information included in the function schemas.
7 . The method of claim 1 , wherein generating the plurality of similarity scores comprises generating the plurality of similarity scores using a supervised model.
8 . The method of claim 1 , wherein generating the function plan comprises generating the function plan using a language model (LM)-based service, wherein a quantity of the subset of functions is based on a context window size of the LM-based service.
9 . The method of claim 8 , wherein generating the function plan comprises receiving, at the LM based service, information identifying the subset of functions, wherein the information identifying the subset of functions does not exceed the context window size of the LM-based service.
10 . A non-transitory computer-readable medium comprising instructions that, when executed by one or more processors of a processing system, cause the processing system to:
receive, as input, a user query;
obtain a plurality of function schemas that include function descriptions and examples for a plurality of functions;
generate, for the user query and based on the plurality of function schemas, a plurality of similarity scores, the plurality of similarity scores including a respective set of similarity scores for each function of the plurality of functions;
select, based on the plurality of similarity scores and a plurality of function-specific thresholds corresponding to the plurality of functions, a subset of the plurality of functions as relevant functions for the user query;
generate, based on the user query and the plurality of function schemas, a function plan that comprises one or more function definitions for one or more functions of the subset of the plurality of functions; and
execute the function plan.
11 . The non-transitory computer-readable medium of claim 10 , wherein generating the plurality of similarity scores comprises generating, for a function of the plurality of functions, multiple similarity scores; and
determining a similarity score, of the plurality of similarity scores, for the function using the multiple similarity scores.
12 . The non-transitory computer-readable medium of claim 11 , where a first similarity score of the multiple similarity scores is for a function description of the function and a second similarity score of the multiple similarity scores is for an example of the function.
13 . The non-transitory computer-readable medium of claim 10 , wherein the plurality of function-specific thresholds comprises a function-specific threshold for a function of the plurality of functions, wherein the function-specific threshold is based on historical data regarding user queries, similarity scores corresponding to the user queries, or selected functions corresponding to the user queries.
14 . The non-transitory computer-readable medium of claim 10 , wherein the plurality of similarity scores are based on embeddings of the user query and embeddings of information included in the plurality of function schemas.
15 . The non-transitory computer-readable medium of claim 14 , wherein the plurality of similarity scores comprise cosine similarity scores for the embeddings of the user query and the embeddings of the information included in the plurality of function schemas.
16 . The non-transitory computer-readable medium of claim 10 , wherein the instructions, to cause the processing system to generate the plurality of similarity scores, are configured to cause the processing system to generate the plurality of similarity scores using a supervised model.
17 . The non-transitory computer-readable medium of claim 10 , wherein the instructions, to cause the processing system to generate the function plan, are configured to cause the processing system to generate the function plan using a language model (LM)-based service, wherein a quantity of the subset of the functions is based on a context window size of the LM-based service.
18 . The non-transitory computer-readable medium of claim 17 , wherein the instructions, to cause the processing system to generate the function plan, are configured to cause the processing system to receive, at the LM-based service, information identifying the subset of functions, wherein the information identifying the subset of functions does not exceed the context window size of the LM-based service.
19 . A processing system comprising one or more processors and one or more memories, the one or more processors configured to cause the processing system to:
receive, as input, a user query;
obtain a plurality of function schemas that include function descriptions and examples for a plurality of functions;
generate, for the user query and based on the plurality of function schemas, a plurality of similarity scores, the plurality of similarity scores including a respective set of similarity scores for each function of the plurality of functions;
select, based on the plurality of similarity scores and a plurality of function-specific thresholds corresponding to the plurality of functions, a subset of the plurality of functions as relevant functions for the user query;
generate, based on the user query and the plurality of function schemas, a function plan that comprises one or more function definitions for one or more functions of the subset of the plurality of functions; and
execute the function plan.
20 . The processing system of claim 19 , wherein the plurality of function-specific thresholds comprises a function-specific threshold for a function of the plurality of functions, wherein the function-specific threshold is based on historical data regarding user queries, similarity scores corresponding to the user queries, or selected functions corresponding to the user queries.