Question and answer method, electronic equipment and storage medium
By finding matching preset questions in the Q&A system and determining the problem types, combined with business-related search results and chat models, the problem of low accuracy in generating reply content of large language models is solved, and the efficiency and quality of the Q&A system is improved.
Patent Information
- Application Number
- CN202411392283.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-07
AI Technical Summary
The response content generated by the large language model is low in accuracy in the Q&A scenario, mainly due to the insufficient correlation between the generated prompt text and user problems, resulting in inaccurate reply content.
By looking for matching preset problems in the first database, if there is no match, the type of user problem is determined, and the search results related to the business are obtained from the second database, and the correlation of reply content is improved by using feature vectors and matching comparisons. and accuracy, or use the chat class reply model to deal with non-preset types of problems.
It improves the accuracy and efficiency of reply content, ensures relevance with user problems, especially when dealing with chat issues, avoids unnecessary search links, and improves the quality and determination efficiency of reply content.
Smart Images

Figure CN119271787A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence, and in particular relates to a question-answering method, an electronic device, and a storage medium. Background Art
[0002] With the development of artificial intelligence technology, large language models (LLMs) can be applied to scenarios such as question-answering and translation. For example, in a question-answering scenario, a large language model can generate corresponding reply content based on the prompt text of the user's question. However, the prompt text generated in the related technology is often less relevant to the user's question or even irrelevant, resulting in low accuracy of the reply content generated by the large language model. Summary of the invention
[0003] The embodiments of the present application provide a question-answering method, an electronic device, and a storage medium, which can solve the problem of low accuracy of answer content generated by a large language model.
[0004] In a first aspect, an embodiment of the present application provides a question-and-answer method, the method comprising: in response to a received user question, searching a first database for a preset question matching the user question, the first database pre-storing a plurality of question-and-answer pairs; if the first database does not include the matching preset question, determining the question type of the user question; if the question type is a preset type, obtaining a retrieval result matching the user question from a second database, the preset type being used to indicate a business-related type, and the second database pre-storing information related to the business; based on the user question and the retrieval result, obtaining a reply content for the user question using a first reply model, the first reply model being obtained by training on business-related text, and the reply content being used to indicate business-related information.
[0005] Through the above technical solution, when the first database does not include a matching preset question, by judging whether the question type of the user question is of the preset type, when the user question is of the preset type, the user question can be characterized as a business-related question, and then combined with the search results determined from the second database, it can be ensured that the search results are relevant to the user question, thereby improving the accuracy of the reply content.
[0006] In a possible implementation, the method further includes: encoding the user question to obtain a feature vector of the user question; determining a degree of match between the user question and the preset question based on the feature vector and the vector corresponding to the preset question; if the highest matching degree is greater than a preset matching degree, determining that the matching preset question is included in the first database; if the highest matching degree is less than or equal to the preset matching degree, determining that the matching preset question is not included in the first database.
[0007] Through the above technical solution, by comparing the highest matching degree with the preset matching degree, there is no need to compare all matching degrees with the preset matching degree, so the detection efficiency can be improved.
[0008] In a possible implementation, the method further includes: if the first database includes the matching preset question, obtaining a reply content to the user question from the first database based on an answer corresponding to the matching preset question.
[0009] Through the above technical solution, when the first database includes matching preset questions, the answers corresponding to the matching preset questions are used as the reply content of the user's question, thereby improving the efficiency of obtaining the reply content and thus improving the question-answering efficiency.
[0010] In one possible implementation, determining the question type of the user question includes: obtaining a first question matching the user question from a first question set, and obtaining a second question matching the user question from a second question set; generating a prompt text for indicating the question type according to the user question, the first question, and the second question; and obtaining the question type based on the prompt text using a classification model, the classification model being obtained by training question samples and the labeled types of the question samples.
[0011] Through the above technical solution, by obtaining the first question and the second question that match the user question from different types of question sets, multiple types of questions related to the user question can be determined, and then by combining the user question, the first question and the second question to generate a prompt text, the comprehensiveness of the prompt text can be improved, thereby improving the accuracy of the question type.
[0012] In a possible implementation, based on the user question and the search result, obtaining the reply content of the user question using the first reply model includes: splicing the user question and the search result to obtain splicing information; if the length of the splicing information is greater than a preset length, extracting related information of the user question from the search result; according to the user question and the related information, obtaining the reply content using the first reply model.
[0013] Through the above technical solution, when the length of the spliced information is greater than the preset length, by extracting related information from the retrieval results, it is possible not only to ensure that the length of the information input into the first reply model meets the preset length, but also to ensure that the reply content matches the user's question, thereby improving the accuracy of the reply content.
[0014] In a possible implementation, the method further includes: if the question type is other than the preset type, based on the user question, using a second reply model to determine the reply content of the user question, the other type includes a chat type, and the second reply model is obtained by training the chat-type conversation text.
[0015] Through the above technical solution, when the user question is not of the preset type, it can be indicated that the user question is a chat-type question, and then the reply content is determined based on the second reply model. This can solve the problem of inaccurate reply content when processing chat-type questions in related technologies, and improve the quality of the reply content. At the same time, since unnecessary retrieval links are avoided when processing chat-type questions, the efficiency of determining the reply content of chat-type questions is improved.
[0016] In a possible implementation, the method further includes: in response to a user operation on the reply content, storing a correspondence between the user question and the reply content in the first database.
[0017] Through the above technical solution, in response to the user's operation on the reply content, the user's question and the corresponding reply content are stored in the first database, which can improve the richness of the first database, thereby increasing the hit probability of the user's question and improving the overall efficiency and quality of the question and answer.
[0018] In a possible implementation, storing the correspondence between the user question and the reply content in the first database includes: encoding the user question to obtain a first vector, and encoding the reply content to obtain a second vector; and storing the correspondence between the first vector and the second vector in the first database.
[0019] Through the above technical solution, the space occupied by the text can be reduced by encoding the user questions and the corresponding reply contents into vectors for storage.
[0020] In a second aspect, an embodiment of the present application provides a question-and-answer device, comprising: a search unit, configured to respond to a received user question and search a first database for a preset question that matches the user question; a determination unit, configured to determine the question type of the user question if the first database does not include the matching preset question; an acquisition unit, configured to acquire a retrieval result that matches the user question from a second database if the question type is a preset type; and an output unit, configured to obtain a reply content of the user question using a first reply model based on the splicing information of the user question and the retrieval result.
[0021] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor: wherein the memory is used to store program instructions; the processor is used to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device executes the above-mentioned question-and-answer method.
[0022] In a fourth aspect, an embodiment of the present application provides a computer storage medium, wherein the computer storage medium stores program instructions, and when the program instructions are executed on an electronic device, a processor of the electronic device executes the above-mentioned question-and-answer method.
[0023] In a fifth aspect, an embodiment of the present application provides a program product, including a computer program, which is executed by a processor of an electronic device to perform the above-mentioned question-and-answer method.
[0024] In addition, the technical effects brought about by the second to fifth aspects can be found in the descriptions related to the methods of each design in the above method part, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a schematic diagram of an application scenario of the question-answering method provided in one embodiment of the present application.
[0026] Figure 2 It is a flowchart of a question-and-answer method provided in one embodiment of the present application.
[0027] Figure 3A , Figure 3B , Figure 3C This is a schematic diagram of input information displayed in a dialogue interface according to an embodiment of the present application.
[0028] Figure 4 It is a flowchart of a question-and-answer method provided in another embodiment of the present application.
[0029] Figure 5 This is an example diagram of preset question and answer pairs in the first database provided by an embodiment of the present application.
[0030] Figure 6 This is an example diagram of a first question set and a second question set provided by an embodiment of the present application.
[0031] Figure 7 It is a functional module diagram of a question-and-answer device provided in one embodiment of the present application.
[0032] Figure 8 It is a software architecture diagram of an electronic device provided in one embodiment of the present application.
[0033] Fig. 9 This is a hardware architecture diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0034] The terms "first" and "second" involved in an embodiment of the present application are only used for descriptive purposes and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in an embodiment of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by technicians in the technical field in the embodiments of the present application. The terms used in the description of the embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the embodiments of the present application. It should be understood that in the embodiments of the present application, unless otherwise specified, " / " means or. For example, A / B can represent A or B. The "and / or" in the embodiments of the present application is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. "At least one" refers to one or more. "Multiple" refers to two or more than two. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0036] Some terminology explanation:
[0037] Language Model: A model used to model natural language. Its purpose is to predict the next word or character of a given text sequence. Language models can be used for a variety of natural language processing tasks, such as text semantic extraction, text generation, machine translation, speech recognition, etc. At present, Transformer-based pre-trained language models (PLM) are more common in various natural language processing tasks and usually achieve good results. For example, the more common pre-trained language models include the Transformer model based on bidirectional encoding representation (Bidirectional Encoder Representation from Transformers, Bert) and the generative pre-trained Transformer model (Generative Pre-Trained Transformer, GPT).
[0038] Large Language Model: It can also be called a large model, natural language model or large language model. A large language model refers to a natural language processing model with large-scale parameters and training data. The training process of a large language model usually adopts an unsupervised learning method, and trains the model through a large text corpus to learn the probability distribution and language rules of the language. During the training process, a large language model usually uses a language model (LanguageModel) as the objective function, and optimizes the model parameters by maximizing the predicted probability of the next word. For example, the GPT series model based on the Transformer model structure is trained on a large-scale corpus and can generate high-quality natural language text, such as articles, conversations, etc.
[0039] Prompt Learning: It is a natural language generation technology based on human prompts. It uses the knowledge of pre-trained language models to better use the knowledge of pre-trained language models. It adds additional text to the input segment to improve the generation quality and efficiency of the final generated model. The basic idea of prompt learning is to give a human prompt or partial generation result during the generation process, called a prompt token, or prompt text, which represents a command or instruction to indicate that the large language model needs to perform an action or generate an output, so that the model can continue to generate text on this basis. Prompt learning can be applied to various natural language generation tasks, such as text summarization, machine translation, and dialogue generation. Prompt learning can help the model better understand the context and context of the generation task, thereby generating more accurate and natural text, which can improve the generation quality and efficiency of the generation model, and also reduce the generation space of the generation model, thereby improving the generation efficiency and speed.
[0040] Enterprise knowledge base: It is a structured, easy-to-operate, easy-to-use, easy-to-store, and inheritable knowledge cluster formed in the enterprise. The enterprise knowledge base can store various documents of the enterprise, such as policies, processes, manuals, training materials, etc. The enterprise knowledge base can also store the experience accumulated by the enterprise in different projects and tasks to help employees solve problems encountered in their work.
[0041] Full-text search engine: is a technology used to quickly retrieve and analyze large amounts of text data. Full-text search engines allow users to search for documents, web pages, or other forms of text content by keywords or phrases. The search object is not only the title or metadata of the document, but also the entire text content of the document.
[0042] ElasticSearch: is a distributed, highly scalable, and highly real-time search and data analysis engine that can quickly store, search, and analyze large amounts of data. ElasticSearch is usually used to implement full-text search functions, but it also supports multiple types of searches, such as structured search, geographic location search, and time series data.
[0043] Vector database: a database specifically used to store and query vectors. The vectors stored in it come from the vectorization of text, speech, images, videos, etc. Compared with traditional databases, vector databases can process more unstructured data (such as images and audio). In machine learning and deep learning, data is usually represented in vector form.
[0044] The embodiment of the present application provides a question-answering method, which can improve the accuracy and quality of reply content, and can also improve the efficiency of obtaining reply content.
[0045] The question-and-answer method provided in the embodiments of the present application can be applied to various question-and-answer service scenarios, such as enterprise office service scenarios, government service consultation scenarios, intelligent customer service scenarios, online education service scenarios, and intelligent medical service scenarios, etc., and the embodiments of the present application are not limited to this. Figure 1 FIG. 1 is a schematic diagram of an application scenario of the question-answering method provided in an embodiment of the present application. The scenario may include various types of terminal devices 100 and a server 200.
[0046] The terminal device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device. The embodiment of the present application does not impose any special restrictions on the specific type of the terminal device 100. The server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides 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, i.e., content delivery networks (CDNs), and big data and artificial intelligence platforms, but is not limited thereto.
[0047] It should be noted that the method in the embodiment of the present application can be executed by the terminal device 100 or the server 200 alone, or can be executed by the server 200 and the terminal device 100 together. When executed by the terminal device 100 or the server 200 alone, the model training and application process can be implemented by the terminal device 100 or the server 200 alone. For example, the trained classification model and the reply model can be obtained by fine-tuning the pre-trained large language model on the terminal device 100. Accordingly, after training, the terminal device 100 can use the trained classification model to identify the question type of the user's question, and use the trained reply model to obtain the reply content of the user's question or input information. The above process can also be executed by the server 200 alone. When the server 200 and the terminal device 100 jointly execute, the server 200 can train the classification model and the response model, and then deploy the trained classification model and response model to the terminal device 100, and the terminal device 100 implements the question-answering process, or part of the model training or application process can be implemented by the terminal device 100, and part of the process can be implemented by the server 200, and the two cooperate to implement the model training or application process. In actual application, specific configuration can be made according to the situation, and no specific limitation is made here.
[0048] It should be noted that when the question-answering method provided in the embodiment of the present application is executed by the server 200 or the terminal device 100 alone, the above-mentioned application scenario may also only include a single device of the server 200 or the terminal device 100, or the server 200 and the terminal device 100 may also be considered to be the same device. In actual application, when the question-answering method provided in the embodiment of the present application is jointly executed by the server 200 and the terminal device 100, the server 200 and the terminal device 100 may also be the same device, that is, the server 200 and the terminal device 100 may be different functional modules of the same device, or virtual devices virtualized from the same physical device.
[0049] In one possible implementation, a user may provide input content through the terminal device 100 to initiate a round of question-and-answer process, and the server 200 may receive the user's questions or input information, and then use the method of the embodiment of the present application to generate reply content of the question-and-answer process, and return it to the terminal device 100 for presentation.
[0050] In the embodiment of the present application, the terminal device 100 and the server 200 can be directly or indirectly connected to each other through one or more networks. The network can be a wired network or a wireless network. For example, the wireless network can be a mobile cellular network or a wireless fidelity (Wireless-Fidelity, WIFI) network. Of course, it can also be other possible networks, which are not limited in the embodiment of the present application. It should be noted that Figure 1 The figure is only an example. In fact, the number of terminal devices and servers is not limited and is not specifically limited in the embodiments of the present application.
[0051] The question-and-answer method provided by the embodiment of the present application is described below in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the embodiments of the present application, and the embodiments of the present application are not limited in this respect.
[0052] See also Figure 2 FIG. 1 is a flowchart of a question-answering method provided by an embodiment of the present application. The question-answering method can be applied to an electronic device, such as a Figure 1 The terminal device 100 or the server 200 shown in the figure, the method specifically includes the following process.
[0053] S201, receiving input information, and determining whether the input information is in a multi-round dialogue.
[0054] In some embodiments of the present application, input information may be received from a terminal device that communicates with the electronic device, and the input information may also be directly input by the user in the electronic device. The input information may include, but is not limited to: text information, voice information. The input information may indicate a user question input by the user, and the input information may also indicate a reply information input by the user. For example, the chatbot outputs "For the current question, please tell me a model", and the input information may be the user's reply information based on "For the current question, please tell me a model".
[0055] In some embodiments of the present application, the electronic device or terminal device may provide a graphical interactive interface as a dialogue interface, and the user may enter input information in the dialogue interface. Figure 3A , Figure 3B , Figure 3A , Figure 3B is a schematic diagram of input information displayed in a dialogue interface provided by an embodiment of the present application. Figure 3A As shown in FIG. 1 , the user can enter “how is the server performance” in the dialogue interface. Figure 3A As shown in , the user can enter "Can I skip this question?" in the dialogue interface. Figure 3BAs shown, the user can enter "Exit Dialogue" in the dialogue interface.
[0056] In some embodiments of the present application, a multi-round dialogue may represent multiple continuous and logically related dialogue rounds in the question-and-answer process, rather than being limited to a simple form of one question and one answer. The electronic device determines whether the input information is in a multi-round dialogue, including: obtaining the conversation content of at least one conversation round in the question-and-answer process, the conversation content may be the input content at the first moment, and the input information may be the input content at the second moment, and the second moment is after the first moment. Calculate the correlation between the input information and the conversation content, and if there are multiple conversation contents, multiple corresponding correlations can be obtained accordingly. If all correlations are less than or equal to the preset correlation, it is determined that the input information is not in a multi-round dialogue. If any correlation is greater than the preset correlation, it is determined that the input information is in a multi-round dialogue. Among them, the correlation can be determined based on the text similarity between the input information and the conversation content, and the preset correlation can be preset, for example, it can be determined and adjusted based on an experience value. This embodiment can accurately determine whether the input information is in a multi-round dialogue by determining the correlation between the input information and the conversation content, and then by comparing the correlation with the preset correlation.
[0057] In some embodiments of the present application, if the input information is not in a multi-round dialogue, it may indicate that the input information is in a question-and-answer format, or it may indicate that the input information is the content of the first round of dialogue in a multi-round dialogue. If the input information is in a multi-round dialogue, it may indicate that the input information is the content of a non-first round of dialogue in a multi-round dialogue, for example, the input information may be the content of the second round of dialogue in a multi-round dialogue, or the input information may be the content of the last round of dialogue in a multi-round dialogue.
[0058] In some embodiments of the present application, if the input information is not in a multi-round dialogue, step S202 is executed; if the input information is in a multi-round dialogue, step S212 is executed.
[0059] S202, identifying whether the intention of the input information is a preset intention.
[0060] In some embodiments of the present application, the preset intention includes but is not limited to: exit intention and skip intention. Among them, the exit intention can represent the intention to exit the question-and-answer process, and the skip intention can represent the intention to skip the current round of dialogue.
[0061] In some embodiments of the present application, identifying whether the intention of input information is a preset intention includes: detecting whether the input information includes preset characters. The preset characters may include, but are not limited to: a first character, a second character. For example, the first character may be a character such as exit that indicates exit, and the second character may be a character such as skip that indicates skip. If the input information includes preset characters, it is determined that the intention of the input information is the preset intention; if the input information does not include preset characters, it is determined that the intention of the input information is not the preset intention. This embodiment can quickly determine whether the intention of the input information is the preset intention by detecting whether the input information includes preset characters.
[0062] In some embodiments of the present application, if the intention of the input information is a preset intention, step S203 is executed; if the intention of the input information is not a preset intention, step S204 is executed.
[0063] S203: Use the first preset reply as the reply content of the input information.
[0064] In some embodiments of the present application, the first preset response can be preset according to the actual application scenario. Figure 3A As shown in the figure, in the product consultation scenario, the intention of inputting information is to skip the intention, and the first preset response can be set as: If I know the specific product model, I can quickly and accurately answer your question, so now I will answer your question according to your current needs. For another example, in the government hall service consultation scenario, the first preset response can be set as: If I know the specific matters to be handled, I can quickly and accurately answer your question, so now I will answer your question according to your current needs.
[0065] S204, searching the first database for a preset question that matches the input information.
[0066] In some embodiments of the present application, a plurality of question-answer pairs are pre-stored in the first database. In practical applications, a plurality of first databases may be set according to different purposes. For example, the first database 01 may store question-answer pairs related to basic information of an enterprise; the first database 02 may store question-answer pairs related to product information of an enterprise; the first database 03 may store question-answer pairs related to product warnings; and the first database 04 may store question-answer pairs related to sensitive issues.
[0067] The first database may store at least one preset question-answer pair, each of which includes a preset question and a corresponding answer. The electronic device searches the first database for a preset question that matches the input information, as described below. Figure 4 The relevant description in step S401 in .
[0068] In some embodiments of the present application, if the first database includes preset questions that match the input information, step S205 is executed; if the first database does not include preset questions that match the input information, step S206 is executed.
[0069] S205, obtaining reply content of the input information from the first database based on the answer corresponding to the matched preset question.
[0070] In some embodiments of the present application, the preset questions matching the input information may include the first k preset questions in the first database that have the highest matching degree with the input information, where k may be an integer greater than or equal to 1.
[0071] In one example, the answer corresponding to the preset question with the highest matching degree to the input information is used as the reply content of the input information. This embodiment improves the efficiency of obtaining reply content by directly using the answer corresponding to the preset question with the highest matching degree as the reply content of the input information, thereby improving the efficiency of question and answer.
[0072] In another example, if the length of the answer corresponding to the matched preset question is greater than the preset length, the answer corresponding to the matched preset question is segmented to obtain multiple segments. Based on the multiple segments, the first reply model is used to obtain the reply content of the input information. Among them, the preset length can be preset, for example, it can be set according to an experience value, and the preset length can include but is not limited to: character length, time length. If the answer corresponding to the matched preset question is text content, the preset length can be character length; if the answer corresponding to the matched preset question is audio content, the preset length can also be time length. The first reply model can be trained based on the model framework of the large language model. This embodiment determines the reply content of the input information by using the first reply model and the answer corresponding to the preset question that matches the input information, which can improve the personalization of the reply content.
[0073] S206, determining whether it is necessary to determine the reply content of the input information based on the preset information.
[0074] In some embodiments of the present application, the preset information may include relevant information of a specified type, for example, the preset information may include information related to a product model. For example, if the input information is: how is the performance of the server, the preset information may include the specific model of the server. The electronic device may detect whether it is necessary to determine the reply content of the input information based on the preset information based on the preset model. The preset model may be trained based on the model framework of the large language model.
[0075] In some embodiments of the present application, if it is not necessary to determine the reply content of the input information based on the preset information, execute step S207; if it is necessary to determine the reply content of the input information based on the preset information, execute step S208.
[0076] S207: Acquire search results matching the input information from the second database.
[0077] In some embodiments of the present application, information related to the business is pre-stored in the second database. The number of second databases can be one or more, for example, relevant information of different product models can be stored in different second databases. The second database can also store general information of different product models. For example, if a certain server has 3 models, there can be 4 second databases, namely, the second database 001 corresponding to the H1 model, the second database 002 corresponding to the H2 model, the second database 003 corresponding to the H3 model, and the second database 004 can be used to store general information of the H1 model-H3 model.
[0078] In some embodiments of the present application, the search result can be obtained from the second database by calling a full-text search engine. The search result can also be obtained by semantic search from the second database. After step S207 is completed, step S211 is executed.
[0079] S208: Determine whether the input information includes preset information.
[0080] In some embodiments of the present application, the preset information may include information required to determine the reply content of the input information. For example, in a product consultation scenario, the preset information may include the relevant product model of a certain product. For another example, in a government hall service consultation scenario, the preset information may include specific matters under a certain matter. This embodiment is conducive to determining reasonable reply content by judging whether the input information includes the preset information.
[0081] In some embodiments of the present application, if the input information does not include preset information, step S209 is executed; if the input information includes preset information, step S210 is executed.
[0082] S209: Use the second preset reply as the reply content of the input information.
[0083] In some embodiments of the present application, the second preset reply can be preset according to the actual application scenario. For example, in a product consultation scenario, the second preset reply can be set as: For the current problem, please tell me a model. For another example, in a government hall service consultation scenario, the second preset reply can be set as: Please tell me the specific matters to be handled.
[0084] S210, screening the third database from the second database according to preset information, and obtaining search results matching the input information from the third database.
[0085] In some embodiments of the present application, the third database may represent a second database corresponding to the preset information. For example, following the above example, the second database includes a second database 001 corresponding to the H1 model, a second database 002 corresponding to the H2 model, a second database 003 corresponding to the H3 model, and a second database 004 stores general information of the H1 model-H3 model. If the preset information is the H1 model, the second database 001 and the second database 004 can be screened from multiple second databases as the third database. In this embodiment, when the input information includes preset information, the third database is screened out from multiple second databases through the preset information, which can reduce the number of database searches, thereby improving the efficiency of obtaining search results.
[0086] In some embodiments of the present application, the method of obtaining the search results matching the input information from the third database is similar to the method of obtaining the search results matching the input information from the second database, and will not be repeated here.
[0087] S211, based on the input information and the search results, using the first reply model to obtain reply content of the input information.
[0088] In some embodiments of the present application, the first reply model can be obtained through the framework training of the large language model based on the business information stored in the second database. The training process of the first reply model may include: obtaining business information and the marked replies corresponding to the business information, and adjusting the network parameters of the large language model based on the business information and the marked replies, until the number of adjustments to the network parameters is greater than the preset number, or the similarity between the output reply of the large language model and the marked reply is greater than the preset similarity, to obtain the first reply model. Among them, the preset number of times and the preset similarity can be set and adjusted according to needs. The business information of the first reply model corresponding to different business scenarios can be different or the same. This embodiment can obtain a suitable first reply model by training the large language model in combination with the business information, thereby improving the rationality of the reply content of the input information.
[0089] In some embodiments of the present application, a separator may be used to concatenate input information and search results to obtain concatenated information.
[0090] In one example, the input information and the search results are spliced by a separator, and any two search results are directly spliced. Specifically, a separator and at least one search result can be added at the end of the input information in sequence. For example, the input information is "How is the server performance?", the search result A is "Fast response speed", and the search result B is "The working noise is relatively loud". If the separator is SEQ, the spliced information can be "How is the server performance? SEQ Fast response speed and relatively loud working noise".
[0091] In another example, the input information and the search results are spliced by the first separator, and any two search results are spliced by the second separator. For example, the first separator and a search result are added in sequence at the end of the input information, and the second separator and the remaining search results are added in sequence at the end of a search result. Among them, the first separator and the second separator can be the same. For example, the input information is "How is the server performance", the search result A is "Fast response speed", and the search result B is "The working noise is relatively loud", the first separator and the second separator are both SEQ, and the splicing information can be "How is the server performance SEQFast response speedSEQThe working noise is relatively loud".
[0092] The first separator and the second separator can be different. For example, if the input information is "How is the server performance?", the search result A is "Fast response speed", and the search result B is "Large working noise", if the first separator is SEQ1 and the second separator is SEQ2, the spliced information can be "How is the server performance? SEQ1 Fast response speed SEQ2 Large working noise".
[0093] In some embodiments of the present application, if the length of the concatenated information is greater than a preset length, the associated information of the input information is extracted from the search results, and the reply content of the input information is obtained using the first reply model based on the input information and the associated information. The associated information may be information in the search results whose matching score with the input information is greater than or equal to a threshold score.
[0094] In one example, the associated information may include at least one first search result, and the first search result may be a search result whose matching score with the input information is greater than or equal to a threshold score. For example, the input information is "How is the server performance?", the search result X is "fast response speed, able to respond at 50 degrees Celsius; able to adapt to different humidity environments and provide responsive services", the search result Y is "relatively loud working noise, sterilization rate up to 90%, precise temperature control", and the search result Z is "low price, high product intelligence, good after-sales service, and rich product line". If the matching score between the input information "How is the server performance?" and the search result X is 0.9, the matching score between the input information "How is the server performance?" and the search result Y is 0.8, the matching score between the input information "How is the server performance?" and the search result Z is 0.4, and the threshold score is 0.7, the associated information may include the search result X and the search result Y; if the threshold score is 0.85, the associated information may include the search result X.
[0095] In another example, the associated information may also include part of the content in the first search result. Continuing with the above example, if the first search result includes search result X and search result Y, and the length of the input information "how is the server performance" and the concatenated information of search result X and search result Y is greater than the preset length, the matching score between the input information and each segment in the first search result is calculated. If the matching score between the input information "how is the server performance" and the first segment in search result X "fast response speed, able to respond at 50 degrees Celsius" is 0.9, and the matching score between the input information "how is the server performance" and the second segment in search result X "able to adapt to different humidity environments and provide responsive services" is 0.8, The matching score between the input information "How is the server performance" and the first segment in the search result Y "The working noise is relatively loud" is 0.9, the matching score between the input information "How is the server performance" and the second segment in the search result Y "The sterilization rate is as high as 90%" is 0.5, the matching score between the input information "How is the server performance" and the third segment in the search result Y "Precise temperature control" is 0.75, the threshold score is 0.85, and the associated information may include: the first segment in the search result X "Fast response speed, able to respond at 50 degrees Celsius" and the second segment in the search result Y "The working noise is relatively loud".
[0096] In another example, the associated information may include part of the content in the second search result, and the second search result may be the search result with the highest matching score with the input information. Continuing with the above example, the second search result may be the search result X "fast response speed, able to respond at 50 degrees Celsius; able to adapt to different humidity environments, and implement response services", if the length of the spliced information of the input information "how is the server performance" and the search result X is greater than the preset length, the relevant score of the input information and each segment in the second search result is calculated, if the matching score of the input information "how is the server performance" and the first segment in the search result X "fast response speed, able to respond at 50 degrees Celsius" is 0.9, the matching score of the input information "how is the server performance" and the second segment in the search result X "able to adapt to different humidity environments, and implement response services" is 0.8, and the threshold score is 0.85, the associated information may include: the first segment in the search result X "fast response speed, able to respond at 50 degrees Celsius".
[0097] In this embodiment, when the length of the concatenated information is greater than the preset length, related information is extracted from the search results, thereby ensuring that the length of the information input into the first reply model meets the preset length.
[0098] In some embodiments of the present application, if the length of the spliced information is greater than a preset length, the spliced information is segmented according to the preset length to obtain a plurality of fragments, and based on the plurality of fragments, the reply content of the input information is obtained through the first reply model. The preset length can be set according to the input length requirement of the first reply model. The length of any fragment can be less than or equal to the preset length. In this embodiment, when the length of the spliced information is greater than the preset length, the spliced information is segmented according to the preset length, so that each fragment input to the first reply model can ensure that the length requirement is met.
[0099] In some embodiments of the present application, the electronic device outputs the reply content. In one example, if the input information is received from a terminal device that communicates with the electronic device, the reply content is fed back to the terminal device. In another example, if the input information is directly input by the user in the electronic device, the reply content is displayed in the dialogue interface of the electronic device.
[0100] S212, determining whether the intention of the input information is an exit intention.
[0101] In some embodiments of the present application, determining whether the intention of the input information is an exit intention includes: detecting whether the input information includes a first character, where the first character may be a character indicating exit, such as "exit", "exit", "close", or "end".
[0102] In some embodiments of the present application, if the intention of the input information is an exit intention, step S213 is executed; if the intention of the input information is not an exit intention, step S214 is executed.
[0103] S213: Use the third preset reply as the reply content of the input information.
[0104] In some embodiments of the present application, the third preset response can be preset according to the actual application scenario. Figure 3B As shown, the intention of inputting information is exit intention, and the third preset response can be set as: "OK, let's stop the current question."
[0105] S214, determining whether the intention of the input information is a skip intention.
[0106] In some embodiments of the present application, determining whether the intention of the input information is a skip intention includes: detecting whether the input information includes a second character, where the second character may be a character indicating skipping, such as "skip", "next", or "skip".
[0107] In some embodiments of the present application, if the intention of the input information is a skip intention, execute step S207; if the intention of the input information is not a skip intention, execute step S215.
[0108] S215, obtaining the conversation content of at least one conversation round in the multiple conversation rounds, and obtaining updated input information according to the conversation content and the input information.
[0109] In some embodiments of the present application, the conversation content is the information of the input information, and the input time of the conversation content is before the input time of the input information. The updated input information can be obtained by splicing the conversation content and the input information. For ease of understanding, please refer to Figure 3C , Figure 3C is a schematic diagram of input information displayed in a dialogue interface provided by an embodiment of the present application. Figure 3C As shown, the input information may be "H1 model", and the conversation content of at least one conversation round in multiple conversation rounds may be "How is the server performance", the intention of the input information is neither an exit intention nor a skip intention, and the updated input information may be "How is the server performance, H1 model".
[0110] In some embodiments of the present application, after step S215 is completed, step S206 is executed.
[0111] The question-and-answer method provided in the embodiment of the present application, when the input information is not in a multi-round dialogue, by identifying whether the intention of the input information is a preset intention, and then when the intention of the input information is the preset intention, the first preset reply is used as the reply content of the input information, and the accurate reply content can be obtained in combination with the intention of the input information, thereby improving the quality of question-and-answer. When the intention of the input information is not the preset intention, by searching the first database for a preset question matching the input information, when the first database includes the matching preset question, the reply content is obtained by obtaining the corresponding answer from the first database, and the efficiency and quality of determining the reply content can be improved. When the first database does not include the matching preset question, by judging whether it is necessary to determine the reply content of the input information based on the preset information, and then when it is not necessary to determine the reply content of the input information based on the preset information, by obtaining the search results matching the input information from the second database, the reply content of the input information is determined, and the comprehensiveness and accuracy of the reply content can be improved. When it is necessary to determine the reply content of the input information based on the preset information, by judging whether the input information includes the preset information, when the input information does not include the preset information, by using the second preset reply as the reply content of the input information, the efficiency and rationality of determining the reply content can be improved. When the input information includes preset information, based on the preset information, the search results matching the input information are obtained from the third database screened out from the second database to determine the reply content of the input information. Since there is no need to search for the corresponding search results from all the second databases, the efficiency of obtaining the search results can be improved, thereby improving the efficiency of determining the reply content.
[0112] See also Figure 4FIG. 1 is a flowchart of a question-answering method provided by another embodiment of the present application. The question-answering method can be applied to an electronic device, such as a Figure 1 The terminal device 100 or the server 200 shown in the figure, the method specifically includes the following process.
[0113] S401, in response to a received user question, searching a first database for a preset question matching the user question.
[0114] In some embodiments of the present application, the user question can be Figure 2 For example, Figure 3A , Figure 3B , Figure 3C As shown, the user question may be "How is the server performance?"
[0115] In some embodiments of the present application, a plurality of question-answer pairs are pre-stored in the first database. The first database may store vector representations of preset question-answer pairs, wherein the preset question-answer pairs include preset questions and corresponding answers. For example, the preset question-answer pairs include question 1 and answer 1. The question column in the first database may include the vector representation of question 1 [0, 2, 0, 1, 0…], and the answer column in the first database may include the vector representation of answer 1 [0, 1, 0, 4, 0…]. For ease of understanding, please refer to Figure 5 , Figure 5 This is an example diagram of a preset question-answer pair in the first database provided in an embodiment of the present application. The vector representation of the preset question-answer pair stored in the first database can be stored in the form of a list, for example Figure 5 The question column and answer column shown in the figure may store vector representations of preset questions, for example, the vector form of question 1, the vector form of question 2, and the vector form of question 3, and the answer column may store vector representations of answers corresponding to preset questions, for example, the vector form of answer 1 corresponding to question 1, the vector form of answer 2 corresponding to question 2, and the vector form of answer 3 corresponding to question 3. This embodiment can reduce the space occupied by preset question and answer pairs by storing preset question and answer pairs in the form of vector representation (for example, question 1 and answer 1 constitute question and answer pair 1). At the same time, storing the vector representation of the preset question and answer pairs in the first database can facilitate the direct matching of subsequent preset questions with user questions.
[0116] In some embodiments of the present application, the index column of the first database may be constructed according to the vector corresponding to the preset question, for example Figure 5 The question column is shown.
[0117] In some embodiments of the present application, searching for preset questions that match user questions in the first database includes: encoding the user questions to obtain a feature vector of the user questions, and obtaining the degree of match between the user questions and the preset questions based on the feature vector and the vector corresponding to the preset questions. Determine whether the highest matching degree is greater than the preset matching degree. If the highest matching degree is greater than the preset matching degree, determine that the first database includes matching preset questions. If the highest matching degree is less than or equal to the preset matching degree, determine that the first database does not include matching preset questions. Among them, the degree of match between the user question and the preset question can be determined based on the similarity between the feature vector and the vector corresponding to the preset question. The preset matching degree can be set based on an empirical value. For example, the preset matching degree can be set to 0.9. In this embodiment, by comparing the highest matching degree with the preset matching degree, since there is no need to compare all matching degrees with the preset matching degree, the detection efficiency can be improved.
[0118] In some embodiments of the present application, if the first database includes matching preset questions, step S402 is executed; if the first database does not include matching preset questions, step S403 is executed.
[0119] S402, based on the answers corresponding to the matched preset questions, obtain the reply content of the user's question.
[0120] In some embodiments of the present application, the answer corresponding to the preset question with the highest matching degree is used as the reply content of the user's question.
[0121] In this embodiment, when the first database includes matching preset questions, the answer to the preset question corresponding to the highest matching degree is used as the reply content of the user question, which can improve the efficiency of obtaining the reply content and thus improve the question-answering efficiency.
[0122] S403: Determine the question type of the user's question.
[0123] In some embodiments of the present application, the question type may include a business-related type and a business-unrelated type. The business-related type may include, but is not limited to, a product consultation type and a product warning type. The business-unrelated type may represent a chat type.
[0124] In some embodiments of the present application, determining the type of the user's question includes: obtaining a first question matching the user's question from a first question set, and obtaining a second question matching the user's question from a second question set. Prompt text is generated according to the user's question, the first question, and the second question, and the question type is obtained using a classification model based on the prompt text.
[0125] The questions stored in the first question set may be irrelevant to the business. For example, the questions stored in the first question set may be small talk questions. For example, the questions stored in the first question set may be: What is the weather like today? The second question set may store multiple business-related questions. For ease of understanding, please refer to Figure 6 , Figure 6 An example diagram of a first set of questions and a second set of questions provided in an embodiment of the present application, such as Figure 6 As shown, the first question set may include vector representations corresponding to multiple chat-related questions. For example, the first question set may include the vector form of question A, the vector form of question B, and the vector form of question C; the second question set may include vector representations corresponding to multiple business-related questions. For example, the second question set may include the vector form of question a, the vector form of question b, and the vector form of question c.
[0126] The first question may include the first m questions with the highest similarity to the user question in the first question set, and the second question may include the first n questions with the highest similarity to the user question in the second question set, where m and n may be positive integers, and m may be equal to n. The prompt text may be constructed based on the user question, the first question, and the second question through prompt engineering. For example, the user question may be "How is the server performance?", the first question obtained from the first question set may be "Is the weather very hot today?", and the second question obtained from the second question set may be "How is the performance of model X server?". Through prompt engineering, based on the user question, the first question, and the second question, the prompt text obtained may be "You are a question classification expert, please help the user to classify according to the following prompts: 'Is the weather very hot today?' is a 'chat type' question; 'How is the performance of model X server?' is a 'product consultation type' question; please determine what type of question 'How is the server performance?'"
[0127] The classification model can be obtained by training or fine-tuning the framework of the large language model. The training or fine-tuning method of the classification model may include: training or fine-tuning the Lora framework of the large language model through question samples and the annotation types of the question samples until the preset conditions are met to obtain the classification model. Question samples may include questions whose annotation types are preset types and questions whose annotation types are not preset types. The preset conditions may include but are not limited to: the number of training times is greater than a certain number of times, and the loss value of the large language model is less than a certain value. Continuing with the above example, the prompt text "You are a question classification expert, please help users classify according to the following prompts: 'Is the weather very hot today' is a 'chat type' question; 'How is the performance of X server' is a 'product consulting type' question; please determine what type of question 'How is the server performance' is" is input into the classification model, and the resulting question type can be "product consulting type".
[0128] This embodiment can determine multiple types of questions related to the user question by obtaining the first question and the second question that match the user question from different types of question sets, and then generate a prompt text by combining the user question, the first question and the second question, which can improve the comprehensiveness of the prompt text and thus improve the accuracy of the question type.
[0129] S404: Determine whether the question type of the user question is a preset type.
[0130] In some embodiments of the present application, the preset type can be used to indicate a type related to a business, and the preset types set in different application scenarios can be different. For example, in a product consultation scenario, the preset type can be set as: product consultation type, and in a government hall service consultation scenario, the preset type can be set as: process consultation type, etc. The preset types set in different application scenarios can also be the same. For example, in a product consultation scenario, the preset type can be set as: business type; in a government hall service consultation scenario, the preset type can also be set as: business type.
[0131] In some embodiments of the present application, the characters of the question type are compared to see whether they are the same as the characters of the preset type. If the characters of the question type are the same as the characters of the preset type, the question type is determined to be the preset type; if the characters of the question type are different from the characters of the preset type, the question type is determined to be other types other than the preset type, and other types include chat types.
[0132] In some embodiments of the present application, if the question type is a preset type, execute step S405; if the question type is a type other than the preset type, execute step S407.
[0133] S405: Acquire search results matching the user's question from the second database.
[0134] In some embodiments of the present application, if the question type is a preset type, the user question may be characterized as a business-related question. The second database may pre-store business-related information, for example, the information stored in the second database includes but is not limited to: text information related to the product.
[0135] In one example, obtaining a search result matching the user question from the second database includes: obtaining stored information from the second database whose matching score with the user question is greater than a preset score as the search result. The matching score can be determined based on the similarity between the user question and the stored information in the second database, and the preset score can be set based on an empirical value. This embodiment matches the user question with the stored information in the second database, and then uses the stored information with a matching score greater than the preset score as the search result, which can improve the accuracy of the search result.
[0136] In another example, obtaining a search result matching the user question from the second database includes: calling a full-text search engine to obtain information matching the user question from the second database as a search result. This embodiment can quickly obtain the corresponding search result from the second database through the full-text search engine.
[0137] S406, based on the user question and the search results, using the first reply model to obtain the reply content of the user question.
[0138] In some embodiments of the present application, the details of step S406 can be found in the above Figure 2 The detailed description of step S211 is omitted here.
[0139] S407: Based on the user's question, determine the reply content of the user's question using the second reply model.
[0140] In some embodiments of the present application, if the question type is other than the preset type, the other type includes the chat type, and the user question can be characterized as a chat type question. The second reply model can be obtained by training the chat type conversation text through the framework of the large language model.
[0141] In some embodiments of the present application, in response to the user's operation on the reply content, the correspondence between the user's question and the reply content is stored in the first database. The users may include but are not limited to: an administrator user with certain permissions, and the party who raises the user's question. The user's operation on the reply content may include but is not limited to: a like operation and a dislike operation. In this embodiment, in response to the user's operation on the reply content, by storing the user's question and the corresponding reply content in the first database, the richness of the first database can be improved, thereby increasing the hit probability of the user's question and improving the overall efficiency and quality of the question and answer.
[0142] In some embodiments of the present application, storing the correspondence between the user question and the reply content in the first database includes: encoding the user question to obtain a first vector, encoding the reply content to obtain a second vector, and storing the correspondence between the first vector and the second vector in the first database. This embodiment can reduce the space occupied by the text by encoding the user question and the corresponding reply content into vectors for storage.
[0143] In some embodiments of the present application, the first vector is added to the index column in the first database. In this embodiment, the index column is updated by the first vector to improve the comprehensiveness of the index column.
[0144] The question-and-answer method provided in the embodiment of the present application, by adding a first database, can facilitate matching the answer that matches the user question from the first database as the reply content, so that when the first database includes the preset question that matches the user question, the efficiency and quality of the reply content can be achieved. When the first database does not include the preset question that matches the user question, by judging whether the question type of the user question is the preset type, when the user question is the preset type, the user question can be characterized as a business-related question, and then combined with the search results determined from the second database, the first reply model can be used to obtain accurate reply content. When the user question is not of the preset type, it indicates that the user question is a chat-type question, and then the reply content is determined based on the second reply model, which can solve the problem of inaccurate reply content when processing chat-type questions in the related art, and improve the quality of the reply content. At the same time, because redundant search links are avoided when processing chat-type questions, the efficiency of determining the reply content of chat-type questions is improved.
[0145] See also Figure 7 As shown, Figure 7 The function module diagram of the question-answering device provided in the embodiment of the present application. The question-answering device 71 includes a search unit 710, a determination unit 711, an acquisition unit 712, an output unit 713, an encoding unit 714, and a storage unit 715. The module / unit referred to in the present application refers to a type of unit that can be processed by a processor (e.g. Fig. 9 A series of computer readable instruction segments that can be obtained by the processor 110 shown in the figure and can perform fixed functions and are stored in a memory (e.g. Fig. 9 In the memory 121) shown.
[0146] A search unit 710 is used to respond to a received user question and search a preset question matching the user question in a first database, where a plurality of question-answer pairs are pre-stored; a determination unit 711 is used to determine the question type of the user question if the first database does not include a matching preset question; an acquisition unit 712 is used to acquire a retrieval result matching the user question from a second database if the question type is a preset type, where the preset type is used to indicate a business-related type, where business-related information is pre-stored; an output unit 713 is used to obtain a reply content for the user question based on the user question and the retrieval result using a first reply model, where the first reply model is obtained by training on business-related text, and the reply content is used to indicate business-related information.
[0147] In one embodiment, the encoding unit 714 is used to encode the user question to obtain a feature vector of the user question; the determination unit 711 is also used to determine the degree of match between the user question and the preset question based on the feature vector and the vector corresponding to the preset question; the determination unit 711 is also used to determine that the first database includes matching preset questions if the highest matching degree is greater than the preset matching degree; the determination unit 711 is also used to determine that the first database does not include matching preset questions if the highest matching degree is less than or equal to the preset matching degree.
[0148] In one embodiment, the output unit 713 is further used to obtain the reply content of the user's question from the first database based on the answer corresponding to the matching preset question if the first database includes a matching preset question.
[0149] In one embodiment, the determination unit 711 is specifically used to: obtain a first question that matches the user question from a first question set, and obtain a second question that matches the user question from a second question set; generate a prompt text for indicating the type of question based on the user question, the first question and the second question; based on the prompt text, obtain the type of question using a classification model, and the classification model is obtained by training question samples and the labeled types of the question samples.
[0150] In one embodiment, the output unit 713 is specifically used to: concatenate the user question and the search results to obtain concatenated information; if the length of the concatenated information is greater than a preset length, extract related information of the user question from the search results; and obtain the reply content using the first reply model based on the user question and the related information.
[0151] In one embodiment, the output unit 713 is also used to determine the reply content of the user question based on the user question by using the second reply model if the question type is other than the preset type. The other types include the chat type, and the second reply model is obtained by training the chat-type conversation text.
[0152] In one embodiment, the storage unit 715 is used to store the corresponding relationship between the user's question and the reply content in the first database in response to the user's operation on the reply content.
[0153] In one embodiment, the storage unit 715 is specifically used to: encode the user question to obtain a first vector, and encode the reply content to obtain a second vector; and store the corresponding relationship between the first vector and the second vector in the first database.
[0154] In multiple embodiments of the present application, when a matching preset question is not included in the first database, by determining whether the question type of the user question is of the preset type, when the user question is of the preset type, the user question can be characterized as a business-related question, and then combined with the search results determined from the second database, it can be ensured that the search results are relevant to the user question, thereby improving the accuracy of the reply content.
[0155] See also Figure 8 As shown, Figure 8 A software architecture diagram of an electronic device provided in an embodiment of the present application. The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. For example, the Android system is, from top to bottom, an application layer 801, a framework layer 802, an Android runtime and a system library 803, a hardware abstraction layer 804, a kernel layer 805, and a hardware layer 806.
[0156] The application layer 801 may include a series of application packages, such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, device control service and other applications.
[0157] The framework layer 802 provides an application programming interface (API) and a programming framework for the application programs of the application layer. The application framework layer includes some predefined functions. For example, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.
[0158] Among them, the window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of an icon or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0159] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library contains two parts: one is the function that the Java language needs to call, and the other is the Android core library.
[0160] The application layer 801 and the framework layer 802 run in a virtual machine. The virtual machine executes the java files of the application layer and the framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0161] The system library 803 may include multiple functional modules, such as a surface manager, a media library, a 3D graphics processing library (such as Open GLES), a 2D graphics engine (such as SGL), etc.
[0162] Among them, the surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of multiple commonly used audio and video formats, as well as static image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.
[0163] The hardware abstraction layer 804 runs in the user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer.
[0164] The kernel layer 805 is a layer between hardware and software, and includes at least a display driver, a touch driver, an audio driver, and a sensor driver.
[0165] The kernel layer 805 is the core of the operating system of the electronic device. It is the first layer of software expansion based on hardware, provides the most basic functions of the operating system, is the basis of the operating system, is responsible for managing the system's processes, memory, device drivers, files and network systems, and determines the performance and stability of the system. For example, the kernel layer can determine the operating time of an application on a certain part of the hardware.
[0166] The kernel layer 805 includes programs closely related to the hardware, such as interrupt handlers, device drivers, etc., as well as basic, common, and high-frequency modules, such as clock management modules, process scheduling modules, etc., and also includes key data structures. The kernel layer can be set in the processor or solidified in the internal memory.
[0167] The hardware layer 806 includes the hardware of the electronic device, such as a display screen, buttons, a camera, etc.
[0168] See also Fig. 9 As shown, Fig. 9 A hardware architecture diagram of an electronic device provided in accordance with an embodiment of the present application.
[0169] The electronic device 10 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a Subscriber Identification Module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0170] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 10. In other embodiments of the present application, the electronic device 10 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0171] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0172] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0173] The processor 110 may also be provided with a memory for storing instructions and data. In one embodiment of the present application, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use instructions or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0174] In one embodiment of the present application, the processor 110 may include one or more interfaces. The interface may include an Inter-integrated Circuit (I2C) interface, an Inter-integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-Purpose Input / Output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and / or a Universal Serial Bus (USB) interface, etc.
[0175] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (Serial Data Line, SDA) and a serial clock line (Serial Clock Line, SCL). In one embodiment of the present application, the processor 110 may include multiple groups of I2C buses. The processor 110 can be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 can be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface to realize the touch function of the electronic device 10.
[0176] The I2S interface can be used for audio communication. In one embodiment of the present application, the processor 110 may include multiple I2S buses. The processor 110 may be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In one embodiment of the present application, the audio module 170 may transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call via a Bluetooth headset.
[0177] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In one embodiment of the present application, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In one embodiment of the present application, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0178] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In one embodiment of the present application, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example: the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In one embodiment of the present application, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0179] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In one embodiment of the present application, the processor 110 and the camera 193 communicate via the CSI interface to realize the shooting function of the electronic device 10. The processor 110 and the display screen 194 communicate via the DSI interface to realize the display function of the electronic device 10.
[0180] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In one embodiment of the present application, the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0181] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a MicroUSB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 10, and can also be used to transfer data between the electronic device 10 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices 10, such as AR devices, etc.
[0182] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 10. In other embodiments of the present application, the electronic device 10 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0183] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 10. While the charging management module 140 is charging the battery 142, it may also power the electronic device 10 through the power management module 141.
[0184] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0185] The wireless communication function of the electronic device 10 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0186] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 10 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0187] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 10. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (Low Noise Amplifier, LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In one embodiment of the present application, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In one embodiment of the present application, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0188] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In one embodiment of the present application, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be arranged in the same device as the mobile communication module 150 or other functional modules.
[0189] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 10. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0190] In one embodiment of the present application, the antenna 1 of the electronic device 10 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 10 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include Global System For Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the Beidou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS) and / or the Satellite Based Augmentation System (SBAS).
[0191] The electronic device 10 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor that connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0192] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode or an active matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, Microled, Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In one embodiment of the present application, the electronic device 10 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0193] The electronic device 10 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0194] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise and brightness of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In one embodiment of the present application, ISP can be set in camera 193.
[0195] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In one embodiment of the present application, the electronic device 10 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0196] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 10 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0197] The video codec is used to compress or decompress digital video. The electronic device 10 may support one or more video codecs. Thus, the electronic device 10 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0198] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 10 can be realized, such as: image recognition, face recognition, information prompts, voice recognition, text understanding, etc.
[0199] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0200] Random access memory may include static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM, for example, the fifth generation DDRSDRAM is generally referred to as DDR5SDRAM), etc.;
[0201] Non-volatile memory may include disk storage devices and flash memory.
[0202] Flash memory can be divided into NORFLASH, NANDFLASH, 3D NANDFLASH, etc. according to the operating principle. It can be divided into single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level. It can be divided into universal flash storage (UFS), embedded Multi Media Card (eMMC), etc. according to the storage specification.
[0203] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.
[0204] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .
[0205] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 10. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.
[0206] The internal memory 121 or the external memory interface 120 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 110. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 110, the screen display detection method executed on the electronic device 10 in the above embodiment can be implemented to implement the screen display detection function of the electronic device 10.
[0207] The electronic device 10 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0208] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In one embodiment of the present application, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0209] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 10 can listen to music or listen to a hands-free call through the speaker 170A.
[0210] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 10 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0211] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 10 can be provided with at least one microphone 170C. In other embodiments, the electronic device 10 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 10 can also be provided with three, four or more microphones 170C to realize the collection of sound signals, noise reduction, identification of sound sources, and realization of directional recording function, etc.
[0212] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm Open Mobile Terminal Platform (OMTP) standard interface or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0213] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 10 may receive key input and generate key signal input related to user settings and function control of the electronic device 10.
[0214] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0215] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0216] The SIM card interface 195 is used to connect the SIM card. The SIM card can be connected to and separated from the electronic device 10 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195. The electronic device 10 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 10 interacts with the network through the SIM card to implement functions such as calls and data communications. In one embodiment of the present application, the electronic device 10 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 10 and cannot be separated from the electronic device 10. The embodiment of the present application also provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on the electronic device 10, the electronic device 10 executes the above-mentioned related method steps to implement the method in the above-mentioned embodiment.
[0217] The embodiments of the present application also provide a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the method in the above-mentioned embodiments.
[0218] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip executes the methods in the above-mentioned method embodiments.
[0219] Among them, the terminal device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0220] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0221] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0222] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0223] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0224] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store program code.
[0225] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. A question-answering method, characterized in that: The method comprises: In response to a received user question, searching a first database for a preset question matching the user question, wherein the first database pre-stores a plurality of question-answer pairs; If the first database does not include the matching preset question, determining the question type of the user question; If the question type is a preset type, obtaining a search result matching the user question from a second database, wherein the preset type is used to indicate a type related to a business, and the second database pre-stores information related to the business; Based on the user question and the search result, a first response model is used to obtain a response content for the user question, the first response model is obtained by training with business-related texts, and the response content is used to indicate information related to the business.
2. The question-answering method according to claim 1, characterized in that: The method further comprises: Encoding the user question to obtain a feature vector of the user question; Determining the matching degree between the user question and the preset question according to the feature vector and the vector corresponding to the preset question; If the highest matching degree is greater than a preset matching degree, determining that the first database includes the matching preset question; If the highest matching degree is less than or equal to the preset matching degree, it is determined that the first database does not include the matching preset question.
3. The question-answering method according to claim 2, characterized in that: The method further comprises: If the first database includes the matching preset question, the reply content of the user question is obtained from the first database based on the answer corresponding to the matching preset question.
4. The question-answering method according to claim 1, characterized in that: Determining the type of the user's question includes: Acquire a first question matching the user question from a first question set, and acquire a second question matching the user question from a second question set; Generate a prompt text for indicating the type of question according to the user question, the first question and the second question; Based on the prompt text, the question type is obtained by using a classification model, and the classification model is obtained by training question samples and the annotated types of the question samples.
5. The question-answering method according to claim 1, characterized in that: The step of obtaining a reply content of the user question based on the user question and the search result by using a first reply model includes: splicing the user question and the search result to obtain splicing information; If the length of the concatenated information is greater than a preset length, extracting the related information of the user question from the search results; The reply content is obtained using the first reply model according to the user question and the associated information.
6. The question-answering method according to claim 1, characterized in that: The method further comprises: If the question type is other than the preset type, based on the user question, a second reply model is used to determine the reply content of the user question, the other type includes a chat type, and the second reply model is obtained by training the chat-type conversation text.
7. The question-answering method according to claim 1 or 6, characterized in that: The method further comprises: In response to the user's operation on the reply content, the corresponding relationship between the user question and the reply content is stored in the first database.
8. The question-answering method according to claim 7, characterized in that: The storing the corresponding relationship between the user question and the reply content in the first database includes: Encoding the user question to obtain a first vector, and encoding the reply content to obtain a second vector; The corresponding relationship between the first vector and the second vector is stored in the first database.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor: The memory is used to store program instructions; The processor is used to read and execute the program instructions stored in the memory. When the program instructions are executed by the processor, the electronic device executes the question-and-answer method as described in any one of claims 1 to 8.
10. A computer storage medium, characterized in that: The computer storage medium stores program instructions, and when the program instructions are executed on an electronic device, a processor of the electronic device executes the question-answering method according to any one of claims 1 to 8.