[go: up one dir, main page]

CN111858899B - Statement processing method, device, system and medium - Google Patents

Statement processing method, device, system and medium Download PDF

Info

Publication number
CN111858899B
CN111858899B CN202010764814.8A CN202010764814A CN111858899B CN 111858899 B CN111858899 B CN 111858899B CN 202010764814 A CN202010764814 A CN 202010764814A CN 111858899 B CN111858899 B CN 111858899B
Authority
CN
China
Prior art keywords
sentence
sentences
determining
item
query
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.)
Active
Application number
CN202010764814.8A
Other languages
Chinese (zh)
Other versions
CN111858899A (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.)
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology Co Ltd
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
ICBC Technology 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 Industrial and Commercial Bank of China Ltd ICBC, ICBC Technology Co Ltd filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202010764814.8A priority Critical patent/CN111858899B/en
Publication of CN111858899A publication Critical patent/CN111858899A/en
Application granted granted Critical
Publication of CN111858899B publication Critical patent/CN111858899B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • 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/3332Query translation
    • G06F16/3337Translation of the query language, e.g. Chinese to English
    • 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/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a sentence processing method, comprising: acquiring an inquiry sentence; determining the problem category aiming at the query statement in a pre-constructed problem library, wherein the problem library comprises p categories of problem statements; determining alternative item sentences of a pre-constructed item library aiming at the inquiry sentences, wherein the item library comprises q item sentences; and determining a reply sentence to the query sentence according to the question category and the alternative item sentence. The present disclosure also provides a sentence processing apparatus, a computer system, and a computer-readable storage medium. The method and apparatus provided by the present disclosure may be used in the field of artificial intelligence, big data, and other fields.

Description

Statement processing method, device, system and medium
Technical Field
The disclosure relates to the technical field of intelligent question and answer, and more particularly, to a sentence processing method, device, system and medium.
Background
With the rapid development of artificial intelligence technology, iterative updating of learning algorithm and basic class of massive question-answer knowledge data, intelligent question-answer technology has been rapidly developed in a plurality of fields.
In implementing the concepts of the present disclosure, the inventors found that there are at least the following problems in the related art: in the related art, the question-answering technology is mainly realized by formulating a large number of expert rules or pre-training a multi-layer deep neural network algorithm. Wherein, the expert rule sets the corresponding relation between the questions and the answers. For special fields like government fields, a large amount of question-answer corpora cannot be accumulated due to slow informatization progress, and rule formulation and algorithm training are not facilitated. Furthermore, because the query sentences of the user are often severely expressed in spoken language, the answers to the user's satisfaction often cannot be precisely matched.
Disclosure of Invention
In view of this, the present disclosure provides a sentence processing method, apparatus, system, and medium for improving the accuracy of a matching-derived reply sentence.
One aspect of the present disclosure provides a sentence processing method, including: acquiring an inquiry sentence; determining the problem category aiming at the query statement in a pre-constructed problem library, wherein the problem library comprises p categories of problem statements; determining alternative item sentences for the inquiry sentences in a pre-constructed item library, wherein the item library comprises q item sentences; and determining a reply sentence for the query sentence according to the question category and the alternative item sentence, wherein p and q are integers greater than or equal to 2.
According to an embodiment of the present disclosure, determining a question category for an inquiry sentence in a pre-constructed question bank includes: inputting the query sentence into a pre-trained classification model, and determining the probability value of the query sentence for the candidate question category; and determining the alternative question category as the question category aiming at the query sentence under the condition that the probability value is greater than or equal to the preset probability value, wherein the classification model is obtained by training the question sentences of p categories.
According to an embodiment of the present disclosure, the sentence processing method further includes determining a preset probability value according to the p categories of problem sentences; comprising the following steps: according to the problem sentences of p categories, m training samples and n test samples are obtained, and the m training samples are used for training a preset classification model to obtain a pre-trained classification model; inputting n test samples into a pre-trained classification model, and determining probability values of the n test samples for alternative problem categories respectively to obtain n probability values; and determining a preset probability value as an average value of n probability values, wherein m and n are integers greater than or equal to 2.
According to an embodiment of the present disclosure, obtaining m training samples and n test samples includes: obtaining r associated question statements associated with the p categories of question statements by at least one of: replacing words in the p categories of problem sentences according to the synonym library to obtain r associated problem sentences; replacing the item sentences included in the problem sentences of the multiple categories according to the p item sentences to obtain r associated problem sentences; translating back the p classes of problem sentences to obtain r associated problem sentences; dividing r associated problem sentences into categories to which the problem sentences with the association relationship belong, and obtaining enhanced problem sentences of p categories; and dividing the enhanced problem sentences of p categories into m training samples and n test samples, wherein r is an integer greater than or equal to 1.
According to an embodiment of the present disclosure, determining an alternative statement to an inquiry statement includes: determining a word vector for the query statement as a first word vector; acquiring word vectors of each item statement in q item statements to obtain q second word vectors; determining the similarity between each second word vector in the q second word vectors and the first word vector to obtain q first similarity; determining target word vectors in the q second word vectors according to the relation between the q first similarities and the preset similarities; and determining the item sentence for which the target word vector is for as an alternative item sentence to the query sentence.
According to an embodiment of the present disclosure, determining a word vector for an interrogation statement as a first word vector includes: dividing words of the inquiry sentence to obtain s first words; removing the disabling words in the s first words according to the disabling word stock to obtain t second words; counting the occurrence times of t second words in the inquiry sentences; and determining a first word vector of the query sentence according to the predetermined word stock and the occurrence times, wherein s and t are integers greater than or equal to 2, and s is greater than or equal to t.
According to an embodiment of the present disclosure, the similarity between each of the second word vectors and the first word vector includes a jaccard similarity; the sentence processing method further comprises the following steps: determining the word vector of each item statement in the item library to obtain q second word vectors; and storing the q second word vectors into the NPZ format file for reading, wherein the q second word vectors are determined according to a predetermined word stock.
According to an embodiment of the present disclosure, the sentence processing method further includes determining a preset similarity according to a plurality of item sentences; comprising the following steps: determining the similarity of q item sentences to each other to obtain [ q (q-1)/2 ] second similarities; and determining preset similarity according to the value distribution of the [ q (q-1)/2 ] second similarities, wherein the preset similarity comprises a first preset similarity and a second preset similarity, and the first preset similarity is larger than the second preset similarity.
According to an embodiment of the present disclosure, determining a target word vector of the plurality of second word vectors includes: determining whether the q second word vectors comprise alternative word vectors with the similarity between the q second word vectors and the first word vector being greater than or equal to a first preset similarity; under the condition that the q second word vectors comprise alternative word vectors, determining the alternative word vectors as the target word vectors; and in the case that the alternative word vector is not included in the q second word vectors: determining a to-be-selected word vector, wherein the similarity between the q second word vectors and the first word vector is smaller than the first preset similarity and larger than or equal to the second preset similarity; sorting the vectors to be selected according to the similarity with the first word vector from big to small to obtain a sequence of vectors to be selected; and determining a preset number of the first ordered candidate word vectors in the candidate word vector sequence as target word vectors.
According to an embodiment of the present disclosure, performing word segmentation processing on the query sentence to obtain s first words includes: replacing words in the query sentences according to the synonym library and the target field word library to obtain replaced query sentences; and performing word segmentation processing on the replaced query sentence to obtain s first words.
According to an embodiment of the present disclosure, the number of the above-described problem categories is one; determining a reply sentence to the query sentence includes: in the case where the number of candidate sentences is one, determining, from a pre-constructed reply sentence library, a reply sentence having a mapping relation with both the candidate sentence and the question category as a reply sentence for the query sentence; in the case where the number of alternative sentences is at least two: determining target item sentences aiming at the inquiry sentences in at least two alternative item sentences by adopting a lightweight semantic model; and determining the reply sentence having a mapping relation with the target item sentence and the question category as a reply sentence for the query sentence from a pre-constructed reply sentence library.
According to an embodiment of the present disclosure, determining a target item statement for an inquiry statement includes: generating at least two standard inquiry sentences for the at least two alternative item sentences according to the problem category and the at least two alternative item sentences; taking an inquiry sentence and each standard inquiry sentence in at least two standard inquiry sentences as a sentence pair, and inputting a lightweight semantic model to obtain the similarity between the inquiry sentence and each standard inquiry sentence; and determining the alternative item statement aimed at by the standard inquiry statement with the maximum similarity with the inquiry statement as a target item statement.
Another aspect of the present disclosure provides a sentence processing apparatus, including: the sentence acquisition module is used for acquiring an inquiry sentence; the category determining module is used for determining the category of the question aiming at the query statement in a pre-constructed question library, wherein the question library comprises p categories of question statements; the item determining module is used for determining alternative item sentences aiming at the inquiry sentences in a pre-constructed item library, wherein the item library comprises q item sentences; and a reply determination module for determining reply sentences for the inquiry sentences according to the question category and the alternative item sentences, wherein p and q are integers greater than or equal to 2.
Another aspect of the present disclosure provides a computer system comprising: one or more processors; and a storage means for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the sentence processing method described above.
Another aspect of the present disclosure provides a computer-readable storage medium storing computer-executable instructions which, when executed by a processor, are for performing the sentence processing method as described above.
Another aspect of the present disclosure provides a computer program comprising computer executable instructions which, when executed, are for implementing a sentence processing method as described above.
According to the embodiment of the disclosure, the technical problems that informatization in the related art is slow in progress and the fields with more professional expressions are often not matched with answers satisfied by users can be at least partially avoided. According to the method and the device, the core intention of the user problem can be effectively represented by matching the problem category and the alternative item statement from the pre-constructed problem library and the item library respectively according to the inquiry statement, and therefore the accuracy of the reply statement determined according to the problem category and the alternative item statement can be improved, and the user experience is improved.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be more apparent from the following description of embodiments of the disclosure with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates application scenarios of sentence processing methods, apparatuses, systems and media according to embodiments of the present disclosure;
FIG. 2 schematically illustrates a flow chart of a sentence processing method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow chart of determining a question category for an inquiry sentence in accordance with an embodiment of the present disclosure;
Fig. 4 schematically illustrates a flowchart of determining a preset probability value according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow diagram of determining alternative sentences for an inquiry sentence in accordance with an embodiment of the present disclosure;
FIG. 6 schematically illustrates a distribution histogram of a plurality of second similarities in accordance with an embodiment of the present disclosure;
FIG. 7 schematically shows a block diagram of a sentence processing apparatus according to an embodiment of the present disclosure; and
fig. 8 schematically illustrates a block diagram of a computer system adapted to perform a sentence processing method in accordance with an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is only exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. In addition, in the following description, descriptions of well-known structures and techniques are omitted so as not to unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and/or the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It should be noted that the terms used herein should be construed to have meanings consistent with the context of the present specification and should not be construed in an idealized or overly formal manner.
Where expressions like at least one of "A, B and C, etc. are used, the expressions should generally be interpreted in accordance with the meaning as commonly understood by those skilled in the art (e.g.," a system having at least one of A, B and C "shall include, but not be limited to, a system having a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Embodiments of the present disclosure provide a sentence processing method that first obtains an inquiry sentence. The question categories for the query statement in a pre-constructed question library comprising a plurality of categories of question statements is then determined. An alternative item statement for the query statement in a pre-constructed item library is then determined, the item library comprising a plurality of item statements. And finally, determining a reply sentence aiming at the inquiry sentence according to the question category and the alternative item sentence.
Fig. 1 schematically illustrates application scenarios of sentence processing methods, apparatuses, systems and media according to embodiments of the present disclosure. It should be noted that fig. 1 illustrates only an example of an application scenario in which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments, or scenarios.
As shown in fig. 1, the application scenario 100 of this embodiment may include, for example, terminal devices 111, 112, 113, a network 120 and an application server 130, the network being used as a medium for providing a communication link between the terminal devices 111, 112, 113 and the application server 130. The network 120 may include various connection types, such as wired, wireless communication links, and the like.
The terminal devices 111, 112, 113 may be, for example, various electronic devices with a display screen and with processing capabilities, including but not limited to smartphones, tablet computers, laptop computers, desktop computers, smart wearable devices, etc. The terminal device may be installed with various client applications such as a web browsing type application, a client application of each service organization, an instant messaging type application, and the like, for example.
By way of example, various knowledge bases may be maintained in advance in the application server 130, for example, and the client applications in the terminal devices 111, 112, 113 may acquire query sentences in response to the user through operations on the input devices or voice information of the user, acquire knowledge from the knowledge bases maintained in the application server 130 according to the query sentences, and present the acquired knowledge to the user via the terminal devices.
For example, knowledge in a knowledge base may be set according to actual requirements, for example, for a government field, the knowledge base may include a question base and a reply sentence base, for example. The question library comprises a plurality of question sentences, the answer sentence library comprises a plurality of answer sentences, and a mapping relation is established between the question sentences in the question sentence library and the answer sentences in the answer sentence library. To determine a reply sentence having a mapping relation by looking up a question sentence that matches the query sentence.
According to the embodiment of the disclosure, in order to avoid the situation that reply sentences cannot be precisely matched due to serious spoken expression of query sentences in the fields of insufficient corpus, professional corpus and the like such as government fields, the knowledge base maintained by the application program server can comprise a question base and a reply sentence base, for example, a matter sentence base can be maintained, the question base can comprise question sentences with a plurality of question angles, and mapping relations between the reply sentences and the matter sentences and the question angles are established. Thus, when determining the reply sentence, the question angle corresponding to the question sentence and the question sentence matched with the inquiry sentence can be determined respectively, and then the matched reply sentence can be determined. Therefore, compared with the direct question matching, the method can grasp the key information of the query statement in a finer granularity, judge the intention of the user more accurately and improve the accuracy of the determined reply statement.
Illustratively, as shown in FIG. 1, the application scenario may also include, for example, a server 140, the server 140 interacting with terminal devices and application servers via the network 120. The terminal device may for example send an inquiry sentence to the server 140, which server 140 determines a reply sentence from a knowledge base maintained in the application server 130.
It should be noted that, the sentence processing method in the embodiment of the present disclosure may be generally executed by the terminal device. Accordingly, the sentence processing apparatus of the embodiments of the present disclosure may be generally disposed in the terminal device. Alternatively, the sentence processing method of the embodiment of the present disclosure may be executed by the server. Accordingly, the sentence processing device of the embodiment of the present disclosure may also be disposed in the server.
It should be understood that the terminal devices, networks, application servers, and servers in fig. 1 are merely illustrative. There may be any type of terminal device, network, application server, and server, as desired for implementation.
The sentence processing method according to the embodiments of the present disclosure will be described in detail below with reference to fig. 2 to 6 in conjunction with the application scenario described in fig. 1.
Fig. 2 schematically shows a flowchart of a sentence processing method according to an embodiment of the present disclosure.
As shown in fig. 2, the sentence processing method of this embodiment may include operations S210 to S240.
In operation S210, an inquiry sentence is acquired.
According to an embodiment of the present disclosure, the query sentence may be obtained, for example, in response to an operation of a peripheral input device of the terminal device by the user, or an input module built in the terminal device. Alternatively, the query term may be responsive to the user's voice information by converting the voice information to textual information.
In operation S220, a question category for the query sentence in a pre-constructed question library is determined, the question library including p categories of question sentences. Wherein p is an integer of 2 or more.
According to the embodiment of the disclosure, the category of the question sentences included in the question library can be set according to actual requirements, for example. For example, in the government field, the p categories may include, for example, a "transacted materials" category, a "transacted places" category, a "transacted time limits" category, a "transacted ranges" category, a "transacted fees" category, a "transacted flows" category, a "transacted conditions" category, a "materials requirements" category, and the like. Where, the question statement of the "transacted materials" category may include, for example, "which materials need to be prepared? "," what materials need to be provided? "etc.
According to the embodiment of the disclosure, the query sentence and the question sentences of p categories in the question library can be respectively matched, and the category to which the question sentence with the highest similarity with the query sentence belongs is determined to be the question category for the query sentence. In the matching, the query sentence and the question sentence may be converted into sentence vectors, respectively, and then the similarity between the sentence vectors may be used as the similarity between the query sentence and the question sentence. The similarity may be embodied in any of the following parameters: cosine similarity, jacquard similarity coefficients, pearson correlation coefficients, szelman correlation coefficients, and the like. The term vector may be obtained by, for example, first word-segmenting a sentence, and converting a word sequence obtained by word segmentation into a vector by a word2vec (word to vector) method.
According to the embodiment of the disclosure, the classification model can be obtained by training the question sentences of p categories in the question library. The query sentence is then input into a pre-trained classification model, and the question category for the query sentence is determined from the output of the classification model.
The output of the classification model may, for example, be a probability vector of probability composition of the query sentence for each of a plurality of predetermined question categories, each element of the probability vector corresponding to a question category. And finally, determining the problem category corresponding to the element with the largest value in the probability vector as the problem category aiming at the query sentence.
The output vector of the classification model may be, for example, a vector with a value of 0 or 1 for each element, and each element corresponds to a problem category. And finally determining the problem category corresponding to the element with the value of 1 as the problem category aiming at the inquiry statement.
The output of the classification model may also comprise, for example, a word vector for a question category of the query sentence and a probability of the query sentence for the question category. The word vector of the question category can be directly matched with the preset question category, and the question category with the highest matching degree is determined to be the question category aiming at the query sentence.
In an embodiment, the problem category for the query sentence may also be implemented by the flow described in the following fig. 3, which is not described herein.
In operation S230, an alternative item sentence to the query sentence in a pre-constructed item library is determined, the item library including q item sentences. Wherein q is an integer of 2 or more.
According to the embodiment of the disclosure, q item sentences included in the item library can be set according to actual requirements, for example. For example, for the government field, the item sentences may include, for example, sentences for indicating items such as "social insurance", "pension", "complaint", and the like.
According to the embodiment of the disclosure, q item sentences in the item library can be respectively matched with the query sentence, and the item sentence with the highest similarity with the query sentence is determined to be the candidate item sentence for the query sentence. In the matching, the query statement and the item statement may be converted into statement vectors, respectively, and then the similarity between the statement vectors is used as the similarity between the query statement and the question statement. The term vector may be obtained by, for example, first word-segmenting a sentence, and converting a word sequence obtained by word segmentation into a vector by a word2vec (word to vector) method.
According to the embodiment of the disclosure, in consideration of poor professional properties of query sentences of users in the field with strong professional properties (such as government field), in order to improve the accuracy of the determined similarity, for example, when calculating the similarity, the similarity of word level can be calculated. Therefore, the operation S230 may be specifically implemented by, for example, the flow described in the following fig. 5, which is not described herein.
In operation S240, a reply sentence to the query sentence is determined according to the question category and the alternative item sentence.
According to an embodiment of the present disclosure, in order to facilitate determination of reply sentences, for example, a plurality of reply sentences may be maintained in advance in a knowledge base of the embodiment, the plurality of reply sentences constituting a pre-constructed reply sentence library, and for each reply sentence, a mapping relationship of the reply sentence with the question category and the item sentence is established. In an embodiment, a reply sentence having a mapping relation with the question category and the alternative item sentence may be determined as a reply sentence to the query sentence.
According to the embodiment of the disclosure, in order to avoid a situation that the answer sentences are at least two due to at least two determined item sentences, the user cannot be answered accurately. The embodiment may first determine whether an alternative statement exists. If the candidate sentences exist, the number of the candidate sentences is determined. If the number of alternative item sentences is one, since the question category determined by the method in operation S220 is also only one, it is possible to directly determine, from among the pre-constructed reply sentences, a reply sentence having a mapping relationship with both the alternative item sentence and the question category as a reply sentence to the query sentence.
For example, when the number of the candidate sentences is at least two, for example, the at least two candidate sentences may be spliced with the words representing the problem category to form a new sentence, so as to obtain at least two new sentences. And then determining the alternative item statement included in the statement with the highest similarity with the query statement in the at least two new statements as a target item statement. Finally, the reply sentence with mapping relation with the target item sentence and the question category is determined as the reply sentence aiming at the inquiry sentence from the pre-constructed reply sentence.
For example, in order to improve accuracy, a predetermined model may also be used to determine a target item sentence for the query sentence among the at least two candidate item sentences. Wherein, in order to ensure the response speed of the intelligent question and answer, the predetermined model can adopt a lightweight semantic model. In one embodiment, the lightweight semantic model may employ, for example, an Albert model.
According to the embodiment of the disclosure, when the lightweight semantic model is adopted to determine the target item statement, at least two standard query statements respectively aiming at least two alternative item statements can be specifically generated according to the problem category and the at least two alternative item statements. Wherein each standard query term may be formed by a concatenation of an alternative term and a word characterizing the problem category. The query sentence and each standard query sentence are then formed into a sentence pair, resulting in at least two sentence pairs. And then respectively inputting the at least two sentence pairs into a lightweight semantic model, and outputting to obtain the similarity of each standard inquiry sentence and each inquiry sentence to obtain at least two similarities. And finally, determining the similarity with the maximum value in the at least two similarities. And taking the alternative item statement aimed at by the standard inquiry statement corresponding to the maximum similarity as a target item statement.
In summary, according to the embodiment of the disclosure, by matching the question category and the alternative item statement from the pre-constructed question library and the item library respectively according to the query statement, the core intention of the user question can be effectively represented, and therefore, the accuracy of the reply statement determined according to the question category and the alternative item statement can be improved, and the user experience is improved.
FIG. 3 schematically illustrates a flow chart of determining a question category for an inquiry sentence in accordance with an embodiment of the present disclosure.
As shown in fig. 3, in the present embodiment, the operation S220 of determining the question category for the query sentence may include, for example, operations S321 to S322.
In operation S321, an inquiry sentence is input into a pre-trained classification model, and an alternative question category for the inquiry sentence and a probability value for the inquiry sentence for the alternative question category are determined.
In operation S322, in case that the probability value is equal to or greater than the preset probability value, it is determined that the candidate question category is a question category for the query sentence.
In accordance with embodiments of the present disclosure, the pre-trained classification model may include, for example, a Convolutional Neural Network (CNN) model. For example, to enhance the intended understanding of the query statement, the pre-trained classification model may be, for example, a cnn+crf (Conditional Random Field ) classification model.
According to embodiments of the present disclosure, in order to avoid a case where a problem due to a user query is a problem that is not related to a function provided by a current client application, a problem category determined according to an output of a pre-trained classification model may be taken as an alternative problem category, and a preset probability value may be assigned to the problem category for the query sentence. And determining the candidate problem category as the problem category aiming at the query sentence only when the probability value of the query sentence aiming at the candidate problem category output by the pre-trained classification model is larger than or equal to a preset probability value. The preset probability value may be set according to actual requirements, for example. For example, the preset probability value may be any value greater than 0.5.
In an embodiment, in order to improve accuracy of the determined problem category, the sentence processing method of this embodiment may further include an operation of determining a preset probability value according to the problem sentences of p categories, which may be implemented, for example, by a flowchart described in fig. 4.
Fig. 4 schematically illustrates a flowchart of determining a pre-set probability value according to an embodiment of the disclosure.
As shown in fig. 4, the operation of determining the preset probability value according to the p categories of problem sentences may include, for example, operations S451 to S453.
In operation S451, m training samples and n test samples are obtained according to the problem sentences of the p categories, and the m training samples are used for training a predetermined classification model to obtain a pre-trained classification model. Wherein m and n are integers greater than or equal to 2.
According to an embodiment of the present disclosure, the predetermined classification model may be, for example, an acquired open-source classification model. The present embodiment may divide all of the question sentences in the question bank into two parts, one part for generating training samples and one part for generating test samples. In order to improve the accuracy of the model, all problem sentences can be uniformly distributed according to the problem category when being divided into two parts. For example, the question statements for each question category may be divided into two parts, one for generating training samples and one for generating test samples.
After dividing all the question sentences into two parts, a training sample or a test sample can be obtained by assigning labels capable of indicating the question categories to which the question sentences belong to each question sentence and converting the question sentences assigned with the labels into sentence vectors. The conversion into the sentence vector may be implemented, for example, by firstly word-segmenting the sentence, and then converting the word sequence obtained by word segmentation into the vector by a word2vec (word to vector) method.
After the training samples are obtained, m training samples can be sequentially input into a preset classification model, and parameters of the preset classification model are adjusted and optimized by comparing the output of the preset classification model with the labels of the training samples, so that a pre-trained classification model is obtained.
According to the embodiment of the disclosure, in order to avoid the problem statement in the problem library from being insufficient in model precision caused by less corpus in a special field, the embodiment can also supplement the problem statement in the problem library by data enhancement (Data Augmentation) before generating the training sample and the test sample. Specifically, a plurality of associated question sentences associated with a plurality of categories of question sentences may be obtained by, for example, at least one of the following methods, and the question sentences are expanded in accordance with the associated question sentences.
For example, the application server may maintain a synonym library in advance, and the embodiment may obtain r associated question sentences by replacing words in the p categories of question sentences according to the synonym library. For example, for the question sentence "how to pay social security", the word "pay" may be replaced by "pay" according to the synonym library, so as to obtain an associated question sentence "how to pay social security". Wherein r is an integer of 1 or more.
Illustratively, r associated question sentences may be obtained from a plurality of question sentences replacing the question sentences included in the p categories of question sentences. For example, for the question statement "how to pay social security", one associated question statement "how to pay pension" may be obtained by replacing the statement "social security" representing a matter with "pension". Wherein r is an integer of 1 or more.
Illustratively, by back-translating the p categories of question statements, r associated question statements are derived. For example, for a question sentence of a chinese expression, the question sentence may be translated into an english sentence, and then the translated english sentence may be translated into a sentence of a chinese expression, thereby obtaining a related question sentence. It can be understood that the associated problem statement of the problem statement can also be obtained according to methods such as middle-method translation, middle-Russian translation and the like. Wherein r is an integer of 1 or more.
After obtaining the associated question sentences, in order to facilitate the generation of the training samples and the test samples, r associated question sentences can be divided into categories to which the question sentences having an associated relation with the r associated question sentences belong, and the r associated question sentences and the plurality of question sentences are used as enhanced question sentences of p categories. And finally dividing the enhanced problem sentences of p categories into two parts to obtain m training samples and n test samples.
In operation S452, n test samples are input into the pre-trained classification model, and probability values of the n test samples for the candidate problem categories are determined, so as to obtain a plurality of n probability values.
In operation S453, a preset probability value is determined as an average value of n probability values.
According to the embodiment of the disclosure, n candidate problem categories for the n test samples and probability values for the candidate problem categories for which the n test samples are aimed can be obtained by respectively taking the n test samples as inputs of the pre-trained classification model and outputting, so that n probability values corresponding to the n test samples one by one are obtained in total. Finally, taking the average value of the n probability values as a preset probability value.
Fig. 5 schematically illustrates a flow chart of determining alternative statement for an inquiry statement in accordance with an embodiment of the present disclosure.
As shown in fig. 5, the operation S230 of determining the alternative item sentence to the query sentence of this embodiment may include, for example, operations S531 to S535.
In operation S531, a word vector for an inquiry sentence is determined as a first word vector.
According to the embodiment of the disclosure, the query sentence may be first subjected to word segmentation processing, so as to obtain s first words of the query sentence, for example, the Bert tool may be used for word segmentation processing. And then converting the s first words into first word vectors according to a predetermined dictionary. It will be appreciated that the above-described methods of word segmentation are merely examples to facilitate an understanding of the present disclosure, which is not limited thereto, and that any method may be employed by the present disclosure for word segmentation. Wherein s is an integer of 2 or more.
According to embodiments of the present disclosure, consider that there are typically no "disable words," "have" etc. in an issue statement, whereas an inquiry statement typically has a disable word due to the expression comparison spoken. Therefore, in order to avoid the interference of the deactivated words on sentence matching, after the s first words are obtained through word division processing, the embodiment may maintain a deactivated word stock, and reject deactivated words in the s first words according to the deactivated word stock, so as to obtain t second words. Finally, t second words are converted to obtain a first word vector. Wherein t is an integer greater than or equal to 2, and s is greater than or equal to t.
According to the embodiment of the disclosure, in order to further avoid low matching accuracy caused by the spoken language of the query sentence, the embodiment may also perform word segmentation processing on the query sentence before performing word segmentation processing on the query sentence, for example, and replace words in the query sentence according to the synonym word stock and the target domain word stock to obtain a replaced query sentence. After the replaced query sentence is obtained, word division processing can be performed on the replaced query sentence, and s first words are obtained. The target domain word library may be maintained with various specialized words of the target domain, for example. For example, for government affairs field, professional words such as "social insurance", "payment proportion", "visit up" and the like may be maintained. When the query term includes "social security", the target domain word stock may be used to replace "social security" with "social security".
According to the embodiment of the present disclosure, in order to further improve accuracy of similarity calculation, the present embodiment may, for example, pass the number of occurrences of each of a plurality of words in an inquiry sentence when the plurality of words (first word or second word) according to the inquiry sentence are converted into a word vector. Finally, a first word vector of the query sentence is determined according to the occurrence times and a preset word library. Each element in the first word vector corresponds to a word in a predetermined word stock. And the value of each element is the number of occurrences of its corresponding word in the query sentence.
Illustratively, for the query statement "how to transact social insurance and loss insurance", the resulting plurality of second words may be: by statistics, what, society, will, insurance, loss, industry, insurance, the number of occurrences of "how", "what", "managing", "society", "will", "save", "lose", "business" is 1, and the number of occurrences of "risk" is 2. If the predetermined word stock includes 15 words, and the positions of "how", "what", "handle", "social", "will", "insurance", "danger", "losing", "industry" in the 15 words are 1, 2, 4, 5, 7, 9, 10, 11, 13, 15 respectively, the converted first word vector a may be expressed as: 11 0 11 0 10 11 2 0 10 1.
In operation S532, a word vector for each of the q item sentences is acquired, resulting in q second word vectors.
According to an embodiment of the present disclosure, this operation S532 may obtain a word vector of each item sentence, for example, using a method similar to operation S531. Note that, since the stop word is not generally included in the item sentence, the operation of eliminating the stop word is not required to be performed.
According to the embodiment of the present disclosure, in order to increase the sentence processing rate, and considering that the transaction library is maintained in advance and the variation is small, the word vector of each transaction sentence in the transaction library may be determined in advance by a method similar to operation S531, resulting in q second word vectors. After q second word vectors are obtained, in order to facilitate reading in sentence processing, the q second word vectors may be stored in a predetermined file, and the compressed file may be stored in a predetermined storage space. The predetermined file may be, for example, a file in NPZ format, specifically, a file with suffix ". NPZ", which is a compressed file. The file can be read using an np.load () function, for example, by using a NumPy tool in Python. The q second word vectors may be stored in a file, for example, by using a numpy.savez function, which outputs the compressed file. Accordingly, operation S532 may obtain q second word vectors by reading a file with suffix ". Npz" in a predetermined storage space. The NumPy tool is an open-source numerical computation extension tool of Python, which can be used for storing and processing large-scale matrixes, supporting a large number of dimensional data and matrix operations, and providing a large number of mathematical function libraries for array operations.
In operation S533, the similarity between each of the q second word vectors and the first word vector is determined, resulting in q first similarities.
According to an embodiment of the present disclosure, the first similarity may be embodied by any of the foregoing parameter forms.
Illustratively, the similarity may be embodied by a Jacquard similarity coefficient. The first word vector and the second word vector are word frequency vectors. For the first word vector a and any second word vector B, the similarity between the two can be calculated by the following formula:
from the above formula, the Jacquard similarity coefficient is the ratio of the size of the intersection of two vectors to the size of the union of the two vectors. Wherein the intersection characterizes co-occurrence information of the query statement and the item statement. The size of the intersection divided by the size of the union characterizes the proportion of co-occurrence information to the overall information of the query statement and the item statement.
According to embodiments of the present disclosure, considering that an inquiry sentence is generally a spoken expression and a matter sentence is generally a professional expression, this may result in a large difference in character length and content of the expression between the inquiry sentence and the matter sentence to some extent. If the similarity between the query sentence and the item sentence is directly calculated by using the above formula, there is a problem that the word which does not exist in many item sentences appears in the spoken language expression, the size of the union is increased uncontrollably, the calculated similarity is low, and the matched item sentence cannot be obtained. To avoid this problem, the present embodiment can determine the first word vector and the second word vector, for example, from the same predetermined dictionary, thereby defining the range of words to which the union refers. In this way, the number of elements included in the determined first word self-vector is equal to the number of elements included in the second word vector.
Illustratively, in the embodiment of how to transact social insurance and unemployment insurance using the inquiry sentence, a= | 11 0 11 0 1 0 11 2 0 1 0 1|, if the item sentence is "social insurance", b= |0 0 0 0 0 0 1 0 11 1 0 0 0 0|, the number of elements included in a and B are equal to the number of words included in the predetermined dictionary. If element a in the same position in A and B i And b i If none of the elements is 0, calculating the element a at the corresponding position obtained by intersection i And b i The smaller value of the element a is calculated and obtained by the union i And b i Is larger in value. The vector obtained by the intersection of a and B may be represented as |0 0 0 0 0 0 1 0 11 1 0 0 0 0|, and the value of a n B in the above formula is the sum of all the elements in the vector, and a n b=4 is calculated: the vector obtained by the union of a and B may be represented as | 11 0 11 0 1 0 11 2 0 1 0 1|, and the value of a u B in the above formula may be represented as the sum of all elements in the vector, and a u b=11 is calculated. The final calculated Jacquard similarity coefficient is 4/11, approximately equal to 0.364.
In operation S534, a target word vector of the q second word vectors is determined according to the relationship between the q first similarities and the preset similarity.
In operation S535, it is determined that the item sentence for which the target word vector is for the query sentence is an alternative item sentence.
According to an embodiment of the present disclosure, it may be determined that a word vector having a first similarity with the first word vector of the second word vector not smaller than a preset similarity is a target word vector. The preset similarity can be set according to actual requirements. For example, the preset similarity may take any value smaller than 1, such as 0.5, 0.6, etc.
According to an embodiment of the present disclosure, in order to improve adaptability, the embodiment may further select, as the target word vector, a predetermined number of word vectors having a larger first similarity from q second word vectors, in a case that the first similarity between each second word vector and the first word vector is smaller than a preset similarity. The predetermined number may be determined according to the total number of item sentences in the item library, for example, the predetermined number may be a predetermined ratio of the total number, for example, a value of 0.1 times or 0.2 times the total number. Alternatively, the predetermined number may take any value less than the total number, for example, may be 2, 5, 8, 10, etc. Alternatively, the predetermined number may be set according to actual needs, which is not limited by the present disclosure.
According to the embodiment of the disclosure, in order to avoid the situation that the reply sentence fed back according to the obtained alternative item sentence cannot meet the user requirement due to the too low similarity, the preset similarities may be set to two, wherein a first preset similarity of the two preset similarities is used as a similarity upper limit, and a second preset similarity of the two preset similarities is used as a similarity lower limit. Correspondingly, the first preset similarity is greater than the second preset similarity. The two preset similarities can be set according to actual requirements.
Accordingly, operation S534 may first determine whether the q second word vectors include alternative word vectors having a similarity to the first word vector greater than or equal to a first preset similarity, for example. If so, determining the alternative word vector as a target word vector. If the first word vector is not included, determining that the similarity between the q second word vectors and the first word vector is smaller than the first preset similarity and is larger than or equal to the second preset similarity. And then sequencing the vectors to be selected according to the similarity with the first word vector from large to small, so as to obtain a sequence of the vectors to be selected. And finally, determining a preset number of the first-ordered candidate word vectors in the candidate word vector sequence as target word vectors.
In summary, this embodiment can maximally weaken redundant information of query sentences and item sentences by calculating word-level similarity, so that the determined similarity can effectively pay attention to the portions of the query sentences and item sentences that are common.
According to the embodiment of the disclosure, in order to avoid the situation that the preset similarity cannot be set according to actual requirements under the cold start condition. The embodiment may set the preset similarity according to the similarity between the plurality of item sentences in the item library. Specifically, for example, the similarity between q item sentences in the item library may be determined first, and q (q-1)/2 second similarities may be obtained. Namely, the similarity between any two item sentences in the q item sentences is determined. And then determining the preset similarity according to the value distribution of the [ q (q-1)/2 ] second similarities.
Fig. 6 schematically shows a distribution histogram of q (q-1)/2 second similarities according to an embodiment of the present disclosure.
The similarity between any two item sentences may be obtained, for example, by a method similar to the method of calculating the first similarity as described above. In one embodiment, the value distribution of the [ q (q-1)/2 ] second similarities may be reflected by a histogram as shown in fig. 6, for example. Wherein, the abscissa is the value of the similarity, and the ordinate is the percentage of the total number of the [ q (q-1)/2 ] second similarities to the number of the similarity corresponding to each value in the [ q (q-1)/2 ] second similarities.
As can be seen from the histogram of fig. 6, among the plurality of second similarities, the value of the similarity is mainly concentrated between 0.1 and 0.9. This may indicate to some extent that there are more item sentences that are less distinguishable and that there are few of the two item sentences that have a similarity of greater than 0.9 or less than 0.1. In an embodiment, for example, the first preset similarity may be set to 0.9, and the second preset similarity may be set to 0.1.
It is to be understood that the foregoing method for determining the preset similarity and the method for representing the value distribution of the plurality of second similarities are merely examples, which are not limited by the present disclosure.
Fig. 7 schematically shows a block diagram of a sentence processing apparatus according to an embodiment of the present disclosure.
As shown in fig. 7, the sentence processing apparatus 700 of this embodiment may include a sentence acquisition module 710, a category determination module 720, a matter determination module 730, and a reply determination module 740.
The statement acquisition module 710 is configured to acquire an inquiry statement. In an embodiment, the sentence acquisition module 710 may be used to perform the operation S210 described in fig. 2, which is not described herein.
The category determination module 720 is configured to determine a category of questions for the query sentence in a pre-constructed question library, where the question library includes p categories of question sentences. In an embodiment, the category determining module 720 may be used to perform the operation S220 described in fig. 2, which is not described herein. Wherein p is an integer of 2 or more.
The item determination module 730 is configured to determine an alternative item sentence for an inquiry sentence in a pre-constructed item library, where the item library includes q item sentences. In an embodiment, the transaction determining module 730 may be used to perform the operation S230 described in fig. 2, which is not described herein. Wherein q is an integer of 2 or more.
The answer determination module 740 is configured to determine an answer sentence for the query sentence according to the question category and the alternative item sentence. In an embodiment, the reply determination module 740 may be used to perform operation S240 described in fig. 2, for example, and will not be described herein.
According to an embodiment of the present disclosure, the category determining module 720 may specifically determine the category of the question for the query sentence by performing operations S321 to S322 described in fig. 3, which are not described herein.
According to an embodiment of the present disclosure, the sentence processing device 700 may further include a probability value determining module, for determining a preset probability value by performing operations S451 to S453 described in fig. 4, which are not described herein.
According to an embodiment of the present disclosure, the item determining module 730 may determine the alternative item sentence for the query sentence by performing operations S531 to S535 described in fig. 5, for example, and will not be described again.
Any number of modules, sub-modules, units, sub-units, or at least some of the functionality of any number of the sub-units according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented as split into multiple modules. Any one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system-on-chip, a system-on-substrate, a system-on-package, an Application Specific Integrated Circuit (ASIC), or in any other reasonable manner of hardware or firmware that integrates or encapsulates the circuit, or in any one of or a suitable combination of three of software, hardware, and firmware. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the present disclosure may be at least partially implemented as computer program modules, which when executed, may perform the corresponding functions.
Fig. 8 schematically illustrates a block diagram of a computer system adapted to perform a sentence processing method in accordance with an embodiment of the present disclosure.
As shown in fig. 8, a computer system 800 according to an embodiment of the present disclosure includes a processor 801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. The processor 801 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or an associated chipset and/or special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), or the like. The processor 801 may also include on-board memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing the different actions of the method flows according to embodiments of the disclosure.
In the RAM 803, various programs and data required for the operation of the computer system 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. The processor 801 performs various operations of the method flow according to the embodiments of the present disclosure by executing programs in the ROM 802 and/or the RAM 803. Note that the program may be stored in one or more memories other than the ROM 802 and the RAM 803. The processor 801 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, computer system 800 may also include an input/output (I/O) interface 805, the input/output (I/O) interface 805 also being connected to bus 804. Computer system 800 may also include one or more of the following components connected to I/O interface 805: an input portion 806 including a keyboard, mouse, etc.; an output portion 807 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and a speaker; a storage section 808 including a hard disk or the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. The drive 810 is also connected to the I/O interface 805 as needed. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as needed so that a computer program read out therefrom is mounted into the storage section 808 as needed.
According to embodiments of the present disclosure, the method flow according to embodiments of the present disclosure may be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication section 809, and/or installed from the removable media 811. The above-described functions defined in the computer system of the embodiments of the present disclosure are performed when the computer program is executed by the processor 801. The systems, devices, apparatus, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the disclosure.
The present disclosure also provides a computer-readable storage medium that may be embodied in the apparatus/device/system described in the above embodiments; or may exist alone without being assembled into the apparatus/device/system. The computer-readable storage medium carries one or more programs which, when executed, implement methods in accordance with embodiments of the present disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to embodiments of the present disclosure, the computer-readable storage medium may include ROM 802 and/or RAM 803 and/or one or more memories other than ROM 802 and RAM 803 described above.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that the features recited in the various embodiments of the disclosure and/or in the claims may be combined in various combinations and/or combinations, even if such combinations or combinations are not explicitly recited in the disclosure. In particular, the features recited in the various embodiments of the present disclosure and/or the claims may be variously combined and/or combined without departing from the spirit and teachings of the present disclosure. All such combinations and/or combinations fall within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the embodiments cannot be used advantageously in combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be made by those skilled in the art without departing from the scope of the disclosure, and such alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (15)

1. A sentence processing method, comprising:
acquiring an inquiry sentence;
determining the problem category aiming at the inquiry statement in a pre-constructed problem library, wherein the problem library comprises problem statements of p categories;
determining alternative item sentences for the inquiry sentences in a pre-constructed item library, wherein the item library comprises q item sentences;
determining a reply sentence for the inquiry sentence according to the question category and the alternative item sentence;
wherein p and q are integers greater than or equal to 2;
the number of the problem categories is one; determining a reply sentence to the query sentence includes:
In the case where the number of alternative sentences is at least two:
determining target item sentences aiming at the query sentences in at least two alternative item sentences based on the similarity between the query sentences and each standard query sentence by adopting a lightweight semantic model; and
determining a reply sentence having a mapping relation with the target item sentence and the question category as a reply sentence for the query sentence from a pre-constructed reply sentence library.
2. The method of claim 1, wherein the determining a question category for the query statement in the pre-constructed question bank comprises:
inputting the query sentence into a pre-trained classification model, and determining an alternative problem category for the query sentence and a probability value of the query sentence for the alternative problem category; and
determining the alternative question category as the question category for the query sentence under the condition that the probability value is larger than or equal to a preset probability value,
the classification model is obtained through training according to the p categories of problem sentences.
3. The method of claim 2, further comprising: determining the preset probability value according to the problem sentences of the p categories; comprising the following steps:
According to the problem sentences of the p categories, m training samples and n test samples are obtained, wherein the m training samples are used for training a preset classification model to obtain a pre-trained classification model;
inputting the n test samples into the pre-trained classification model, and determining probability values of the n test samples for alternative problem categories respectively to obtain n probability values; and
determining the preset probability value as an average value of the n probability values,
wherein m and n are integers greater than or equal to 2.
4. The method of claim 3, wherein the obtaining m training samples and n test samples comprises:
obtaining r associated question statements associated with the p categories of question statements by at least one of: replacing words in the p categories of problem sentences according to the synonym library to obtain r associated problem sentences; replacing the item sentences included in the p categories of problem sentences according to the q item sentences to obtain r associated problem sentences; the p classes of problem sentences are compiled back to obtain r associated problem sentences;
dividing the r associated problem sentences into categories to which the problem sentences with the association relationship belong, and obtaining enhanced problem sentences of p categories; and
Dividing the enhanced problem sentences of p categories into m training samples and n test samples,
wherein r is an integer of 1 or more.
5. The method of claim 1, wherein determining an alternative statement to the query statement comprises:
determining a word vector for the query statement as a first word vector;
acquiring word vectors of each item statement in the q item statements to obtain q second word vectors;
determining the similarity between each second word vector in the q second word vectors and the first word vector to obtain q first similarity;
determining target word vectors in the q second word vectors according to the relation between the q first similarities and preset similarities; and
determining the item statement aimed by the target word vector as an alternative item statement aimed by the inquiry statement.
6. The method of claim 5, wherein determining a word vector for the query statement as a first word vector comprises:
dividing words of the inquiry sentence to obtain s first words;
removing the disabling words in the s first words according to the disabling word stock to obtain t second words;
Counting the occurrence times of the t second words in the inquiry sentences; and
determining a first word vector of the query sentence according to a predetermined word stock and the occurrence number,
wherein s and t are integers greater than or equal to 2, and s is greater than or equal to t.
7. The method of claim 5, wherein the similarity between each second word vector and the first word vector comprises a jaccard similarity; the method further comprises the steps of:
determining a word vector of each item statement in the item library to obtain q second word vectors; and
storing the q second word vectors in a compressed file for reading,
the q second word vectors are determined according to a preset word stock.
8. The method of claim 5, further comprising: determining the preset similarity according to the q item sentences; comprising the following steps:
determining the similarity of the q item sentences to each other to obtain [ q (q-1)/2 ] second similarities; and
determining the preset similarity according to the value distribution of the [ q (q-1)/2 ] second similarities,
the preset similarity comprises a first preset similarity and a second preset similarity, and the first preset similarity is larger than the second preset similarity.
9. The method of claim 8, wherein determining a target word vector of the q second word vectors comprises:
determining whether the q second word vectors comprise alternative word vectors with the similarity with the first word vector being greater than or equal to the first preset similarity;
determining that the alternative word vector is the target word vector when the alternative word vector is included in the q second word vectors; and
in the case that the alternative word vector is not included in the q second word vectors:
determining a to-be-selected word vector, wherein the similarity between the q second word vectors and the first word vector is smaller than the first preset similarity and is greater than or equal to the second preset similarity;
sorting the vectors to be selected according to the similarity with the first word vector from big to small to obtain a sequence of vectors to be selected; and
and determining a preset number of the first-ordered candidate word vectors in the candidate word vector sequence as the target word vector.
10. The method of claim 6, wherein said word-splitting the query sentence to obtain s first words comprises:
replacing words in the query sentences according to the synonym library and the target field word library to obtain replaced query sentences; and
And carrying out word segmentation processing on the replaced query sentence to obtain the s first words.
11. The method of claim 1, wherein the number of problem categories is one; determining a reply sentence to the query sentence further includes:
in the case where the number of candidate sentences is one, it is determined from the pre-constructed reply sentence library that reply sentences having a mapping relationship with both the candidate sentences and the question category are reply sentences to the query sentence.
12. The method of claim 1, wherein determining a target item sentence for an query sentence in at least two alternative item sentences based on the similarity of the query sentence to each standard query sentence using a lightweight semantic model comprises:
generating at least two standard inquiry sentences for the at least two alternative item sentences according to the problem category and the at least two alternative item sentences;
taking the query sentence and each standard query sentence in the at least two standard query sentences as a sentence pair, and inputting the lightweight semantic model to obtain the similarity between the query sentence and each standard query sentence; and
And determining the alternative item statement aimed at by the standard inquiry statement with the maximum similarity with the inquiry statement as the target item statement.
13. A sentence processing apparatus comprising:
the sentence acquisition module is used for acquiring an inquiry sentence;
the category determining module is used for determining the category of the question aiming at the query statement in a pre-constructed question library, wherein the question library comprises p categories of question statements;
the item determining module is used for determining alternative item sentences aiming at the inquiry sentences in a pre-constructed item library, wherein the item library comprises q item sentences;
a reply determining module, configured to determine a reply sentence for the query sentence according to the question category and the alternative item sentence;
wherein p and q are integers greater than or equal to 2;
the number of the problem categories is one; determining a reply sentence to the query sentence includes:
in the case where the number of alternative sentences is at least two:
determining target item sentences aiming at the query sentences in at least two alternative item sentences based on the similarity between the query sentences and each standard query sentence by adopting a lightweight semantic model; and
Determining a reply sentence having a mapping relation with the target item sentence and the question category as a reply sentence for the query sentence from a pre-constructed reply sentence library.
14. A computer system, comprising:
one or more processors;
storage means for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-12.
15. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any of claims 1 to 12.
CN202010764814.8A 2020-07-31 2020-07-31 Statement processing method, device, system and medium Active CN111858899B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010764814.8A CN111858899B (en) 2020-07-31 2020-07-31 Statement processing method, device, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010764814.8A CN111858899B (en) 2020-07-31 2020-07-31 Statement processing method, device, system and medium

Publications (2)

Publication Number Publication Date
CN111858899A CN111858899A (en) 2020-10-30
CN111858899B true CN111858899B (en) 2023-09-15

Family

ID=72954343

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010764814.8A Active CN111858899B (en) 2020-07-31 2020-07-31 Statement processing method, device, system and medium

Country Status (1)

Country Link
CN (1) CN111858899B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114154501B (en) * 2022-02-09 2022-04-26 南京擎天科技有限公司 Chinese address word segmentation method and system based on unsupervised learning

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959529A (en) * 2018-06-29 2018-12-07 北京百度网讯科技有限公司 Determination method, apparatus, equipment and the storage medium of problem answers type
CN109840277A (en) * 2019-02-20 2019-06-04 西南科技大学 A kind of government affairs Intelligent Service answering method and system
CN110377721A (en) * 2019-07-26 2019-10-25 京东方科技集团股份有限公司 Automatic question-answering method, device, storage medium and electronic equipment
CN111241245A (en) * 2020-01-14 2020-06-05 百度在线网络技术(北京)有限公司 Human-computer interaction processing method and device and electronic equipment
CN111428010A (en) * 2019-01-10 2020-07-17 北京京东尚科信息技术有限公司 Man-machine intelligent question and answer method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108509411B (en) * 2017-10-10 2021-05-11 腾讯科技(深圳)有限公司 Semantic analysis method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108959529A (en) * 2018-06-29 2018-12-07 北京百度网讯科技有限公司 Determination method, apparatus, equipment and the storage medium of problem answers type
CN111428010A (en) * 2019-01-10 2020-07-17 北京京东尚科信息技术有限公司 Man-machine intelligent question and answer method and device
CN109840277A (en) * 2019-02-20 2019-06-04 西南科技大学 A kind of government affairs Intelligent Service answering method and system
CN110377721A (en) * 2019-07-26 2019-10-25 京东方科技集团股份有限公司 Automatic question-answering method, device, storage medium and electronic equipment
CN111241245A (en) * 2020-01-14 2020-06-05 百度在线网络技术(北京)有限公司 Human-computer interaction processing method and device and electronic equipment

Also Published As

Publication number Publication date
CN111858899A (en) 2020-10-30

Similar Documents

Publication Publication Date Title
US11227118B2 (en) Methods, devices, and systems for constructing intelligent knowledge base
US11544474B2 (en) Generation of text from structured data
EP3958145A1 (en) Method and apparatus for semantic retrieval, device and storage medium
US20220318275A1 (en) Search method, electronic device and storage medium
CN110377733B (en) Text-based emotion recognition method, terminal equipment and medium
CN117390170B (en) Method and device for matching data standards, electronic equipment and readable storage medium
JP7291181B2 (en) Industry text increment method, related apparatus, and computer program product
CN111858899B (en) Statement processing method, device, system and medium
US20240320252A1 (en) Featuring engineering based on semantic types
Pan et al. Research on the training and application methods of a lightweight agricultural domain-specific large language model supporting mandarin chinese and uyghur
JP2024159517A (en) Information processing method and device
CN109446322B (en) Text analysis method and device, electronic equipment and readable storage medium
CN111666770A (en) Semantic matching method and device
CN116244432B (en) Pre-training method and device for language model and electronic equipment
CN110955755A (en) Method and system for determining target standard information
CN116150376A (en) Sample data distribution optimization method, device and storage medium
US20220076143A1 (en) Automatically recommending an existing machine learning project as adaptable for use in a new machine learning project
CN112579774A (en) Model training method, model training device and terminal equipment
CN115017291B (en) Hotspot problem analysis method and device, computer equipment and storage medium
CN113971216B (en) Data processing method and device, electronic equipment and memory
US12073299B2 (en) Systems and methods for using contrastive pre-training to generate text and code embeddings
CN115114902B (en) Sentence component recognition method, sentence component recognition device, sentence component recognition computer device, and sentence component recognition storage medium
Wang et al. What are Models Thinking about? Understanding Large Language Model Hallucinations" Psychology" through Model Inner State Analysis
CN117909756A (en) A text detection method, device and storage medium
CN114692970A (en) User intention prediction model training method, user intention prediction method and device

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