CN118093836A - Online question-answering prompt word optimization generation method based on large language model - Google Patents

Online question-answering prompt word optimization generation method based on large language model Download PDF

Info

Publication number
CN118093836A
CN118093836A CN202410491451.3A CN202410491451A CN118093836A CN 118093836 A CN118093836 A CN 118093836A CN 202410491451 A CN202410491451 A CN 202410491451A CN 118093836 A CN118093836 A CN 118093836A
Authority
CN
China
Prior art keywords
words
prompt
word
prompting
representing
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.)
Granted
Application number
CN202410491451.3A
Other languages
Chinese (zh)
Other versions
CN118093836B (en
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.)
Xiangjiang Laboratory
Original Assignee
Xiangjiang Laboratory
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 Xiangjiang Laboratory filed Critical Xiangjiang Laboratory
Priority to CN202410491451.3A priority Critical patent/CN118093836B/en
Publication of CN118093836A publication Critical patent/CN118093836A/en
Application granted granted Critical
Publication of CN118093836B publication Critical patent/CN118093836B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Machine Translation (AREA)

Abstract

The embodiment of the disclosure provides an online question-answering prompt word optimization generation method based on a large language model, which belongs to the technical field of computation and specifically comprises the following steps: constructing a consultation problem database; forming a keyword set; vectorization of prompt words; calculating cosine similarity between the vectorized input prompt word and each vectorized consultation prompt word; randomly combining the keyword sets according to semantics; merging the first prompting word set and the second prompting word set; calculating the score of each individual in the initialized population according to the adaptive value function; performing single-point cross operation; performing flow-related variation; calculating the score of the prompting word set after the flow association variation; selecting half of the prompting words from the target prompting word set according to the target score set and the roulette algorithm; circularly obtaining a new prompt word set and a new score set corresponding to the new prompt word set; the scores in the new score set are ordered and the top X items are selected to make up the set. Through the scheme of the disclosure, the solution accuracy and efficiency are improved.

Description

Online question-answering prompt word optimization generation method based on large language model
Technical Field
The embodiment of the disclosure relates to the technical field of computing, in particular to an online question-answering prompt word optimization generation method based on a large language model.
Background
Currently, a Large Language Model (LLM) is a deep learning model trained based on massive text data, which not only can generate natural language text, but also can deeply understand text meaning and process various natural language tasks such as text abstracts, questions and answers, translation and the like. In the online question and answer of the large language model, a user often faces the problems of unclear description, unsmooth expression, lack of expertise and the like when describing the problem, so that the large language model is difficult to accurately understand the user intention, and therefore the answer meeting the user expectation cannot be provided, and the user satisfaction degree and experience degree are reduced.
Therefore, an online question-answering prompt word optimization generation method based on a large language model for automatically and accurately solving the problems is needed.
Disclosure of Invention
In view of the above, the embodiments of the present disclosure provide an online question-answering prompt word optimization generation method based on a large language model, which at least partially solves the problem in the prior art that the solution efficiency and the accuracy are poor.
The embodiment of the disclosure provides an online question-answer prompt word optimization generation method based on a large language model, which comprises the following steps:
Step 1, constructing a consultation problem database, wherein the consultation problem database comprises a first data set and a second data set, the first data set comprises keywords related to the consultation problem and classifies the keywords according to the field to which the consultation problem belongs, and the second data set comprises consultation prompt words;
Step 2, matching the keyword information of the input prompt words with the corresponding keywords in the first data set by using a large language model to form a keyword set;
Step 3, vectorizing the input prompt words and the consultation prompt words in the second data set by using a Word2Vec model;
Step 4, calculating cosine similarity between the vectorized input prompt words and each vectorized consultation prompt word to obtain a similarity set, and sequencing the similarity set to obtain a vector set closest to the vectorized input prompt words to obtain a first prompt word set corresponding to the vector set;
Step 5, randomly combining the keyword sets by the large language model according to the semantics to form a second prompting word set;
step 6, combining the first prompting word set and the second prompting word set to form an initial prompting word set, and taking the initial prompting word set as an initialization population;
Step 7, calculating the score of each individual in the initialized population according to the adaptive value function to form an initial population to obtain diversity;
Step 8, randomly selecting two prompting words in the initial prompting word set as parent prompting words, performing single-point cross operation on the two prompting words to obtain two new prompting words, and repeating the operation to obtain a prompting word set after the cross operation;
step 9, carrying out flow association mutation on the prompt word set obtained after the cross operation;
step 10, calculating the score of the prompting word set after the flow association variation;
Step 11, merging the initial prompt word set and the prompt word set after the flow association variation to obtain a target prompt word set, merging the score set of the initial prompt word set and the score set of the prompt word set after the flow association variation to obtain a target score set, and selecting half of the prompt words and corresponding scores from the target prompt word set according to the target score set and a roulette algorithm;
Step 12, circulating the steps 8 to 11 for preset times to obtain a new prompting word set and a new score set corresponding to the new prompting word set;
And 13, sorting the scores in the new score set from large to small, selecting the former X item composition set, and outputting and displaying the corresponding prompt word formation set to a user interface.
According to a specific implementation manner of the embodiment of the present disclosure, the expression of the cosine similarity is
Wherein,Input prompt word representing vectorization,/>Vectorized/>Consultation prompt term,/>Representation/>And/>Cosine similarity of/>Representation/>And/>Inner product of/>And/>Respectively express/>And/>Is a mold of (a).
According to a specific implementation manner of the embodiment of the disclosure, the expression of the adaptive value function is
Wherein,Representing similarity,/>Representing coherence,/>The complexity of the representation is indicated as such,Respectively express/>、/>,/>And/>
Wherein the method comprises the steps of,/>,/>Representing the number of words in the first set of hint words,/>Representing the number of words in the second prompting word set;
initial set of hint words representing vectorization/> />Vectors,/>Representing the set of vectors that are most similar to the vectorized input prompt term/>/>Vectors,/>Representation ofVector set/>Average cosine similarity of vectors in (1), wherein/>Representing vectors/>Vector of ANDInner product of/>And/>Respectively represent vector/>Sum vector/>Modulus of/>Representing vectors/>To a collectionIs a total distance of (2);
Wherein, ,/>Representing a large language model,/>Representing an initial set of hint words/>Words of prompt,/>Representing large language model pairs/>Consistency scoring of/>The grammar correctness, logic and definiteness of the prompt words are respectively expressed,Representing large language model versus prompt words/>Is scored for grammatical correctness, logically or explicitly, the score being defined at/>,/>Weights representing scores and/>
Wherein, if the prompt word is Chinese text,Presenting hint words/>If the prompt word is english text,/>Presenting hint words/>Word number of/>Presenting hint words/>Average number of syllables,/>Representing large language model versus prompt words/>Scoring of complexity of/>Representation ofOr/>And/>
According to a specific implementation manner of the embodiment of the present disclosure, the expression of the average number of bytes is
Wherein the method comprises the steps ofPresenting hint words/>Average number of syllables,/>Presenting hint words/>Character number,/>Presenting hint words/>Is a word number of (a) in the word.
According to a specific implementation manner of the embodiment of the present disclosure, the step 9 specifically includes:
collecting prompt words obtained after cross operation The prompt word in (1) is recorded asWherein/>Presenting hint words/>/>Individual words, each/>A fixed flow value/>, is setAnd threshold/>And/>
JudgingWhether or not a mutation occurs, if/>When variation occurs, the corresponding flow value/>Flows backward in a decreasing manner according to the flow formula if flowing to/>At that point, flow value/>Decreasing to/>And/>Then/>Also variant, otherwise,/>No change occurs.
According to a specific implementation of the embodiment of the disclosure, the flow formula is
Wherein the method comprises the steps ofRepresentation/>Flow value of/>Representation/>Flow to/>Flow value at time,/>Is a positive decrementing coefficient, controls the rate of decrementing,/>Representation/>Position subscript of/>Representation/>Position subscript of/>Representation/>Threshold at/>Representation/>A threshold value at.
According to a specific implementation of the embodiment of the disclosure, the expression of the roulette algorithm is that
Represents the/>Probability of individual hint words being selected,/>Representing the/>, in a set of target scoresScore of individual cue words.
The online question-answer prompt word optimization generation scheme based on the large language model in the embodiment of the disclosure comprises the following steps: step 1, constructing a consultation problem database, wherein the consultation problem database comprises a first data set and a second data set, the first data set comprises keywords related to the consultation problem and classifies the keywords according to the field to which the consultation problem belongs, and the second data set comprises consultation prompt words; step 2, matching the keyword information of the input prompt words with the corresponding keywords in the first data set by using a large language model to form a keyword set; step 3, vectorizing the input prompt words and the consultation prompt words in the second data set by using a Word2Vec model; step 4, calculating cosine similarity between the vectorized input prompt words and each vectorized consultation prompt word to obtain a similarity set, and sequencing the similarity set to obtain a vector set closest to the vectorized input prompt words to obtain a first prompt word set corresponding to the vector set; step 5, randomly combining the keyword sets by the large language model according to the semantics to form a second prompting word set; step 6, combining the first prompting word set and the second prompting word set to form an initial prompting word set, and taking the initial prompting word set as an initialization population; step 7, calculating the score of each individual in the initialized population according to the adaptive value function to form an initial population to obtain diversity; step 8, randomly selecting two prompting words in the initial prompting word set as parent prompting words, performing single-point cross operation on the two prompting words to obtain two new prompting words, and repeating the operation to obtain a prompting word set after the cross operation; step 9, carrying out flow association mutation on the prompt word set obtained after the cross operation; step 10, calculating the score of the prompting word set after the flow association variation; step 11, merging the initial prompt word set and the prompt word set after the flow association variation to obtain a target prompt word set, merging the score set of the initial prompt word set and the score set of the prompt word set after the flow association variation to obtain a target score set, and selecting half of the prompt words and corresponding scores from the target prompt word set according to the target score set and a roulette algorithm; step 12, circulating the steps 8 to 11 for preset times to obtain a new prompting word set and a new score set corresponding to the new prompting word set; and 13, sorting the scores in the new score set from large to small, selecting the former X item composition set, and outputting and displaying the corresponding prompt word formation set to a user interface.
The beneficial effects of the embodiment of the disclosure are that: according to the scheme, a method of combining a large language model with an improved genetic algorithm is adopted, and a flow correlation mutation method is provided, wherein the traditional mutation strategy is changed through introducing a flow value and a threshold value, and the mutation capability of the genetic algorithm is further enhanced. Through the mutation strategy, the generation efficiency and quality of the prompt words are improved, and the accuracy and efficiency of solving the problems are improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and other drawings may be obtained according to these drawings without inventive effort to a person of ordinary skill in the art.
FIG. 1 is a schematic flow chart of an online question-answer prompt word optimization generation method based on a large language model provided by an embodiment of the disclosure;
FIG. 2 is a schematic diagram of a specific implementation flow of an online question-answer prompt word optimization generation method based on a large language model according to an embodiment of the disclosure;
Fig. 3 is a schematic diagram of a flow process of a flow value according to an embodiment of the disclosure.
Detailed Description
Embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
Other advantages and effects of the present disclosure will become readily apparent to those skilled in the art from the following disclosure, which describes embodiments of the present disclosure by way of specific examples. It will be apparent that the described embodiments are merely some, but not all embodiments of the present disclosure. The disclosure may be embodied or practiced in other different specific embodiments, and details within the subject specification may be modified or changed from various points of view and applications without departing from the spirit of the disclosure. It should be noted that the following embodiments and features in the embodiments may be combined with each other without conflict. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure are intended to be within the scope of this disclosure.
It is noted that various aspects of the embodiments are described below within the scope of the following claims. It should be apparent that the aspects described herein may be embodied in a wide variety of forms and that any specific structure and/or function described herein is merely illustrative. Based on the present disclosure, one skilled in the art will appreciate that one aspect described herein may be implemented independently of any other aspect, and that two or more of these aspects may be combined in various ways. For example, an apparatus may be implemented and/or a method practiced using any number of the aspects set forth herein. In addition, such apparatus may be implemented and/or such methods practiced using other structure and/or functionality in addition to one or more of the aspects set forth herein.
It should also be noted that the illustrations provided in the following embodiments merely illustrate the basic concepts of the disclosure by way of illustration, and only the components related to the disclosure are shown in the drawings and are not drawn according to the number, shape and size of the components in actual implementation, and the form, number and proportion of the components in actual implementation may be arbitrarily changed, and the layout of the components may be more complicated.
In addition, in the following description, specific details are provided in order to provide a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects may be practiced without these specific details.
The embodiment of the disclosure provides an online question-answering prompt word optimization generation method based on a large language model, which can be applied to the online user answering process of government affairs or enterprises.
Referring to fig. 1, a flowchart of an online question-answer prompt word optimization generation method based on a large language model is provided in an embodiment of the present disclosure. As shown in fig. 1 and 2, the method mainly comprises the following steps:
Step 1, constructing a consultation problem database, wherein the consultation problem database comprises a first data set and a second data set, the first data set comprises keywords related to the consultation problem and classifies the keywords according to the field to which the consultation problem belongs, and the second data set comprises consultation prompt words;
in specific implementation, a consultation problem database can be constructed The database consists of two parts: /(I)And/>The method comprises the steps of including various keywords related to the consultation problems, classifying the keywords according to the field of the consultation problems, such as identity card handling types including { identity card, updating, losing, applying, flow and other } keywords; tax transaction class including { personal income tax, real estate tax, vehicle tax, flow, time, etc. } keywords; educational transactions class including { school fees, scores, books, education, time, place, etc. } keywords. /(I)Consists of consultation prompt words, wherein/>Represents the/>Consultation prompting words, namely the problem that consultation needs to be carried out,/>Vectorization by Word2VecWherein/>Represents vectorized/>And (5) consulting the prompt words.
Step 2, matching the keyword information of the input prompt words with the corresponding keywords in the first data set by using a large language model to form a keyword set;
In particular, the method can be implemented by a large language model Will input prompt words/>Keyword information of/>Corresponding keywords in the key words are matched to form a keyword set/>Wherein/>Represents the/>And a key.
Step 3, vectorizing the input prompt words and the consultation prompt words in the second data set by using a Word2Vec model;
In specific implementation, the Word2Vec model can be utilized to vectorize the input prompt words and the consultation prompt words in the second data set so as to carry out subsequent operation flow.
Step 4, calculating cosine similarity between the vectorized input prompt words and each vectorized consultation prompt word to obtain a similarity set, and sequencing the similarity set to obtain a vector set closest to the vectorized input prompt words to obtain a first prompt word set corresponding to the vector set;
On the basis of the embodiment, the expression of the cosine similarity is
Wherein,Input prompt word representing vectorization,/>Vectorized/>Consultation prompt term,/>Representation/>And/>Cosine similarity of/>Representation/>And/>Inner product of/>AndRespectively express/>And/>Is a mold of (a).
In specific implementation, calculateAnd/>Cosine similarity of (5) >, get/>Representation/>And/>And calculating the obtained cosine similarity. Will/>Ordering to obtain AND/>Most similar vector setWherein/>Represents the/>Vectors, and/>. Vector set/>The corresponding set of hint words is denoted/>,/>Vectorization by Word2Vec yields/>Wherein/>
Formulas for calculating cosine similarity are as follows (1):
(1)
Wherein the method comprises the steps of Input prompt word representing vectorization,/>Vectorized/>Consultation prompt term,/>Representation/>And/>Cosine similarity of/>Representing vectors/>And/>Inner product of/>And/>Respectively express/>And/>Is a mold of (a).
Step 5, randomly combining the keyword sets by the large language model according to the semantics to form a second prompting word set;
In particular, the method can be implemented by a large language model Will gather/>Randomly combining the prompting word sets according to the semantics,/>Represents the/>The prompting words;
step 6, combining the first prompting word set and the second prompting word set to form an initial prompting word set, and taking the initial prompting word set as an initialization population;
in particular implementation, the first prompt word set And a second set of hint wordsMerging to obtain initial prompt word set/>And takes it as an initialized population, wherein/>Represents the/>Individual prompt words, and/>And can collect the initial prompt wordVectorization by Word2Vec yields the set/>
Step 7, calculating the score of each individual in the initialized population according to the adaptive value function to form an initial population to obtain diversity;
on the basis of the embodiment, the expression of the adaptive value function is
Wherein,Representing similarity,/>Representing coherence,/>The complexity of the representation is indicated as such,Respectively express/>、/>,/>And/>
Wherein the method comprises the steps of,/>,/>Representing the number of words in the first set of hint words,/>Representing the number of words in the second prompting word set;
initial set of hint words representing vectorization/> />Vectors,/>Representing the set of vectors that are most similar to the vectorized input prompt term/>/>Vectors,/>Representation/>Vector set/>Average cosine similarity of vectors in (1), wherein/>Representing vectors/>Vector/>Inner product of/>And/>Respectively represent vector/>Sum vector/>Modulus of/>Representing vectors/>To a collectionIs a total distance of (2);
Wherein, ,/>Representing a large language model,/>Representing an initial set of hint words/>Words of prompt,/>Representing large language model pairs/>Consistency scoring of/>The grammar correctness, logic and definiteness of the prompt words are respectively expressed,Representing large language model versus prompt words/>Is scored for grammatical correctness, logically or explicitly, the score being defined at/>,/>Weights representing scores and/>
Wherein, if the prompt word is Chinese text,Presenting hint words/>If the prompt word is english text,/>Presenting hint words/>Word number of/>Presenting hint words/>Average number of syllables,/>Representing large language model versus prompt words/>Scoring of complexity of/>Representation ofOr/>And/>
Further, the average number of bytes is expressed as
Wherein the method comprises the steps ofPresenting hint words/>Average number of syllables,/>Representing a prompt wordCharacter number,/>Presenting hint words/>Is a word number of (a) in the word.
In particular, the method is to collectAccording to the fitness value function/>Scoring is carried out, and the score is recorded as,/>Represents the/>Score of individual cue words.
The fitness function (F) is as in equation (2):
(2)
Wherein the method comprises the steps of Representing similarity,/>Representing coherence,/>Representing complexity. /(I)Respectively express/>、/>,/>And/>
The calculation mode of (a) is as shown in a formula (3):
(3)
Wherein the method comprises the steps of
Initial set of hint words representing vectorization/>/>Vectors,/>Representing the set of vectors that are most similar to the vectorized input prompt term/>/>Vectors,/>Representation/>Vector set/>Average cosine similarity of vectors in (1), wherein/>Representing vectors/>Vector/>Inner product of/>And/>Respectively represent vector/>Sum vector/>Is a mold of (a). /(I)Representing vectors/>To collection/>Is a function of the total distance of (a).
The calculation mode of (a) is as shown in a formula (4):
(4)
Wherein the method comprises the steps of
Representing a large language model,/>Representing collections/>/>Words of prompt,/>Representing large language model pairs/>Consistency scoring of/>Grammar correctness, logics and definiteness of expressed prompt words respectively,/>Representing large language model versus prompt words/>Is scored for grammatical correctness, logically or explicitly, the score being defined at/>;/>Weight of score is represented and
The calculation mode of (a) is as shown in a formula (5):
(5)
If the alert word is a chinese text, Presenting hint words/>Is the number of words of (a); if the prompt is English text,/>Presenting hint words/>Word number of/>Presenting hint words/>Average number of syllables,/>Representing large language model versus prompt words/>Scoring of complexity of/>Representation ofOr/>And/>
The calculation formula of the average pitch number is as formula (6):
(6)
Wherein the method comprises the steps of Presenting hint words/>Average number of syllables,/>Representing a prompt wordCharacter number,/>Presenting hint words/>Is a word number of (a) in the word.
Step 8, randomly selecting two prompting words in the initial prompting word set as parent prompting words, performing single-point cross operation on the two prompting words to obtain two new prompting words, and repeating the operation to obtain a prompting word set after the cross operation;
in specific implementation, the initial prompt word set can be randomly selected Two prompting words in the tree are used as parent prompting words, and single-point cross operation is carried out on the two prompting words to obtain prompting words/>And/>Repeating the above operation to obtain the prompting word set/>
Step 9, carrying out flow association mutation on the prompt word set obtained after the cross operation;
on the basis of the above embodiment, the step 9 specifically includes:
collecting prompt words obtained after cross operation The prompt word in (1) is recorded asWherein/>Presenting hint words/>/>Individual words, each/>A fixed flow value/>, is setAnd threshold/>And/>
JudgingWhether or not a mutation occurs, if/>When variation occurs, the corresponding flow value/>Flows backward in a decreasing manner according to the flow formula if flowing to/>At that point, flow value/>Decreasing to/>And/>Then/>Also variant, otherwise,/>No change occurs.
Further, the flow formula is
Wherein the method comprises the steps ofRepresentation/>Flow value of/>Representation/>Flow to/>Flow value at time,/>Is a positive decrementing coefficient, controls the rate of decrementing,/>Representation/>Position subscript of/>Representation/>Position subscript of/>Representation/>Threshold at/>Representation/>A threshold value at.
In specific implementation, the prompt word set obtained after the cross operation can be collectedPerforming 'flow-related mutation', and marking the mutated prompt word set as/>. The "flow-related variation" operates as follows:
Prompt word Consists of several words, noted as/>Wherein/>Presenting hint words/>/>Individual words, each/>A fixed flow value/>, is setAnd threshold/>And/>
Whether a mutation occurs is as shown in formula (7):
where r is a uniformly distributed random number and CR is a predefined probability of variation.
If it isThe variation occurs, then its corresponding flow value/>Will flow in a decreasing manner backwards (flow formula such as formula (8)), if flowing to/>At that point, flow value/>Decreasing to/>And/>Then/>Also variant, otherwise,/>No change occurs. Wherein the variation is defined by a large language model/>From the database/>In and/>The same category and closest word is replaced.
Flow formula as formula (8):
(8)
Wherein the method comprises the steps of Representation/>Flow value of/>Representation/>Flow to/>Flow value at time,/>Is a positive decrementing coefficient, controls the rate of decrementing,/>Representation/>Position subscript of/>Representation/>Position subscript of/>Representation/>Threshold at/>Representation/>A threshold value at.
The flow process of the flow value is schematically shown in FIG. 3, and FIG. 3 shows"Flow-dependent variation" process of (1), when/>The solid line in FIG. 3 shows/>, when a variation occursCorresponding flow value/>When/>Flow to/>At the time of treatment,/>Decreasing to/>And/>Less than/>Threshold/>,/>No variation occurs when/>Flow to/>At the time of treatment,/>Greater than/>Threshold/>,/>Variations will occur. Same principle/>Variation can occur,/>No variation occurs. The dotted line in FIG. 3 shows/>Corresponding flow value/>And the same applies to the flow process of (1)/(2) in this processVariation can occur,/>And/>No variation occurs. /(I)
Step 10, calculating the score of the prompting word set after the flow association variation;
For example, a set of post-flow-related mutated hint words can be computed Score/>Is marked as
Step 11, merging the initial prompt word set and the prompt word set after the flow association variation to obtain a target prompt word set, merging the score set of the initial prompt word set and the score set of the prompt word set after the flow association variation to obtain a target score set, and selecting half of the prompt words and corresponding scores from the target prompt word set according to the target score set and a roulette algorithm;
Further, the expression of the roulette algorithm is
Represents the/>Probability of individual hint words being selected,/>Representing the/>, in a set of target scoresScore of individual cue words.
In the concrete implementation, the prompt word setAnd the resulting set of prompt words/>Merging to obtain a prompt word set/>Will/>Score set/>And/>Score set/>Merging to obtain/>According to score set/>And roulette algorithm slave/>In selection/>The prompt words are recorded as
Roulette algorithm such as formula (9)
(9)
Represents the/>Probability of individual hint words being selected,/>Represents the/>Score of individual cue words. And then/>The intervals are divided into/>, according to the cumulative probabilityEach part has a length of/>Decision, generate one/>Random numbers rand between them, and then select the corresponding hint words according to which part of the wheel the rand falls on.
Step 12, circulating the steps 8 to 11 for preset times to obtain a new prompting word set and a new score set corresponding to the new prompting word set;
in specific implementation, the number of circulation times can be preset according to the requirement, and then the preset times from the step 8 to the step 11 can be circulated according to the preset number of circulation times, so as to obtain a new prompting word set And a new set of scores
And 13, sorting the scores in the new score set from large to small, selecting the former X item composition set, and outputting and displaying the corresponding prompt word formation set to a user interface.
For example, score setsThe scores in (1) are ordered from big to small and the top X item composition set/>, is selectedScore set/>Corresponding prompt word sets are marked asWord set to be prompted/>As feedback for user selection.
Through the steps, the user initially inputs the prompt wordOptimization generation as a set of hint wordsThe user can select the prompt word which is most suitable for the consultation will of the user from the set, and the large language model can answer according to the optimized consultation problem, so that the user can obtain more satisfactory answers, and the service pressure of staff is further reduced.
According to the online question-answering prompt word optimization generation method based on the large language model, a flow association mutation method is provided by adopting a method of combining the large language model with an improved genetic algorithm, and the traditional mutation strategy is changed by introducing a flow value and a threshold value, so that the mutation capability of the genetic algorithm is further enhanced. Through the mutation strategy, the generation efficiency and quality of the prompt words are improved, and the accuracy and efficiency of solving the problems are improved.
It should be understood that portions of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof.
The foregoing is merely specific embodiments of the disclosure, but the protection scope of the disclosure is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the disclosure are intended to be covered by the protection scope of the disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (7)

1. An online question-answering prompt word optimization generation method based on a large language model is characterized by comprising the following steps:
Step 1, constructing a consultation problem database, wherein the consultation problem database comprises a first data set and a second data set, the first data set comprises keywords related to the consultation problem and classifies the keywords according to the field to which the consultation problem belongs, and the second data set comprises consultation prompt words;
Step 2, matching the keyword information of the input prompt words with the corresponding keywords in the first data set by using a large language model to form a keyword set;
Step 3, vectorizing the input prompt words and the consultation prompt words in the second data set by using a Word2Vec model;
Step 4, calculating cosine similarity between the vectorized input prompt words and each vectorized consultation prompt word to obtain a similarity set, and sequencing the similarity set to obtain a vector set closest to the vectorized input prompt words to obtain a first prompt word set corresponding to the vector set;
Step 5, randomly combining the keyword sets by the large language model according to the semantics to form a second prompting word set;
step 6, combining the first prompting word set and the second prompting word set to form an initial prompting word set, and taking the initial prompting word set as an initialization population;
Step 7, calculating the score of each individual in the initialized population according to the adaptive value function to form an initial population to obtain diversity;
Step 8, randomly selecting two prompting words in the initial prompting word set as parent prompting words, performing single-point cross operation on the two prompting words to obtain two new prompting words, and repeating the operation to obtain a prompting word set after the cross operation;
step 9, carrying out flow association mutation on the prompt word set obtained after the cross operation;
step 10, calculating the score of the prompting word set after the flow association variation;
Step 11, merging the initial prompt word set and the prompt word set after the flow association variation to obtain a target prompt word set, merging the score set of the initial prompt word set and the score set of the prompt word set after the flow association variation to obtain a target score set, and selecting half of the prompt words and corresponding scores from the target prompt word set according to the target score set and a roulette algorithm;
Step 12, circulating the steps 8 to 11 for preset times to obtain a new prompting word set and a new score set corresponding to the new prompting word set;
And 13, sorting the scores in the new score set from large to small, selecting the former X item composition set, and outputting and displaying the corresponding prompt word formation set to a user interface.
2. The method of claim 1, wherein the cosine similarity is expressed as
Wherein,Input prompt word representing vectorization,/>Vectorized/>Consultation prompt term,/>Representation/>And/>Cosine similarity of/>Representation/>And/>Inner product of/>And/>Respectively express/>And/>Is a mold of (a).
3. The method of claim 2, wherein the adaptive value function has an expression of
Wherein,Representing similarity,/>Representing coherence,/>Representing complexity,/>Respectively express/>、/>And/>
Wherein the method comprises the steps of,/>,/>Representing the number of words in the first set of hint words,/>Representing the number of words in the second prompting word set;
initial set of hint words representing vectorization/> />Vectors,/>Representing the set of vectors that are most similar to the vectorized input prompt term/>/>Vectors,/>Representation/>Vector set/>Average cosine similarity of vectors in (1), wherein/>Representing vectors/>Vector/>Inner product of/>And/>Respectively represent vector/>Sum vector/>Modulus of/>Representing vectors/>To a collectionIs a total distance of (2);
Wherein, ,/>Representing a large language model,/>Representing initial set of hint words/>/>Words of prompt,/>Representing large language model pairsConsistency scoring of/>Grammar correctness, logics and definiteness of expressed prompt words respectively,/>Representing large language model versus prompt words/>Is scored for grammatical correctness, logically or explicitly, the score being defined at/>,/>Weights representing scores and/>
Wherein, if the prompt word is Chinese text,Presenting hint words/>If the prompt word is english text,/>Presenting hint words/>Word number of/>Presenting hint words/>Average number of syllables,/>Representing large language model versus prompt words/>Scoring of complexity of/>Representation/>Or/>And/>
4. A method according to claim 3, wherein the average number of bytes is expressed as
Wherein the method comprises the steps ofPresenting hint words/>Average number of syllables,/>Presenting hint words/>Character number,/>Presenting hint words/>Is a word number of (a) in the word.
5. The method according to claim 4, wherein the step 9 specifically comprises:
collecting prompt words obtained after cross operation The prompt word in (1) is recorded asWherein/>Presenting hint words/>/>Individual words, each/>A fixed flow value/>, is setAnd threshold/>And/>
JudgingWhether or not a mutation occurs, if/>When variation occurs, the corresponding flow value/>Flows backward in a decreasing manner according to the flow formula if flowing to/>At that point, flow value/>Decreasing to/>And/>Then/>Also variant, otherwise,/>No change occurs.
6. The method of claim 5, wherein the flow formula is
Wherein the method comprises the steps ofRepresentation/>Flow value of/>Representation/>Flow to/>Flow value at time,/>Is a positive decrementing coefficient, controls the rate of decrementing,/>Representation/>Position subscript of/>Representation/>Position subscript of/>Representation/>Threshold at/>Representation/>A threshold value at.
7. The method of claim 6, wherein the roulette algorithm is expressed as
Represents the/>Probability of individual hint words being selected,/>Representing the first of a set of target scoresScore of individual cue words.
CN202410491451.3A 2024-04-23 2024-04-23 Online question-answering prompt word optimization generation method based on large language model Active CN118093836B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410491451.3A CN118093836B (en) 2024-04-23 2024-04-23 Online question-answering prompt word optimization generation method based on large language model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410491451.3A CN118093836B (en) 2024-04-23 2024-04-23 Online question-answering prompt word optimization generation method based on large language model

Publications (2)

Publication Number Publication Date
CN118093836A true CN118093836A (en) 2024-05-28
CN118093836B CN118093836B (en) 2024-07-16

Family

ID=91158717

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410491451.3A Active CN118093836B (en) 2024-04-23 2024-04-23 Online question-answering prompt word optimization generation method based on large language model

Country Status (1)

Country Link
CN (1) CN118093836B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150347385A1 (en) * 2014-05-30 2015-12-03 Educational Testing Service Systems and Methods for Determining Lexical Associations Among Words in a Corpus
US20210382923A1 (en) * 2020-06-04 2021-12-09 Louis Rudolph Gragnani Systems and methods of question answering against system of record utilizing natural language interpretation
US20230072171A1 (en) * 2021-08-30 2023-03-09 Accenture Global Solutions Limited System and method for training and refining machine learning models
CN116362180A (en) * 2022-12-13 2023-06-30 南京理工大学 GaN HEMT large signal model parameter integrated extraction method
CN116860949A (en) * 2023-08-21 2023-10-10 人民网股份有限公司 Question-answering processing method, device, system, computing equipment and computer storage medium
CN117216227A (en) * 2023-10-30 2023-12-12 广东烟草潮州市有限责任公司 Tobacco enterprise intelligent information question-answering method based on knowledge graph and large language model
CN117576267A (en) * 2024-01-16 2024-02-20 广州光点信息科技股份有限公司 Digital person generation method based on LLM and ANN and application of digital person generation method in cloud video
CN117744796A (en) * 2023-12-15 2024-03-22 青岛海尔电冰箱有限公司 Method and device for constructing prompt word based on generation type large model and intelligent equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150347385A1 (en) * 2014-05-30 2015-12-03 Educational Testing Service Systems and Methods for Determining Lexical Associations Among Words in a Corpus
US20210382923A1 (en) * 2020-06-04 2021-12-09 Louis Rudolph Gragnani Systems and methods of question answering against system of record utilizing natural language interpretation
US20230072171A1 (en) * 2021-08-30 2023-03-09 Accenture Global Solutions Limited System and method for training and refining machine learning models
CN116362180A (en) * 2022-12-13 2023-06-30 南京理工大学 GaN HEMT large signal model parameter integrated extraction method
CN116860949A (en) * 2023-08-21 2023-10-10 人民网股份有限公司 Question-answering processing method, device, system, computing equipment and computer storage medium
CN117216227A (en) * 2023-10-30 2023-12-12 广东烟草潮州市有限责任公司 Tobacco enterprise intelligent information question-answering method based on knowledge graph and large language model
CN117744796A (en) * 2023-12-15 2024-03-22 青岛海尔电冰箱有限公司 Method and device for constructing prompt word based on generation type large model and intelligent equipment
CN117576267A (en) * 2024-01-16 2024-02-20 广州光点信息科技股份有限公司 Digital person generation method based on LLM and ANN and application of digital person generation method in cloud video

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
XIANGYANG LIU: "Federated Prompting and Chain-of-Thought Reasoning for Improving LLMs Answering", KSEM2023, 16 August 2023 (2023-08-16), pages 3 - 11 *
刘星宝: "种子检测器刺激-应答变异算法研究", 高技术通讯, vol. 19, no. 3, 25 March 2009 (2009-03-25), pages 273 - 278 *

Also Published As

Publication number Publication date
CN118093836B (en) 2024-07-16

Similar Documents

Publication Publication Date Title
CN110222163B (en) Intelligent question-answering method and system integrating CNN and bidirectional LSTM
CN108804689B (en) Question-answering platform-oriented label recommendation method integrating user hidden connection relation
CN110083705A (en) A kind of multi-hop attention depth model, method, storage medium and terminal for target emotional semantic classification
CN111797898B (en) Online comment automatic reply method based on deep semantic matching
CN107256494B (en) Article recommendation method and device
Sun et al. Salmon: Self-alignment with principle-following reward models
CN111814982A (en) Multi-hop question-answer oriented dynamic reasoning network and method
Wu et al. Knowledge or gaming? Cognitive modelling based on multiple-attempt response
CN109299464B (en) Topic embedding and document representing method based on network links and document content
CN112905736A (en) Unsupervised text emotion analysis method based on quantum theory
Lu et al. Student performance prediction model based on discriminative feature selection
CN112734510B (en) Commodity recommendation method based on fusion improvement fuzzy clustering and interest attenuation
Sun et al. SALMON: Self-Alignment with Instructable Reward Models
Hong et al. Competitive self-training technique for sentiment analysis in mass social media
CN105760965A (en) Pre-estimated model parameter training method, service quality pre-estimation method and corresponding devices
CN118093836B (en) Online question-answering prompt word optimization generation method based on large language model
Pathuri et al. Feature based sentimental analysis for prediction of mobile reviews using hybrid bag-boost algorithm
Vedavathi et al. Deep flamingo search and reinforcement learning based recommendation system for e-learning platform using social media
Luaces et al. Including content-based methods in peer-assessment of open-response questions
CN109815323B (en) Human-computer interaction training question-answer generation algorithm
Kumar et al. A Recommendation System & Their Performance Metrics using several ML Algorithms
Jo et al. A Scalable Chatbot Platform Leveraging Online Community Posts: A Proof-of-Concept Study
Elgibreen et al. RULES-IT: incremental transfer learning with RULES family
Hoiriyah et al. Lexicon-Based and Naive Bayes Sentiment Analysis for Recommending the Best Marketplace Selection as a Marketing Strategy for MSMEs
Schneider Efficient and Flexible Topic Modeling using Pretrained Embeddings and Bag of Sentences

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
GR01 Patent grant