A question-and-answer interaction method, system, device and storage medium
By establishing a corpus of interactive data in rural scenes and using BERT model for semantic analysis, the problem of inaccurate semantic understanding of intelligent Q&A in rural education scenarios is solved, and the reliability and pertinence of responses are improved.
Patent Information
- Application Number
- CN202111627460.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2041-12-28
AI Technical Summary
The existing intelligent question-and-answer technology has inaccurate semantic understanding and answers unquestioned questions in rural education scenarios, and lacks data resources for rural education scenarios, which cannot provide reliable help.
By establishing a corpus that collects interactive data of rural scenes, the method of converting statement text into vector data and analyzing vector weights is adopted, and semantic analysis is performed in combination with the attention mechanism-based BERT model to identify the statement scene and generate responses.
The reliability and pertinence of the response in the Q&A interaction in rural education has been improved, making the response more in line with the rural education scenario, reducing the vector dimension, and improving the accuracy of vector representation and the stability of semantic analysis.
Smart Images

Figure CN114357133B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of information technology, and in particular, to a question-and-answer interaction method, system, device, and storage medium. Background Art
[0002] Rural construction, as an important aspect of the "three rural issues", has received extensive attention from all sectors of society in recent years. Rural construction can not only improve the living standards of rural residents, but also is a key link in the coordinated development of urban and rural areas in China, playing a crucial role in promoting the steady improvement of urban production levels. With the development of technology, the lives of urban residents have become more and more intelligent and automated, while rural development has been relatively slow. Therefore, it is particularly important to use emerging technologies to assist rural construction. Among them, rural education has always been in a leading position in rural construction.
[0003] Intelligent question and answer is a technology used to reduce labor costs and improve work efficiency in educational scenarios. However, at present, intelligent question and answer still has disadvantages such as inaccurate semantic understanding and answering irrelevant questions, and due to the lack of data resources in rural education scenarios, it cannot provide reliable help for the practical problems of rural education. Summary of the Invention
[0004] An object of the present invention is to solve at least to some extent one of the technical problems existing in the prior art.
[0005] To this end, an object of an embodiment of the present invention is to provide a question-and-answer interaction method, which realizes high-accuracy responses that conform to rural education scenarios.
[0006] Another object of an embodiment of the present invention is to provide a question-and-answer interaction system.
[0007] In order to achieve the above technical objectives, the technical solutions adopted in the embodiments of the present invention include:
[0008] In a first aspect, an embodiment of the present invention provides a question-and-answer interaction method, including the following steps:
[0009] Obtain a statement text;
[0010] Convert the statement text into multiple vector data;
[0011] Perform weight analysis on each of the vector data according to a corpus, and generate vector weights. The corpus includes pre-collected and real-time collected rural scenario interaction data;
[0012] Analyze the semantics of the statement text according to the vector data and the vector weights through a BERT model based on an attention mechanism;
[0013] Identify the statement scenario according to the semantics;
[0014] Generate a response according to the semantics and the sentence scenario.
[0015] A question-and-answer interaction method according to an embodiment of the present invention improves the reliability and pertinence of responses in the real scenario of question-and-answer interaction by establishing a corpus collecting rural scenario interaction data, making the responses more suitable for the question-and-answer interaction scenario; by converting sentence texts into vector data and analyzing the weights of each vector data, the dimension of the vector is reduced, the accuracy of vector representation is improved, and at the same time, semantic analysis is performed through a BERT model based on the attention mechanism, improving the stability and accuracy of semantics, and further improving the pertinence of responses.
[0016] In addition, a question-and-answer interaction method according to the above embodiment of the present invention may further have the following additional technical features:
[0017] Further, in a question-and-answer interaction method according to an embodiment of the present invention, the obtaining of the sentence text includes:
[0018] Collect voice data;
[0019] Convert the voice data into text to obtain the sentence text.
[0020] Further, in an embodiment of the present invention, the converting the sentence text into a plurality of vector data includes:
[0021] Segment the sentence text into sentences;
[0022] Perform word segmentation on the sentences to obtain a plurality of words;
[0023] Convert the words into discrete vectors through a bag-of-words model, and analyze and express the vector relationship between the discrete vectors through a Skip-Gram model to form the vector data.
[0024] Further, in an embodiment of the present invention, the weight analysis of each vector data according to the corpus to generate vector weights includes:
[0025] Count the occurrence frequency of the words corresponding to the vector data;
[0026] Count the number of contexts of the words corresponding to the vector data;
[0027] Generate the vector weights according to the occurrence frequency and the number of contexts.
[0028] Further, in an embodiment of the present invention, the sentence scenarios include daily interaction scenarios, education classroom scenarios, and safety help-seeking scenarios;
[0029] When the statement scenario is the daily interaction scenario, generating a response according to the semantics and the statement scenario includes:
[0030] Querying from the corpus whether there is a corresponding answer according to the semantics and the statement scenario;
[0031] If so, generating the response according to the corresponding answer;
[0032] If not, generating the response by searching Internet resources.
[0033] Further, in an embodiment of the present invention, when the statement scenario is the education classroom scenario, generating a response according to the semantics and the statement scenario includes:
[0034] Querying from Internet resources whether there is a corresponding course resource according to the semantics and the statement scenario;
[0035] If so, playing the corresponding course resource;
[0036] If not, querying relevant course resources from Internet resources and playing them.
[0037] Further, in an embodiment of the present invention, when the statement scenario is the safety help-seeking scenario, generating a response according to the semantics and the statement scenario includes:
[0038] Querying from the corpus whether there is a first solution according to the semantics and the statement scenario;
[0039] If so, generating the response according to the first solution;
[0040] If not, obtaining a second solution by searching Internet resources and generating the response according to the second solution.
[0041] In a second aspect, an embodiment of the present invention provides a question-and-answer interaction system, including:
[0042] A statement text acquisition module, configured to acquire statement text;
[0043] A vector data conversion module, configured to convert the statement text into a plurality of vector data;
[0044] A vector weight generation module, configured to perform weight analysis on each of the vector data according to a corpus to generate vector weights;
[0045] A semantic analysis module, configured to analyze the semantics of the statement text according to the vector data and the vector weights through a BERT model based on an attention mechanism;
[0046] A statement scenario recognition module, configured to recognize a statement scenario according to the semantics;
[0047] A response generation module, configured to generate a response according to the semantics and the statement scenario.
[0048] In a third aspect, an embodiment of the present invention provides a question-and-answer interaction device, including:
[0049] At least one processor;
[0050] At least one memory, configured to store at least one program;
[0051] When the at least one program is executed by the at least one processor, the at least one processor is caused to implement the described question-and-answer interaction method.
[0052] In a fourth aspect, an embodiment of the present invention provides a storage medium, in which a program executable by a processor is stored, and the program executable by the processor is used to implement the described question-and-answer interaction method when executed by the processor.
[0053] The advantages and beneficial effects of the present invention will be partially given in the following description, partially will become obvious from the following description, or will be understood through the practice of this application:
[0054] By establishing a corpus collecting rural scene interaction data, the embodiment of the present invention improves the reliability and pertinence of responses in the real scene of rural education question-and-answer interaction, making the responses more suitable for the rural education question-and-answer interaction scene; by converting statement texts into vector data and analyzing the weights of each vector data, the dimension of the vector is reduced, the accuracy of vector representation is improved, and at the same time, semantic analysis is performed through a BERT model based on the attention mechanism, improving the stability and accuracy of semantics, and further improving the pertinence of responses. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following introduces the accompanying drawings of the related technical solutions in the embodiments of the present application or the prior art. It should be understood that the accompanying drawings below are only for conveniently and clearly presenting some embodiments of the technical solutions in the present application. For those skilled in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0056] Figure 1 It is a schematic flowchart of a specific embodiment of a question-and-answer interaction method of the present invention;
[0057] Figure 2 It is a schematic structural diagram of a specific embodiment of a question-and-answer interaction system of the present invention;
[0058] Figure 3 This is a schematic structural diagram of a specific embodiment of a question-and-answer interaction device of the present invention. Specific implementation manner
[0059] The embodiments of the present invention will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, in which the same or similar reference numerals represent the same or similar elements or elements having the same or similar functions from beginning to end. The embodiments described below by referring to the accompanying drawings are exemplary and are only used to explain the present application and should not be construed as a limitation to the present application. For the step numbers in the following embodiments, they are only set for the convenience of description and explanation, and no limitation is imposed on the order between the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
[0060] The terms "first", "second", "third", "fourth", etc. in the specification, claims and drawings of the present invention are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0061] Referring to "embodiment" in the present invention means that a specific feature, structure or characteristic described in combination with the embodiment can be included in at least one embodiment of the present invention. The appearance of this phrase in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0062] Rural construction, as an important aspect of the "issues concerning agriculture, rural areas and farmers", has received extensive attention from all sectors of society in recent years. Rural construction can not only improve the living standards of villagers, but also is a key link in the coordinated development of urban and rural areas in China, playing a crucial role in promoting the steady improvement of urban production levels. With the development of technology, the lives of urban residents have become more and more intelligent and automated, while rural development has been relatively slow. Therefore, it is particularly important to use emerging technologies to assist rural construction. Among them, rural education has always been in a leading position in rural construction.
[0063] Intelligent question and answer is a technology used to reduce labor costs and improve work efficiency in educational scenarios. However, at present, intelligent question and answer still has disadvantages such as inaccurate semantic understanding and answering irrelevant questions, and due to the lack of data resources in rural education scenarios, it cannot provide reliable help for the practical problems of rural education.
[0064] To this end, the present invention proposes a question-and-answer interaction method and system. By establishing a corpus collecting rural scene interaction data, the reliability and pertinence of responses in the real scene of rural education question-and-answer interaction are improved, making the responses more suitable for the rural education question-and-answer interaction scene. By converting the sentence text into vector data and analyzing the weights of each vector data, the dimension of the vector is reduced, and the accuracy of the vector representation is improved. At the same time, semantic analysis is performed through the BERT model based on the attention mechanism, improving the stability and accuracy of semantics, and further improving the pertinence of responses.
[0065] Next, a question-and-answer interaction method and system proposed according to an embodiment of the present invention will be described in detail with reference to the accompanying drawings. First, a question-and-answer interaction method proposed according to an embodiment of the present invention will be described with reference to the accompanying drawings.
[0066] Refer to Figure 1 , an embodiment of the present invention provides a question-and-answer interaction method. The question-and-answer interaction method in the embodiment of the present invention can be applied to a terminal, or to a server, or can also be software running on a terminal or a server, etc. The terminal can be a tablet computer, a notebook computer, a desktop computer, etc., but is not limited thereto. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms. The question-and-answer interaction method in the embodiment of the present invention mainly includes the following steps:
[0067] S101. Obtain sentence text;
[0068] Among them, the sentence text is the text converted from the user's voice.
[0069] S101 can be further divided into the following steps S1011-S1012:
[0070] Step S1011. Collect voice data;
[0071] Specifically, the voice data of the user is collected through a sound sensor.
[0072] Step S1012. Convert the voice data into text to obtain the sentence text.
[0073] Specifically, the voice data is converted into text through a speech-to-text (STT) interface to obtain the sentence text.
[0074] S102. Convert the sentence text into a plurality of vector data;
[0075] Specifically, in the embodiments of the present invention, the sentence text is converted into a plurality of vector data through a vector processing method of a hybrid model (bag-of-words model and Skip-Gram model).
[0076] S102 can be further divided into the following steps S1021 - S1023:
[0077] Step S1021: Split the sentence text into individual sentences;
[0078] Specifically, the sentence text is segmented by punctuation marks.
[0079] Step S1022: Perform word segmentation on the sentences to obtain a plurality of words;
[0080] Specifically, a word segmentation model based on probability statistics is used to perform word segmentation on the sentences to obtain a plurality of words.
[0081] Step S1023: Convert the words into discrete vectors through the bag-of-words model, and analyze the vector relationships between the discrete vectors through the Skip-Gram model to form the vector data.
[0082] Specifically, a hybrid word vector representation model combining the bag-of-words model and the Skip-Gram model is used. The words are converted into independent and random discrete vectors through the bag-of-words model, and the vector relationships between the discrete vectors are represented by the Euclidean distance using the Skip-Gram model to form the vector data.
[0083] S103: Perform weight analysis on each of the vector data according to the corpus to generate vector weights;
[0084] Among them, the corpus includes pre-collected and real-time collected rural scene interaction data. It includes interaction corpora between children and children, children and parents, and children and teachers in real scenarios. In order to simulate the interaction situation between rural users (children) and others to the greatest extent, the corpora collected in the corpus are stored in the form of question and answer.
[0085] Specifically, according to the corpus, the occurrence frequency and the number of contexts in which the words corresponding to each vector data appear are counted, and the vector weights of the vector data are adjusted.
[0086] S103 can be further divided into the following steps S1031 - S1033:
[0087] Step S1031: Count the occurrence frequency of the words corresponding to the vector data;
[0088] Among them, the higher the occurrence frequency of the word corresponding to the vector data, the greater the vector weight.
[0089] Step S1032: Count the number of contexts of the word corresponding to the vector data;
[0090] Among them, the fewer the number of contexts in which the word corresponding to the vector data appears, the higher the discrimination degree of the word, and the greater the vector weight.
[0091] Step S1033: Generate the vector weight according to the occurrence frequency and the number of contexts.
[0092] According to the analysis and generation rule of the vector weight in step S1031 and step S1032, balance the occurrence frequency and the number of contexts to generate the vector weight.
[0093] S104: Analyze the semantics of the statement text through the BERT model based on the attention mechanism according to the vector data and the vector weight;
[0094] Among them, the bidirectional BERT model based on the attention mechanism is trained after preprocessing the collected education data and rural data.
[0095] Specifically, the bidirectional BERT model based on the attention mechanism can execute concurrently, extract the relationship features of the word in the statement text, and extract relationship features at multiple different levels, so as to more comprehensively reflect the semantics of the statement text. In the embodiment of the present invention, semantic analysis is performed through the bidirectional BERT model based on the attention mechanism, which improves the stability and accuracy of semantic analysis and extraction, and further improves the pertinence of subsequent response generation.
[0096] S105: Identify the statement scenario according to the semantics;
[0097] Specifically, identify the statement scenario according to the semantics analyzed in step S104, and classify the statement scenario through the bidirectional BERT model based on the attention mechanism. The statement scenarios include daily interaction scenarios, education classroom scenarios, and safety help scenarios.
[0098] In the embodiment of the present invention, the identified statement scenario is matched with the corresponding scenario in the corpus, and the information of the semantics not covered by the corresponding scenario in the corpus in the statement scenario is updated to the corresponding scenario in the corpus.
[0099] S106: Generate a response according to the semantics and the statement scenario.
[0100] Specifically, according to step S105, the statement scenarios are classified into three categories: daily interaction scenarios, education classroom scenarios, and safety assistance scenarios through a bidirectional BERT model based on the attention mechanism. According to the semantics analyzed in step S104 and the corresponding statement scenarios identified in step S105, responses are generated and fed back to the user, as follows:
[0101] (1) When the statement scenario is the daily interaction scenario, generating a response according to the semantics and the statement scenario includes:
[0102] Querying from the corpus whether there is a corresponding answer according to the semantics and the statement scenario;
[0103] If so, generating the response according to the corresponding answer;
[0104] If not, generating the response by searching Internet resources.
[0105] Specifically, in the embodiments of the present invention, the daily interaction scenarios include the daily communications of rural users, such as current affairs news, weather reports, and emotional companionship. The response is generated into a voice response using a text-to-speech (TTS) interface.
[0106] (2) When the statement scenario is the education classroom scenario, generating a response according to the semantics and the statement scenario includes:
[0107] Querying whether there is a corresponding course resource by searching Internet resources according to the semantics and the statement scenario;
[0108] If so, playing the corresponding course resource;
[0109] If not, querying and playing relevant course resources by searching Internet resources.
[0110] Specifically, when playing the course resource, the rural user is informed of the current course title and duration, and when no corresponding course resource is found, "no course available" is prompted, and the resource with the highest matching degree is played. The output prompts and educational resources are generated into voice responses using a text-to-speech (TTS) interface and played to the rural user.
[0111] (3) When the statement scenario is the safety assistance scenario, generating a response according to the semantics and the statement scenario includes:
[0112] Querying from the corpus whether there is a first solution according to the semantics and the statement scenario;
[0113] If so, generating the response according to the first solution;
[0114] If not, a second solution is obtained by searching Internet resources, and the response is generated according to the second solution.
[0115] Specifically, the first solution and the second solution include emergency suggestions, one-touch alarm and contacting a caregiver. The response output uses a text-to-speech (TTS) interface to generate a voice response.
[0116] In the embodiment of the present invention, the specific implementation process for rural children's education is as follows:
[0117] When rural children speak (input voice data), the voice data is converted into sentence text using the speech-to-text (STT) interface. Then, the sentence text is segmented by punctuation marks, and then the word segmentation model based on statistical probability is used. After the word segmentation is completed, the bag-of-words model is combined with the Skip-Gram model to generate vector data. Among them, the bag-of-words model converts words into independent vector data, and the Skip-Gram model represents the vector relationship between each vector data through Euclidean distance. Furthermore, the frequency of occurrence of each word and the number of contexts in which the word appears are counted, and the vector weights are jointly calculated and adjusted to complete the vector expression. The bidirectional BERT model based on the attention mechanism is used to extract the semantics of the sentence text input by rural children, and classify them according to daily interaction scenarios, educational classroom scenarios, and safety help scenarios. When it is classified as a daily interactive scene sentence, the daily interactive corpus of the local interactive corpus is searched to see if there is a similar question. If so, the answer corresponding to the question is output as a response. If not, the Internet resource is connected to conduct an online query, and the answer searched online is output as a response. The responses are all generated by a text-to-speech (TTS) interface to generate voice responses. When it is classified as an educational classroom scene, the educational classroom corpus of the local interactive corpus is used to retrieve online educational resources based on the learning or course semantics in the sentence text. If there is, the name and duration of the educational resource are prompted and then playback begins. If not, If relevant resources are retrieved, the prompt "No courses yet" will be displayed, and the resource with the highest matching degree will be played. The output prompts and educational resources will use the text-to-speech (TTS) interface to generate voice responses and play them to rural children. When classified as a safety help scenario sentence, the safety help corpus of the local interactive corpus is used to search the local interactive corpus based on the help semantics in the sentence text. If there is a solution in the local interactive corpus, it will be directly output as a response. If not, Internet resources will be used to search and generate a response output. The response output uses a text-to-speech (TTS) interface to generate a voice response. In case of emergency, you can call the police or contact the caregiver with one click after generating safety suggestions. In addition, each time a question-and-answer interaction is completed, the corpus information not covered by the local interactive corpus is updated and supplemented to prepare for the next question-and-answer interaction service.
[0118] It should be noted that through the training of the corpus and the hybrid model, a question-and-answer interaction method according to an embodiment of the present invention can be applied not only to rural education scenarios, but also to other education scenarios or other interaction scenarios.
[0119] Secondly, a question-and-answer interaction system according to an embodiment of the present application will be described with reference to the accompanying drawings.
[0120] Figure 2 It is a schematic structural diagram of a question-and-answer interaction system according to an embodiment of the present application.
[0121] The system specifically includes:
[0122] A statement text acquisition module 201, configured to acquire statement text;
[0123] A vector data conversion module 202, configured to convert the statement text into a plurality of vector data;
[0124] A vector weight generation module 203, configured to perform weight analysis on each of the vector data according to a corpus to generate vector weights;
[0125] A semantic analysis module 204, configured to analyze the semantics of the statement text according to the vector data and the vector weights through a BERT model based on an attention mechanism;
[0126] A statement scenario recognition module 205, configured to recognize a statement scenario according to the semantics;
[0127] A response generation module 206, configured to generate a response according to the semantics and the statement scenario.
[0128] It can be seen that the content in the above method embodiments is applicable to the system embodiments of the present invention. The functions specifically implemented by the system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those of the above method embodiments.
[0129] Referring to Figure 3 , an embodiment of the present application provides a question-and-answer interaction device, including:
[0130] At least one processor 301;
[0131] At least one memory 302, configured to store at least one program;
[0132] When the at least one program is executed by the at least one processor 301, the at least one processor 301 is caused to implement the above-mentioned question-and-answer interaction method.
[0133] Similarly, the content in the above method embodiments is applicable to the device embodiments of the present application. The functions specifically implemented by the device embodiments of the present application are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those of the above method embodiments.
[0134] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order mentioned in the operation diagrams. For example, depending on the functions / operations involved, two consecutive blocks shown may actually be executed substantially simultaneously or the blocks can sometimes be executed in the reverse order. In addition, the embodiments presented and described in the flowcharts of the present application are provided by way of example for the purpose of providing a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logical flows presented herein. Alternative embodiments are contemplated where the order of various operations is changed and where sub-operations described as part of a larger operation are executed independently.
[0135] In addition, although the present application is described in the context of functional modules, it should be understood that unless otherwise stated to the contrary, one or more of the functions and / or features may be integrated in a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It can also be understood that a detailed discussion of the actual implementation of each module is not necessary for understanding the present application. Rather, given the attributes, functions, and internal relationships of the various functional modules in the devices disclosed herein, the actual implementation of the modules will be understood within the ordinary skills of an engineer. Therefore, those skilled in the art can implement the present application as set forth in the claims without undue experimentation using ordinary skills. It can also be understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present application, which is determined by the full scope of the appended claims and their equivalents.
[0136] If the above functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several programs for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0137] The logic and / or steps represented in the flowchart or otherwise described herein can, for example, be considered as a definitional list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by or in connection with a program execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch and execute the program from the program execution system, apparatus, or device. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport the program for use by or in connection with the program execution system, apparatus, or device.
[0138] More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which the program can be printed, as the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other suitable processing as necessary, and then stored in a computer memory.
[0139] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable program execution system. For example, if implemented in hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gates for implementing logical functions on data signals, application specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), and the like.
[0140] In the foregoing description of this specification, the descriptions with reference to the terms "one embodiment / example", "another embodiment / example", or "certain embodiments / examples", etc., mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0141] Although embodiments of the present application have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present application. The scope of the present application is defined by the claims and their equivalents.
[0142] The above is a specific description of the preferred embodiments of the present application, but the present application is not limited to the described embodiments. Those skilled in the art can also make various equivalent deformations or substitutions without departing from the spirit of the present application, and these equivalent deformations or substitutions are all included within the scope defined by the claims of the present application.
Claims
1. A question-and-answer interaction method, characterized in that, It includes the following steps: Obtain the statement text; Convert the statement text into multiple vector data; Perform weight analysis on each of the vector data according to a corpus, generating vector weights, where the corpus includes pre-collected and real-time collected rural scene interaction data; Analyze the semantics of the statement text according to the vector data and the vector weights through a BERT model based on an attention mechanism; Identify the statement scene according to the semantics, and classify the statement scene through a bidirectional BERT model based on an attention mechanism; Generate a response according to the semantics and the statement scene; Among them, the performing weight analysis on each of the vector data according to a corpus, generating vector weights, includes: Statistically analyze the occurrence frequency and the number of contexts of the words corresponding to each of the vector data according to the corpus, and adjust the vector weights of the vector data; The generating a response according to the semantics and the statement scene includes: Query whether there is a corresponding response in the corpus according to the semantics and the statement scene; If not, generate a response by searching Internet resources; The method for real-time collecting of the rural scene interaction data includes: Every time a question-and-answer interaction is completed, update and supplement the corpus information not covered by the local interaction corpus.
2. The question-and-answer interaction method according to claim 1, characterized in that, The obtaining the statement text includes: Collect voice data; Convert the voice data into text to obtain the statement text.
3. The question-and-answer interaction method according to claim 1, characterized in that, The converting the statement text into multiple vector data includes: Segment the statement text into sentences; Perform word segmentation on the sentences to obtain multiple words; Convert the words into discrete vectors through a bag-of-words model, and analyze and express the vector relationship between the discrete vectors through a Skip-Gram model to form the vector data.
4. The question-and-answer interaction method according to claim 3, characterized in that, The performing weight analysis on each of the vector data according to a corpus, generating vector weights, includes: Statistically analyze the occurrence frequency of the words corresponding to the vector data; Statistically analyze the number of contexts of the words corresponding to the vector data; Generate the vector weights according to the occurrence frequency and the number of contexts.
5. The question-and-answer interaction method according to claim 1, characterized in that, The statement scenes include daily interaction scenes, education classroom scenes, and safety assistance scenes; When the statement scene is the daily interaction scene, the generating a response according to the semantics and the statement scene includes: Query whether there is a corresponding answer in the corpus according to the semantics and the statement scene; If so, generate the response according to the corresponding answer; If not, generate the response by searching Internet resources.
6. The question-and-answer interaction method according to claim 5, characterized in that, When the statement scene is the education classroom scene, the generating a response according to the semantics and the statement scene includes: Query whether there is a corresponding course resource by searching Internet resources according to the semantics and the statement scene; If so, play the corresponding course resource; If not, query and play relevant course resources by searching Internet resources.
7. A question-and-answer interaction method according to claim 5, characterized in that: When the statement scene is the safety assistance scene, the generating a response according to the semantics and the statement scene includes: Query whether there is a first solution in the corpus according to the semantics and the statement scene; If so, generate the response according to the first solution; If not, obtain a second solution by searching Internet resources, and generate the response according to the second solution.
8. A question-and-answer interaction system, characterized in that: It includes: A statement text acquisition module for acquiring statement text; A vector data conversion module for converting the statement text into multiple vector data; A vector weight generation module for performing weight analysis on each of the vector data according to a corpus, generating vector weights, where the corpus includes pre-collected and real-time collected rural scene interaction data; A semantic analysis module for analyzing the semantics of the statement text according to the vector data and the vector weights through a BERT model based on an attention mechanism; A statement scene recognition module for recognizing a statement scene according to the semantics, and classifying the statement scene through a bidirectional BERT model based on an attention mechanism; A response generation module for generating a response according to the semantics and the statement scene; Among them, the performing weight analysis on each of the vector data according to a corpus and generating vector weights includes: Counting the occurrence frequency and the number of contexts where the words corresponding to each of the vector data appear according to the corpus, and adjusting the vector weights of the vector data; The generating a response according to the semantics and the statement scene includes: Querying whether there is a corresponding response in the corpus according to the semantics and the statement scene; If not, generate a response by searching Internet resources; The method for real-time collection of the rural scene interaction data includes: Every time a question-and-answer interaction is completed, update and supplement the corpus information not covered by the local interaction corpus.
9. A question-and-answer interaction device, characterized in that: It includes: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements a question-and-answer interaction method according to any one of claims 1-7.
10. A storage medium storing a program executable by a processor, characterized in that: The program executable by the processor is used to implement a question-and-answer interaction method according to any one of claims 1-7 when executed by the processor.
Citation Information
Patent Citations
Man-machine interaction method and device, server and storage medium
CN109961780A
Text classification service deployment method, device and equipment and computer storage medium
CN112632271A