Prompt word generation method, prompt word-based dialogue method and related device
By adjusting the prompt words of the natural language dialogue model, the problem of long training time and high cost of large models in dialogue tasks in the field of network security is solved, efficient and accurate dialogue task execution is achieved, and training resource consumption is reduced.
Patent Information
- Application Number
- CN202311028838.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-02-25
AI Technical Summary
When existing natural language processing models perform dialogue tasks in the field of network security, they have a long training time, high cost and require a large number of sample texts, which makes it unrealistic to train the model itself.
By extracting multiple sample Q&A pairs about the target domain and adjusting the initial prompt words using the natural language dialogue model until the preset conditions are met, the target prompt words are generated to instruct the model to generate answer text related to the target domain.
It realizes that without directly training model parameters, the efficiency and accuracy of natural language dialogue models in different fields can be improved, and the consumption of training resources and training time is reduced.
Smart Images

Figure CN119513237A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a prompt word generation method, a prompt word-based dialogue method, and related devices. Background Art
[0002] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. With the popularity of Chat Generative Pre-trained Transformer (chatGPT) on social media, large models with huge parameter counts have attracted more and more attention, and larger models usually have better performance. For example, the GPT-3 model has 175 billion parameters, while the GPT-4 model has an even larger parameter scale. These models are applied in the field of Natural Language Processing (NLP), can understand and generate human language, and perform well in tasks such as text translation, question-answering systems, and language generation.
[0003] The method in which users use the big model of this type of natural language processing sample to process dialogue tasks is usually to input the question text into the big model in the form of asking questions, so as to obtain the answer text corresponding to the question text as the dialogue result. For example, the user inputs the question text "What is a crawler?" into the big model, and obtains the answer text "A crawler is a program that automatically obtains web page content" or "A crawler is a vertebrate" output by the big model as the dialogue result. When the user wants the big model to perform dialogue tasks in the field of network security, that is, to hope that the big model outputs the answer text "A crawler is a program that automatically obtains web page content" as the dialogue result, if the user wants to train the big model itself, the training time will be too long, the training cost will be high, and the sample text required for training will be too much. The method of training the big model itself is not very realistic.
[0004] Therefore, the prompt word mechanism came into being. Specifically, when the user inputs the question text into the big model in the form of a question, he also inputs the prompt word, and the prompt word instructs the big model to obtain a more accurate answer text. The prompt word can improve the expressiveness of the big model of natural language processing, and it does not need to modify the parameters of the big model itself, and the big model can also perform dialogue tasks in various fields. Summary of the invention
[0005] The embodiment of the present application provides a prompt word generation method, a prompt word-based dialogue method and a related device, which can efficiently generate a target prompt word, and the target prompt word indicates that the natural language dialogue model generates a high accuracy answer text corresponding to the question text. The technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a prompt word generation method, the prompt word generation method comprising:
[0007] Acquire a plurality of sample question-answer pairs about the target domain, wherein the sample question-answer pairs include a question sample text and an answer sample text;
[0008] According to the initial prompt word and the plurality of the question sample texts, obtaining answer training texts corresponding to the question sample texts through a natural language dialogue model;
[0009] According to the plurality of answer training texts and the plurality of answer sample texts, the initial prompt word is adjusted until a target prompt word is obtained when a preset condition is met.
[0010] In a second aspect, an embodiment of the present application provides a conversation method based on prompt words, and the conversation method based on prompt words includes:
[0011] Obtaining a question text and a target prompt word, wherein the target prompt word is obtained by the prompt word generation method described above;
[0012] According to the question text and the target prompt word, an answer text corresponding to the question text is obtained through a natural language dialogue model, and the answer text is related to the target field corresponding to the target prompt word.
[0013] In a third aspect, an embodiment of the present application provides a prompt word generation device, the prompt word generation device comprising:
[0014] A sample acquisition module, used to acquire a plurality of sample question-answer pairs about a target domain, wherein the sample question-answer pairs include a question sample text and an answer sample text;
[0015] An answer generation module is used to obtain answer training texts corresponding to the question sample texts through a natural language dialogue model according to the initial prompt word and the multiple question sample texts;
[0016] The target adjustment module is used to adjust the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until a target prompt word is obtained when a preset condition is met.
[0017] In a fourth aspect, an embodiment of the present application provides a dialogue device based on prompt words, and the dialogue device based on prompt words includes:
[0018] A question acquisition module, used to acquire question text and target prompt words, wherein the target prompt words are obtained by the prompt word generation method described above;
[0019] The answer acquisition module is used to obtain the answer text corresponding to the question text through a natural language dialogue model according to the question text and the target prompt word, and the answer text is related to the target field corresponding to the target prompt word.
[0020] In a fifth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.
[0021] In a sixth aspect, an embodiment of the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.
[0022] The beneficial effects brought about by the technical solutions provided by some embodiments of the present application include at least:
[0023] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 It is a flowchart of a natural language dialogue model performing a dialogue task provided by an embodiment of the present application;
[0026] Figure 2It is a flowchart of a prompt word generation method provided in an embodiment of the present application;
[0027] Figure 3 It is a flowchart of obtaining multiple sample question-answer pairs provided in an embodiment of the present application;
[0028] Figure 4 It is a flowchart of a prompt word generation method provided in an embodiment of the present application;
[0029] Figure 5 It is a flowchart of another prompt word generation method provided in an embodiment of the present application;
[0030] Figure 6 It is a flowchart of a dialogue method based on prompt words provided in an embodiment of the present application;
[0031] Figure 7 It is a structural schematic diagram of a prompt word generating device provided in an embodiment of the present application;
[0032] Figure 8 It is a structural diagram of a dialogue device based on prompt words provided in an embodiment of the present application;
[0033] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.
[0036] The present application is described in detail below with reference to specific embodiments.
[0037] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the sample data and user information involved in this application are all obtained with full authorization.
[0038] Natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language people use in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies.
[0039] As Chat Generative Pre-trained Transformer (chatGPT) has become popular on social media, large models with huge parameter counts have attracted more and more attention, and larger models usually have better performance. For example, the GPT-3 model has 175 billion parameters, while the GPT-4 model has an even larger parameter scale. These models are applied in the field of Natural Language Processing (NLP), can understand and generate human language, and perform well in tasks such as text translation, question-answering systems, and language generation.
[0040] The method in which users use this type of natural language processing large model to handle dialogue tasks is usually to input question text into the large model in the form of asking questions, so as to obtain the answer text corresponding to the question text as the dialogue result. For example, the user inputs the question text "What is a crawler?" into the large model, and obtains the answer text "A crawler is a program that automatically obtains web page content" or "A crawler is a vertebrate" output by the large model as the dialogue result. When the user wants the large model to perform dialogue tasks in the field of network security, that is, to want the large model to output the answer text "A crawler is a program that automatically obtains web page content" as the dialogue result, if the user wants to train the large model itself, the training time will be too long, the training cost will be high, and the sample text required for training will be too much. The method of training the large model itself is not very realistic.
[0041] Therefore, the prompt mechanism came into being. Specifically, when the user inputs the question text into the big model in the form of asking questions, he also inputs the prompt word, which instructs the big model through the prompt word, so as to obtain a more accurate answer text. Figure 1 As shown, Figure 1 It is a flow chart of a natural language dialogue model performing a dialogue task provided by an embodiment of the present application. When a question text 102 is input into a natural language dialogue model 103, a prompt word 101 is also input, so as to obtain an answer text 104 corresponding to the input question text 102 output by the natural language dialogue model 103. For example, the content of the prompt word 101 is "You are an expert in the field of network security", and the prompt word 101 is related to the field of network security. The content of the question text 102 is "What is a crawler?", and the probability that the content of the answer text 104 generated by the natural language dialogue model 103 is "A crawler is a program that automatically obtains web page content" is higher than the probability of generating "A crawler is a vertebrate".
[0042] In summary, the expression ability of the large model of natural language processing can be improved through prompt words, and the large model can also perform dialogue tasks in various fields without modifying the parameters of the large model itself. In other words, for multiple natural language dialogue models, and each natural language dialogue model performs dialogue tasks in multiple different fields, how to obtain the most appropriate prompt words, so as to instruct the natural language dialogue model to generate answer text related to the target field corresponding to the prompt words for the question text, has become an urgent problem to be solved.
[0043] Therefore, the present application proposes a prompt word generation method to solve part or all of the above problems. Figure 2 As shown, it is a flow chart of a prompt word generation method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a prompt word generation device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0044] Specifically, the prompt word generation method includes:
[0045] S101. Obtain multiple sample question-answer pairs about the target domain.
[0046] The execution subject of the embodiment of the present application is a terminal device, which is an electronic device used by a user. The electronic device can be a personal computer, a mobile phone, a tablet computer, etc., which has a certain computing power and runs an application or web page with a prompt word generation function. It can also be 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 (Content Delivery Network), and big data and artificial intelligence platforms. It can be understood that the number and type of the above-mentioned terminal devices are only for illustration, and the embodiment of the present application does not impose any restrictions on this.
[0047] The sample question and answer pair includes a sample text of a question and a sample text of an answer. The sample text, or the text described below, can be understood as a text segment composed of Chinese or non-Chinese natural languages that can express meaning, including any text quantity such as sentences, paragraphs, articles, and any language form such as English, Chinese, German, Japanese, etc., and the sample text includes any information that technical personnel in the field need to extract, such as text, semantics, text location, punctuation, and the frequency of repeated words. Natural language includes multiple fields. For example, natural language includes multiple large and small fields such as medicine, science, food, and safety. The target field can be understood as one of the above multiple fields. A sample question and answer pair includes a sample text of a question and a sample text of an answer. The sample text of an answer can be understood as a text that answers the question content of the sample text of the question.
[0048] In one embodiment, the method for obtaining sample question-answer pairs is: obtaining sample text data about the target field; dividing the sample text data to generate multiple sample question-answer pairs about the target field. Specifically, first, sample text data including multiple fields is obtained. For example, the sample text data can come from three classic natural language public data sets, including: Reuters News Corpus Volume I (RCV1-V2) data set, The New York Times Annotated Corpus (NYT) data set and the Web of Science (WOS) data set. The RCV1-V2 data set and the NYT data set are both news text corpora, while the WOS data set includes abstracts of published papers from the Web of Science.
[0049] Further, the sample text data can be clustered to obtain sample text data corresponding to multiple fields, and the sample text data in each field includes multiple sample texts with the same characteristics, that is, the content of the sample text is related to the same field. In this embodiment, the clustering method can be a clustering algorithm or a classification algorithm in machine learning, so that the sample text data including multiple fields is clustered to obtain multiple clustering results, each clustering result corresponds to the sample text data in one field. The clustering process can also be any applicable clustering algorithm that can be conceived by those skilled in the art, such as K-means clustering, DBSCAN clustering, quantum clustering, or any applicable classification algorithm that can be conceived by those skilled in the art, such as linear regression, logistic regression, KNN, support vector machine, etc.
[0050] Furthermore, the sample text data of the target domain is preprocessed. For example, the sample text data of the target domain is cleaned, including removing stop words and special symbols from the multiple samples included in the sample text data, to avoid using stop words or special symbols as text. Assume that after processing, the number of texts is f and the vocabulary size is C. Removing stop words can significantly reduce the number of C and remove redundant information. The special symbols mentioned here include punctuation marks, currency symbols, mathematical symbols, etc. that appear in sentences.
[0051] Furthermore, the preprocessed sample text data is divided and processed to obtain multiple sample question-answer pairs. Dividing the preprocessed sample text data means dividing a Chinese sequence or a sequence in other languages into individual Chinese words or words in other languages, and generating sample question-answer pairs through the segmented text paragraphs. For example, the more mature Jieba text segmentation system is used, and the specific text segmentation method is not limited. The preset segmentation unit includes at least one of the following: character as a unit, word as a unit, sentence as a unit, and paragraph as a unit, which are set according to the needs of relevant technical personnel.
[0052] like Figure 3 As shown, Figure 3 2 is a flow chart of obtaining multiple sample question-answer pairs provided by an embodiment of the present application. The sample text data 201 is related to the target field, for example, the network security field. The sample text data 201 is divided and processed, and multiple sample question-answer pairs are generated according to multiple text paragraphs obtained by the division process. Figure 3 As shown, based on the sample text data 201, at least sample question and answer pair 202, sample question and answer pair 203, sample question and answer pair 204, and sample question and answer pair 205 are obtained, sample question and answer pair 202 includes a question sample text 2021 and an answer sample text 2022, sample question and answer pair 203 includes a question sample text 2031 and an answer sample text 2032, sample question and answer pair 204 includes a question sample text 2041 and an answer sample text 2042, and sample question and answer pair 205 includes a question sample text 2051 and an answer sample text 2052.
[0053] For example, based on sample text data 201 related to the field of network security, the sample text data 201 is divided and processed to obtain a text paragraph "As a program for automatically acquiring web page content, crawler tools are used by many search engines." Based on the above text paragraph, a corresponding sample answer pair 202 is generated, including a question sample text 2021 "What is a crawler?" and an answer sample text 2022 "A crawler is a program for automatically acquiring web page content."
[0054] Understandably, Figure 3 The number of sample answer pairs shown is for illustration only and is not intended to be a limitation of this application.
[0055] S102: Based on the initial prompt word and multiple question sample texts, obtain the answer training text corresponding to each question sample through a natural language dialogue model.
[0056] The initial prompt words can be understood as prompt words set by relevant personnel or randomly generated and not trained. The natural language dialogue model may include a convolutional neural network (CNN), a recurrent neural network (RNN), or a Transformer network based on the attention mechanism Attention and a classification layer, wherein CNN, RNN, and Transformer are used to semantically encode the input prompt words, and the classification layer is used to map the label dimension of the encoding vector. For another example, the natural language dialogue model can be a BERT pre-trained model. The BERT (Bidirectional Encoder Representation from Transformers) pre-trained model is a model that recalls at least one dialogue result corresponding to the prompt word by running a self-supervised learning method based on a large amount of corpus. Self-supervised learning refers to supervised learning running on data without manual annotation. For another example, the natural language dialogue model is a Chat Generative Pre-trained Transforme (chatGPT) or a causal language model (CLM, Causal Language Model).
[0057] In one embodiment, the natural language dialogue model used in the embodiment of the present application is the ChatGLM model. The ChatGLM model is a pre-trained model that combines bidirectional and unidirectional attention. The ChatGLM model not only solves the problem that unidirectional attention models such as GPT cannot utilize contextual information, but also overcomes the defects of bidirectional attention models such as BERT in generating tasks. The ChatGLM model is loaded through the AutoModel.from_pretrained function of the transformer library preset by Hugging Face, where the trust_remote_code parameter is set to True, thereby using the ChatGLM model with custom code. The word segmenter of the ChatGLM model is loaded using the AutoTokenizer.from_pretrained of the transformer library, and the vocabulary is obtained through the get_vocab function, and the vocabulary size is 130344.
[0058] It is understandable that the natural language dialogue model of the embodiment of the present application is not limited to the above-mentioned model, and other natural language dialogue models that can perform dialogue tasks are applicable.
[0059] S103, adjusting the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until the target prompt word is obtained under a preset condition.
[0060] The target prompt word can be understood as the prompt word that is ultimately used to instruct the natural language dialogue model to generate an answer text corresponding to the question text. In one embodiment, the target prompt word has entity meaning compared to the initial prompt word. For example, the initial prompt word is composed of a plurality of randomly generated characters, and the target prompt word is a sentence with entity meaning. In another embodiment, the target prompt word and the initial prompt word are vector expressions or function expressions. This embodiment does not limit the representation method of the target prompt word and the initial prompt word.
[0061] The method for adjusting the initial prompt word can be: according to the initial prompt word and each question sample text, obtain the answer training text corresponding to the question sample through the natural language dialogue model, further adjust the initial prompt word according to the difference information between the answer sample text corresponding to the question sample text and the answer training text to obtain the adjusted initial prompt word; further according to the adjusted initial prompt word and another question sample text, obtain the answer training text corresponding to the question sample through the natural language dialogue model, further according to the difference information between the answer sample text corresponding to the question sample and the answer training text, adjust the adjusted initial prompt word again to obtain the initial prompt word adjusted twice. The initial prompt word is continuously adjusted through the above process until the preset conditions are met and the target prompt word is obtained.
[0062] Alternatively, the method for adjusting the initial prompt word may also be: according to the initial prompt word and multiple question sample texts, a plurality of answer training texts corresponding to the multiple question sample texts are obtained through a natural language dialogue model; further, the initial prompt word is adjusted to obtain an adjusted initial prompt word through the combined difference information between the multiple answer training texts and the multiple answer sample texts corresponding to the multiple question sample texts; further, according to the adjusted initial prompt word and multiple question sample texts, a plurality of answer training texts corresponding to the multiple question sample texts are obtained through a natural language dialogue model, and the adjusted initial prompt word is adjusted again to obtain a twice adjusted initial prompt word. The initial prompt word is continuously adjusted through the above process until the target prompt word is obtained when the preset conditions are met.
[0063] The preset condition may be that the initial prompt word is adjusted, and the difference information between the answer training text and the answer sample text obtained by the natural language dialogue model based on the question sample text meets the expectation. The preset condition may also be that the number of adjustments to the initial prompt word meets the expectation. It is understood that the specific content of the preset condition is set by the relevant personnel as needed, and the above is only an example.
[0064] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0065] In one embodiment, Figure 4 As shown, it is a flow chart of a prompt word generation method proposed in an embodiment of the present application, which can be implemented by a computer program and can be run on a prompt word generation device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0066] Specifically, the prompt word generation method includes:
[0067] S201. Obtain multiple sample question-answer pairs about the target domain.
[0068] The sample question-answer pair includes a sample question text and a sample answer text. See S101 above, which will not be described again.
[0069] S202, obtaining an initial prompt word, and obtaining an initial prompt word vector corresponding to the initial prompt word through a prompt word generation model to be trained.
[0070] The method for obtaining the initial prompt word may be to obtain the pre-selected setting of the relevant personnel from the memory, or to generate it randomly through a random algorithm. The embodiment of the present application does not impose any limitation on the method for obtaining the initial prompt word.
[0071] The prompt word generation model to be trained is used to generate an initial prompt vector corresponding to the initial prompt word. In one embodiment, the prompt word generation model to be trained is a long short-term memory network model (Long Short-Term Memory, LSTM), the LSTM model is a bidirectional network, the hidden layer node feature dimension is 2048, and the number of layers is 2 layers.
[0072] In one embodiment, the process of generating the initial prompt word vector by the prompt word generation model to be trained is: converting the characters of the initial prompt word into numbers by mapping, and then vectorizing the numbers to obtain the vector of the initial prompt word. For example, the embedding of words can be used to implement the vectorization process; the vector is input into the encoding module for semantic encoding to obtain the encoding result. For example, the encoding module uses the encoding Encoder module in the Transformer architecture to extract features from the vector to obtain the encoded initial prompt word vector. For example, the dimension of the initial prompt word vector is 768×2048. It can be understood that the above process is only an example.
[0073] S203. According to the initial prompt word vector and multiple question sample texts, the answer training text corresponding to each question sample is obtained through a natural language dialogue model.
[0074] Specifically, based on multiple question sample texts, a question sample vector corresponding to each question sample text is obtained; the initial prompt word vector and each question sample vector are connected to obtain a fusion vector corresponding to each question sample text; based on the fusion vector corresponding to each question sample text, the answer training text corresponding to each question sample text is obtained through the natural language dialogue model. Based on each question sample text, a question sample vector corresponding to each question sample text is obtained, and the length of the question sample vector is the same as the length required by the natural language dialogue model for the input vector, and the same as the length of the initial prompt word vector.
[0075] In one embodiment, the initial prompt word vector and each question sample vector are connected to obtain a fusion vector corresponding to each question sample text, including: determining a target connection method corresponding to connecting the initial prompt word vector and each question sample vector according to the structure type of the natural language dialogue model; and connecting the initial prompt word vector and each question sample vector according to the target connection method to obtain a fusion vector corresponding to each question sample text.
[0076] like Figure 5 As shown, Figure 5 301. The number of initial prompt words 301 is multiple, specifically including initial prompt words P0, P1, P2, ..., P n-2 , P n-1 , P n According to the prompt word generation model 302 Long Short-Term Memory Mode, multiple initial prompt word vectors corresponding to the initial prompt words 301 are generated, specifically generating an initial prompt word vector h0 corresponding to the initial prompt word P0, an initial prompt word vector h1 corresponding to the initial prompt word P1, an initial prompt word vector h2 corresponding to the initial prompt word P2, ..., an initial prompt word P n-2 The corresponding initial prompt word vector h n-2 、Initial prompt word P n-1 The corresponding initial prompt word vector h n-1 、Initial prompt word P n The corresponding initial prompt word vector h n .
[0077] Further, according to the problem sample vector corresponding to the problem sample text 3031Text, the problem sample vector includes the problem sample vector e1, the problem sample vector e2, ..., the problem sample vector e n , the question sample vector corresponding to the question sample text 3031Text and the initial prompt word vector are concatted to obtain a fusion vector. In this embodiment, the target connection method is to connect the initial prompt word vector to the front end and the back end of the question sample vector respectively, such as Figure 5 shown.
[0078] Furthermore, the fusion vector corresponding to the question sample text 3031 is input into the natural language dialogue model 304 Pre-trained Language Model to obtain the answer training text 3022 corresponding to the question sample text 3031 .
[0079] The target connection method includes at least one of the following connection methods: connecting the initial prompt word vector to the front end and the back end of the question sample vector, connecting the initial prompt word vector to the front end of the question sample vector, and connecting the initial prompt word vector to the back end of the question sample vector. For example, in this embodiment, the natural language dialogue model 304 is a ChatGLM model, so the target connection method of the initial prompt word vector 301 and the question sample text 3031 is to connect the initial prompt word vector 301 to the front end and the back end of the question sample vector 3031, respectively. In other embodiments, depending on the different structural types of the natural language dialogue model 304, the initial prompt word vector can also be connected to the front end of the question sample vector, or the initial prompt word vector can be connected to the back end of the question sample vector, or the initial prompt word vector can be connected to the front end and the middle of the question sample vector, or other forms of target connection methods.
[0080] S204, adjusting the prompt word generation model to be trained according to the multiple answer training texts and the multiple answer sample texts until convergence to obtain the prompt word generation model.
[0081] The prompt word generation model is used to obtain the target prompt word vector corresponding to the initial prompt word, and the target prompt word vector is used to characterize the target prompt word. In other words, in this embodiment, the parameters of the prompt word generation model to be trained are trained by multiple answer training texts and multiple answer sample texts until the prompt word generation model to be trained converges, and then the prompt word generation model is obtained. The target prompt word vector is used to characterize the target prompt word. For example, the target prompt word vector can be converted into a sentence or phrase including entity semantics through other models. For another example, the initial prompt word and the target prompt word are both expressed as vectors, and the target prompt word vector is the target prompt word.
[0082] In one embodiment, according to a plurality of answer training texts and a plurality of answer sample texts, the prompt word generation model to be trained is adjusted to convergence through a cross entropy loss function and an autoregressive calculation method to obtain a prompt word generation model. Figure 5As shown, after obtaining the answer training text 3022 corresponding to the question sample text 3031, according to the answer training text 3022 and the answer sample text 3031 corresponding to the question sample text 3023, as well as other multiple answer training texts and answer sample texts, the prompt word generation model to be trained is adjusted to convergence through the cross entropy loss function Cross Entropy Loss and the autoregressive calculation method to obtain the prompt word generation model. Cross entropy can measure the difference between two different probability distributions in a random variable, which is expressed as the difference between the true probability distribution and the predicted probability distribution in this embodiment. The smaller the value of the cross entropy loss function, the better the effect of the prompt word generation model in generating the answer training text related to the question sample text and the target field. Autoregressive calculation Autoregressive is a calculation method for statistically processing time series. In this embodiment, the prompt word generation model to be trained is adjusted through the cross entropy loss function and the autoregressive calculation method, which can improve the effect of the prompt word generation model in generating the answer training text related to the question sample text and the target field.
[0083] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0084] In one embodiment, Figure 6 As shown, it is a flowchart of a prompt word-based dialogue method proposed in an embodiment of the present application. The method can be implemented by a computer program and can be run on a prompt word-based dialogue device based on the von Neumann system. The computer program can be integrated into an application or run as an independent tool application.
[0085] Specifically, the prompt word-based dialogue method includes:
[0086] S301, obtaining question text and target prompt words.
[0087] In this embodiment, the target prompt word is based on Figures 1 to 5The prompt word generation method shown is generated and stored in an electronic device that executes the prompt word-based dialogue method, or in other electronic devices. The electronic device that executes the prompt word-based dialogue method obtains the target prompt word and question text by receiving them from a user or other electronic devices, or by other feasible acquisition methods.
[0088] S302: According to the question text and the target prompt word, an answer text corresponding to the question text is obtained through a natural language dialogue model.
[0089] The answer text is related to the target domain corresponding to the target prompt word. For example, the question text obtained is "What is a crawler?" The target prompt word is "You are an expert in the field of network security", and the answer text obtained through the natural language dialogue model is "A crawler is a program that automatically obtains web page content", that is, the domain of the answer text is related to the domain of the target prompt word.
[0090] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0091] The following are device embodiments of the present application, which can be used to execute the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
[0092] See also Figure 7 , which shows a schematic diagram of the structure of a prompt word generation device provided by an exemplary embodiment of the present application. The prompt word generation device can be implemented as all or part of the device through software, hardware or a combination of both. The prompt word generation device includes a sample acquisition module 701, an answer generation module 702 and a target adjustment module 703.
[0093] A sample acquisition module 701 is used to acquire a plurality of sample question-answer pairs about a target domain, wherein the sample question-answer pairs include a sample question text and a sample answer text;
[0094] The answer generation module 702 is used to obtain answer training texts corresponding to the question sample texts through a natural language dialogue model according to the initial prompt word and the multiple question sample texts;
[0095] The target adjustment module 703 is used to adjust the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until a target prompt word is obtained when a preset condition is met.
[0096] In one embodiment, the answer generation module 702 includes:
[0097] A vector generation unit, used to obtain the initial prompt word, and obtain an initial prompt word vector corresponding to the initial prompt word through a prompt word generation model to be trained;
[0098] An answer generation unit, configured to obtain answer training texts corresponding to the question sample texts through the natural language dialogue model according to the initial prompt word vector and the plurality of question sample texts;
[0099] The target adjustment module 703 includes:
[0100] A target adjustment unit is used to adjust the prompt word generation model to be trained according to the multiple answer training texts and the multiple answer sample texts until convergence to obtain a prompt word generation model, the prompt word generation model is used to obtain a target prompt word vector corresponding to the initial prompt word, and the target prompt word vector is used to represent the target prompt word.
[0101] In one embodiment, the answer generation unit includes:
[0102] A first subunit is used to obtain a question sample vector corresponding to each of the question sample texts according to the plurality of question sample texts;
[0103] The second subunit is used to connect the initial prompt word vector and each of the question sample vectors to obtain a fusion vector corresponding to each of the question sample texts;
[0104] The third subunit is used to obtain the answer training text corresponding to each of the question sample texts through the natural language dialogue model according to the fusion vector corresponding to each of the question sample texts.
[0105] In one embodiment, the second subunit is specifically used to determine a target connection mode corresponding to connecting the initial prompt word vector and each of the question sample vectors according to the structure type of the natural language dialogue model;
[0106] And according to the target connection mode, the initial prompt word vector and each of the question sample vectors are connected to obtain a fusion vector corresponding to each of the question sample texts.
[0107] In one embodiment, the target connection method includes at least one of the following connection methods: connecting the initial prompt word vector to the front end and the back end of the question sample vector respectively, connecting the initial prompt word vector to the front end of the question sample vector, and connecting the initial prompt word vector to the back end of the question sample vector.
[0108] In one embodiment, the target adjustment unit includes:
[0109] The target adjustment subunit is used to adjust the prompt word generation model to be trained to converge according to the multiple answer training texts and the multiple answer sample texts through a cross entropy loss function and an autoregressive calculation method to obtain a prompt word generation model.
[0110] In one embodiment, the sample acquisition module 701 includes:
[0111] A first acquisition unit, used to acquire sample text data about a target domain;
[0112] The second acquisition unit is used to divide the sample text data to generate the multiple sample question-answer pairs about the target field.
[0113] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0114] It should be noted that the prompt word generation device provided in the above embodiment only uses the division of the above functional modules as an example when executing the prompt word generation method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the prompt word generation device provided in the above embodiment and the prompt word generation method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.
[0115] See also Figure 8 , which shows a schematic diagram of the structure of a dialogue device based on prompt words provided by an exemplary embodiment of the present application. The dialogue device based on prompt words can be implemented as all or part of the device through software, hardware or a combination of both. The dialogue device based on prompt words includes a question acquisition module 801 and an answer acquisition module 802.
[0116] The question acquisition module 801 is used to acquire the question text and the target prompt word. The target prompt word is obtained by Figure 1 - Figure 5 Any of the prompt word generation methods is obtained;
[0117] The answer acquisition module 802 is used to obtain the answer text corresponding to the question text through a natural language dialogue model according to the question text and the target prompt word, and the answer text is related to the target field corresponding to the target prompt word.
[0118] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0119] It should be noted that the above embodiment provides a dialogue device based on prompt words, when executing the dialogue method based on prompt words, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the dialogue device based on prompt words and the dialogue method based on prompt words provided in the above embodiment belong to the same concept, and the embodiment and implementation process thereof are detailed in the method embodiment, which will not be repeated here.
[0120] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0121] The present application also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded and executed by a processor as described above. Figure 1 - Figure 6 The image source tracking method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 - Figure 6 The specific description of the illustrated embodiment will not be repeated here.
[0122] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 - Figure 6 The image source tracking method of the embodiment shown in the figure can be specifically executed by referring to Figure 1 - Figure 6 The specific description of the illustrated embodiment will not be repeated here.
[0123] See also Fig. 9 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 900 may include: at least one processor 901 , at least one network interface 904 , a user interface 903 , a memory 905 , and at least one communication bus 902 .
[0124] The communication bus 902 is used to realize the connection and communication between these components.
[0125] The user interface 903 may include a display screen (Display) and a camera (Camera), and the optional user interface 903 may also include a standard wired interface and a wireless interface.
[0126] The network interface 904 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0127] Among them, the processor 901 may include one or more processing cores. The processor 901 uses various interfaces and lines to connect various parts within the entire server 900, and executes various functions and processes data of the server 900 by running or executing instructions, programs, code sets or instruction sets stored in the memory 905, and calling data stored in the memory 905. Optionally, the processor 901 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 901 can integrate one or more combinations of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 901, and it can be implemented by a single chip.
[0128] Among them, the memory 905 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 905 includes a non-transitory computer-readable storage medium. The memory 905 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 905 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 905 may optionally be at least one storage device located away from the aforementioned processor 901. As Fig. 9 As shown, the memory 905 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a prompt word generation and / or a prompt word-based dialogue application.
[0129] exist Fig. 9In the electronic device 900 shown, the user interface 903 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 901 can be used to call the prompt word generation application stored in the memory 905 and specifically perform the following operations:
[0130] Acquire a plurality of sample question-answer pairs about the target domain, wherein the sample question-answer pairs include a question sample text and an answer sample text;
[0131] According to the initial prompt word and the plurality of the question sample texts, obtaining answer training texts corresponding to the question sample texts through a natural language dialogue model;
[0132] According to the plurality of answer training texts and the plurality of answer sample texts, the initial prompt word is adjusted until a target prompt word is obtained when a preset condition is met.
[0133] In one embodiment, the processor 901 executes the process of obtaining, according to the initial prompt word and the plurality of the question sample texts, the answer training text corresponding to each of the question sample texts through the natural language dialogue model, specifically performing:
[0134] Obtaining the initial prompt word, and obtaining an initial prompt word vector corresponding to the initial prompt word through a prompt word generation model to be trained;
[0135] According to the initial prompt word vector and the plurality of question sample texts, obtaining answer training texts corresponding to the question sample texts through the natural language dialogue model;
[0136] Processor 901 executes the step of adjusting the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until a target prompt word is obtained when a preset condition is met, specifically performing:
[0137] According to the plurality of answer training texts and the plurality of answer sample texts, the prompt word generation model to be trained is adjusted until convergence to obtain a prompt word generation model, the prompt word generation model is used to obtain a target prompt word vector corresponding to the initial prompt word, and the target prompt word vector is used to represent the target prompt word.
[0138] In one embodiment, the processor 901 executes the step of obtaining, according to the initial prompt word vector and the plurality of question sample texts, answer training texts corresponding to the question sample texts through the natural language dialogue model, specifically performing:
[0139] According to the plurality of question sample texts, obtaining a question sample vector corresponding to each of the question sample texts;
[0140] Connecting the initial prompt word vector and each of the question sample vectors to obtain a fusion vector corresponding to each of the question sample texts;
[0141] According to the fusion vector corresponding to each of the question sample texts, the answer training text corresponding to each of the question sample texts is obtained through the natural language dialogue model.
[0142] In one embodiment, the processor 901 executes the connection of the initial prompt word vector and each of the question sample vectors to obtain a fusion vector corresponding to each of the question sample texts, specifically performing:
[0143] Determining, according to the structural type of the natural language dialogue model, a target connection mode corresponding to when connecting the initial prompt word vector and each of the question sample vectors;
[0144] According to the target connection mode, the initial prompt word vector and each of the question sample vectors are connected to obtain a fusion vector corresponding to each of the question sample texts.
[0145] In one embodiment, the target connection method includes at least one of the following connection methods: connecting the initial prompt word vector to the front end and the back end of the question sample vector respectively, connecting the initial prompt word vector to the front end of the question sample vector, and connecting the initial prompt word vector to the back end of the question sample vector.
[0146] In one embodiment, the processor 901 performs the step of adjusting the prompt word generation model to be trained to obtain the prompt word generation model when convergence according to the plurality of answer training texts and the plurality of answer sample texts, specifically performing:
[0147] According to the plurality of answer training texts and the plurality of answer sample texts, the prompt word generation model to be trained is adjusted to convergence through a cross entropy loss function and an autoregressive calculation method to obtain a prompt word generation model.
[0148] In one embodiment, the processor 901 may be used to call a prompt word-based dialogue application stored in the memory 905, and specifically perform the following operations:
[0149] Obtain the question text and the target prompt word, the target prompt word is obtained by Figures 1 to 5 Any of the prompt word generation methods is obtained;
[0150] According to the question text and the target prompt word, an answer text corresponding to the question text is obtained through a natural language dialogue model, and the answer text is related to the target field corresponding to the target prompt word.
[0151] This application uses a natural language dialogue model to obtain answer training texts corresponding to each question sample text based on an initial prompt word and multiple question sample texts, and further adjusts the initial prompt word until a target prompt word is obtained by comparing the answer training text and the answer sample text corresponding to each question sample text. The target prompt word is used to indicate that the answer text generated by the natural language dialogue model based on the question text is related to the target field. Compared with directly training the parameters of the natural language dialogue model until the natural language dialogue model can perform dialogue tasks in the target field, only adjusting the prompt words suitable for the natural language dialogue model takes up less training resources and has high training efficiency. Different target prompt words can be adjusted for each target field based on the initial prompt word, so that the same natural language dialogue model can perform dialogue tasks in different fields, that is, plug-in use of different dialogue tasks is achieved, which has better effects and is easy to promote.
[0152] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0153] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A method for generating a prompt word, characterized in that: The method comprises: Acquire a plurality of sample question-answer pairs about the target domain, wherein the sample question-answer pairs include a question sample text and an answer sample text; According to the initial prompt word and the plurality of the question sample texts, obtaining answer training texts corresponding to the question sample texts through a natural language dialogue model; According to the plurality of answer training texts and the plurality of answer sample texts, the initial prompt word is adjusted until a target prompt word is obtained when a preset condition is met.
2. The method for generating prompt words according to claim 1, characterized in that: The method of obtaining answer training texts corresponding to the question sample texts through a natural language dialogue model based on the initial prompt word and the plurality of question sample texts includes: Obtaining the initial prompt word, and obtaining an initial prompt word vector corresponding to the initial prompt word through a prompt word generation model to be trained; According to the initial prompt word vector and the plurality of question sample texts, obtaining answer training texts corresponding to the question sample texts through the natural language dialogue model; The step of adjusting the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until a target prompt word is obtained when a preset condition is met includes: According to the plurality of answer training texts and the plurality of answer sample texts, the prompt word generation model to be trained is adjusted until convergence to obtain a prompt word generation model, the prompt word generation model is used to obtain a target prompt word vector corresponding to the initial prompt word, and the target prompt word vector is used to represent the target prompt word.
3. The method for generating prompt words according to claim 2, characterized in that: The step of obtaining answer training texts corresponding to the question sample texts through the natural language dialogue model according to the initial prompt word vector and the plurality of question sample texts includes: According to the plurality of question sample texts, obtaining a question sample vector corresponding to each of the question sample texts; Connecting the initial prompt word vector and each of the question sample vectors to obtain a fusion vector corresponding to each of the question sample texts; According to the fusion vector corresponding to each of the question sample texts, the answer training text corresponding to each of the question sample texts is obtained through the natural language dialogue model.
4. The method for generating prompt words according to claim 3, characterized in that: The step of connecting the initial prompt word vector and each of the question sample vectors to obtain a fusion vector corresponding to each of the question sample texts includes: Determining, according to the structural type of the natural language dialogue model, a target connection mode corresponding to when connecting the initial prompt word vector and each of the question sample vectors; According to the target connection mode, the initial prompt word vector and each of the question sample vectors are connected to obtain a fusion vector corresponding to each of the question sample texts.
5. The method for generating prompt words according to claim 4, characterized in that: The target connection method includes at least one of the following connection methods: connecting the initial prompt word vector to the front end and the back end of the question sample vector respectively, connecting the initial prompt word vector to the front end of the question sample vector, and connecting the initial prompt word vector to the back end of the question sample vector.
6. A conversation method based on prompt words, characterized in that: The dialogue method comprises: Obtaining a question text and a target prompt word, wherein the target prompt word is obtained by the prompt word generation method according to any one of claims 1 to 7; According to the question text and the target prompt word, an answer text corresponding to the question text is obtained through a natural language dialogue model, and the answer text is related to the target field corresponding to the target prompt word.
7. A prompt word generating device, characterized in that: The prompt word generating device comprises: A sample acquisition module, used to acquire a plurality of sample question-answer pairs about a target domain, wherein the sample question-answer pairs include a question sample text and an answer sample text; An answer generation module is used to obtain answer training texts corresponding to the question sample texts through a natural language dialogue model according to the initial prompt word and the multiple question sample texts; The target adjustment module is used to adjust the initial prompt word according to the plurality of answer training texts and the plurality of answer sample texts until a target prompt word is obtained when a preset condition is met.
8. A conversation device based on prompt words, characterized in that: The dialogue device based on prompt words includes: A question acquisition module, used to acquire a question text and a target prompt word, wherein the target prompt word is obtained by the prompt word generation method according to any one of claims 1 to 5; The answer acquisition module is used to obtain the answer text corresponding to the question text through a natural language dialogue model according to the question text and the target prompt word, and the answer text is related to the target field corresponding to the target prompt word.
9. A computer storage medium, characterized in that The computer storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 6.
10. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 6.
Citation Information
Cited By
Problem prompt word generation method and system and electronic equipment
CN119782768A
Security reply generation method, related device, equipment and storage medium
CN120408414A