Prompt generation method and device, electronic equipment and computer readable storage medium
The prompt generation method enhances the accuracy of intelligent answering systems by using unlabeled datasets and target scoring functions to improve the general language model's performance in zero-sample and few-sample scenarios, leading to more accurate prompts.
Patent Information
- Application Number
- CN202411392018.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2024-12-31
AI Technical Summary
Intelligent question-answering systems based on general language models suffer from inaccuracies in zero-sample and few-sample scenarios due to the quality and quantity of examples, leading to erroneous outputs.
A prompt generation method involving unlabeled datasets, task type information, and a target scoring function selection process to enhance the general language model's performance by generating more accurate prompts.
Improves the accuracy of intelligent answering systems in zero-sample and few-sample scenarios, providing a better user experience by generating more precise prompts.
Smart Images

Figure CN119226482A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to but are not limited to the field of financial technology, and in particular to a prompt generation method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the continuous development of social economy and the continuous advancement of science and technology, people's living standards are constantly improving. In the financial industry, intelligent question-answering systems have been increasingly used to answer questions raised by users. At present, intelligent question-answering systems are usually implemented based on general language models, which are large neural network models that can handle a variety of natural language processing tasks. General language models have certain few-sample capabilities, and can complete tasks through prompts or examples even without training data for specific tasks. However, few-sample performance is affected by the quality and quantity of examples, and is prone to produce erroneous outputs, which in turn affects the accuracy of the intelligent answering system. Summary of the invention
[0003] The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
[0004] In order to solve the problems mentioned in the above background technology, the embodiments of the present application provide a prompt generation method, device, electronic device and computer-readable storage medium, which can improve the performance of the general language model in zero-sample and few-sample scenarios, making the output more accurate, thereby improving the accuracy of the intelligent answering system and bringing users a better user experience.
[0005] In a first aspect, an embodiment of the present application provides a prompt generation method, comprising:
[0006] Obtain unlabeled dataset and task type information;
[0007] Inputting the unlabeled data set into a pre-trained general language model for inference processing to obtain candidate response information;
[0008] Concatenating the unlabeled data set with the candidate response information to obtain a candidate pseudo example;
[0009] Selecting a target scoring function from a preset selector according to the task type information;
[0010] Screening the candidate pseudo examples according to the target scoring function to obtain a target pseudo example;
[0011] The target pseudo example is predicted and processed according to the general language model to obtain prediction prompt information.
[0012] According to some embodiments of the present application, the step of inputting the unlabeled data set into a pre-trained general language model for inference processing to obtain candidate response information includes:
[0013] Preprocessing the unlabeled data set to obtain preprocessed data;
[0014] Converting the preprocessed data into multidimensional vector data;
[0015] The multi-dimensional vector data is input into the self-attention mechanism network model of the universal language model for parallel computing processing to obtain the candidate response information.
[0016] According to some embodiments of the present application, selecting a target scoring function from a preset selector according to the task type information includes one of the following:
[0017] In a case where the task type information is classification task information, determining the negative entropy scoring function in the selector as the target scoring function;
[0018] In a case where the task type information is short text generation task information, determining the consistency scoring function in the selector as the target scoring function;
[0019] In a case where the task type information is long text generation task information, the bilingual evaluation scoring function in the selector is determined as the target scoring function.
[0020] According to some embodiments of the present application, when the target scoring function is the negative entropy scoring function, the step of screening the candidate pseudo examples according to the target scoring function to obtain the target pseudo examples includes:
[0021] Performing a category probability calculation process on each pseudo example in the candidate pseudo examples based on the negative entropy scoring function to obtain a first scoring value, wherein the first scoring value corresponds to the pseudo example one by one;
[0022] The pseudo example having the highest first score value is used as the target pseudo example.
[0023] According to some embodiments of the present application, when the target scoring function is the consistency scoring function, the step of screening the candidate pseudo examples according to the target scoring function to obtain the target pseudo examples includes:
[0024] Performing cosine similarity calculation processing on each pseudo example in the candidate pseudo examples based on the consistency scoring function to obtain a second scoring value, wherein the second scoring value corresponds to the pseudo example one by one;
[0025] The pseudo example with the highest second score value is used as the target pseudo example.
[0026] According to some embodiments of the present application, when the bilingual evaluation scoring function is the target scoring function, the screening process of the candidate pseudo-examples according to the target scoring function to obtain the target pseudo-examples includes:
[0027] Based on the bilingual evaluation scoring function, an evaluation index calculation process is performed on each pseudo example in the candidate pseudo examples to obtain a third scoring value, wherein the third scoring value corresponds to the pseudo example one by one;
[0028] The pseudo example having the highest third score value is taken as the target pseudo example.
[0029] According to some embodiments of the present application, performing prediction processing on the target pseudo example according to the general language model to obtain prediction prompt information includes:
[0030] Extracting features of the target pseudo-example to obtain pseudo-example feature information;
[0031] Performing pooling processing on the pseudo-example feature information to obtain dimension-reduced feature information;
[0032] The dimension reduction feature information is subjected to classification prediction processing to obtain the prediction prompt information.
[0033] In a second aspect, an embodiment of the present application further provides a prompt generating device, the device comprising:
[0034] The first processing module is used to obtain unlabeled data sets and task type information;
[0035] A second processing module is used to input the unlabeled data set into a pre-trained general language model for reasoning processing to obtain candidate response information;
[0036] A third processing module is used to concatenate the unlabeled data set with the candidate response information to obtain a candidate pseudo example;
[0037] A fourth processing module, used for selecting a target scoring function from a preset selector according to the task type information;
[0038] A fifth processing module, configured to screen the candidate pseudo examples according to the target scoring function to obtain a target pseudo example;
[0039] The sixth processing module is used to perform prediction processing on the target pseudo example according to the general language model to obtain prediction prompt information.
[0040] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the prompt generation method as described in the first aspect above is implemented.
[0041] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the prompt generation method as described in the first aspect above.
[0042] The prompt generation method according to the embodiment provided in the present application has at least the following beneficial effects: in the process of prompt generation, firstly, an unlabeled data set and task type information are obtained; then, the unlabeled data set is input into a pre-trained general language model for inference processing to obtain candidate response information; then, the unlabeled data set and the candidate response information are concatenated to obtain candidate pseudo-examples; then, a target scoring function is selected from a preset selector according to the task type information; then, the obtained candidate pseudo-examples are screened according to the target scoring function to obtain the target pseudo-examples; finally, the target pseudo-examples are predicted according to the general language model to obtain predicted prompt information; through the above technical scheme, a target scoring function is selected from a preset selector based on the task type information, and then, the target pseudo-examples can be screened according to the corresponding target scoring function to obtain the target pseudo-examples, and finally, the target pseudo-examples can be predicted using the general language model to obtain the corresponding predicted prompt information, so that the generation of prompt information can be more accurate, thereby improving the accuracy of the intelligent answering system, bringing users a better user experience, and also improving the performance of the general language model in zero-sample and few-sample scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0044] Figure 1 is a flowchart of a prompt generation method provided by an embodiment of the present application;
[0045] Figure 2 is a specific flow chart of step S200 provided in one embodiment of the present application;
[0046] Figure 3 is a specific flow chart of step S400 provided in one embodiment of the present application;
[0047] Figure 4 is a specific flow chart of step S500 provided in one embodiment of the present application;
[0048] Figure 5 is a specific flow chart of step S500 provided in another embodiment of the present application;
[0049] Figure 6 is a specific flow chart of step S500 provided in another embodiment of the present application;
[0050] Figure 7 is a specific flow chart of step S600 provided in one embodiment of the present application;
[0051] Figure 8 is a schematic diagram of a prompt generating device provided by an embodiment of the present application;
[0052] Fig. 9 It is a schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] It should be noted that although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification and claims and the above drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0055] It should be noted that, unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0057] AI is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. Artificial intelligence is a branch of computer science. Artificial intelligence attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robots, language recognition, image recognition, natural language processing and expert systems. Artificial intelligence can simulate the information process of human consciousness and thinking. Artificial intelligence is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0058] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0059] Artificial intelligence is AI. AI is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0060] The servers involved in artificial intelligence technology can be independent servers or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0061] The present application provides a prompt generation method, device, electronic device and computer-readable storage medium. In the process of prompt generation, first, an unlabeled data set and task type information are obtained; then, the unlabeled data set is input into a pre-trained general language model for inference processing to obtain candidate response information; then, the unlabeled data set and the candidate response information are spliced to obtain candidate pseudo examples; then, a target scoring function is selected from a preset selector according to the task type information; then, the obtained candidate pseudo examples are screened according to the target scoring function to obtain the target pseudo examples; finally, the target pseudo examples are predicted according to the general language model to obtain predicted prompt information; through the above technical solution, a target scoring function is selected from a preset selector based on the task type information, and then the target pseudo examples can be screened according to the corresponding target scoring function to obtain the target pseudo examples, and finally, the target pseudo examples can be predicted using the general language model to obtain the corresponding predicted prompt information, so that the generation of prompt information can be more accurate, thereby improving the accuracy of the intelligent answering system, bringing users a better user experience, and also improving the performance of the general language model in zero-sample and few-sample scenarios.
[0062] The prompt generation method provided in the embodiment of the present application relates to the field of financial technology. The prompt generation method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the prompt generation method, etc., but is not limited to the above forms.
[0063] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0064] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0065] The embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0066] like Figure 1 As shown, Figure 1 It is a flowchart of a prompt generation method provided by an embodiment of the present application, and the prompt generation method includes but is not limited to steps S100 to S600.
[0067] Step S100, obtaining unlabeled data set and task type information;
[0068] Step S200, inputting the unlabeled data set into a pre-trained general language model for inference processing to obtain candidate response information;
[0069] Step S300, concatenating the unlabeled data set with the candidate response information to obtain a candidate pseudo example;
[0070] Step S400, selecting a target scoring function from a preset selector according to task type information;
[0071] Step S500, screening candidate pseudo examples according to a target scoring function to obtain a target pseudo example;
[0072] Step S600: predict the target pseudo example according to the general language model to obtain prediction prompt information.
[0073] It should be noted that, in the process of prompt generation, first obtain an unlabeled dataset and task type information; then input the unlabeled dataset into the pre-trained general language model for inference processing to obtain candidate response information; then concatenate the unlabeled dataset and the candidate response information to obtain candidate pseudo-examples; then select the target scoring function from the preset selector according to the task type information; then filter the obtained candidate pseudo-examples according to the target scoring function to obtain the target pseudo-examples; finally, predict the target pseudo-examples according to the general language model to obtain predicted prompt information; through the above technical solution, the target scoring function is selected from the preset selector based on the task type information, and then the target pseudo-examples can be filtered according to the corresponding target scoring function, and finally the target pseudo-examples can be predicted using the general language model to obtain the corresponding predicted prompt information, so that the generation of prompt information can be more accurate, thereby improving the accuracy of the intelligent answering system, bringing users a better user experience, and also improving the performance of the general language model in zero-sample and few-sample scenarios.
[0074] It is worth noting that the unlabeled data set in the embodiment of the present application can be obtained by converting the intelligent question-answering system of the financial industry. When the user asks the intelligent question-answering system about relevant questions, the intelligent question-answering system will convert the recognized voice signal into an unlabeled data set through the voice recognition function; and in the process of obtaining the unlabeled data set, the user's permission or consent will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or separate consent will be obtained through a pop-up window or jump to a confirmation page. After clearly obtaining the user's separate permission or separate consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained. And the unlabeled data set corresponds to the task type information, and each unlabeled data set corresponds to the task type information one by one. For example, when the user asks the intelligent question-answering system about insurance classification, the task type information corresponding to the obtained unlabeled data set is characterized as a classification task.
[0075] It is worth noting that a general language model refers to an artificial intelligence model that can understand and generate natural language text. This model learns from a large amount of text data and masters the laws and structure of the language, so that it can perform a variety of language processing tasks such as language understanding, generation, translation, and summarization. The characteristics of the general language model include: the ability to handle various types of text and language tasks; automatic learning and extraction of language laws from data through machine learning algorithms; the ability to understand the contextual meaning of the text and perform more accurate language processing; continuous evolution: with the increase of training data and the improvement of algorithms, the performance of the model will continue to improve; general language models have a wide range of applications in the field of natural language processing, such as chatbots, voice assistants, text analysis, automatic translation, etc.; with the development of technology, these models are increasingly able to simulate human language understanding and generation capabilities. General language models play a variety of important roles in the fields of artificial intelligence and natural language processing. The following are some key application scenarios: helping machines understand the meaning of text, including sentiment analysis, topic identification, intent recognition, etc.; generating natural and fluent text for chatbots, content creation, automatic replies, etc.; translating text from one language into another language to improve the efficiency of cross-language communication; automatically generating summaries of text to help users quickly understand the main content of the text; building intelligent question-and-answer systems that can understand users' questions and provide accurate answers; classifying text, such as spam identification, news article classification, etc.; combining with speech recognition technology to improve the accuracy of speech-to-text conversion; improving search engine search results and providing more relevant content; helping users check grammatical errors, provide writing suggestions, automatically complete sentences, etc.; as a teaching aid to help students learn language and writing; analyzing large amounts of text data to provide information support for decision makers; recommending relevant content based on users' reading habits and preferences.
[0076] It is worth noting that in deep learning and machine learning, the preset selector is used to select specific samples or entities from the data set for further processing or analysis; the objective function is the key to evaluating the performance of the model, which defines the optimization goal in the model training process. Among them, in machine learning, the objective function is used to evaluate the performance of the model. Common objective functions include mean square error, cross entropy loss function, hinge loss function, log likelihood loss function, etc. The choice of objective function depends on the specific task, such as classification, regression or reinforcement learning. In an embodiment of the present application, the unlabeled data set is input into the general language model for reasoning to obtain candidate response information; then the unlabeled data set and the candidate response information are spliced to obtain candidate pseudo-examples; then the target scoring function can be selected from the preset selector according to the task type information; then the candidate pseudo-examples are screened according to the target scoring function to obtain the target pseudo-examples; finally, the target pseudo-examples are predicted according to the general language model to obtain the prediction prompt information. In the above manner, the generation of prompt information can be more accurate. And the prediction prompt information can be generated based on the unlabeled data set, which greatly improves the performance of the general language model in zero-sample and few-sample scenarios.
[0077] It should be noted that for different task type information, the corresponding target scoring function can be selected from the preset selector, and then the target scoring function can be used to screen the candidate pseudo-examples to obtain the target pseudo-examples, and finally the target pseudo-examples can be predicted and processed according to the general language model to obtain the corresponding prediction prompt information, so that the prompt generation can be more accurate. Exemplarily, when a user asks the intelligent question-answering system about fund classification, the target scoring function can be selected from the selector according to the classification task, and then the candidate pseudo-examples can be screened and processed according to the target scoring function to obtain the target pseudo-examples, and finally the target pseudo-examples can be predicted and processed according to the general language model to obtain the corresponding prediction prompt information to answer the fund classification question asked by the user.
[0078] In some embodiments, Figure 2 As shown, the above step S200 may include but is not limited to steps S210 to S230.
[0079] Step S210, preprocessing the unlabeled data set to obtain preprocessed data;
[0080] Step S220, converting the preprocessed data into multi-dimensional vector data;
[0081] Step S230, input the multi-dimensional vector data into the self-attention mechanism network model of the general language model for parallel computing processing to obtain candidate response information.
[0082] It should be noted that, in the process of inputting the unlabeled dataset into the pre-trained general language model for inference processing to obtain candidate response information, the unlabeled dataset is first preprocessed to obtain preprocessed data; then the preprocessed data is converted into multi-dimensional vector data; finally, the multi-dimensional vector data can be input into the self-attention mechanism network model of the general language model for parallel calculation processing to obtain the candidate response information. After obtaining the candidate response information, the prerequisite preparation for candidate pseudo-example generation can be made.
[0083] It is worth noting that preprocessing the unlabeled dataset can obtain preprocessed data, which is a prerequisite for subsequent vector conversion; then the preprocessed data is converted into multi-dimensional vector data to meet the input requirements of the self-attention mechanism network model; the multi-dimensional vector data is input into the self-attention mechanism network model of the general language model for parallel calculation processing to obtain the corresponding candidate response information.
[0084] It is worth noting that the self-attention network model, especially the Transformer architecture, has become a milestone in the field of natural language processing and deep learning. The core of this model is that it can capture long-range dependencies in sequence data and can process data in parallel, which is a significant advantage over traditional recurrent neural networks and long short-term memory networks. The Transformer model consists of an encoder and a decoder, both of which use the self-attention mechanism. The encoder converts the input sequence into a continuous representation, while the decoder generates an output sequence based on this representation. The self-attention mechanism allows the model to calculate attention scores on each element in the sequence. These scores indicate the relevance of other elements in the sequence to the current element. In the self-attention mechanism, each input element is converted into a query, key, and value vector. The model then calculates the dot product of the query vector with all key vectors to obtain an attention score matrix; this score matrix is normalized by the softmax function to obtain the attention weight of each element. Finally, these weights are multiplied with the value vector to obtain the weighted output representation. The advantage of the self-attention mechanism is that it can process sequences of arbitrary length, capture long-distance dependencies, and has a high degree of parallelism; these characteristics have enabled the self-attention mechanism to achieve significant performance improvements in natural language processing tasks such as machine translation, text summarization, named entity recognition, etc. In addition, the self-attention mechanism has also been applied in the field of computer vision, such as in image classification and object detection tasks, to improve the accuracy of the model by focusing on key areas in the image.
[0085] In some embodiments, Figure 3 As shown, the above step S400 may include but is not limited to step S410 to step S430.
[0086] Step S410, when the task type information is classification task information, determining the negative entropy scoring function in the selector as the target scoring function;
[0087] Step S420, when the task type information is short text generation task information, determining the consistency scoring function in the selector as the target scoring function;
[0088] Step S430: When the task type information is long text generation task information, the bilingual evaluation scoring function in the selector is determined as the target scoring function.
[0089] It should be noted that, in the process of selecting the target scoring function from the preset selector according to the task type information, when the task type information is classification task information, the negative entropy scoring function in the selector can be determined as the target scoring function; when the task type information is short text generation task information, the consistency scoring function in the selector can be determined as the target scoring function; when the task type information is long text task information, the bilingual evaluation function in the selector can be determined as the target scoring function; for different task type information, different target scoring functions can be selected, so as to better adapt to the prompt information generation of different tasks, so that the generated prompt information can be more accurate.
[0090] It is worth noting that the task type information can be classified task information. For example, when a user asks the intelligent question and answer system "What is the specific annual interest rate for different deposit methods", the intelligent question and answer system can generate classified task information; or, when a user asks the intelligent system "What is a bond", the intelligent question and answer system can generate short text generation task information; or, when a user asks the intelligent system "What is the specific process of purchasing insurance", the intelligent question and answer system can generate long text generation task information.
[0091] It is worth noting that for classification tasks, negative entropy is used as the scoring function. This is because in classification tasks, the model's prediction of the category is as certain as possible, that is, the category probability distribution is as concentrated as possible. For short text generation tasks, consistency is used as the scoring function. This is because in short text generation tasks, the output of the model is as stable as possible, that is, the responses obtained by multiple decodings are as similar as possible. For long text generation tasks, a bilingual evaluation scoring function is used as the scoring function. This is because in long text generation tasks, the responses generated by the model are as relevant or appropriate as possible to the unlabeled query.
[0092] In some embodiments, Figure 4 As shown, in the case where the target scoring function is a negative entropy scoring function, the above step S500 may include but is not limited to steps S510 to S520.
[0093] Step S510, performing category probability calculation processing on each pseudo example in the candidate pseudo examples based on the negative entropy scoring function to obtain a first scoring value, wherein the first scoring value corresponds to the pseudo example one by one;
[0094] Step S520: taking the pseudo example with the highest first score as the target pseudo example.
[0095] It should be noted that, in the process of screening candidate pseudo-examples according to the target scoring function to obtain the target pseudo-example, the first scoring value can be obtained by first calculating the category probability of each pseudo-example in the candidate pseudo-examples based on the negative entropy scoring function, and the first scoring value corresponds to the pseudo-example one by one; then, the pseudo-example with the highest first scoring value is used as the target pseudo-example to facilitate the subsequent prompt information generation process for the classification task.
[0096] It is worth noting that the meaning of the negative entropy scoring function is to select candidate pseudo-examples for which the zero-shot model is relatively certain about the category prediction, that is, when the category probability distribution is relatively concentrated. Negative entropy is an indicator to measure the uncertainty of probability distribution. When the probability distribution is more concentrated, the negative entropy is larger, and vice versa. Therefore, the candidate pseudo-example with the largest negative entropy is selected as the best prompt. In order to ensure the coverage of the category space, it is also necessary to consider that at least one candidate pseudo-example is selected for each category, so as to avoid certain categories being ignored or over-represented. Therefore, when selecting a candidate pseudo-example, it will be checked whether the category it belongs to has been selected. If so, it will be skipped. If not, it will be added to the final prompt set.
[0097] In some embodiments, Figure 5 As shown, in the case where the target scoring function is a consistency scoring function, the above step S500 may include but is not limited to steps S530 to S540.
[0098] Step S530, performing cosine similarity calculation processing on each pseudo example in the candidate pseudo examples based on the consistency scoring function to obtain a second scoring value, wherein the second scoring value corresponds to the pseudo example one by one;
[0099] Step S540: taking the pseudo example with the highest second score as the target pseudo example.
[0100] It should be noted that, in the process of screening the candidate pseudo-examples according to the target scoring function to obtain the target pseudo-example, the second scoring value can be obtained by first performing cosine similarity calculation on each pseudo-example in the candidate pseudo-examples based on the consistency scoring function, and the second scoring value corresponds to the pseudo-example one-to-one; then, the pseudo-example with the highest second scoring value is used as the target pseudo-example to facilitate the subsequent prompt information generation process for the short text generation task.
[0101] It is worth noting that the meaning of the consistency scoring function is to select candidate pseudo-examples that are relatively stable in generating responses for the zero-shot model, that is, when the responses obtained from multiple decodings are relatively similar. Consistency is an indicator to measure the stability of the model output. When the responses obtained from multiple decodings are more similar, the consistency is higher, and vice versa. Therefore, the candidate pseudo-example with the highest consistency is selected as the best hint. In order to calculate the consistency, it is necessary to decode each unlabeled query multiple times to obtain different responses. This is because in the generation task, the output of the model is random, and even for the same input, each decoding may obtain a different output. In order to introduce randomness, temperature sampling is used as the decoding strategy, that is, at each time step, a word is sampled as the output according to the probability distribution of the model output and a temperature parameter. The temperature parameter can control the diversity of the output. When the temperature is higher, the output is more diverse, and when the temperature is lower, the output is more certain; a fixed temperature parameter and a fixed number of decodings are used for multiple decodings.
[0102] In some embodiments, Figure 6 As shown, in the case where the target scoring function is a bilingual assessment scoring function, the above step S500 may include but is not limited to steps S550 to S560.
[0103] Step S550, performing evaluation index calculation processing on each pseudo example in the candidate pseudo examples based on the bilingual evaluation scoring function to obtain a third scoring value, wherein the third scoring value corresponds to the pseudo example one-to-one;
[0104] Step S560: taking the pseudo example with the highest third score as the target pseudo example.
[0105] It should be noted that, in the process of screening the candidate pseudo-examples according to the target scoring function to obtain the target pseudo-example, the third scoring value can be obtained by first calculating the evaluation index of each pseudo-example in the candidate pseudo-examples based on the bilingual evaluation scoring function, and the third scoring value corresponds to the pseudo-example one by one; then, the pseudo-example with the highest third scoring value is used as the target pseudo-example to facilitate the subsequent prompt information generation process for the long text generation task.
[0106] It is worth noting that the meaning of the bilingual evaluation scoring function is to select candidate pseudo examples whose responses generated by the zero-shot model are more relevant or more appropriate to the unlabeled query. The evaluation index is a measure of the quality and relevance between the generated text and the reference text. When the generated text is more consistent with the requirements of the reference text, the evaluation index is higher, and vice versa. Therefore, the candidate pseudo example with the highest evaluation index is selected as the best hint.
[0107] In some embodiments, Figure 7As shown, the above step S600 may include but is not limited to step S610 to step S630.
[0108] Step S610, extracting features from the target pseudo-example to obtain pseudo-example feature information;
[0109] Step S620, performing pooling processing on the pseudo-example feature information to obtain dimension-reduced feature information;
[0110] Step S630: performing classification prediction processing on the dimension reduction feature information to obtain prediction prompt information.
[0111] It should be noted that in the process of predicting the target pseudo-example according to the general language model to obtain the prediction prompt information, the target pseudo-example is firstly subjected to feature extraction to obtain the pseudo-example feature information; then the pseudo-example feature information is pooled to obtain the dimension reduction feature information; subsequently, the dimension reduction feature information can be classified and predicted to obtain the prediction prompt information. Through the above technical solution, the target pseudo-example can be predicted using the general language model to obtain the corresponding prediction prompt information; through the above method, the generation of prompt information can be more accurate.
[0112] It is worth noting that the above technical solutions have improved the performance of the general language model in zero-shot and few-shot scenarios, enabling it to handle more types and more complex natural language processing tasks without the need for additional training data or computing resources. The ability of the general language model to migrate between different tasks has been improved, enabling it to adaptively generate appropriate prompts and pseudo-examples based on the task type without the need for human intervention or expertise. The reliability and interpretability of the general language model in generating high-quality output has been improved, enabling it to select the best pseudo-examples based on indicators such as confidence, diversity, and consistency without the need for true labels or other supervisory information.
[0113] In addition, if Figure 8 As shown, an embodiment of the present application further provides a prompt generating device 10, comprising:
[0114] The first processing module 100 is used to obtain an unlabeled data set and task type information;
[0115] The second processing module 200 is used to input the unlabeled data set into the pre-trained general language model for inference processing to obtain candidate response information;
[0116] The third processing module 300 is used to concatenate the unlabeled data set with the candidate response information to obtain a candidate pseudo example;
[0117] The fourth processing module 400 is used to select a target scoring function from a preset selector according to the task type information;
[0118] A fifth processing module 500 is used to screen the candidate pseudo examples according to the target scoring function to obtain a target pseudo example;
[0119] The sixth processing module 600 is used to perform prediction processing on the target pseudo example according to the general language model to obtain prediction prompt information.
[0120] It should be noted that, in the process of prompt generation, first obtain an unlabeled dataset and task type information; then input the unlabeled dataset into the pre-trained general language model for inference processing to obtain candidate response information; then concatenate the unlabeled dataset and the candidate response information to obtain candidate pseudo-examples; then select the target scoring function from the preset selector according to the task type information; then filter the obtained candidate pseudo-examples according to the target scoring function to obtain the target pseudo-examples; finally, predict the target pseudo-examples according to the general language model to obtain predicted prompt information; through the above technical solution, the target scoring function is selected from the preset selector based on the task type information, and then the target pseudo-examples can be filtered according to the corresponding target scoring function, and finally the target pseudo-examples can be predicted using the general language model to obtain the corresponding predicted prompt information, so that the generation of prompt information can be more accurate, thereby improving the accuracy of the intelligent answering system, bringing users a better user experience, and also improving the performance of the general language model in zero-sample and few-sample scenarios.
[0121] The specific implementation of the prompt generating device 10 is substantially the same as the specific implementation of the prompt generating method described above, and will not be described in detail herein.
[0122] In addition, if Fig. 9 As shown, an embodiment of the present application further provides an electronic device 700 , which includes: a memory 720 , a processor 710 , and a computer program stored in the memory 720 and executable on the processor 710 .
[0123] The processor 710 and the memory 720 may be connected via a bus or in other ways.
[0124] The non-transitory software programs and instructions required to implement the prompt generation methods of the above embodiments are stored in the memory 720 , and when executed by the processor 710 , the prompt generation methods of the above embodiments are executed.
[0125] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are executed by a processor 710 or a controller, for example, by a processor 710 in the above-mentioned device embodiment, so that the above-mentioned processor 710 can execute the prompt generation method in the above-mentioned embodiment.
[0127] The above embodiments may be used in combination, and modules with the same name in different embodiments may be the same or different.
[0128] The above describes specific embodiments of the present application, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0129] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0130] The apparatus, device, computer-readable storage medium and method provided in the embodiments of the present application correspond to each other. Therefore, the apparatus, device and non-volatile computer storage medium also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding apparatus, device and computer storage medium will not be repeated here.
[0131] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask chip manufacturers to design and produce dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs. The original code before compilation must also be written in a specific programming language, which is called Hardware Description Language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Basic Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCall, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used one is VHDL (Very-High-Speed Integrated Circuit Hardware Description Language). Those skilled in the art should also be aware that by programming the method flow in the above-mentioned hardware description languages and programming it into an integrated circuit, a hardware circuit for implementing the logic method flow can be easily obtained.
[0132] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the means for realizing various functions may be regarded as both a software module for realizing the method and a structure within a hardware component.
[0133] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0134] For the convenience of description, the above devices are described in terms of functions and are divided into various units. Of course, when implementing the embodiments of the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the embodiments of the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the embodiments of the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0136] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0139] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0140] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash memory (Flash RAM). The memory is an example of a computer-readable medium.
[0141] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (Transitory Med ia), such as modulated data signals and carrier waves.
[0142] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0143] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0144] Embodiments of the present application may be described in the general context of computer executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. Embodiments of the present application may also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0145] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A prompt generation method, characterized in that: The method comprises: Obtain unlabeled dataset and task type information; Inputting the unlabeled data set into a pre-trained general language model for inference processing to obtain candidate response information; Concatenating the unlabeled data set with the candidate response information to obtain a candidate pseudo example; Selecting a target scoring function from a preset selector according to the task type information; Screening the candidate pseudo examples according to the target scoring function to obtain a target pseudo example; The target pseudo example is predicted and processed according to the general language model to obtain prediction prompt information.
2. The prompt generation method according to claim 1, characterized in that: The step of inputting the unlabeled data set into a pre-trained general language model for inference processing to obtain candidate response information includes: Preprocessing the unlabeled data set to obtain preprocessed data; Converting the preprocessed data into multidimensional vector data; The multi-dimensional vector data is input into the self-attention mechanism network model of the universal language model for parallel computing processing to obtain the candidate response information.
3. The prompt generation method according to claim 1, characterized in that: The selecting a target scoring function from a preset selector according to the task type information includes one of the following: In a case where the task type information is classification task information, determining the negative entropy scoring function in the selector as the target scoring function; In a case where the task type information is short text generation task information, determining the consistency scoring function in the selector as the target scoring function; In a case where the task type information is long text generation task information, the bilingual evaluation scoring function in the selector is determined as the target scoring function.
4. The prompt generation method according to claim 3, characterized in that: In the case where the target scoring function is the negative entropy scoring function, the step of screening the candidate pseudo examples according to the target scoring function to obtain the target pseudo examples includes: Performing a category probability calculation process on each pseudo example in the candidate pseudo examples based on the negative entropy scoring function to obtain a first scoring value, wherein the first scoring value corresponds to the pseudo example one by one; The pseudo example having the highest first score value is used as the target pseudo example.
5. The prompt generation method according to claim 3, characterized in that: In the case where the target scoring function is the consistency scoring function, the step of screening the candidate pseudo examples according to the target scoring function to obtain the target pseudo examples includes: Performing cosine similarity calculation processing on each pseudo example in the candidate pseudo examples based on the consistency scoring function to obtain a second scoring value, wherein the second scoring value corresponds to the pseudo example one by one; The pseudo example with the highest second score value is used as the target pseudo example.
6. The prompt generation method according to claim 3, characterized in that: In the case where the bilingual evaluation scoring function is the target scoring function, the step of screening the candidate pseudo examples according to the target scoring function to obtain the target pseudo examples includes: Performing evaluation index calculation processing on each pseudo example in the candidate pseudo examples based on the bilingual evaluation scoring function to obtain a third scoring value, wherein the third scoring value corresponds to the pseudo example one by one; The pseudo example having the highest third score value is taken as the target pseudo example.
7. The prompt generation method according to claim 1, characterized in that: The step of performing prediction processing on the target pseudo example according to the general language model to obtain prediction prompt information includes: Extracting features of the target pseudo-example to obtain pseudo-example feature information; Performing pooling processing on the pseudo-example feature information to obtain dimension-reduced feature information; The dimension reduction feature information is subjected to classification prediction processing to obtain the prediction prompt information.
8. A prompt generating device, characterized in that: include: The first processing module is used to obtain unlabeled data sets and task type information; A second processing module is used to input the unlabeled data set into a pre-trained general language model for reasoning processing to obtain candidate response information; A third processing module is used to concatenate the unlabeled data set with the candidate response information to obtain a candidate pseudo example; A fourth processing module, used for selecting a target scoring function from a preset selector according to the task type information; A fifth processing module, configured to screen the candidate pseudo examples according to the target scoring function to obtain a target pseudo example; The sixth processing module is used to perform prediction processing on the target pseudo example according to the general language model to obtain prediction prompt information.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the prompt generating method as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing computer-executable instructions, characterized in that: The computer executable instructions are used to execute the prompt generating method as described in any one of claims 1 to 7.
Citation Information
Cited By
Text generation method and electronic equipment
CN120012727A