CN116719920A - Dynamic sampling dialogue generation model training method, device, equipment and medium - Google Patents

Dynamic sampling dialogue generation model training method, device, equipment and medium Download PDF

Info

Publication number
CN116719920A
CN116719920A CN202310725410.1A CN202310725410A CN116719920A CN 116719920 A CN116719920 A CN 116719920A CN 202310725410 A CN202310725410 A CN 202310725410A CN 116719920 A CN116719920 A CN 116719920A
Authority
CN
China
Prior art keywords
word
answer
sentence
generation model
dialogue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310725410.1A
Other languages
Chinese (zh)
Inventor
舒畅
陈又新
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN202310725410.1A priority Critical patent/CN116719920A/en
Publication of CN116719920A publication Critical patent/CN116719920A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/3332Query translation
    • G06F16/3334Selection or weighting of terms from queries, including natural language queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • G06N3/0455Auto-encoder networks; Encoder-decoder networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Mathematical Physics (AREA)
  • General Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Machine Translation (AREA)

Abstract

The invention relates to the technical field of artificial intelligence, and discloses a dynamic sampling dialogue generation model training method, which comprises the following steps: dividing the reference answer sentence into words to obtain an answer word sequence, and obtaining a reference answer word and word position information according to the answer word sequence; inputting the query sentence corresponding to the reference answer sentence into a dialogue generating model to obtain an ith position answer word; acquiring a reference answer word corresponding to an ith position answer word in the answer word sequence based on the word position information, and acquiring an (i+1) th position input word according to the replacement probability of the reference answer word; inputting the (i+1) th position input word into a dialogue generation model to generate an (i+1) th position answer word; and collecting the answer words at each position to obtain standard answer sentences, and generating fine tuning training data according to the query sentences and the standard answer sentences to train the dialogue generation model. The invention also provides a dynamic sampling dialogue generation model training device, equipment and a storage medium. The invention can improve the accuracy of the financial dialogue generation model.

Description

Dynamic sampling dialogue generation model training method, device, equipment and medium
Technical Field
The present invention relates to the field of artificial intelligence technologies, and in particular, to a method, an apparatus, a device, and a medium for training a dynamic sampling dialogue generation model.
Background
The dialogue generation is an important field in the natural language processing direction, and has very wide application prospect in a plurality of fields such as financial document translation, financial consultation and the like. Currently, the industry generally uses a search method or a generation method to generate a dialogue, wherein the search method is to vectorize a financial query sentence of a user, then perform similarity calculation with the vectorized answer sentence in a financial database, and then search the most similar answer sentence of the financial query sentence in the financial database. The method of generating the formula is to acquire the coding features of the financial inquiry statement through the coder, and input the coding features into the decoder to generate the answer of the financial inquiry statement. However, both the retrievable and generative methods have the disadvantage that they result in lower recall rates when there is no query statement-like data in the financial database, and the generative methods generally result in far away answers from the financial query statement, with lower accuracy of the answers.
Disclosure of Invention
The invention provides a dynamic sampling dialogue generation model training method, device, equipment and medium, and mainly aims to improve the accuracy of a financial dialogue generation model.
In order to achieve the above object, the present invention provides a method for training a dynamically sampled dialog generation model, including:
step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
step B, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3 … n and the initial value is 1;
step C, acquiring a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating the replacement probability of the reference answer word, and obtaining an i+1-th position input word according to the replacement probability;
step D, inputting the (i+1) th position input word into the dialogue generation model to generate an (i+1) th position answer word, and returning to the step C until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words at a plurality of positions;
And E, collecting the answer words at each position to obtain a standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
Optionally, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generating model to obtain an ith position answer word, including:
word segmentation is carried out on the query sentence based on a word segmentation device in the dialogue generation model, so as to obtain a query word sequence;
converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
and generating an i-th position answer word of the query sentence through a decoding layer of a transducer in the dialogue generation model.
Optionally, the word segmentation is performed on the reference answer sentence to obtain an answer word sequence, which includes:
constructing a prefix dictionary according to a preset statistical dictionary, and dividing the reference answer sentence by using a regular expression to obtain a divided answer sentence;
constructing a directed acyclic graph of the segmentation answer sentence according to the prefix dictionary;
And obtaining a probability maximum path of the directed acyclic graph by using a dynamic programming method, and segmenting words according to the probability maximum path to obtain the answer word sequence.
Optionally, the obtaining the i+1st position input word according to the replacement probability includes:
acquiring a preset replacement probability threshold;
judging whether the replacement probability is larger than or equal to the replacement probability threshold value;
if the replacement probability is greater than or equal to the replacement probability threshold, using the reference answer word as the (i+1) th position input word;
and if the replacement probability is smaller than the replacement probability threshold, taking the ith position answer word as the (i+1) th position input word.
Optionally, after the training of the dialog generation model by the fine tuning training data, the method further comprises:
acquiring multi-dimensional objective indexes, testing and analyzing a standard dialogue generating model obtained by training the dialogue generating model through the fine tuning training data through the multi-dimensional objective indexes, and judging whether the standard dialogue model reaches a preset fine tuning target or not;
c, if the standard dialogue generating model does not reach the preset fine tuning target, returning to the step C;
And if the standard dialogue generating model reaches the preset fine tuning target, finishing fine tuning training of the standard dialogue generating model.
Optionally, the calculating the substitution probability of the reference answer word includes:
calculating the substitution probability N of the test answer words through the following probability calculation formula:
wherein said y andrespectively corresponding to the answer words at the current positionReferring to answer words, T is the total number of positions, is a preset parameter value, μ is a distribution, and-represents equivalence.
In order to solve the above problem, the present invention further provides a dynamically sampled dialog generation model training device, which includes:
the word information acquisition module is used for acquiring a reference answer sentence, segmenting the reference answer sentence to obtain an answer word sequence, and acquiring a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
the input word acquisition module is used for inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2 and 3 … n are initial values of 1, the reference answer word corresponding to the i-th position answer word in the answer word sequence is acquired based on the word position information, the replacement probability of the reference answer word is calculated, and the i+1th position input word is obtained according to the replacement probability;
The answer word acquisition module is used for inputting the (i+1) th position input word into the dialogue generation model, generating the (i+1) th position answer word, and returning to the previous step until the corresponding reference answer word does not exist in the answer word sequence, so as to obtain answer words at a plurality of positions;
and the model training module is used for collecting the answer words at each position, obtaining the standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
Optionally, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generating model to obtain an ith position answer word, including:
word segmentation is carried out on the query sentence based on a word segmentation device in the dialogue generation model, so as to obtain a query word sequence;
converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
and generating an i-th position answer word of the query sentence through a decoding layer of a transducer in the dialogue generation model.
In order to solve the above-mentioned problems, the present invention also provides an electronic apparatus including:
At least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the dynamically sampled dialog generation model training method as described above.
In order to solve the above-mentioned problems, the present invention also provides a computer-readable storage medium including a storage data area storing created data and a storage program area storing a computer program; wherein the computer program, when executed by a processor, implements a dynamically sampled dialog generation model training method as described above.
In the embodiment of the invention, a reference answer sentence is firstly obtained, word segmentation is carried out on the reference answer sentence to obtain an answer word sequence, a reference answer word and word position information are obtained according to the answer word sequence, the purpose of obtaining word information is achieved, then an inquiry sentence corresponding to the reference answer sentence is input into a dialogue generating model to obtain an ith position answer word, a reference answer word corresponding to the ith position answer word in the answer word sequence is obtained based on the word position information, a replacement probability is calculated to obtain an ith+1 position input word, then the ith+1 position input word is input into a dialogue generating model to generate an ith+1 position answer word, the purpose of obtaining answer words at a plurality of positions is achieved, finally the answer words at all positions are collected to obtain standard answer sentences, and fine tuning training data are generated according to the inquiry sentence and the standard answer sentence to train a dialogue generating model. According to the invention, the answer words are replaced according to the replacement probability of the reference answer words by comparing the reference answer words with the answer words generated by the pre-trained financial dialogue generation model, so that the fine tuning training data for training the financial dialogue generation model is obtained, and the purpose of improving the accuracy of the financial dialogue generation model is realized.
Drawings
FIG. 1 is a flow chart of a method for training a dynamically sampled dialog generation model according to an embodiment of the present application;
FIG. 2 is a detailed flowchart of a step in a training method for a dynamically sampled dialog generation model according to an embodiment of the present application;
FIG. 3 is a detailed flowchart of a step in a training method for a dynamically sampled dialog generation model according to an embodiment of the present application;
FIG. 4 is a schematic block diagram of a dynamically sampled dialog generation model training device according to an embodiment of the present application;
fig. 5 is a schematic diagram of an internal structure of an electronic device for implementing a training method of a dialog generation model for dynamic sampling according to an embodiment of the present application.
The achievement of the objects, functional features and advantages of the present application will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The embodiment of the application provides a dynamic sampling dialogue generation model training method. The execution subject of the dynamically sampled dialog generation model training method includes, but is not limited to, at least one of a server, a terminal, etc. capable of being configured to execute the method provided by the embodiment of the application. The server may be an independent server, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. In other words, the dynamically sampled dialog generation model training method may be performed by software or hardware installed on a remote device or a server device, and the software may be a blockchain platform. The service end includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Referring to fig. 1, a flow chart of a dynamically sampled dialog generating model training method according to an embodiment of the present invention is shown. In this embodiment, the dynamically sampled dialog generation model training method includes the following steps S1-S5:
s1, acquiring a reference answer sentence, segmenting the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence.
In the embodiment of the invention, the reference answer sentence can be obtained from a pre-constructed training database. The word segmentation of the reference answer sentence is represented by recombining continuous word sequences into semantic independent word sequences according to a certain specification, and the word segmentation method has multiple choices according to different languages, and particularly is determined according to the language type of the reference answer sentence.
For example, if the reference answer sentence is a chinese text, the word segmentation method may be jieba word segmentation method, hanLP word segmentation method, or the like, and if the reference answer sentence is an english text, the word segmentation method may be NLTK word segmentation method, spaCy word segmentation method, or the like.
Further, the reference answer sentence may be various answer sentences of the financial industry, for example, "you are going to transact long-term loan or short-term loan woolen", "we have xx insurance, xxx insurance, etc., ask you to transact that insurance woolen", "you expect how much funds to invest for financing", etc.
In the embodiment of the present invention, each reference answer word in the answer word sequence is separated by a "/" symbol, and further, each answer word sequence has a prefix [ CLS ] and a suffix [ SEP ], for example, a prefix "recite the frist law", and a suffix "end of service". The prefix and the suffix are used for determining the positions of the answer word sequences, and dividing the answer word sequences.
Further, referring to fig. 2, the word segmentation is performed on the reference answer sentence to obtain an answer word sequence, which includes:
s101, constructing a prefix dictionary according to a preset statistical dictionary, and dividing the reference answer sentence by using a regular expression to obtain a divided answer sentence;
s102, constructing a directed acyclic graph of the segmentation answer sentence according to the prefix dictionary;
s103, obtaining a probability maximum path of the directed acyclic graph by using a dynamic programming method, and segmenting words according to the probability maximum path to obtain the answer word sequence.
In the embodiment of the present invention, the reference answer words are constituent words forming the answer word sequence, and the word position information is the ordering position of the reference answer words in the answer word sequence, that is, the word of which number each reference answer word is located in the answer word sequence.
Further, the obtaining the reference answer sentence includes:
acquiring search question and answer data in training data, and constructing a training database according to a labeling part in the search question and answer data;
and acquiring a reference answer sentence from the training database.
In the embodiment of the invention, the search question and answer data is data for training a preset dialogue generation model, and the search question and answer data is provided with unlabeled search question and answer data and labeled search question and answer data, wherein the unlabeled search question and answer data is generally used for a pre-training link of a training step in the dialogue generation model, and the labeled search question and answer data is generally used for a fine-tuning link of the training step in the dialogue generation model. Further, the labeled search question and answer data comprises a query sentence and a reference answer sentence.
Further, the noted search question and answer data is data noted by a manual or a labeling tool, wherein the labeling tool can be a LabelImg tool, a RectLabel tool, or the like.
In detail, the annotation type of the annotated search question and answer data comprises classification annotation, annotation, picture frame annotation and the like, and the data type of the annotated search question and answer data is data such as pictures, voices, texts and the like. The marked search question and answer data in the scheme are text data, and the marked type is an answer annotation mark.
Further, the labeled search question and answer data is in the form of < query_database, answer_database >, wherein 'query_database' is an query sentence as input of an encoder in the dialogue generation model, and answer_database is a reference answer sentence as a true result of labeling.
S2, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain the i-th position answer word.
In the embodiment of the invention, the query sentence is a query part in the marked search question and answer data, is a question type sentence used for training the dialogue generation model, and has the expression form of query_database.
For example, training data is < "do you want to make stock investments? "whether stock risk is too great or investment fund bar" >, query statement is "do you want stock investment? "part".
In detail, i in the i-th position answer word is a representation of each position answer word, i=1, 2, 3..n, and the initial value is 1.
In the embodiment of the invention, the Pre-trained dialogue generation model is a GPT-2 model (generating Pre-trained Transformer 2), is a generated neural network model, and can be applied to a plurality of text-related fields, such as machine translation, question answering, basic reading understanding, emotion analysis, text abstract, text generation and the like.
The GPT-2 model has two training methods of Pre-training and Fine tuning, and is trained by using massive unlabeled language texts in the Pre-training stage, so that the model is initialized into a generated language model, and the model after Pre-training is Fine-tuned by using relevant labeling data according to different requirements of specific tasks in the Fine tuning stage.
Referring to fig. 3, in the embodiment of the present invention, inputting the query sentence corresponding to the reference answer sentence in the training database into a pre-trained dialogue generating model to obtain an i-th position answer word includes:
s201, word segmentation is carried out on the query sentence based on a word segmentation device in the dialogue generation model, and a query word sequence is obtained;
s201, converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
s201, generating an i-th position answer word of the query sentence through a decoding layer of a transducer in the dialogue generation model.
In the embodiment of the invention, the word segmentation device (token) is a default tool for segmenting the input text in the dialogue generation model.
In detail, the Word Embedding algorithm (Word Embedding) is a method of converting words in text into digital vectors. The word embedding method enables each word or phrase to be mapped into a vector on the real number domain by embedding a high-dimensional space with a number of words being all numbers of words into a continuous vector space with a much lower number of words.
Further, the transducer is a self-attention mechanism based deep learning model, and consists of an encoding layer (Encoder) and a decoding layer (Decoder). Wherein the pre-trained dialog generation model is composed of a plurality of transducers.
S3, acquiring a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating the replacement probability of the reference answer word, and obtaining the i+1-th position input word according to the replacement probability.
In the embodiment of the invention, the reference answer word is a word corresponding to each position answer word in the answer word sequence obtained according to the reference answer sentence, and the reference answer word can replace each position answer word to construct a new input word.
In the embodiment of the present invention, the substitution probability is a probability of determining whether to substitute each position answer word with the reference answer word in the answer word sequence.
In an embodiment of the present invention,
calculating the substitution probability N of the test answer words through the following probability calculation formula:
wherein said y andrespectively a current position answer word and a reference answer word corresponding to the current position answer word, wherein T is the total number of positions, < + >>All positions y and +.>If the accumulated values are the same, adding 1 if the accumulated values are the same, adding 0 if the accumulated values are different, and beta is preset [0,1 ]]The parameter value is dynamically reduced with the increase of time, the quantity of each reduction is 10% of the word number of the answer word sequence, mu is distribution, and the meaning is equivalent to that of the answer word sequence.
Further, the obtaining the (i+1) th position input word according to the replacement probability includes:
acquiring a preset replacement probability threshold;
judging whether the replacement probability is larger than or equal to the replacement probability threshold value;
if the replacement probability is greater than or equal to the replacement probability threshold, using the reference answer word as the (i+1) th position input word;
and if the replacement probability is smaller than the replacement probability threshold, taking the ith position answer word as the (i+1) th position input word.
S4, inputting the (i+1) th position input word into the dialogue generation model to generate an (i+1) th position answer word, and returning to S3 until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words at a plurality of positions.
In another embodiment of the present invention, a model may be generated for the dialog for inputting the i+1th position input word into the pre-training, generating an i+1th position answer word, and returning to S3 until the answer word output ends.
S5, collecting the answer words at each position to obtain standard answer sentences of the query sentences, generating fine tuning training data according to the query sentences and the standard answer sentences, and training the dialogue generation model through the fine tuning training data.
In an embodiment of the present invention, after the training of the dialog generating model by the fine tuning training data, the method further includes:
acquiring multi-dimensional objective indexes, testing and analyzing a standard dialogue generating model obtained by training the dialogue generating model through the fine tuning training data through the multi-dimensional objective indexes, and judging whether the standard dialogue model reaches a preset fine tuning target or not;
if the standard dialogue generating model does not reach the preset fine tuning target, returning to the step S3;
and if the standard dialogue generating model reaches the preset fine tuning target, finishing fine tuning training of the standard dialogue generating model.
In the embodiment of the invention, the multi-dimensional finger objective index may be indexes such as BLEU, ROUGE and confusion, and the preset fine tuning target may be BLEU index, ROUGE index and confusion index of the standard dialogue generation model to reach a preset multiple of the pre-trained dialogue generation model.
The BLEU (bilingual evaluation understudy) index is a bilingual inter-translation quality evaluation index for evaluating the translation quality of the dialogue generation model used for machine translation, the ROUGE (Recall-Oriented Understudy for Gisting Evaluation) index is a Recall-based quality evaluation index, and the confusion degree (perplexity) is an index for evaluating the quality of the language model.
Further, after the standard dialogue generation model is trained, financial consulting services can be provided for clients through the standard dialogue generation model, so that the problems such as 'i want to make financial investment, i can make an online risk assessment to obtain the most suitable financial investment type of i', 'i want to make a shop, and a low-information loan is needed, and the questions of which channels can help i solve the problem' are asked to answer.
In the embodiment of the invention, a reference answer sentence is firstly obtained, word segmentation is carried out on the reference answer sentence to obtain an answer word sequence, a reference answer word and word position information are obtained according to the answer word sequence, the purpose of obtaining word information is achieved, then an inquiry sentence corresponding to the reference answer sentence is input into a dialogue generating model to obtain an ith position answer word, a reference answer word corresponding to the ith position answer word in the answer word sequence is obtained based on the word position information, a replacement probability is calculated to obtain an ith+1 position input word, then the ith+1 position input word is input into a dialogue generating model to generate an ith+1 position answer word, the purpose of obtaining answer words at a plurality of positions is achieved, finally the answer words at all positions are collected to obtain standard answer sentences, and fine tuning training data are generated according to the inquiry sentence and the standard answer sentence to train a dialogue generating model. According to the invention, the answer words are replaced according to the replacement probability of the reference answer words by comparing the reference answer words with the answer words generated by the pre-trained financial dialogue generation model, so that the fine tuning training data for training the financial dialogue generation model is obtained, and the purpose of improving the accuracy of the financial dialogue generation model is realized.
FIG. 4 is a schematic diagram of a dynamically sampled dialog generation model training device in accordance with the present invention.
The dynamically sampled dialog generation model training device 100 of the present invention may be installed in an electronic device. Depending on the implemented functionality, the dynamically sampled dialog generation model training device may include a word information acquisition module 101, an input word acquisition module 102, an answer word acquisition module 103, and a model training module 104. The module of the invention, which may also be referred to as a unit, refers to a series of computer program segments, which are stored in the memory of the electronic device, capable of being executed by the processor of the electronic device and of performing a fixed function.
In the present embodiment, the functions concerning the respective modules/units are as follows:
the word information obtaining module 101 is configured to obtain a reference answer sentence, divide the reference answer sentence into words, obtain an answer word sequence, and obtain a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
an input word obtaining module 102, configured to input an inquiry sentence corresponding to the reference answer sentence into a pre-trained dialogue generating model to obtain an i-th position answer word, where i=1, 2, 3 … n, an initial value is 1, obtain a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculate a replacement probability of the reference answer word, and obtain an i+1th position input word according to the replacement probability;
An answer word obtaining module 103, configured to input the i+1th position input word into the dialogue generation model, generate an i+1th position answer word, and return to the previous step until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words in multiple positions;
the model training module 104 is configured to aggregate the answer words at each position, obtain a standard answer sentence of the query sentence, generate fine tuning training data according to the query sentence and the standard answer sentence, and train the dialog generation model through the fine tuning training data.
In detail, each module in the dynamically sampled dialog generating model training device 100 in the embodiment of the present invention adopts the same technical means as the dynamically sampled dialog generating model training method described in fig. 1 to 3 and can generate the same technical effects when in use, which is not described herein.
Fig. 5 is a schematic structural diagram of an electronic device implementing the dynamic sampling dialogue generation model training method according to the present invention.
The electronic device may comprise a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and may further comprise a computer program, such as a dynamically sampled dialog generation model training program, stored in the memory 11 and executable on the processor 10.
The processor 10 may be formed by an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be formed by a plurality of integrated circuits packaged with the same function or different functions, including one or more central processing units (Central Processing Unit, CPU), a microprocessor, a digital processing chip, a graphics processor, a combination of various control chips, and so on. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the entire electronic device using various interfaces and lines, executes or executes programs or modules (e.g., a dialogue generation model training program or the like that performs dynamic sampling) stored in the memory 11, and invokes data stored in the memory 11 to perform various functions of the electronic device and process the data.
The memory 11 includes at least one type of readable storage medium including flash memory, a removable hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, such as a mobile hard disk of the electronic device. The memory 11 may in other embodiments also be an external storage device of the electronic device, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used not only for storing application software installed in an electronic device and various types of data, such as codes of a dynamically sampled dialog generation model training program, but also for temporarily storing data that has been output or is to be output.
The communication bus 12 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. The bus is arranged to enable a connection communication between the memory 11 and at least one processor 10 etc.
The communication interface 13 is used for communication between the electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), typically used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a Display (Display), an input unit such as a Keyboard (Keyboard), or alternatively a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, or the like. The display may also be referred to as a display screen or display unit, as appropriate, for displaying information processed in the electronic device and for displaying a visual user interface.
Fig. 5 shows only an electronic device with components, and it will be understood by those skilled in the art that the structure shown in fig. 5 is not limiting of the electronic device and may include fewer or more components than shown, or may combine certain components, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power source (such as a battery) for supplying power to the respective components, and preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that functions of charge management, discharge management, power consumption management, and the like are implemented through the power management device. The power supply may also include one or more of any of a direct current or alternating current power supply, recharging device, power failure detection circuit, power converter or inverter, power status indicator, etc. The electronic device may further include various sensors, bluetooth modules, wi-Fi modules, etc., which are not described herein.
It should be understood that the embodiments described are for illustrative purposes only and are not limited to this configuration in the scope of the patent application.
The dynamically sampled dialog generation model training program stored by the memory 11 in the electronic device is a combination of a plurality of computer programs that, when run in the processor 10, may implement:
Step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
step B, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3 … n and the initial value is 1;
step C, acquiring a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating the replacement probability of the reference answer word, and obtaining an i+1-th position input word according to the replacement probability;
step D, inputting the (i+1) th position input word into the dialogue generation model to generate an (i+1) th position answer word, and returning to the step C until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words at a plurality of positions;
and E, collecting the answer words at each position to obtain a standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
In particular, the specific implementation method of the processor 10 on the computer program may refer to the description of the relevant steps in the corresponding embodiment of fig. 1, which is not repeated herein.
Further, the electronic device integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a non-volatile computer readable storage medium. The computer readable storage medium may be volatile or nonvolatile. For example, the computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM).
The present invention also provides a computer readable storage medium storing a computer program which, when executed by a processor of an electronic device, can implement:
step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
Step B, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3 … n and the initial value is 1;
step C, acquiring a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating the replacement probability of the reference answer word, and obtaining an i+1-th position input word according to the replacement probability;
step D, inputting the (i+1) th position input word into the dialogue generation model to generate an (i+1) th position answer word, and returning to the step C until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words at a plurality of positions;
and E, collecting the answer words at each position to obtain a standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
In the several embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over 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.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The blockchain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and the like. The Blockchain (Blockchain), which is essentially a decentralised database, is a string of data blocks that are generated by cryptographic means in association, each data block containing a batch of information of network transactions for verifying the validity of the information (anti-counterfeiting) and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, an application services layer, and the like.
The embodiment of the application can acquire and process the related data based on the artificial intelligence technology. Among these, artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a digital computer-controlled machine to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use knowledge to obtain optimal results.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (10)

1. A method of dynamically sampled dialog generation model training, the method comprising:
step A, obtaining a reference answer sentence, performing word segmentation on the reference answer sentence to obtain an answer word sequence, and obtaining a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
step B, inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2, 3 … n and the initial value is 1;
step C, acquiring a reference answer word corresponding to the i-th position answer word in the answer word sequence based on the word position information, calculating the replacement probability of the reference answer word, and obtaining an i+1-th position input word according to the replacement probability;
step D, inputting the (i+1) th position input word into the dialogue generation model to generate an (i+1) th position answer word, and returning to the step C until no corresponding reference answer word exists in the answer word sequence, so as to obtain answer words at a plurality of positions;
And E, collecting the answer words at each position to obtain a standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
2. The method for training a dynamically sampled dialog generation model according to claim 1, wherein inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialog generation model to obtain an ith position answer word comprises:
word segmentation is carried out on the query sentence based on a word segmentation device in the dialogue generation model, so as to obtain a query word sequence;
converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
and generating an i-th position answer word of the query sentence through a decoding layer of a transducer in the dialogue generation model.
3. The method for training a dynamically sampled dialog generation model as claimed in claim 1, wherein the word segmentation of the reference answer sentence to obtain an answer word sequence comprises:
constructing a prefix dictionary according to a preset statistical dictionary, and dividing the reference answer sentence by using a regular expression to obtain a divided answer sentence;
Constructing a directed acyclic graph of the segmentation answer sentence according to the prefix dictionary;
and obtaining a probability maximum path of the directed acyclic graph by using a dynamic programming method, and segmenting words according to the probability maximum path to obtain the answer word sequence.
4. The method for training a dynamically sampled dialog generation model as claimed in claim 1, wherein the deriving the i+1-th position input word from the substitution probability comprises:
acquiring a preset replacement probability threshold;
judging whether the replacement probability is larger than or equal to the replacement probability threshold value;
if the replacement probability is greater than or equal to the replacement probability threshold, using the reference answer word as the (i+1) th position input word;
and if the replacement probability is smaller than the replacement probability threshold, taking the ith position answer word as the (i+1) th position input word.
5. The dynamically sampled dialog generation model training method of claim 1, wherein after the dialog generation model is trained with the fine-tuning training data, the method further comprises:
acquiring multi-dimensional objective indexes, testing and analyzing a standard dialogue generating model obtained by training the dialogue generating model through the fine tuning training data through the multi-dimensional objective indexes, and judging whether the standard dialogue model reaches a preset fine tuning target or not;
C, if the standard dialogue generating model does not reach the preset fine tuning target, returning to the step C;
and if the standard dialogue generating model reaches the preset fine tuning target, finishing fine tuning training of the standard dialogue generating model.
6. The dynamically sampled dialog generation model training method of claim 1, wherein the calculating the substitution probability of the reference answer word comprises:
calculating the substitution probability N of the test answer words through the following probability calculation formula:
wherein said y andrespectively representing the answer words at the current position and the reference answer words corresponding to the answer words at the current position, wherein T is the total number of positions, beta is a preset parameter value, mu is distribution, and the representation is equivalent to the distribution.
7. A dynamically sampled dialog generation model training device, the device comprising:
the word information acquisition module is used for acquiring a reference answer sentence, segmenting the reference answer sentence to obtain an answer word sequence, and acquiring a plurality of reference answer words and word position information of each reference answer word according to the answer word sequence;
the input word acquisition module is used for inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialogue generation model to obtain an i-th position answer word, wherein i=1, 2 and 3 … n are initial values of 1, the reference answer word corresponding to the i-th position answer word in the answer word sequence is acquired based on the word position information, the replacement probability of the reference answer word is calculated, and the i+1th position input word is obtained according to the replacement probability;
The answer word acquisition module is used for inputting the (i+1) th position input word into the dialogue generation model, generating the (i+1) th position answer word, and returning to the previous step until the corresponding reference answer word does not exist in the answer word sequence, so as to obtain answer words at a plurality of positions;
and the model training module is used for collecting the answer words at each position, obtaining the standard answer sentence of the query sentence, generating fine tuning training data according to the query sentence and the standard answer sentence, and training the dialogue generation model through the fine tuning training data.
8. The dynamically sampled dialog generation model training device of claim 7, wherein inputting the query sentence corresponding to the reference answer sentence into a pre-trained dialog generation model to obtain an ith location answer word comprises:
word segmentation is carried out on the query sentence based on a word segmentation device in the dialogue generation model, so as to obtain a query word sequence;
converting each word in the query word sequence into a word vector through a word embedding algorithm to obtain a word vector sequence;
and generating an i-th position answer word of the query sentence through a decoding layer of a transducer in the dialogue generation model.
9. An electronic device, the electronic device comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the dynamically sampled dialog generation model training method of any of claims 1 to 6.
10. A computer-readable storage medium comprising a storage data area storing created data and a storage program area storing a computer program; wherein the computer program, when executed by a processor, implements a dynamically sampled dialog generation model training method as claimed in any of claims 1 to 6.
CN202310725410.1A 2023-06-16 2023-06-16 Dynamic sampling dialogue generation model training method, device, equipment and medium Pending CN116719920A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310725410.1A CN116719920A (en) 2023-06-16 2023-06-16 Dynamic sampling dialogue generation model training method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310725410.1A CN116719920A (en) 2023-06-16 2023-06-16 Dynamic sampling dialogue generation model training method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN116719920A true CN116719920A (en) 2023-09-08

Family

ID=87867579

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310725410.1A Pending CN116719920A (en) 2023-06-16 2023-06-16 Dynamic sampling dialogue generation model training method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN116719920A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116957047A (en) * 2023-09-19 2023-10-27 苏州元脑智能科技有限公司 Sampling network updating method, device, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116957047A (en) * 2023-09-19 2023-10-27 苏州元脑智能科技有限公司 Sampling network updating method, device, equipment and medium
CN116957047B (en) * 2023-09-19 2024-01-23 苏州元脑智能科技有限公司 Sampling network updating method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN109992664B (en) Dispute focus label classification method and device, computer equipment and storage medium
CN110489555A (en) A kind of language model pre-training method of combination class word information
CN107861954B (en) Information output method and device based on artificial intelligence
CN112052684A (en) Named entity identification method, device, equipment and storage medium for power metering
CN112988963B (en) User intention prediction method, device, equipment and medium based on multi-flow nodes
CN112307168A (en) Artificial intelligence-based inquiry session processing method and device and computer equipment
CN115392237B (en) Emotion analysis model training method, device, equipment and storage medium
CN113706322A (en) Service distribution method, device, equipment and storage medium based on data analysis
CN115357719A (en) Power audit text classification method and device based on improved BERT model
CN113821527A (en) Hash code generation method and device, computer equipment and storage medium
CN116719920A (en) Dynamic sampling dialogue generation model training method, device, equipment and medium
CN116681082A (en) Discrete text semantic segmentation method, device, equipment and storage medium
CN115759119A (en) Financial text emotion analysis method, system, medium and equipment
CN115374771A (en) Text label determination method and device
CN116522944A (en) Picture generation method, device, equipment and medium based on multi-head attention
CN116341646A (en) Pretraining method and device of Bert model, electronic equipment and storage medium
CN110287396A (en) Text matching technique and device
CN115617959A (en) Question answering method and device
CN114676699A (en) Entity emotion analysis method and device, computer equipment and storage medium
CN112749264A (en) Problem distribution method and device based on intelligent robot, electronic equipment and storage medium
US11989520B2 (en) System and method for morality assessment
CN114462411B (en) Named entity recognition method, device, equipment and storage medium
CN113064887B (en) Data management method, device, equipment and storage medium
CN116451706A (en) Emotion recognition method and device based on specific words, electronic equipment and storage medium
CN116825391A (en) Method, device, equipment and storage medium for question and answer sorting model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination