CN112949317B - Text semantic recognition method and device, computer equipment and storage medium - Google Patents

Text semantic recognition method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112949317B
CN112949317B CN202110218904.1A CN202110218904A CN112949317B CN 112949317 B CN112949317 B CN 112949317B CN 202110218904 A CN202110218904 A CN 202110218904A CN 112949317 B CN112949317 B CN 112949317B
Authority
CN
China
Prior art keywords
text
vector
standard
recognition result
intention
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
CN202110218904.1A
Other languages
Chinese (zh)
Other versions
CN112949317A (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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202110218904.1A priority Critical patent/CN112949317B/en
Publication of CN112949317A publication Critical patent/CN112949317A/en
Application granted granted Critical
Publication of CN112949317B publication Critical patent/CN112949317B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/117Tagging; Marking up; Designating a block; Setting of attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Character Discrimination (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the application belongs to the field of artificial intelligence and relates to a text semantic recognition method which comprises the steps of inputting a detection text to a preset basic model, and outputting a first sentence vector of the detection text through a coding layer of the preset basic model; inputting the first sentence vector to an access gate of a preset basic model, and outputting a second sentence vector of the detection text according to the access gate; obtaining an interference characteristic vector of the detection text, and screening the second sentence vector according to the interference characteristic vector to obtain a third sentence vector; and acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determination gate in a preset basic model, and selecting the hit intention in the matching intention according to the determination gate to determine that the hit intention is the text intention of the detected text. The application also provides a text semantic recognition device, computer equipment and a storage medium. Further, the present application relates to blockchain techniques, where the text intent can be stored in a blockchain. The method and the device improve the accuracy of text semantic recognition.

Description

Text semantic recognition method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of artificial intelligence technologies, and in particular, to a text semantic recognition method, an apparatus, a computer device, and a storage medium.
Background
Currently, the existing semantic intelligent recognition model usually adopts a large amount of manual labeling data, and then is obtained by labeling data training. The data annotation of the semantic recognition model is long in time consumption, high in labor time cost and poor in timeliness. Traditional models are less likely to be incapable of customized development and modification, and internal parameters are not changeable once training is completed. When the accuracy of the semantic recognition model is found to be low in production and the model needs to be modified in time, the model cannot be adjusted in advance according to the alternative scheme. The restoration of the semantic recognition model can only be performed by adding regular logic on the outer layer of the semantic recognition model, but whether the regular logic and the model conflict or not cannot be confirmed, and the regular logic, coverage and accuracy are difficult to guarantee. Finally, the semantic recognition model has low accuracy in recognizing the semantic meaning.
Disclosure of Invention
The embodiment of the application aims to provide a text semantic recognition method, a text semantic recognition device, computer equipment and a storage medium, so as to solve the technical problem of low text semantic recognition accuracy.
In order to solve the above technical problem, an embodiment of the present application provides a text semantic recognition method, which adopts the following technical solutions:
inputting a detection text to a preset basic model, and outputting through a coding layer of the preset basic model to obtain a first sentence vector of the detection text;
inputting the first sentence vector to an entry gate of the preset basic model, and outputting a second sentence vector of the detection text according to the entry gate;
obtaining an interference feature vector of the detection text, and screening the second sentence vector according to the interference feature vector to obtain a third sentence vector;
and acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determination gate in the preset basic model, selecting a hit intention in the matching intention according to the determination gate, and determining that the hit intention is the text intention of the detected text.
Further, the step of inputting the detection text to a preset basic model, and obtaining the first sentence vector of the detection text through the coding layer output of the preset basic model specifically includes:
and inputting the detection text to a coding layer of the preset basic model, and carrying out position coding, classification coding and embedded coding on the detection text based on the coding layer to obtain a first sentence vector of the detection text.
Further, the step of obtaining the interference feature vector of the detected text specifically includes:
acquiring a preset standard text, and calculating the text similarity between the detection text and the standard text according to a preset matching algorithm;
and when the text similarity is greater than or equal to a preset text similarity threshold, determining that the detection text and the standard text are successfully matched, acquiring a marked text vector of the standard text, and taking the marked text vector as an interference feature vector of the detection text.
Further, the step of obtaining the tagged text vector of the standard text specifically includes:
a plurality of standard texts are collected in advance, and intention recognition is carried out on each standard text according to the preset basic model to obtain a prediction recognition result;
and acquiring a real recognition result of the standard text, and determining a marked text vector of the standard text according to the predicted recognition result and the real recognition result.
Further, the step of determining the tagged text vector of the standard text according to the predicted recognition result and the real recognition result specifically includes:
determining whether the predicted recognition result of the standard text is consistent with the real recognition result, and when the predicted recognition result is inconsistent with the real recognition result, taking the standard text with the predicted recognition result inconsistent with the real recognition result as a first text and taking the predicted recognition result as a marking result of the first text;
and acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, and determining the text vector of the first text as the marking text vector of the second text.
Further, the step of obtaining the matching intention of the third sentence vector specifically includes:
acquiring a preset standard vector, calculating the first cosine similarity of the third sentence vector and the standard vector, and selecting the standard vector of which the first cosine similarity is more than or equal to a first preset similarity as a matching vector;
and acquiring the vector intention of the matching vector, and determining that the vector intention is the matching intention of the third sentence vector.
Further, the step of selecting a hit intention from the matching intents according to the determination gate specifically includes:
calculating a second cosine similarity of the third sentence vector and a preset sentence vector of the detection text according to the determination gate;
and when the second cosine similarity is greater than or equal to a second preset similarity, determining that the third sentence vector is successfully matched with the preset sentence vector, and determining that the matching intention corresponding to the successfully matched preset sentence vector is the hit intention.
In order to solve the above technical problem, an embodiment of the present application further provides a text semantic recognition apparatus, which adopts the following technical solutions:
the encoding module is used for inputting a detection text to a preset basic model and outputting a first sentence vector of the detection text through an encoding layer of the preset basic model;
the first output module is used for inputting the first sentence vector to an entry gate of the preset basic model and outputting a second sentence vector of the detection text according to the entry gate;
the second output module is used for obtaining an interference characteristic vector of the detection text, and screening the second sentence vector according to the interference characteristic vector to obtain a third sentence vector;
and the confirming module is used for acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determining gate in the preset basic model, selecting the hit intention in the matching intention according to the determining gate, and determining that the hit intention is the text intention of the detected text.
In order to solve the above technical problem, an embodiment of the present application further provides a computer device, which includes a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, where the processor implements the steps of the text semantic recognition method when executing the computer readable instructions.
In order to solve the above technical problem, an embodiment of the present application further provides a computer-readable storage medium, where computer-readable instructions are stored, and when executed by a processor, the computer-readable instructions implement the steps of the text semantic recognition method.
The text semantic recognition method includes inputting a detection text to a preset basic model, and outputting a first sentence vector of the detection text through a coding layer of the preset basic model; then, inputting the first sentence vector to an access gate of a preset basic model, and outputting a second sentence vector of the detected text according to the access gate, so that the first sentence vector is screened for the first time through the access gate, and the efficiency and the accuracy of subsequent text intention identification are improved; then, obtaining interference characteristic vectors of the detected text, screening the second sentence vectors according to the interference characteristic vectors to obtain a third sentence vector, realizing the secondary screening of the sentence vectors, avoiding the interference of the interference characteristic vectors possibly existing on the intention identification result, and further improving the accuracy of the text intention identification; and finally, acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determination gate in a preset basic model, selecting the hit intention in the matching intention according to the determination gate, and determining that the hit intention is the text intention of the detected text, so that the text intention is accurately identified, the response speed of the model is reduced, the identification efficiency of the model on the text intention is improved, and the intention of the current text can be quickly and accurately identified through the model.
Drawings
In order to more clearly illustrate the solution of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below, and it is obvious that the drawings in the description below are some embodiments of the present application, and that other drawings may be obtained by those skilled in the art without inventive effort.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a text semantic recognition method according to the present application;
FIG. 3 is a schematic structural diagram of an embodiment of a text semantic recognition apparatus according to the present application;
FIG. 4 is a schematic block diagram of one embodiment of a computer device according to the present application.
Reference numerals: the text semantic recognition device 300, an encoding module 301, a first output module 302, a second output module 303, and a confirmation module 304.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof in the description and claims of this application and the description of the figures above, are intended to cover non-exclusive inclusions. The terms "first," "second," and the like in the description and claims of this application or in the above-described drawings are used for distinguishing between different objects and not for describing a particular order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein may be combined with other embodiments.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is the medium used to provide communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that the text semantic recognition method provided in the embodiment of the present application is generally executed by a server/terminal device, and accordingly, the text semantic recognition apparatus is generally disposed in the server/terminal device.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continuing reference to FIG. 2, a flow diagram of one embodiment of a method of text semantic recognition according to the present application is shown. The text semantic recognition method comprises the following steps:
step S201, inputting a detection text to a preset basic model, and outputting through a coding layer of the preset basic model to obtain a first sentence vector of the detection text;
in this embodiment, the preset basic model is a preset basic recognition model, the basic recognition model includes a coding layer, an access permission layer, an access prohibition layer and a determination layer, and feature coding is performed on the detection text according to the coding layer, so as to obtain a first sentence vector of the detection text. The entry gate is a first screening layer, the entry gate is a forbidden gate, and the determination gate is a third screening layer and a fourth screening layer, and the first sentence vectors can be sequentially screened according to the entry gate, the forbidden gate and the determination gate.
Step S202, inputting the first sentence vector to an entry gate of the preset basic model, and outputting a second sentence vector of the detection text according to the entry gate;
in this embodiment, the admission gate is a first screening layer in the preset basic model, and the first sentence vector may be screened according to the admission gate. Specifically, a screening threshold of the current admission gate is obtained, and a first sentence vector which is greater than or equal to the screening threshold is determined as a second sentence vector. Taking a Sigmoid function as an example, the Sigmoid function is an activation function of a neural network, and can map variables between 0 and 1, so that when a first sentence vector is obtained, the probability value of the interval [0 and 1] of the first sentence vector is obtained through the Sigmoid function, and the first sentence vector with the probability value larger than or equal to a screening threshold value is determined as a second sentence vector through the admission gate.
Step S203, obtaining an interference feature vector of the detection text, and screening the second sentence vector according to the interference feature vector to obtain a third sentence vector;
in this embodiment, when the second sentence vector is obtained, an interference feature vector of the current detection text is obtained, where the interference feature vector is an interference item of the detection text obtained in advance, and when the detection text is subjected to intent recognition, an error of the intent recognition may be caused due to the existence of the interference item. Therefore, when the second sentence vector is obtained, the interference characteristic vector of the current detection text is obtained, and the interference characteristic vector and the second sentence vector are input into a forbidden gate in a preset basic model; and screening out the vectors consistent with the interference characteristic vector from the second sentence vectors according to the access gate, and determining the remaining second sentence vectors as third sentence vectors.
Step S204, obtaining the matching intention of the third sentence vector, inputting the third sentence vector into a determining gate in the preset basic model, selecting the hit intention in the matching intention according to the determining gate, and determining the hit intention as the text intention of the detected text.
In this embodiment, when the third sentence vector is obtained, the matching intention of the third sentence vector is obtained. Specifically, the matching intention is a text intention matched with the third sentence vector, when the intention recognition is performed on the third sentence vector, a plurality of intentions may be recognized, and the intention with the highest matching score is selected as the matching intention of the third sentence vector. And when the matching intention is obtained, inputting the third sentence vector into a determination gate in the preset basic model, determining whether a sentence vector successfully matched with the preset sentence vector exists in the third sentence vector through the determination gate, and determining the matching intention corresponding to the successfully matched sentence vector as a hit intention, wherein the hit intention is the text intention of the currently detected text.
It is emphasized that the text intent may also be stored in a node of a blockchain in order to further ensure the privacy and security of the text intent.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
According to the embodiment, the text intention can be accurately identified, the response speed of the model is reduced, the identification efficiency of the model on the text intention is improved, and the intention of the current text can be quickly and accurately identified through the model.
In some embodiments of the present application, the inputting the detection text into a preset basic model, and obtaining the first sentence vector of the detection text through the output of the coding layer of the preset basic model includes:
and inputting the detection text to a coding layer of the preset basic model, and carrying out position coding, classification coding and embedded coding on the detection text based on the coding layer to obtain a first sentence vector of the detection text.
In this embodiment, the coding layer of the predetermined base model includes position coding, classification coding, and embedding coding. When a detection text is obtained, inputting the detection text into a coding layer of the preset basic model, and respectively carrying out position coding, classification coding and embedded coding on the detection text to obtain a first coding vector, a second coding vector and a third coding vector; and combining the first coding vector, the second coding vector and the third coding vector to obtain a first sentence vector corresponding to the detection text. Taking UniLM (UNIfied pre-trained Language Model) as an example, uniLM includes 24 layers of transform networks, 1024 hidden sizes, 16 attention heads, through which uni, sequence-to-sequence and bi-directional prediction tasks can be completed. And when the detection text is obtained, inputting the detection text into a coding layer in the UniLM model, and outputting to obtain a first sentence vector.
In the embodiment, the sentence vector is obtained by encoding the detection text, so that the intention of the detection text can be accurately identified through the sentence vector, and the accuracy of text intention identification is further improved.
In some embodiments of the present application, the obtaining the interference feature vector of the detected text includes:
acquiring a preset standard text, and calculating the text similarity of the detection text and the standard text according to a preset matching algorithm;
and when the text similarity is greater than or equal to a preset text similarity threshold value and the matching between the detected text and the standard text is determined to be successful, obtaining a marked text vector of the standard text, and taking the marked text vector as an interference feature vector of the detected text.
In this embodiment, the standard texts are collected discrimination texts, and when the interference feature vector of the currently detected text is obtained, a plurality of pre-stored standard texts are obtained. And when the standard text is obtained, calculating the text similarity of the standard text and the detected text according to a preset matching algorithm. Specifically, when text similarity is calculated according to a preset matching algorithm, a standard text and a detection text are respectively converted into corresponding word sets; then, respectively calculating the word frequencies of the two word sets, and carrying out word frequency vectorization on the word frequencies to obtain corresponding word frequency vectors; and finally, calculating cosine similarity between word frequency vectors respectively corresponding to the detected text and the standard text, and obtaining the text similarity of the standard text and the detected text. And when the text similarity is greater than or equal to a preset text similarity threshold value, determining that the standard text and the detection text are successfully matched. At this time, the marked text vector corresponding to the standard text successfully matched with the detected text is the interference feature vector of the detected text. The marked text vector is an interference characteristic vector of the standard text, and the marked text vector and the standard text are pre-associated and stored in a database; when the standard text is obtained, the marked text vector corresponding to the standard text can be obtained through the association relation.
In the embodiment, the interference feature vector of the detected text is obtained, so that the first sentence vector can be screened through the interference feature vector, thereby avoiding the interference of the vector which possibly causes the intention recognition error, and further improving the accuracy of the intention recognition.
In some embodiments of the application, the obtaining of the tagged text vector of the standard text includes:
a plurality of standard texts are collected in advance, and intention recognition is carried out on each standard text according to the preset basic model to obtain a prediction recognition result;
and acquiring a real recognition result of the standard text, and determining a marked text vector of the standard text according to the predicted recognition result and the real recognition result.
In this embodiment, when the labeled text vector of the standard text is obtained, a plurality of standard texts need to be collected in advance, and each standard text is subjected to intention recognition according to the current preset basic model, so as to obtain a prediction recognition result corresponding to each standard text. And obtaining a real recognition result of the standard text, wherein the real recognition result is a real intention result of each standard text, comparing the predicted recognition result with the real recognition result, and determining a marked text vector of each standard text according to the predicted recognition result and the real recognition result. Specifically, a real recognition result and a predicted recognition result of each standard text are obtained, when the predicted recognition result is inconsistent with the real recognition result, the standard text with the predicted recognition result inconsistent with the real recognition result is used as a first text, and the predicted recognition result is used as a marking result of the first text. And then, acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, wherein the marking text vector of the first text is determined as the marking text vector of the second text.
In the embodiment, the interference characteristic vector is accurately acquired by acquiring the real identification result and the prediction identification result, so that the interference of the interference characteristic vector on the identification result is avoided when the intention is identified.
In some embodiments of the application, the determining, according to the predicted recognition result and the actual recognition result, a tagged text vector of the standard text includes:
determining whether the predicted recognition result of the standard text is consistent with the real recognition result, and when the predicted recognition result is inconsistent with the real recognition result, taking the standard text with the predicted recognition result inconsistent with the real recognition result as a first text and taking the predicted recognition result as a marking result of the first text;
and acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, and determining the text vector of the first text as the marking text vector of the second text.
In this embodiment, when a tagged text vector of a standard text is determined according to a predicted recognition result and a real recognition result, the real recognition result and the predicted recognition result of each standard text are obtained, the real recognition result and the predicted recognition result of each standard text are compared, if the predicted recognition result is inconsistent with the real recognition result, the standard text is used as a first text, and the predicted recognition result corresponding to the standard text is used as a tagged result. And then, obtaining texts of which the predicted recognition result and the real recognition result are the marking results in all the standard texts, wherein the texts are second texts.
Since the predicted recognition result of the first text and the predicted recognition result and the actual recognition result of the second text are consistent, that is, the tagged text vector representing the first text may interfere with the text intent recognition corresponding to the second text, so that when the text is subjected to intent recognition, the text intent of the first text included in the detected text may be recognized as the text intent of the second text. Therefore, the marked text vector of the first text is determined as the marked text vector of the second text, and when the detected text is identified, the interfering characteristic vector in the sentence vector corresponding to the detected text is screened out, so that the false identification of the intention is avoided.
In the embodiment, the marked text vector is determined, so that the interference characteristic vector can be accurately obtained through the marked text vector, and the accuracy of text intention identification is further improved.
In some embodiments of the present application, the obtaining of the matching intention of the third sentence vector includes:
acquiring a preset standard vector, calculating the first cosine similarity of the third sentence vector and the standard vector, and selecting the standard vector of which the first cosine similarity is more than or equal to a first preset similarity as a matching vector;
and acquiring the vector intention of the matching vector, and determining that the vector intention is the matching intention of the third sentence vector.
In this embodiment, when the matching intention of the third sentence vector is obtained, the matching intention can be obtained by obtaining a standard vector and determining the matching intention according to the first cosine similarity between the standard vector and the third sentence vector. Specifically, a standard vector is obtained, the standard vector is a preset and stored vector, and each standard vector is associated with a corresponding matching intention. When the standard vector is obtained, calculating the first cosine similarity of the standard vector and the third sentence vector, and taking the first cosine similarity as the matching score of the third sentence vector and each standard vector; and selecting the standard vector with the first cosine similarity larger than or equal to the first preset similarity as the matching vector of the third sentence vector. And acquiring a vector intention corresponding to the matching vector, wherein the vector intention is the matching intention of the third sentence vector.
According to the embodiment, the vector intention of the standard vector matched with the third sentence vector is obtained, so that the obtaining time of text intention identification is shortened, and the obtaining efficiency and the accuracy of the text intention are improved.
In some embodiments of the application, the selecting hit intents from the matching intents according to the determination gate includes:
calculating a second cosine similarity of the third sentence vector and a preset sentence vector of the detection text according to the determination gate;
and when the second cosine similarity is greater than or equal to a second preset similarity, determining that the third sentence vector is successfully matched with the preset sentence vector, and determining that the matching intention corresponding to the successfully matched preset sentence vector is the hit intention.
In this embodiment, the predetermined sentence vector is a predetermined special hit vector. When the matching intention of the third sentence vector is obtained, there may be a plurality of matching intents, and in addition to selecting the matching intention with the highest matching score in the matching intents as the hit intention, in this embodiment, a preset sentence vector of the detected text and a second cosine similarity between the third sentence vector and the preset sentence vector may also be obtained through a confirmation gate. When the second cosine similarity is greater than or equal to a second preset similarity, determining that the third sentence vector is successfully matched with the preset sentence vector, wherein the matching intention corresponding to the successfully matched preset sentence vector is the hit intention; and when the matching threshold is smaller than a second preset similarity, determining that the matching of the third sentence vector and the preset sentence vector fails, and selecting the intention with the highest matching score from the matching intents corresponding to the third sentence vector as the hit intention.
In the embodiment, the intention of the specific vector is confirmed by acquiring the preset sentence vector, the selection of the non-optimal intention although the matching score is high is avoided, and the accuracy of text intention identification is further improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above may be implemented by hardware that is configured to be instructed by computer-readable instructions, which can be stored in a computer-readable storage medium, and when executed, the programs may include the processes of the embodiments of the methods described above. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
With further reference to fig. 3, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a text semantic recognition apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 3, the text semantic recognition apparatus 300 according to the embodiment includes: an encoding module 301, a first output module 302, a second output module 303, and a confirmation module 304. Wherein:
the encoding module 301 is configured to input a detection text to a preset basic model, and obtain a first sentence vector of the detection text through an encoding layer output of the preset basic model;
wherein, the encoding module 301 comprises:
and the coding unit is used for inputting the detection text to a coding layer of the preset basic model, and carrying out position coding, classification coding and embedded coding on the detection text based on the coding layer to obtain a first sentence vector of the detection text.
In this embodiment, the preset basic model is a preset basic recognition model, the basic recognition model includes a coding layer, an access permission layer, an access prohibition layer and a determination layer, and feature coding is performed on the detection text according to the coding layer, so as to obtain a first sentence vector of the detection text. The admission gate is a first screening layer, the forbidding gate and the determining gate are a third screening layer and a fourth screening layer, and the first sentence vectors can be sequentially screened according to the admission gate, the forbidding gate and the determining gate.
A first output module 302, configured to input the first sentence vector to an entry gate of the preset basic model, and obtain a second sentence vector of the detection text according to the entry gate output;
in this embodiment, the admission gate is a first screening layer in the preset basic model, and the first sentence vector can be screened according to the admission gate. Specifically, a screening threshold of the current admission gate is obtained, and a first sentence vector which is greater than or equal to the screening threshold is determined as a second sentence vector. Taking a Sigmoid function as an example, the Sigmoid function is an activation function of a neural network, and can map variables between 0 and 1, so that when a first sentence vector is obtained, the probability value of the interval [0 and 1] of the first sentence vector is obtained through the Sigmoid function, and the first sentence vector with the probability value larger than or equal to a screening threshold value is determined as a second sentence vector through the admission gate.
A second output module 303, configured to obtain an interference feature vector of the detected text, and filter the second sentence vector according to the interference feature vector to obtain a third sentence vector;
wherein, the second output module 303 includes:
the acquisition unit is used for acquiring a preset standard text and calculating the text similarity of the detection text and the standard text according to a preset matching algorithm;
and the first confirming unit is used for determining that the detection text is successfully matched with the standard text when the text similarity is greater than or equal to a preset text similarity threshold, acquiring a marked text vector of the standard text, and taking the marked text vector as an interference feature vector of the detection text.
Wherein the first confirming unit includes:
the acquisition subunit is used for acquiring a plurality of standard texts in advance, and performing intention recognition on each standard text according to the preset basic model to obtain a prediction recognition result;
and the first confirming subunit is used for acquiring a real recognition result of the standard text and determining a marked text vector of the standard text according to the predicted recognition result and the real recognition result.
Wherein, the first affirmation subunit comprises:
a second confirming subunit, configured to determine whether a predicted recognition result of the standard text and the real recognition result are consistent, and if the predicted recognition result is inconsistent with the real recognition result, take the standard text with the predicted recognition result inconsistent with the real recognition result as a first text, and take the predicted recognition result as a marking result of the first text;
and the third confirming subunit is used for acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, and determining the text vector of the first text as the marking text vector of the second text.
In this embodiment, when the second sentence vector is obtained, an interference feature vector of the current detection text is obtained, where the interference feature vector is an interference item of the detection text obtained in advance, and when the detection text is subjected to intent recognition, an error of the intent recognition may be caused due to the existence of the interference item. Therefore, when a second sentence vector is obtained, the interference characteristic vector of the current detection text is obtained, and the interference characteristic vector and the second sentence vector are input into a forbidden gate in a preset basic model; and screening out the vectors consistent with the interference characteristic vector from the second sentence vectors according to the access gate, and determining the remaining second sentence vectors as third sentence vectors.
A determining module 304, configured to obtain matching intents of the third sentence vector, input the third sentence vector into a determining gate in the preset basic model, select a hit intention of the matching intents according to the determining gate, and determine that the hit intention is a text intention of the detected text.
Wherein, the confirming module 304 comprises:
the calculating unit is used for acquiring a preset standard vector, calculating the first cosine similarity of the third sentence vector and the standard vector, and selecting the standard vector with the first cosine similarity being more than or equal to a first preset similarity as a matching vector;
and the second confirming unit is used for acquiring the vector intention of the matching vector and determining that the vector intention is the matching intention of the third sentence vector.
The matching unit is used for calculating the second cosine similarity of the third sentence vector and the preset sentence vector of the detection text according to the determining gate;
and the third confirming unit is used for determining that the third sentence vector is successfully matched with the preset sentence vector when the second cosine similarity is greater than or equal to a second preset similarity, and determining that the matching intention corresponding to the successfully matched preset sentence vector is the hit intention.
In this embodiment, when the third sentence vector is obtained, the matching intention of the third sentence vector is obtained. Specifically, the matching intention is a text intention matched with the third sentence vector, when the intention of the third sentence vector is identified, a plurality of intentions may be identified, and the intention with the highest matching score is selected as the matching intention of the third sentence vector. And when the matching intention is obtained, inputting the third sentence vector into a determination gate in the preset basic model, determining whether a sentence vector successfully matched with the preset sentence vector exists in the third sentence vector through the determination gate, and determining the matching intention corresponding to the successfully matched sentence vector as a hit intention, wherein the hit intention is the text intention of the currently detected text.
It is emphasized that the text intent may also be stored in a node of a blockchain in order to further ensure privacy and security of the text intent.
The block chain referred by the application is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a string of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, which is used for verifying the validity (anti-counterfeiting) of the information and generating a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The text semantic recognition device provided by the embodiment realizes accurate recognition of the text intention, reduces the response speed of the model, improves the recognition efficiency of the model on the text intention, and enables the intention of the current text to be quickly and accurately recognized through the model.
In order to solve the technical problem, an embodiment of the present application further provides a computer device. Referring to fig. 4 in particular, fig. 4 is a block diagram of a basic structure of a computer device according to the embodiment.
The computer device 6 includes a memory 61, a processor 62, and a network interface 63 communicatively connected to each other via a system bus. It is noted that only the computer device 6 having the components 61-63 is shown in the figure, but it is understood that not all of the shown components are required to be implemented, and that more or less components may be implemented instead. As will be understood by those skilled in the art, the computer device is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and the hardware includes, but is not limited to, a microprocessor, an Application Specific Integrated Circuit (ASIC), a Programmable Gate Array (FPGA), a Digital Signal Processor (DSP), an embedded device, and the like.
The computer device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The computer equipment can carry out man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch panel or voice control equipment and the like.
The memory 61 includes at least one type of readable storage medium including a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the memory 61 may be an internal storage unit of the computer device 6, such as a hard disk or a memory of the computer device 6. In other embodiments, the memory 61 may also be an external storage device of the computer device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the computer device 6. Of course, the memory 61 may also comprise both an internal storage unit of the computer device 6 and an external storage device thereof. In this embodiment, the memory 61 is generally used for storing an operating system and various application software installed on the computer device 6, such as computer readable instructions of a text semantic recognition method. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is configured to execute computer readable instructions stored in the memory 61 or process data, for example, execute computer readable instructions of the text semantic recognition method.
The network interface 63 may comprise a wireless network interface or a wired network interface, and the network interface 63 is typically used for establishing a communication connection between the computer device 6 and other electronic devices.
The computer device provided by the embodiment realizes accurate recognition of the text intention, reduces the response speed of the model, improves the recognition efficiency of the model on the text intention, and enables the intention of the current text to be quickly and accurately recognized through the model.
The present application further provides another embodiment, which is to provide a computer-readable storage medium storing computer-readable instructions executable by at least one processor to cause the at least one processor to perform the steps of the text semantic identification method as described above.
The computer-readable storage medium provided by the embodiment realizes accurate recognition of the text intention, reduces the response speed of the model, and improves the recognition efficiency of the model on the text intention, so that the intention of the current text can be quickly and accurately recognized through the model.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present application.
It should be understood that the above-described embodiments are merely exemplary of some, and not all, embodiments of the present application, and that the drawings illustrate preferred embodiments of the present application without limiting the scope of the claims appended hereto. This application is capable of embodiments in many different forms and the embodiments are provided so that this disclosure will be thorough and complete. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to one skilled in the art that the present application may be practiced without modification or with equivalents of some of the features described in the foregoing embodiments. All equivalent structures made by using the contents of the specification and the drawings of the present application are directly or indirectly applied to other related technical fields and are within the protection scope of the present application.

Claims (7)

1. A text semantic recognition method is characterized by comprising the following steps:
inputting a detection text to a preset basic model, and outputting through a coding layer of the preset basic model to obtain a first sentence vector of the detection text;
inputting the first sentence vector to an entry gate of the preset basic model, outputting a second sentence vector of the detection text according to the entry gate, specifically, obtaining a screening threshold of the current entry gate, and determining the first sentence vector which is greater than or equal to the screening threshold as the second sentence vector;
obtaining an interference feature vector of the detection text, screening the second sentence vector according to the interference feature vector to obtain a third sentence vector, wherein,
the step of obtaining the interference feature vector of the detection text specifically includes:
acquiring a preset standard text, and calculating the text similarity between the detection text and the standard text according to a preset matching algorithm;
when the text similarity is greater than or equal to a preset text similarity threshold, determining that the detection text and the standard text are successfully matched, acquiring a marked text vector of the standard text, and taking the marked text vector as an interference feature vector of the detection text,
the step of obtaining the tagged text vector of the standard text specifically includes:
a plurality of standard texts are collected in advance, and intention recognition is carried out on each standard text according to the preset basic model to obtain a prediction recognition result;
acquiring a real recognition result of the standard text, and determining a marked text vector of the standard text according to the predicted recognition result and the real recognition result, wherein,
the step of determining the tagged text vector of the standard text according to the predicted recognition result and the real recognition result specifically includes:
determining whether the predicted recognition result of the standard text is consistent with the real recognition result, and when the predicted recognition result is inconsistent with the real recognition result, taking the standard text with the predicted recognition result inconsistent with the real recognition result as a first text and taking the predicted recognition result as a marking result of the first text;
acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, and determining a marking text vector of the first text as a marking text vector of the second text, wherein the marking text vector is an interference feature vector of the standard text, the marking text vector and the standard text are pre-associated and stored in a database, and the interference feature vector of the standard text is a pre-obtained interference item of the standard text;
and acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determination gate in the preset basic model, selecting a hit intention in the matching intention according to the determination gate, and determining that the hit intention is the text intention of the detected text.
2. The text semantic recognition method according to claim 1, wherein the step of inputting the detection text to a preset basic model and obtaining a first sentence vector of the detection text through an output of a coding layer of the preset basic model specifically comprises:
and inputting the detection text to a coding layer of the preset basic model, and carrying out position coding, classification coding and embedded coding on the detection text based on the coding layer to obtain a first sentence vector of the detection text.
3. The text semantic recognition method according to claim 1, wherein the step of obtaining the matching intention of the third sentence vector specifically comprises:
acquiring a preset standard vector, calculating the first cosine similarity of the third sentence vector and the standard vector, and selecting the standard vector with the first cosine similarity being more than or equal to a first preset similarity as a matching vector;
and acquiring the vector intention of the matching vector, and determining that the vector intention is the matching intention of the third sentence vector.
4. The text semantic recognition method according to claim 1, wherein the step of selecting a hit intention from the matching intentions according to the determination gate specifically comprises:
calculating a second cosine similarity of the third sentence vector and a preset sentence vector of the detection text according to the determination gate;
and when the second cosine similarity is greater than or equal to a second preset similarity, determining that the third sentence vector is successfully matched with the preset sentence vector, and determining that the matching intention corresponding to the successfully matched preset sentence vector is the hit intention.
5. A text semantic recognition apparatus, comprising:
the encoding module is used for inputting a detection text to a preset basic model and outputting a first sentence vector of the detection text through an encoding layer of the preset basic model;
the first output module is used for inputting the first sentence vector to an entry gate of the preset basic model, obtaining a second sentence vector of the detection text according to the entry gate output, specifically, obtaining a screening threshold of the current entry gate, and determining the first sentence vector which is greater than or equal to the screening threshold as the second sentence vector;
a second output module, configured to obtain an interference feature vector of the detected text, and filter the second sentence vector according to the interference feature vector to obtain a third sentence vector, where the step of obtaining the interference feature vector of the detected text specifically includes: acquiring a preset standard text, and calculating the text similarity of the detection text and the standard text according to a preset matching algorithm; when the text similarity is greater than or equal to a preset text similarity threshold, determining that the detected text and the standard text are successfully matched, obtaining a marked text vector of the standard text, and using the marked text vector as an interference feature vector of the detected text, where the marked text vector is the interference feature vector of the standard text, the marked text vector and the standard text are pre-associated and stored in a database, the interference feature vector of the standard text is a pre-obtained interference item of the standard text, and the step of obtaining the marked text vector of the standard text specifically includes: a plurality of standard texts are collected in advance, and intention recognition is carried out on each standard text according to the preset basic model to obtain a prediction recognition result; acquiring a real recognition result of the standard text, and determining a marked text vector of the standard text according to the predicted recognition result and the real recognition result, wherein the step of determining the marked text vector of the standard text according to the predicted recognition result and the real recognition result specifically comprises the following steps: determining whether the predicted recognition result of the standard text is consistent with the real recognition result, and when the predicted recognition result is inconsistent with the real recognition result, taking the standard text with the predicted recognition result inconsistent with the real recognition result as a first text and taking the predicted recognition result as a marking result of the first text; acquiring a second text of which the predicted recognition result and the real recognition result are the marking results in the standard text, and determining the marking text vector of the first text as the marking text vector of the second text;
and the confirming module is used for acquiring the matching intention of the third sentence vector, inputting the third sentence vector into a determining gate in the preset basic model, selecting the hit intention in the matching intention according to the determining gate, and determining that the hit intention is the text intention of the detected text.
6. A computer device comprising a memory having computer readable instructions stored therein and a processor that when executed performs the steps of the text semantic identification method according to any one of claims 1 to 4.
7. A computer-readable storage medium, having computer-readable instructions stored thereon, which, when executed by a processor, implement the steps of the text semantic identification method according to any one of claims 1 to 4.
CN202110218904.1A 2021-02-26 2021-02-26 Text semantic recognition method and device, computer equipment and storage medium Active CN112949317B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110218904.1A CN112949317B (en) 2021-02-26 2021-02-26 Text semantic recognition method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110218904.1A CN112949317B (en) 2021-02-26 2021-02-26 Text semantic recognition method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112949317A CN112949317A (en) 2021-06-11
CN112949317B true CN112949317B (en) 2022-10-11

Family

ID=76246544

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110218904.1A Active CN112949317B (en) 2021-02-26 2021-02-26 Text semantic recognition method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112949317B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110928997A (en) * 2019-12-04 2020-03-27 北京文思海辉金信软件有限公司 Intention recognition method and device, electronic equipment and readable storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9684876B2 (en) * 2015-03-30 2017-06-20 International Business Machines Corporation Question answering system-based generation of distractors using machine learning
CN109657232A (en) * 2018-11-16 2019-04-19 北京九狐时代智能科技有限公司 A kind of intension recognizing method
CN111462752B (en) * 2020-04-01 2023-10-13 北京思特奇信息技术股份有限公司 Attention mechanism, feature embedding and BI-LSTM (business-to-business) based customer intention recognition method
CN111488426B (en) * 2020-04-17 2024-02-02 支付宝(杭州)信息技术有限公司 Query intention determining method, device and processing equipment
CN111813899A (en) * 2020-08-31 2020-10-23 腾讯科技(深圳)有限公司 Intention identification method and device based on multiple rounds of conversations

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110928997A (en) * 2019-12-04 2020-03-27 北京文思海辉金信软件有限公司 Intention recognition method and device, electronic equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向任务型多轮对话的粗粒度意图识别方法;叶铱雷 等;《小型微型计算机***》;20200831;第41卷(第8期);第1620-1626页 *

Also Published As

Publication number Publication date
CN112949317A (en) 2021-06-11

Similar Documents

Publication Publication Date Title
CN112685565B (en) Text classification method based on multi-mode information fusion and related equipment thereof
CN112395390B (en) Training corpus generation method of intention recognition model and related equipment thereof
CN113761577B (en) Big data desensitization method, device, computer equipment and storage medium
CN112528029A (en) Text classification model processing method and device, computer equipment and storage medium
CN112417887B (en) Sensitive word and sentence recognition model processing method and related equipment thereof
CN113220734A (en) Course recommendation method and device, computer equipment and storage medium
CN112632278A (en) Labeling method, device, equipment and storage medium based on multi-label classification
CN112468658B (en) Voice quality detection method and device, computer equipment and storage medium
CN112836521A (en) Question-answer matching method and device, computer equipment and storage medium
CN112084779B (en) Entity acquisition method, device, equipment and storage medium for semantic recognition
CN112446209A (en) Method, equipment and device for setting intention label and storage medium
CN113505601A (en) Positive and negative sample pair construction method and device, computer equipment and storage medium
CN112699213A (en) Speech intention recognition method and device, computer equipment and storage medium
CN115438149A (en) End-to-end model training method and device, computer equipment and storage medium
CN112528040B (en) Detection method for guiding drive corpus based on knowledge graph and related equipment thereof
CN112669850A (en) Voice quality detection method and device, computer equipment and storage medium
CN112949320A (en) Sequence labeling method, device, equipment and medium based on conditional random field
CN115730237B (en) Junk mail detection method, device, computer equipment and storage medium
CN112949317B (en) Text semantic recognition method and device, computer equipment and storage medium
CN115730603A (en) Information extraction method, device, equipment and storage medium based on artificial intelligence
CN115967549A (en) Anti-leakage method based on internal and external network information transmission and related equipment thereof
CN115373634A (en) Random code generation method and device, computer equipment and storage medium
CN112417886A (en) Intention entity information extraction method and device, computer equipment and storage medium
CN113657104A (en) Text extraction method and device, computer equipment and storage medium
CN113988223A (en) Certificate image recognition method and device, computer equipment and storage medium

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