Conversation answering method and device based on corpus, equipment and storage medium
By deploying multiple large models on the server and using event source objects and listeners to generate streaming response text, the problem of insufficient response speed in human-computer dialogue is solved, achieving more efficient data transmission and faster response time.
Patent Information
- Application Number
- CN202411101643.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2025-01-07
AI Technical Summary
In existing technologies, the machine's response speed during human-computer dialogue cannot meet the user's real-time needs, and the polling method results in too many unnecessary requests and responses, affecting the response speed.
Multiple large models are deployed on the server and trained based on a pre-built corpus. Streaming response text is generated and transmitted through event source objects and listeners, reducing unnecessary requests and responses.
It improves the real-time performance of human-computer interaction, reduces the consumption of network resources and bandwidth, and enhances the user's application experience.
Smart Images

Figure CN119271767A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a corpus-based dialogue answering method, device, equipment and storage medium. Background Art
[0002] With the rapid development of computer technology, human-computer dialogue is gradually used in various scenarios. In the process of human-computer dialogue, users not only have demands for the accuracy of the answers, but also have higher and higher requirements for the speed of the machines' answers.
[0003] In the related technologies based on conversation data transmission between the front end and the server, polling method is mostly used, where the front end periodically sends requests to the server to obtain the latest data. However, this polling method will generate many unnecessary requests and responses, affecting the machine's answering speed and failing to meet the user's real-time conversation needs. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present disclosure provide a corpus-based dialogue answering method, apparatus, device and storage medium.
[0005] In a first aspect, an embodiment of the present disclosure provides a corpus-based dialogue answering method, which is applied to a server, where a plurality of different large models are deployed, and the plurality of large models are trained based on a pre-built corpus, and the method includes:
[0006] Receiving first request information sent by a target application, wherein the first request information includes a first question text;
[0007] Establishing a first event source object corresponding to the first request information, and adding a first event listener to the first event source object;
[0008] Generate a streaming answer text of the first question text based on a corresponding corpus using a target large model among the multiple large models that matches the first request information;
[0009] The streaming answer text is sent to the first event source object, so that the target application receives the streaming answer text through the first event listener.
[0010] Optionally, the first request information includes a model identifier and / or an identifier of an object to be processed corresponding to the first question text, and the step of generating a streaming answer text of the first question text based on a corresponding corpus using a target large model among the multiple large models that matches the first request information includes:
[0011] Determine, according to the model identifier and / or the to-be-processed object identifier, a target large model matching the first request information from among the multiple large models;
[0012] The first question text is parsed by the target large model to obtain corresponding data from a corresponding corpus, and a streaming answer text of the first question text is generated.
[0013] Optionally, sending the streaming answer text to the first event source object includes:
[0014] The streaming answer text is sent to the first event source object in the form of an event.
[0015] Optionally, after receiving the first request information sent by the target application, the method further includes:
[0016] receiving a second request message sent by the target application, wherein the second request message includes a second question text;
[0017] Establishing a second event source object corresponding to the second request information, and adding a second event listener for the second event source object, wherein the first event source object and the second event source object are different;
[0018] The generated streaming answer text of the second question text is sent to the second event source object, so that the target application receives the streaming answer text of the second question text based on the second event listener during the process in which the streaming answer text of the first question text is received by the first event listener.
[0019] Optionally, the first event source object supports configuration of request header.
[0020] In a second aspect, an embodiment of the present disclosure provides a corpus-based dialogue answering method, which is applied to a target application, and the method includes:
[0021] Obtaining a first question text, and generating first request information according to the first question text;
[0022] Sending the first request information to a server, where the server is used to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object;
[0023] The streaming answer text of the first question text is received through the first event listener, and the streaming answer text is generated by the server through a target big model that matches the first request information among multiple big models deployed, based on the corpus used to train the target big model.
[0024] Optionally, after generating the first request information according to the first question text, the method further includes:
[0025] Obtaining a second question text, and generating second request information according to the second question text;
[0026] Sending the second request information to the server, the server is used to establish a second event source object corresponding to the second request information, and add a second event listener for the second event source object, wherein the first event source object and the second event source object are different;
[0027] In the process of receiving the streaming answer text of the first question text based on the first event listener, the streaming answer text of the second question text is received based on the second event listener, wherein the streaming answer text of the second question text is generated by the server and sent to the second event source object.
[0028] Optionally, the method further includes:
[0029] The streaming answer text is displayed, and / or the voice generated based on the streaming answer text is played.
[0030] In a third aspect, an embodiment of the present disclosure provides a corpus-based dialogue answering device, which is applied to a server, wherein a plurality of different large models are deployed on the server, wherein the plurality of large models are trained based on a pre-built corpus, and the device comprises:
[0031] A first receiving unit, configured to receive first request information sent by a target application, wherein the first request information includes a first question text;
[0032] An establishing unit, configured to establish a first event source object corresponding to the first request information, and add a first event listener to the first event source object;
[0033] a text generation unit, configured to generate a streaming answer text of the first question text based on a corresponding corpus by using a target large model among the multiple large models that matches the first request information;
[0034] The first sending unit is used to send the streaming answer text to the first event source object, so that the target application receives the streaming answer text through the first event listener.
[0035] In a fourth aspect, an embodiment of the present disclosure provides a corpus-based dialogue answering device, which is applied to a target application, and the device includes:
[0036] An acquisition unit, configured to acquire a first question text and generate first request information according to the first question text;
[0037] A second sending unit, configured to send the first request information to a server, wherein the server is configured to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object;
[0038] A second receiving unit is used to receive a streaming answer text of the first question text through the first event listener, wherein the streaming answer text is generated by the server through a target big model that matches the first request information among multiple big models deployed, based on a corpus used to train the target big model.
[0039] In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including:
[0040] Memory;
[0041] Processor; and
[0042] Computer programs;
[0043] Wherein, the computer program is stored in the memory and is configured to be executed by the processor to implement the corpus-based dialogue answering method as described above.
[0044] In a sixth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned corpus-based dialogue answering method.
[0045] The corpus-based dialogue answering method provided by the present disclosure is applied to a server, and multiple different large models are deployed on the server, and the multiple large models are obtained by training based on a pre-built corpus. The method includes: receiving a first request message sent by a target application, wherein the first request message includes a first question text; establishing a first event source object corresponding to the first request message, and adding a first event listener to the first event source object; generating a streaming answer text of the first question text based on the corresponding corpus through a target large model that matches the first request message among multiple large models; and sending the streaming answer text to the first event source object, so that the target application receives the streaming answer text through the first event listener. With the method provided by the present application, the application can receive the data sent by the server in a timely manner, reduce unnecessary requests and responses, improve the answer speed, ensure the real-time requirements of the dialogue, and adopt a streaming answer method, which also improves the user application experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A flowchart of a corpus-based dialogue answering method provided in an embodiment of the present disclosure;
[0049] Figure 2 A flowchart of another corpus-based dialogue answering method provided in an embodiment of the present disclosure;
[0050] Figure 3 A schematic diagram of an interface of a target application provided by an embodiment of the present disclosure;
[0051] Figure 4 A schematic diagram of the structure of a corpus-based dialogue answering device provided in an embodiment of the present disclosure;
[0052] Figure 5 A schematic diagram of the structure of another corpus-based dialogue answering device provided in an embodiment of the present disclosure;
[0053] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0054] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0055] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0056] Specifically, when it comes to providing real-time data to front-end applications, in general, the front-end application will periodically send requests to the server to obtain updated data, but this polling method will waste bandwidth resources and server resources. Browser compatibility The full-duplex communication protocol (WebSocket) is a new standard added by HTML5. It has requirements for the server version and has relatively poor compatibility. It is not supported in some older versions of browsers. There are many restrictions on the server communicating with the front-end, which in turn affects the machine's response speed.
[0057] In view of the above technical problems, the embodiment of the present disclosure provides a corpus-based dialogue answering method, which is applied to a server. A plurality of different large models are deployed on the server. The large models are obtained based on corpus training. After receiving the request information sent by the front end, the server establishes an event source object. The event source object can realize parallel transmission of multiple data sources, has strong scalability, and has a relatively small impact on the load of the server. Subsequently, an event listener is registered on the event source object, so that the front end can obtain the latest information faster and reduce the delay of data update. Subsequently, the question text carried in the request information is identified by the large model, and a streaming answer text is generated based on the corpus. Compared with the polling method, the event listening and streaming generation methods reduce unnecessary requests and responses, saving network resources and bandwidth. When processing the streaming answer text, the streaming answer text is stacked in queue order, and is not affected by asynchronous data processing when popping out of the stack, and is rendered and returned in order. In addition, the event source object supports request header configuration, which also increases scalability to a certain extent. It is specifically described in detail through one or more of the following embodiments.
[0058] The corpus-based dialogue answering method provided by the embodiment of the present disclosure can be applied to data interaction scenarios. The method can be performed by a corpus-based dialogue answering device, which can be implemented by software and / or hardware, and the device can be integrated in an electronic device. Among them, the electronic device can include but is not limited to mobile terminals such as smart phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Tablet Personal Computers, Tablet PCs), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), wearable devices, etc., and fixed terminals such as digital televisions, desktop computers, smart home devices, etc.
[0059] Figure 1 A flowchart of a corpus-based dialogue answering method provided in an embodiment of the present disclosure is applied to a server, where multiple large models are deployed on the server. The multiple large models are trained based on a pre-built corpus, specifically including: Figure 1 Steps shown:
[0060] Understandably, there are multiple trained large models deployed on the server, and the multiple large models are trained based on the corpus. Specifically, the working principle of the large model is mainly to use deep learning technology and corpus for training, so that the large model can simulate the language generation and understanding in human conversations, such as the dialogue large model, etc. The dialogue large model can automatically infer the semantics of the question text according to the context, and generate the corresponding answer text from the corpus according to the user's question text. Other possible large models are not described in detail. Among them, the corpus is a large-scale electronic text library obtained after data processing, which stores language materials that have actually appeared in the actual use of the language. Among them, one possible situation is that each large model has a corresponding corpus, and each large model processes different tasks, and the corresponding corpus is also different. For example, the dialogue large model used to process the dialogue task is trained based on the dialogue corpus, and the multimodal model used to process computer vision and multimodal tasks is trained based on the image and text corpus. Another possible situation is that at least some of the multiple large models are trained based on the same corpus. The at least some of the large models can be trained based on the same corpus but with different model parameters, and / or based on the same corpus but trained to process different tasks. For example, the dialogue large model is trained based on the dialogue corpus and used for dialogue tasks. The language large model is also trained based on the dialogue corpus and is used to learn semantic understanding from the dialogue corpus and then process image tasks. Alternatively, a large-scale corpus is constructed. The large-scale corpus includes sub-corpora corresponding to multiple languages. The data volume is relatively large and is used to train a multilingual model. The multilingual model is a single model that can process multiple languages at the same time.
[0061] S101: Receive first request information sent by a target application.
[0062] The first request information includes a first question text.
[0063] It is understandable that the first request information sent by the target application is received. The target application refers to an application deployed on the front end. The front end and the server can transmit data through the network protocol. The first request information is generated by the target application and sent to the server. The first request information is used to request the establishment of an event source object and carries a first question text. The first request information can be HTTP request information. Specifically, the first request information includes the first question text and information related to the dialogue request. The first question text indicates the inquiry content or the operation content. For example, the first question text is "Is AA BB?", which indicates the inquiry content. The first question text can also be "Understand AA", which indicates the operation content. The first question text can be text directly entered by the user on the target application, or text recognized by the target application based on the user's input information.
[0064] S102: Create a first event source object corresponding to the first request information, and add a first event listener to the first event source object.
[0065] The first event source object supports configuration of the request header.
[0066] It is understandable that, based on the above S101, after receiving the first request information, a first event source object corresponding to the first request information is established. Each request information carrying the question text will suggest a corresponding event source object. The event source object is used to implement the function of the server pushing data to the front end. The pushed data is the data generated when the server executes the request information. Among them, the event source object can be an EventSource object, and the event source object supports the configuration of the request header information. In addition, the EventSource object allows the server to send data to the front end through a persistent connection, and the front end does not need to continuously send request information to the server. That is, the target program in the front end can receive the streaming answer text by sending only one request information until the conversation is completed. After the establishment of the first event source object, an event listener is registered on the first event source object, that is, the first event listener is added to the first event source object. The event listener is used to perform corresponding operations when receiving the data pushed by the server. The corresponding operation refers to sending the data received in real time and sent by the server to the target application. The data refers to the streaming answer text of the question text generated by the server.
[0067] S103. Generate a streaming answer text for the first question text based on a corresponding corpus using a target large model among the multiple large models that matches the first request information.
[0068] It is understandable that, based on the above S102, the target big model corresponding to the first request information is determined, and the target big model can be a certain dialogue big model. The dialogue big model parses the first question text, and generates a streaming answer text of the first question text based on the corresponding corpus to complete a dialogue. Among them, the first question text and the generated streaming answer text can be recorded as the text involved in a dialogue, and an event source object can be established for each dialogue, or multiple related dialogues can correspond to an event source object. For example, multiple dialogues will be conducted in a continuous question and answer scenario, and multiple dialogues will generate multiple request information. Multiple request information can request to establish an event source object, and the dialogue is subsequently completed based on the same event source object.
[0069] The first request information includes a model identifier and / or an identifier of an object to be processed corresponding to the first question text.
[0070] It is understandable that the first request information includes a model identifier and / or an identifier of an object to be processed corresponding to the first question text. The model identifier refers to an identifier of a trained large model. Based on the model identifier, the corresponding large model can be called. For example, the model identifier can be an identifier of a dialogue large model. The identifier of the object to be processed refers to an identifier of a data type of the object to be processed, for example, an identifier of a data type such as an image, text, document, or table. Based on an image identifier, a large model capable of processing images can be called.
[0071] Optionally, the above-mentioned generating a streaming answer text of the first question text based on a corresponding corpus by using a target large model among the multiple large models that matches the first request information can be specifically implemented by the following steps:
[0072] According to the model identifier and / or the identifier of the object to be processed, a target large model matching the first request information is determined among the multiple large models; the first question text is parsed by the target large model to obtain corresponding data from the corpus, and a streaming answer text of the first question text is generated.
[0073] It is understandable that according to the model identifier and / or the identifier of the object to be processed, a target large model matching the first request information is determined from multiple large models, and the target large model is the model for the streaming answer text to be generated. After the target large model is determined, the first question text is parsed by the target large model, the context information is determined, and the answer text that is consistent with the question text and meaningful is obtained from the corresponding corpus to generate a streaming answer text for the first question text. The corresponding corpus refers to the corpus used to train the target large model. The streaming answer text is a continuous text generated in real time, wherein the streaming answer is to present the generated text in a continuous manner, rather than displaying it all at once, that is, each time a part of the answer text is generated, it is immediately sent to the first event source object, and the target application receives the part of the answer text through the first event listener and presents it to the user in a timely manner, which reduces the user's waiting time and makes the interaction process more natural and smooth.
[0074] S104. Send the streaming answer text to the first event source object, so that the target application receives the streaming answer text through the first event listener.
[0075] It can be understood that, based on the above S103, the generated streaming answer text is sent to the first event source object in real time, and the target application listens to the data transmission event occurring in the first event source object through the first event listener. When it is monitored that the first event source object receives the data sent by the server, the data is sent to the target application in real time and actively. The target application can subsequently perform corresponding processing and display based on the received data, and the data refers to the streaming answer text, that is, the target application will receive the streaming answer text in real time and continuously through the first event source object.
[0076] Optionally, sending the streaming answer text to the first event source object may be implemented by the following steps:
[0077] The streaming answer text is sent to the first event source object in the form of an event.
[0078] It is understandable that after the target large model generates the streaming answer text, it will send the streaming answer text to the first event source object in the form of an event. The target application listens to the event through the first event listener and receives the streaming answer text sent by the server in real time.
[0079] Optionally, after receiving the first request information sent by the target application, the method may be implemented by the following steps:
[0080] Receive a second request message sent by the target application, wherein the second request message includes a second question text; establish a second event source object corresponding to the second request message, and add a second event listener for the second event source object, wherein the first event source object and the second event source object are different; send the generated streaming answer text of the second question text to the second event source object, so that the target application receives the streaming answer text of the second question text based on the second event listener during the process of receiving the streaming answer text of the first question text based on the first event listener.
[0081] It is understandable that after receiving the first request information sent by the target application, during the generation and / or sending of the streaming answer text of the first question text, that is, before the target application receives the complete / all answer text, a second request information sent by the target application may also be received, and the second request information includes a second question text. The second question text and the first question text may be the same or different, that is, the user can ask multiple questions based on the same question before receiving the complete answer text, and the angles of the multiple questions can be adjusted accordingly, or the user can ask questions again for different questions before the previous question is completed. Subsequently, a second event source object corresponding to the second request information is established, and a second event listener is added to the second event source object, wherein the first event source object and the second event source object may be different, or, in the case where the first question text and the second question text are a continuous dialogue, the first event source object may be directly used as the event source object corresponding to the second request information, and a new event source object may be established and recorded as the second event source object. After the second event source object is established, a streaming answer text for the second question text is generated. The specific generation steps can be found in the above embodiment and will not be described in detail here. The streaming answer text for the second question text is then sent to the second event source object, so that the target application can receive the streaming answer text for the second question text based on the second event listener while receiving the streaming answer text for the first question text based on the first event listener. In other words, the target application can receive streaming answer texts for multiple question texts based on multiple event source objects at the same time. This method of using event source objects to realize parallel transmission of multiple data sources has strong scalability and less impact on the server load.
[0082] The embodiment of the present disclosure provides a corpus-based dialogue answering method. After receiving the first request information sent by the target application, the target application can promptly receive the answer data sent by the server through the established event source object, realize real-time update, and establish a corresponding event source object for the request information, thereby realizing parallel transmission of multiple data sources and reducing the impact on the server load. At the same time, the event listener actively sends data to the front end to realize the streaming generation method, which reduces unnecessary requests and responses and saves network resources and bandwidth. In summary, the streaming generation method based on the event source object provided by the present application has broad application prospects in front-end data acquisition and real-time update.
[0083] Based on the above embodiments, Figure 2 A flowchart of another corpus-based dialogue answering method provided in an embodiment of the present disclosure, which is applied to a target application, specifically includes the following steps: Figure 2 Steps shown:
[0084] S201: Obtain a first question text, and generate first request information according to the first question text.
[0085] It is understandable that the user inputs information in the target application, obtains the first question text based on the input information, and generates the first request information according to the first question text. The specific process of generating the request information is not described in detail.
[0086] S202: Send the first request information to a server, where the server is used to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object.
[0087] It is understandable that, based on the above S201, the first request information is sent to the server, requesting the server to establish an event source object and generate a streaming answer text for the first question text. The specific implementation steps of the server establishing the event source object and registering the event listener refer to the above embodiment, which will not be repeated here.
[0088] S203. A streaming answer text of the first question text is received through the first event listener, wherein the streaming answer text is generated by the server through a target big model among multiple big models deployed that matches the first request information, based on a corpus used to train the target big model.
[0089] It is understandable that, based on the above S202, the first event listener listens to the event and receives the streaming answer text sent by the server to the first event source object in real time, wherein the first event listener listens to the data transmission event in which the server sends the streaming answer text to the first event source object in the form of an event. The specific implementation steps of the server generating the streaming answer text refer to the above embodiment and are not described here.
[0090] Optionally, after generating the first request information according to the first question text, the method further includes:
[0091] Obtain a second question text, and generate a second request message according to the second question text; send the second request message to the server, the server is used to establish a second event source object corresponding to the second request message, and add a second event listener for the second event source object, wherein the first event source object and the second event source object are different; in the process of receiving a streaming answer text of the first question text based on the first event listener, receiving a streaming answer text of the second question text based on the second event listener, wherein the streaming answer text of the second question text is generated by the server and sent to the second event source object.
[0092] It is understandable that before receiving the complete answer text, the user re-enters information in the target application. In this scenario, the second question text is obtained based on the re-entered information, and the second request information is generated based on the second question text. The second request information is sent to the server, requesting the server to establish a second event source object and generate a streaming answer text for the second question text, that is, the target application can receive multiple data sources in the server and transmit them in parallel to obtain multiple data. It is understandable that the specific implementation steps of the server establishing the second event source object and generating the streaming answer text for the second question text refer to the above embodiment, which will not be repeated here.
[0093] Optionally, after receiving the streaming answer text, the method further includes:
[0094] The streaming answer text is displayed, and / or the voice generated based on the streaming answer text is played.
[0095] It is understandable that the streaming answer text is displayed on the display interface of the target application, and specifically multiple streaming answer texts of multiple question texts can be displayed simultaneously. The streaming answer text can also be converted into voice and played to provide a richer dialogue experience.
[0096] For example, see Figure 3 , Figure 3A schematic diagram of the interface of a target application provided in an embodiment of the present disclosure, in which a user enters a first question text on the display interface of the target application, and simultaneously sends a request message containing the first question text to the server, requesting the establishment of an EventSource object. After receiving the request message, the server creates an EventSource object and registers an event listener on the EventSource object. The server sends the generated data (streaming answer text of the first question text) to the EventSource object in the form of an event. The target application listens to events occurring on the EventSource object through the event listener, and receives data sent by the server in real time. The target application performs corresponding processing and display according to the received data, such as Figure 3 As shown in FIG. 301 , the display interface displays a first question text, which is “Is AA BB?”, and also displays a streaming answer text of the first question text, which is “AA is BB, the reason is:”. At this time, the complete answer text has not been displayed. In this case, the user continues to enter a second question text in the input area on the display interface, and the second question text is “Is AA CC?”. After the “OK” button is triggered, after a series of interactive operations between the target application and the server, the target application receives the streaming answer text of the second question text, as shown in FIG. Figure 3 As shown in Figure 302, the display interface displays the first question text "Is AA BB?" and the streaming answer text of the first question text. At this time, the streaming answer text is "AA is BB, the reason is: ****, to sum up," and most of the answer text is displayed, but the complete answer text of the first question text has not yet been displayed. At the same time, the second question text "Is AA CC?" and the streaming answer text of the second question text are also displayed. The streaming answer text is "AA is not CC, the reason is:," and the complete answer text of the second question text has not yet been displayed.
[0097] The disclosed embodiment provides a corpus-based dialogue answering method. When a front-end target application sends request information to a server, the front-end target application can promptly receive answer data sent by the server. The real-time performance is higher, and unnecessary requests and responses involved in data transmission between the front-end and the server are reduced, thus saving network resources and bandwidth. The front-end application can obtain the latest data more quickly, and the delay in data updating is reduced. In addition, multiple data sources are displayed in parallel, which improves the user's application experience to a certain extent.
[0098] Figure 4The structure diagram of a corpus-based dialogue answering device provided in an embodiment of the present disclosure is shown in FIG. The corpus-based dialogue answering device provided in an embodiment of the present disclosure can execute the processing flow provided in an embodiment of a corpus-based dialogue answering method, such as Figure 4 As shown, a corpus-based dialogue answering device 400 is applied to a server, and a plurality of different large models are deployed on the server, and the plurality of large models are obtained by training based on a pre-built corpus. The corpus-based dialogue answering device 400 includes a first receiving unit 401, a building unit 402, a text generating unit 403, and a first sending unit 404, wherein:
[0099] The first receiving unit 401 is used to receive a first request message sent by a target application, wherein the first request message includes a first question text;
[0100] An establishing unit 402 is used to establish a first event source object corresponding to the first request information, and add a first event listener to the first event source object;
[0101] A text generation unit 403 is used to generate a streaming answer text of the first question text based on a corresponding corpus by using a target large model among the multiple large models that matches the first request information;
[0102] The first sending unit 404 is used to send the streaming answer text to the first event source object, so that the target application receives the streaming answer text through the first event listener.
[0103] The first request information includes a model identifier and / or an identifier of an object to be processed corresponding to the first question text.
[0104] Optionally, the text generation unit 403 is used to:
[0105] Determine, according to the model identifier and / or the to-be-processed object identifier, a target large model matching the first request information from among the multiple large models;
[0106] The first question text is parsed by the target large model to obtain corresponding data from a corresponding corpus, and a streaming answer text of the first question text is generated.
[0107] Optionally, the first sending unit 404 is configured to:
[0108] The streaming answer text is sent to the first event source object in the form of an event.
[0109] Optionally, the corpus-based dialogue answering device 400 is further used for:
[0110] receiving a second request message sent by the target application, wherein the second request message includes a second question text;
[0111] Establishing a second event source object corresponding to the second request information, and adding a second event listener for the second event source object, wherein the first event source object and the second event source object are different;
[0112] The generated streaming answer text of the second question text is sent to the second event source object, so that the target application receives the streaming answer text of the second question text based on the second event listener during the process in which the streaming answer text of the first question text is received by the first event listener.
[0113] The first event source object supports configuration of the request header.
[0114] Figure 4 The corpus-based dialogue answering device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0115] Figure 5 This is a schematic diagram of the structure of another corpus-based dialogue answering device provided in an embodiment of the present disclosure. The corpus-based dialogue answering device provided in an embodiment of the present disclosure can execute the processing flow provided in the corpus-based dialogue answering method embodiment, such as Figure 5 As shown, the corpus-based dialogue answering device 500 is applied to a target application, and specifically includes an acquisition unit 501, a second sending unit 502, and a second receiving unit 503, wherein:
[0116] The acquisition unit 501 is used to acquire a first question text and generate first request information according to the first question text;
[0117] A second sending unit 502 is used to send the first request information to a server, and the server is used to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object;
[0118] The second receiving unit 503 is used to receive the streaming answer text of the first question text through the first event listener, and the streaming answer text is generated by the server through a target big model that matches the first request information among multiple big models deployed based on the corpus of training the target big model.
[0119] Optionally, the corpus-based dialogue answering device 500 is further used for:
[0120] Obtaining a second question text, and generating second request information according to the second question text;
[0121] Sending the second request information to the server, the server is used to establish a second event source object corresponding to the second request information, and add a second event listener for the second event source object, wherein the first event source object and the second event source object are different;
[0122] In the process of receiving the streaming answer text of the first question text based on the first event listener, the streaming answer text of the second question text is received based on the second event listener, wherein the streaming answer text of the second question text is generated by the server and sent to the second event source object.
[0123] Optionally, the corpus-based dialogue answering device 500 is further used for:
[0124] The streaming answer text is displayed, and / or the voice generated based on the streaming answer text is played.
[0125] Figure 5 The corpus-based dialogue answering device of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0126] Figure 6 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 6 , which shows a schematic diagram of the structure of an electronic device 600 suitable for implementing the embodiment of the present disclosure. The electronic device 600 in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), wearable electronic devices, etc., and fixed terminals such as digital TVs, desktop computers, smart home devices, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0127] like Figure 6As shown, the electronic device 600 may include a processing device 601 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603 to implement the corpus-based dialogue answering method of the embodiment described in the present disclosure. In the RAM 603, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0128] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0129] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the corpus-based dialogue answering method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0130] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0131] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0132] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0133] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0134] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0136] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0137] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0138] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0139] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or gateway that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article or gateway. In the absence of further restrictions, the elements defined by the text "including one..." do not exclude the presence of other identical elements in the process, method, article or gateway that includes the elements.
[0140] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A corpus-based dialogue answering method, characterized in that: Applied to a server, where a plurality of different large models are deployed, and the plurality of large models are trained based on a pre-built corpus, the method comprising: Receiving first request information sent by a target application, wherein the first request information includes a first question text; Establishing a first event source object corresponding to the first request information, and adding a first event listener to the first event source object; Generate a streaming answer text of the first question text based on a corresponding corpus using a target large model among the multiple large models that matches the first request information; The streaming answer text is sent to the first event source object, so that the target application receives the streaming answer text through the first event listener.
2. The method according to claim 1, characterized in that The first request information includes a model identifier and / or an identifier of an object to be processed corresponding to the first question text, and the step of generating a streaming answer text of the first question text based on a corresponding corpus using a target large model among the multiple large models that matches the first request information includes: Determine, according to the model identifier and / or the to-be-processed object identifier, a target large model matching the first request information from among the multiple large models; The first question text is parsed by the target large model to obtain corresponding data from a corresponding corpus, and a streaming answer text of the first question text is generated.
3. The method according to claim 1, characterized in that The sending the streaming answer text to the first event source object comprises: The streaming answer text is sent to the first event source object in the form of an event.
4. The method according to claim 1, characterized in that: After receiving the first request information sent by the target application, the method further includes: receiving a second request message sent by the target application, wherein the second request message includes a second question text; Establishing a second event source object corresponding to the second request information, and adding a second event listener for the second event source object, wherein the first event source object and the second event source object are different; The generated streaming answer text of the second question text is sent to the second event source object, so that the target application receives the streaming answer text of the second question text based on the second event listener during the process in which the streaming answer text of the first question text is received by the first event listener.
5. The method according to claim 1, characterized in that: The first event source object supports configuration of a request header.
6. A corpus-based dialogue answering method, characterized in that: Applied to a target application, the method comprises: Obtaining a first question text, and generating first request information according to the first question text; Sending the first request information to a server, where the server is used to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object; The streaming answer text of the first question text is received through the first event listener, and the streaming answer text is generated by the server through a target big model that matches the first request information among multiple big models deployed, based on the corpus used to train the target big model.
7. The method according to claim 6, characterized in that After generating the first request information according to the first question text, the method further includes: Obtaining a second question text, and generating second request information according to the second question text; Sending the second request information to the server, the server is used to establish a second event source object corresponding to the second request information, and add a second event listener for the second event source object, wherein the first event source object and the second event source object are different; In the process of receiving the streaming answer text of the first question text based on the first event listener, the streaming answer text of the second question text is received based on the second event listener, wherein the streaming answer text of the second question text is generated by the server and sent to the second event source object.
8. The method according to any one of claims 6-7, characterized in that: The method further comprises: The streaming answer text is displayed, and / or the voice generated based on the streaming answer text is played.
9. A corpus-based dialogue answering device, characterized in that: The device is applied to a server, where a plurality of different large models are deployed on the server, and the plurality of large models are trained based on a pre-built corpus, and the device comprises: A first receiving unit, configured to receive first request information sent by a target application, wherein the first request information includes a first question text; An establishing unit, configured to establish a first event source object corresponding to the first request information, and add a first event listener to the first event source object; a text generation unit, configured to generate a streaming answer text of the first question text based on a corresponding corpus by using a target large model among the multiple large models that matches the first request information; The first sending unit is used to send the streaming answer text to the first event source object, so that the target application receives the streaming answer text through the first event listener.
10. A corpus-based dialogue answering device, characterized in that: Applied to a target application, the device comprises: An acquisition unit, configured to acquire a first question text and generate first request information according to the first question text; A second sending unit, configured to send the first request information to a server, wherein the server is configured to establish a first event source object corresponding to the first request information and add a first event listener to the first event source object; A second receiving unit is used to receive a streaming answer text of the first question text through the first event listener, wherein the streaming answer text is generated by the server through a target big model that matches the first request information among multiple big models deployed, based on a corpus used to train the target big model.
11. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the corpus-based dialogue answering method as described in any one of claims 1 to 8.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the corpus-based dialogue answering method as described in any one of claims 1 to 8 are implemented.