Intelligent question answering method and device, storage medium and electronic device
By using intelligent question answering methods and model fusion technology to determine the most similar answers to questions from a knowledge base, the problem of information access difficulties for agricultural planters has been solved, thus improving planting results.
Patent Information
- Application Number
- CN202310318688.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2043-03-28
AI Technical Summary
Agricultural growers have low levels of education and find it difficult to obtain effective information from the internet, resulting in poor agricultural planting results. They also lack open-source agricultural Q&A data and related research support.
This paper proposes an intelligent question answering method that uses a first model and a second model to identify the first question with the highest similarity to the target question from the knowledge base and returns the corresponding answer. It combines TF-IDF and Sentence-BERT models for information retrieval and answer extraction to construct a knowledge base for the agricultural planting field.
By providing the most similar answers quickly and accurately, it helps agricultural growers solve production problems and improves agricultural planting results.
Smart Images

Figure CN116340491B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and more specifically, to an intelligent question-answering method and apparatus, storage medium and electronic device. Background Technology
[0002] With the popularization of the internet and the development of artificial intelligence technology, the agricultural industry is also keeping pace with the trend and constantly integrating with the internet and artificial intelligence. However, the education level of the vast majority of agricultural planting workers in my country is relatively low, making it difficult for them to effectively find useful information from the internet. Moreover, due to the lack of open-source agricultural question-and-answer data and the limited research by domestic and foreign scholars on agricultural planting, it is difficult to help agricultural planting workers better solve planting and production problems, resulting in poor agricultural planting effects.
[0003] There is currently no effective solution to the problem that related technologies are insufficient to help agricultural growers better solve planting and production problems, resulting in poor agricultural planting results. Summary of the Invention
[0004] The main purpose of this application is to provide an intelligent question-answering method, device, storage medium, and electronic device to solve the problem in related technologies that it is difficult to help agricultural growers better solve planting and production problems, resulting in poor agricultural planting results.
[0005] To achieve the above objectives, according to one aspect of this application, an intelligent question-answering method is provided. The method includes: receiving a target question sent by a target object, wherein the target question is related to agricultural planting; based on the target question, and combining a first model and a second model, determining N first questions from a first question set in a knowledge base, wherein the knowledge base stores M first questions related to agricultural planting and answers corresponding to each first question, the first question set including at least M first questions, M greater than or equal to N, and M and N are both positive integers; determining the first question with the highest similarity to the target question from the N first questions; determining a target answer based on the knowledge base, and returning the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0006] Further, based on the target question, and combining the first model and the second model, determining N first questions from the first question set in the knowledge base includes: converting the target question into a first vector using the first model, and converting M first questions into a first set using the first model, wherein the first set includes at least M second vectors; calculating the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; converting the target question into a third vector using the second model, and converting M first questions into a second set using the second model, wherein the second set includes at least M fourth vectors; calculating the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and determining N first questions from the first question set in the knowledge base based on the first similarity set and the second similarity set.
[0007] Further, determining N first questions from the first question set of the knowledge base based on the first similarity set and the second similarity set includes: determining the first weight corresponding to the first model and the second weight corresponding to the second model; calculating the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; sorting the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base to obtain a sorting result; and determining N first questions based on the sorting result.
[0008] Further, converting the target problem into a first vector using the first model includes: performing word segmentation on the target problem to obtain K first words, where K is a positive integer; determining S stop words from the K first words, where K is greater than S and S is a positive integer; removing the S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; and inputting the T first words after removing stop words into the first model for vectorization processing to obtain the first vector.
[0009] Further, determining the first question with the highest similarity to the target question from N first questions includes: performing character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; performing character segmentation on the target question to obtain P second characters, where P is a positive integer; concatenating the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; inputting each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vectors are vectors in the target layer of the third model, the sixth vectors are vectors corresponding to the target characters, the target characters are characters in the target positions of the target statements, U and V are both greater than N, and U and V are both positive integers; and determining the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0010] Further, based on U fifth vectors and V sixth vectors, determining the first question with the highest similarity to the target question from N first questions includes: inputting each sixth vector into a fourth model for processing to obtain Z seventh vectors and X eighth vectors, where the eighth vectors are vectors in the opposite direction to the seventh vectors, and Z and X are both positive integers; concatenating the U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, where the target matrix set includes at least N target matrices; inputting each target matrix into a fifth model for calculation to obtain N fourth similarities, where the fourth similarity is the similarity between the first question among the N first questions and the target question; determining the target similarity from the N fourth similarities, and determining the first question corresponding to the target similarity from the N first questions, where the target similarity is the largest similarity among the N fourth similarities; and selecting the first question corresponding to the target similarity as the first question with the highest similarity to the target question.
[0011] Furthermore, before determining N first questions from the first question set of the knowledge base based on the target question and combining the first model and the second model, the method further includes: determining a target website, wherein the target website is a website related to agricultural planting; obtaining the URL information corresponding to the target webpage in the target website; obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; deleting R and Y first question-and-answer data from the Q first question-and-answer data to obtain M deleted first question-and-answer data, wherein the first question-and-answer data in the R first question-and-answer data are null values, the first question-and-answer data in the Y first question-and-answer data are question-and-answer data unrelated to agricultural planting, and the M deleted first question-and-answer data include at least M first questions and the answer corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; storing the M deleted first question-and-answer data to obtain the knowledge base.
[0012] Further, obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage includes: determining the content information of the target webpage based on the URL information corresponding to the target webpage; obtaining G first question-and-answer data and F address information corresponding to the first webpages based on the content information of the target webpages, wherein the first webpages are webpages on the target website other than the target webpage, G is less than Q, and G and F are both positive integers; determining a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; obtaining H first question-and-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and summarizing the G first question-and-answer data and the H first question-and-answer data to obtain Q first question-and-answer data.
[0013] To achieve the above objectives, according to another aspect of this application, an intelligent question-answering device is provided. The device includes: a first receiving unit, configured to receive a target question sent by a target object, wherein the target question is related to agricultural planting; a first determining unit, configured to determine N first questions from a first question set in a knowledge base based on the target question and in conjunction with a first model and a second model, wherein the knowledge base stores M first questions related to agricultural planting and answers corresponding to each first question, the first question set including at least M first questions, M being greater than or equal to N, and M and N being positive integers; a second determining unit, configured to determine the first question with the highest similarity to the target question from the N first questions; and a first processing unit, configured to determine a target answer based on the knowledge base and return the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0014] Further, the first determining unit includes: a first conversion module, configured to convert the target question into a first vector using the first model, and to convert M first questions into a first set using the first model, wherein the first set includes at least M second vectors; a first calculation module, configured to calculate the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; a second conversion module, configured to convert the target question into a third vector using the second model, and to convert the M first questions into a second set using the second model, wherein the second set includes at least M fourth vectors; a second calculation module, configured to calculate the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and a first determining module, configured to determine N first questions from the first question set of the knowledge base based on the first similarity set and the second similarity set.
[0015] Further, the first determining module includes: a first determining submodule, used to determine the first weight corresponding to the first model and the second weight corresponding to the second model respectively; a first calculation submodule, used to calculate the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; a first ranking submodule, used to rank the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base, and obtain a ranking result; and a second determining submodule, used to determine N first questions based on the ranking result.
[0016] Further, the first conversion module includes: a first processing submodule, used to perform word segmentation on the target problem to obtain K first words, where K is a positive integer; a third determining submodule, used to determine S stop words from the K first words, where K is greater than S and S is a positive integer; a first removal submodule, used to remove the S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; and a first input submodule, used to input the T first words after removing stop words into the first model for vectorization processing to obtain the first vector.
[0017] Further, the second determining unit includes: a first processing module, used to perform character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; a second processing module, used to perform character segmentation on the target question to obtain P second characters, where P is a positive integer; a third processing module, used to concatenate the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; a first input module, used to input each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vectors are vectors in the target layer of the third model, the sixth vectors are vectors corresponding to the target characters, the target characters are characters in the target positions of the target statements, U and V are both greater than N, and U and V are both positive integers; and a second determining module, used to determine the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0018] Further, the determining module includes: a second input submodule, used to input each sixth vector into the fourth model for processing to obtain Z seventh vectors and X eighth vectors, wherein the eighth vectors are vectors in the opposite direction to the seventh vectors, and Z and X are both positive integers; a second processing submodule, used to concatenate U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, wherein the target matrix set includes at least N target matrices; a third input submodule, used to input each target matrix into the fifth model for calculation processing to obtain N fourth similarities, wherein the fourth similarity is the similarity between the first question among the N first questions and the target question; a fourth determining submodule, used to determine the target similarity from the N fourth similarities and determine the first question corresponding to the target similarity from the N first questions, wherein the target similarity is the largest similarity among the N fourth similarities; and a fifth determining submodule, used to take the first question corresponding to the target similarity as the first question with the highest similarity to the target question.
[0019] Furthermore, the apparatus further includes: a third determining unit, configured to determine a target website before determining N first questions from the first question set of the knowledge base based on the target question and in combination with the first model and the second model, wherein the target website is a website related to agricultural planting; a first obtaining unit, configured to obtain the URL information corresponding to the target webpage in the target website; a fourth determining unit, configured to obtain Q first question-and-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; a first deleting unit, configured to delete R first question-and-answer data and Y first question-and-answer data from the Q first question-and-answer data to obtain M deleted first question-and-answer data, wherein the first question-and-answer data in the R first question-and-answer data are null values, the first question-and-answer data in the Y first question-and-answer data are question-and-answer data unrelated to agricultural planting, and the M deleted first question-and-answer data include at least M first questions and answers corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; and a first storage unit, configured to store the M deleted first question-and-answer data to obtain the knowledge base.
[0020] Further, the determining unit includes: a third determining module, used to determine the content information of the target webpage based on the URL information corresponding to the target webpage; a first obtaining module, used to obtain G first question-and-answer data and F address information corresponding to first webpages based on the content information of the target webpage, wherein the first webpages are webpages other than the target webpage in the target website, G is less than Q, and G and F are both positive integers; a fourth determining module, used to determine a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; a second obtaining module, used to obtain H first question-and-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and a fourth processing module, used to summarize and process the G first question-and-answer data and H first question-and-answer data to obtain Q first question-and-answer data.
[0021] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is provided, the storage medium storing a program, wherein the program executes the intelligent question-answering method described in any of the above claims.
[0022] To achieve the above objectives, according to another aspect of this application, an electronic device is provided, the electronic device including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the intelligent question-answering method described in any one of the above.
[0023] This application employs the following steps: receiving a target question sent by a target object, wherein the target question is related to agricultural planting; based on the target question, and combining a first model and a second model, determining N first questions from a first question set in a knowledge base, wherein the knowledge base stores M first questions related to agricultural planting and the corresponding answers for each first question, wherein the first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers; determining the first question with the highest similarity to the target question from the N first questions; determining the target answer based on the knowledge base, and returning the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question, thereby solving the problem in related technologies that it is difficult to help agricultural planting personnel better solve planting and production problems, resulting in poor agricultural planting effects. By sending a target question based on the target object, and combining the first model and the second model, N first questions are determined from the first question set in the knowledge base. The first question with the highest similarity to the target question is then selected from the N first questions. Based on the knowledge base, the target answer corresponding to the first question with the highest similarity to the target question is determined, and the target answer is returned to the target object. This can help agricultural planters better solve planting and production problems, thereby improving the effect of agricultural planting. Attached Figure Description
[0024] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0025] Figure 1 This is a flowchart of the intelligent question-answering method provided according to the embodiments of this application;
[0026] Figure 2 This is a flowchart of the information retrieval algorithm based on model fusion in the embodiments of this application;
[0027] Figure 3 This is a flowchart of the RoBERTa-based answer extraction algorithm in the embodiments of this application;
[0028] Figure 4 This is a flowchart of an optional intelligent question-answering method provided according to an embodiment of this application;
[0029] Figure 5 This is a schematic diagram of an intelligent question-answering device provided according to an embodiment of this application;
[0030] Figure 6 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0031] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0032] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0033] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0034] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.
[0035] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:
[0036] Question answering system: A question answering system is an automated machine that can answer natural language questions. It can accept relatively natural question formats such as text or voice, and after analysis and processing, give friendly, concise and accurate answers.
[0037] TF-IDF (term frequency–inverse document frequency) is a commonly used weighting technique for information retrieval and data mining. TF stands for Term Frequency, and IDF stands for Inverse Document Frequency.
[0038] BM25: Okapi BM25 is an algorithm used to evaluate the relevance between search terms and documents, based on a probabilistic retrieval model.
[0039] BERT: Bidirectional Encoder Representations from Transformers, is a pre-trained language model that can be used for many natural language processing tasks, including language modeling, text classification, question answering systems, etc.
[0040] RoBERTa: A Robustly Optimized BERT Pretraining Approach, is an improved version of BERT.
[0041] SOTA: an abbreviation for State of the Arts, refers to the best-performing model in a particular field.
[0042] NLP: Natural Language Processing (NLP) is a discipline that studies language problems in human-computer interaction.
[0043] Token Embedding: Token encoding, which converts a sequence into a string of characters / words and their corresponding character / word vectors.
[0044] Segment Embedding: Used to distinguish between two given sequences.
[0045] Position Embedding: Used to mark the position of a word / character in a sequence.
[0046] BiGRU: bidirectional gated recurrent unit.
[0047] TextCNN model: Proposed by Yoon Kim, it is a text classification model based on convolutional neural networks.
[0048] Requests: An HTTP (Hypertext Transfer Protocol) library based on urllib (a built-in standard Python library for handling network requests) and developed under the Apache2 License (a free software license). It is highly encapsulated from built-in Python modules and can simulate browser requests.
[0049] The present invention will now be described in conjunction with preferred implementation steps. Figure 1This is a flowchart of the intelligent question-answering method provided according to the embodiments of this application, such as... Figure 1 As shown, the method includes the following steps:
[0050] Step S101: Receive the target question sent by the target object, wherein the target question is a question related to agricultural planting.
[0051] For example, a user (the target audience mentioned above) can input their desired questions about agricultural planting (the target questions mentioned above) into the question-and-answer system. That is, the user could be an agricultural planting worker, and the question-and-answer system can first receive the questions about agricultural planting sent by the agricultural planting worker. For example, the question sent by the agricultural planting worker to the question-and-answer system could be: How to prevent and control rice bakanae disease.
[0052] Step S102: Based on the target problem, and combining the first model and the second model, determine N first problems from the first problem set in the knowledge base. The knowledge base is used to store M first problems related to agricultural planting and the answers corresponding to each first problem. The first problem set includes at least M first problems, M is greater than or equal to N, and M and N are both positive integers.
[0053] For example, a question-answering system can consist of three main parts: question analysis, information retrieval, and answer extraction. The question analysis part mainly processes the user's input question by segmenting it into words and removing stop words; the information retrieval part retrieves questions from the knowledge base to obtain the Top-K most similar questions; the answer extraction part further matches and filters based on the Top-K, returning the questions with the highest similarity and their corresponding answers.
[0054] The core of the information retrieval part is to ensure that the candidate question set contains as many questions in the knowledge base as possible that are similar to the user input. This is because if the candidate question set does not contain questions similar to the user input, the answer extraction part will not return the correct answer. Currently, the most commonly used retrieval algorithms are keyword-based TF-IDF and BM25.
[0055] However, in the information retrieval part of question-answering systems, the commonly used algorithms are keyword-based TF-IDF and BM25 retrieval algorithms. These algorithms can retrieve information based on the surface features of the text. Their biggest advantage is that the algorithm is simple and computationally efficient, but they cannot solve the problems of synonyms and polysemy.
[0056] Therefore, to address the limitations of TF-IDF and BM25 algorithms in resolving synonym and polysemous word issues, this embodiment employs a model fusion-based information retrieval algorithm. This algorithm can quickly retrieve the Top-K most similar questions within a short time, narrowing down the range of possible answers. Furthermore, the aforementioned model fusion can utilize a TF-IDF model and a Sentence-BERT model (used to convert text into vectors, which can be used to extract semantic features from user questions) to calculate the text similarity between each question in the knowledge base and the user's input question. Then, based on the calculated text similarity, the Top-K most similar questions (the aforementioned N first questions) are obtained from multiple agricultural planting questions in the knowledge base (the M first questions mentioned above), and these Top-K most similar questions (the aforementioned N first questions) are used as a candidate question set.
[0057] Step S103: Determine the first question with the highest similarity to the target question from among the N first questions.
[0058] For example, the answer extraction part performs deep text matching between the user's question and the candidate question set from the information retrieval part. Then, it selects the question most likely to be similar to the user's question (the first question with the highest similarity to the target question) from the candidate question set (the N first questions mentioned above). Its design goal is to obtain the highest possible accuracy. With the introduction of pre-trained models, pre-trained models such as BERT and RoBERTa have achieved state-of-the-art (SOTA) performance in text matching tasks, significantly improving the accuracy of text matching compared to traditional neural networks.
[0059] Step S104: Based on the knowledge base, determine the target answer and return the target answer to the target object. The target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0060] For example, after selecting the question most likely to be similar to the user's question (the first question with the highest similarity to the target question) from the candidate question set (the N first questions mentioned above), the answer corresponding to the question most likely to be similar to the user's question (the first question with the highest similarity to the target question mentioned above) can be found in the knowledge base (the target answer mentioned above). Then, the answer found in the knowledge base is sent to the user (the target object mentioned above), and the user mentioned above can be an agricultural planting person.
[0061] It should be noted that this embodiment can be applied to scenarios where financial institutions provide financial services to agriculture and rural areas. Specifically, while providing farmers with financial services such as deposits and wealth management, financial institutions also pay particular attention to the development of planting. Therefore, the method provided in this embodiment, by leveraging artificial intelligence technology, offers farmers a quick and accurate way to solve planting problems, thereby helping them obtain more economic income.
[0062] Through the steps S101 to S104 described above, based on the target question sent to the target object, and combined with the first model and the second model, N first questions are determined from the first question set in the knowledge base. The first question with the highest similarity to the target question is then determined from the N first questions. Based on the knowledge base, the target answer corresponding to the first question with the highest similarity to the target question is determined and returned to the target object. This can help agricultural planters better solve planting and production problems, thereby improving the effectiveness of agricultural planting.
[0063] Optionally, in the intelligent question-answering method provided in this application embodiment, before determining N first questions from the first question set of the knowledge base based on the target question and in combination with the first model and the second model, the method further includes: determining a target website, wherein the target website is a website related to agricultural planting; obtaining the URL information corresponding to the target webpage in the target website; obtaining Q first question-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; deleting R first question-answer data and Y first question-answer data from the Q first question-answer data to obtain M deleted first question-answer data, wherein the first question-answer data in the R first question-answer data is null, the first question-answer data in the Y first question-answer data is question-answer data unrelated to agricultural planting, and the M deleted first question-answer data includes at least M first questions and the answer corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; and storing the M deleted first question-answer data to obtain a knowledge base.
[0064] For example, constructing a knowledge base in the field of agricultural planting (the knowledge base mentioned above) can be divided into the following steps:
[0065] (1) Data acquisition: First, obtain websites about agricultural knowledge learning and Q&A from the Internet, then obtain the URLs of the web pages on the websites, and then obtain multiple Q&A data about agricultural planting based on the obtained URL information (the above Q first Q&A data);
[0066] (2) Data preprocessing: Delete the data containing null values (the R first question and answer data mentioned above) and the question and answer data that are not related to agricultural planting (the Y first question and answer data mentioned above) to obtain multiple question and answer data after deletion (the M deleted first question and answer data mentioned above);
[0067] (3) Data storage: After the data preprocessing is completed, the deleted question and answer data are stored in the form of question-answer to form a knowledge base.
[0068] The above approach allows for the rapid and accurate construction of a knowledge base containing multiple question-and-answer data sets.
[0069] Optionally, in the intelligent question-answering method provided in this application embodiment, obtaining Q first question-answer data based on the URL information corresponding to the target webpage includes: determining the content information of the target webpage based on the URL information corresponding to the target webpage; obtaining G first question-answer data and F address information corresponding to the first webpages based on the content information of the target webpages, wherein the first webpages are webpages other than the target webpage in the target website, G is less than Q, and G and F are both positive integers; determining a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; obtaining H first question-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and summarizing the G first question-answer data and H first question-answer data to obtain Q first question-answer data.
[0070] For example, when constructing a knowledge base for the agricultural planting field (the aforementioned knowledge base), the data acquisition steps can be as follows:
[0071] Since there are numerous websites on the internet for learning about agricultural knowledge and answering questions, this embodiment utilizes Python to crawl the question-and-answer data from agricultural planting websites. The crawling process is as follows:
[0072] Step 1: Set the initial URL (the URL of the target webpage mentioned above). There can be one or more initial URLs.
[0073] Step 2: Crawl the webpage content of the URL. The Requests package can be used to obtain the webpage content (the content information of the target webpage mentioned above). The webpage content is actually an HTML file (Hypertext Markup Language file), which contains not only question-and-answer data but also various tags;
[0074] Step 3: Parse the webpage content. The webpage content obtained by the Requests packet contains a lot of useless data. Extract the useful data and persist it, including question and answer data (G first question and answer data) and URLs to be crawled (F URLs corresponding to the first webpages).
[0075] Step 4: Add the new URL to the URL queue to be crawled. Set up a list of crawled data. This list can be used to determine whether the current URL is an uncrawled URL address. If it is a new URL, add it to the URL queue; otherwise, discard it.
[0076] Step 5: Repeat the above process.
[0077] The above method can quickly and accurately obtain multiple Q&A data related to agricultural planting.
[0078] Optionally, in the intelligent question-answering method provided in this application embodiment, determining N first questions from the first question set in the knowledge base based on the target question and combining the first model and the second model includes: converting the target question into a first vector using the first model, and converting M first questions into a first set using the first model, wherein the first set includes at least M second vectors; calculating the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; converting the target question into a third vector using the second model, and converting M first questions into a second set using the second model, wherein the second set includes at least M fourth vectors; calculating the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and determining N first questions from the first question set in the knowledge base based on the first similarity set and the second similarity set.
[0079] Optionally, in the intelligent question-answering method provided in this application embodiment, determining N first questions from the first question set of the knowledge base based on the first similarity set and the second similarity set includes: determining the first weight corresponding to the first model and the second weight corresponding to the second model respectively; calculating the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; sorting the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base to obtain the sorting result; and determining N first questions based on the sorting result.
[0080] For example, the TF-IDF algorithm has the advantages of simple computation and high efficiency, and can capture keyword information, but it cannot handle synonyms and polysemy well. Sentence-BERT, a Siamese network based on BERT, can extract deep semantic information of sentences from context, thus compensating for the shortcomings of the TF-IDF algorithm, but it may overlook some surface information. Combining the two can achieve a complementary effect. Both TF-IDF and Sentence-BERT algorithms calculate text similarity by first converting the text into vectors and then using cosine similarity to calculate the vector distance model parameters. Furthermore, Figure 2 This is a flowchart of the information retrieval algorithm based on model fusion in the embodiments of this application, such as... Figure 2 As shown, the detailed process is as follows:
[0081] (1) Process user questions, including word segmentation, stop word removal and vectorization. Assume that the TF-IDF model and the Sentence-BERT model convert user questions into vectors respectively; similarly, each question in the corpus is represented by a vector using the TF-IDF model and the Sentence-BERT model.
[0082] (2) Match user questions with questions in the corpus. During matching, cosine similarity is used to calculate similarity scores, denoted as Score (TF-IDF) and Score (Sentence-BERT), respectively. Assume that the vector representations of X and Y are (x1, x2, ..., x...). n ) and (y1,y2,…,y n The formula for calculating cosine similarity is shown in equation (1);
[0083]
[0084] (3) The scores of the two algorithms are weighted and summed according to the set weights to obtain the comprehensive similarity score. avg The formula for calculating the overall score is shown in equation (2). The values of weights λ1 and λ2 are in the range [0, 1] and their sum is 1, as shown in equation (3). In equation (3), λ1 represents the weight corresponding to the TF-IDF model, and λ2 represents the weight corresponding to the Sentence-BERT model. When assigning weights to the two models, the model with better individual experimental performance is usually given a larger weight, and the model with poor individual experimental performance is given a smaller weight.
[0085] Score avg =λ1·Score(TF-IDF)+λ2·Score(Sentence-BERT) (2)
[0086] λ1+λ2=1 (3)
[0087] (4) Sort the scores in descending order based on the overall score;
[0088] (5) Select Top-K as the candidate problem set and return it.
[0089] In summary, the model fusion-based information retrieval algorithm in this embodiment can quickly retrieve the Top-K results with high similarity in a short time, thereby narrowing the range of possible answers. At the same time, it can also handle the problems of synonyms and polysemy that cannot be solved by TF-IDF and BM25 algorithms in related technologies.
[0090] Optionally, in the intelligent question-answering method provided in this application embodiment, converting the target question into a first vector through a first model includes: performing word segmentation on the target question to obtain K first words, where K is a positive integer; determining S stop words from the K first words, where K is greater than S and S is a positive integer; removing the S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; and inputting the T first words after removing stop words into the first model for vectorization processing to obtain a first vector.
[0091] For example, the first model mentioned above can be a TF-IDF model. When using the TF-IDF model to convert the user's input question into a vector, the user's input question can first be segmented into words, then stop words can be removed from the segmented words (the K first words mentioned above), and then the words without stop words can be input into the TF-IDF model for vector representation.
[0092] The above method can quickly and accurately convert user-input questions into vectors.
[0093] Optionally, in the intelligent question-answering method provided in this application embodiment, determining the first question with the highest similarity to the target question from N first questions includes: performing character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; performing character segmentation on the target question to obtain P second characters, where P is a positive integer; performing concatenation on the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; inputting each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vector is a vector in the target layer of the third model, the sixth vector is a vector corresponding to the target character, the target character is a character in the target position of the target statement, U and V are both greater than N, and U and V are both positive integers; and determining the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0094] Optionally, in the intelligent question-answering method provided in this application embodiment, determining the first question with the highest similarity to the target question from N first questions based on U fifth vectors and V sixth vectors includes: inputting each sixth vector into a fourth model for processing to obtain Z seventh vectors and X eighth vectors, where the eighth vector is a vector in the opposite direction to the seventh vector, and Z and X are both positive integers; concatenating the U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, where the target matrix set includes at least N target matrices; inputting each target matrix into a fifth model for calculation to obtain N fourth similarities, where the fourth similarity is the similarity between the first question among the N first questions and the target question; determining the target similarity from the N fourth similarities, and determining the first question corresponding to the target similarity from the N first questions, where the target similarity is the largest similarity among the N fourth similarities; and taking the first question corresponding to the target similarity as the first question with the highest similarity to the target question.
[0095] For example, to address the issue of semantic information loss in pre-trained models such as BERT and RoBERTa, an answer extraction algorithm based on RoBERTa was proposed. This algorithm performs deep matching between the user's question and the Top-K candidate question set to find the question most similar to the user's input and returns its answer.
[0096] For example, in this embodiment, a RoBERTa-BiGRU-TextCNN network model is constructed, and the structure of this model consists of four layers: an input layer, an encoding layer, an information extraction layer, and a matching layer. Furthermore, Figure 3This is a flowchart of the RoBERTa-based answer extraction algorithm in this embodiment of the application. The structure of the RoBERTa-BiGRU-TextCNN network model constructed in this embodiment is as follows: Figure 3 As shown.
[0097] (1) Input layer
[0098] The input layer operates on the original text to be matched, ensuring that the processed text representation conforms to the input requirements of the encoding layer. Suppose the sentence pair to be matched is {How to prevent and control rice bakanae disease, what are the prevention and control measures for rice bakanae disease?}, the sentence pair is segmented into characters and denoted as X = {x1, x2, ... x}. m}, Y = {y1, y2, ..., y n Then, the two sentences X and Y are concatenated using the special markers “[CLS]” and “[SEP]”, and the concatenation formula is shown in equation (4).
[0099] S = {[CLS], x1, x2, ..., x} m ,[SEP],y1,y2,...,y n ,[SEP]} (4)
[0100] Here, "[CLS]" can be used as a classification marker, the first "[SEP]" is used to separate X and Y, the second "[SEP]" is the end marker, m is the length of sentence X, and n is the length of sentence Y.
[0101] (2) Coding layer
[0102] The encoding layer uses the RoBERTa-wwm-ext model. After performing Token Embedding, Segment Embedding, and Position Embedding operations, it retains the [CLS] vectors of all even-numbered layers and the semantic vectors of tokens at positions other than [CLS] in the last layer, denoted as T. even T other See equations (5) and (6).
[0103] T even ={T cls2 ,T cls4 ,T cls6 ,T cls8 ,T cls10 ,T cls12} (5)
[0104] T other ={T x1 ,T x2 ,...,T sep ,T y1 ,Ty2 ,...,T sep ,...} (6)
[0105] (3) Information extraction layer
[0106] In addition to [CLS], the last layer of the RoBERTa model outputs vectors at multiple other positions. This layer uses a BiGRU network model to extract semantic information from the vectors at other positions besides [CLS] in the last layer. The input of BiGRU is the vectors at other positions besides [CLS] output by the encoding layer, and its output is the output of the last time step in both directions, as shown in Equation (7).
[0107]
[0108] (4) Matching layer
[0109] The vector at the [CLS] position output by the even-numbered encoder layer and the output vectors in both directions of the BiGRU information extraction layer are concatenated. The concatenated feature matrix is denoted as V, as shown in Equation (8). Then, the feature matrix is fed into the TextCNN model, and after 1D convolution and 1D pooling, the text similarity is finally obtained through Softmax.
[0110]
[0111] The above scheme can utilize vectors from the highest level and other levels, as well as shallow vectors, to express a large amount of semantic information, thereby avoiding the loss of semantic information.
[0112] For example, a question-answering system comprises three main parts: question analysis, information retrieval, and answer extraction. The question analysis part mainly processes user input by segmenting it into words and removing stop words; the information retrieval part searches the knowledge base for questions to obtain the Top-K most similar ones to the user's question; the answer extraction part further matches and filters based on the Top-K, returning the questions with the highest similarity and their corresponding answers.
[0113] The core of the information retrieval part is to ensure that the candidate question set contains as many questions in the knowledge base as possible that are similar to the user input. This is because if the candidate question set does not contain questions similar to the user input, the answer extraction part will not return the correct answer. Currently, the most commonly used retrieval algorithms are keyword-based TF-IDF and BM25.
[0114] The answer extraction part performs deep text matching between the user's question and the candidate set from the information retrieval part, returning the question most likely similar to the user's question. Its design goal is to achieve the highest possible accuracy. With the advent of pre-trained models, BERT, RoBERTa, and other pre-trained models have achieved state-of-the-art (SOTA) performance in text matching tasks, significantly improving the accuracy of text matching compared to traditional neural networks.
[0115] However, question-answering systems in related technologies have the following drawbacks:
[0116] (1) Due to the lack of question-and-answer corpora and training data in the field of agricultural planting, there is relatively little research on question-and-answer systems for the field of agricultural planting.
[0117] (2) In the information retrieval part of the question-answering system, the commonly used algorithms are the keyword-based TF-IDF and BM25 retrieval algorithms. These algorithms can retrieve information based on the surface features of the text. Their biggest advantage is that the algorithm is simple and computationally efficient, but they cannot solve the problems of synonyms and polysemy.
[0118] (3) The core of the answer extraction part is to perform deep text matching. In the text matching task, pre-trained models such as BERT and RoBERTa only use the vector corresponding to the highest layer [CLS] position. The vectors at other positions and shallow vectors also express a lot of semantic information. Directly adopting the discard strategy will cause the loss of semantic information.
[0119] Therefore, in this embodiment, starting from the components of a question-answering system, a question-answering system for the agricultural planting field is constructed. First, a knowledge base for the agricultural planting field is built. Then, addressing the limitations of TF-IDF and BM25 algorithms in resolving synonyms and polysemy, an information retrieval algorithm based on model fusion is designed. This algorithm can quickly retrieve the Top-K most similar questions in a short time, narrowing the range of possible answers. To address the issue of semantic information loss in pre-trained models such as BERT and RoBERTa, an answer extraction algorithm based on RoBERTa is proposed. This algorithm performs deep matching between the user's question and the Top-K candidate questions, finding the question most similar to the user's input and returning its answer. Furthermore, Figure 4 This is a flowchart of an optional intelligent question-answering method provided according to an embodiment of this application; that is, the working principle of the intelligent question-answering method is as follows: Figure 4 As shown, it includes the following steps:
[0120] 1. Construct a knowledge base for the agricultural planting field
[0121] (1) Data Acquisition
[0122] There are numerous websites on the internet for learning about agriculture and answering questions. This article uses Python to crawl the question-and-answer data from agricultural planting websites. The crawling process is as follows:
[0123] Step 1: Set the initial URL. There can be one or more initial URLs;
[0124] Step 2: Crawl the webpage content from the URL. The Requests library can be used to retrieve the webpage content. The webpage content is actually an HTML file, containing not only question-and-answer data but also various tags.
[0125] Step 3: Parse the webpage content. The webpage content obtained by the Requests packet contains a lot of useless data. Extract the useful data and persist it, including the question and answer data and the corresponding URLs to be crawled;
[0126] Step 4: Add the new URL to the URL queue to be crawled. Set up a list of crawled data. This list can be used to determine whether the current URL is an uncrawled URL address. If it is a new URL, add it to the URL queue; otherwise, discard it.
[0127] Step 5: Repeat the above process.
[0128] (2) Data preprocessing
[0129] Delete question and answer data containing empty values or unrelated to agricultural planting; also clean up some question and answer data containing redundant HTML tags and attributes.
[0130] (3) Data is stored in the form of questions and answers after data preprocessing to form a knowledge base.
[0131] 2. Research on Information Retrieval Algorithms Based on Model Fusion
[0132] The TF-IDF algorithm boasts advantages such as computational simplicity and high efficiency, and can capture keyword information. However, it struggles with synonyms and polysemy. Sentence-BERT, a Siamese network based on BERT, can extract deep semantic information from sentences based on context, compensating for the shortcomings of TF-IDF. However, it may overlook some surface-level information. Combining the two can achieve a complementary effect. Both TF-IDF and Sentence-BERT algorithms calculate text similarity by first converting the text into vectors and then using cosine similarity to calculate the vector distance model parameters, such as... Figure 2 As shown, the detailed process is as follows:
[0133] (1) Process user questions, including word segmentation, stop word removal and vectorization. Assume that the TF-IDF model and the Sentence-BERT model convert user questions into vectors respectively; similarly, each question in the corpus is represented by a vector using the TF-IDF model and the Sentence-BERT model.
[0134] (2) Match user questions with questions in the corpus. During matching, cosine similarity is used to calculate similarity scores, denoted as Score (TF-IDF) and Score (Sentence-BERT), respectively. Assume that the vector representations of X and Y are (x1, x2, ..., x...). n ) and (y1,y2,…,y n The formula for calculating cosine similarity is shown in equation (1);
[0135]
[0136] (3) The scores of the two algorithms are weighted and summed according to the set weights to obtain the comprehensive similarity score. avg The formula for calculating the overall score is shown in equation (2). The values of weights λ1 and λ2 are in the range [0, 1] and their sum is 1, as shown in equation (3). In equation (3), λ1 represents the weight corresponding to the TF-IDF model, and λ2 represents the weight corresponding to the Sentence-BERT model. When assigning weights to the two models, the model with better individual experimental performance is usually given a larger weight, and the model with poor individual experimental performance is given a smaller weight.
[0137] Score avg =λ1·Score(TF-IDF)+λ2·Score(Sentence-BERT) (2)
[0138] λ1+λ2=1 (3)
[0139] (4) Sort the scores in descending order based on the overall score;
[0140] (5) Select Top-K as the candidate problem set and return it.
[0141] 3. Research on the answer extraction algorithm based on RoBERTa
[0142] BERT is a significant milestone in the field of NLP and is also of great importance to question answering systems. However, BERT also has certain limitations and shortcomings.
[0143] (1) A token (the basic unit of model input) in BERT is a word, but a word cannot fully express the semantics;
[0144] (2) The essence of the question answering system's answer extraction stage is to perform text matching. During the pre-training stage, BERT learns the logical relationship between sentences through the NSP (Next Sentence Predict) task. For the text matching task, although the semantics are similar, there is no contextual logical relationship. At this time, the NSP task will interfere with the text matching task.
[0145] (3) Softmax (normalized exponential function) cannot fully utilize semantic information;
[0146] (4) Only the vectors corresponding to the [CLS] position are retained, while the intermediate layer vectors and other semantic vectors are discarded, which will result in the loss of semantic information.
[0147] To address the aforementioned shortcomings, this embodiment proposes the RoBERTa-BiGRU-TextCNN network model. The model structure consists of four layers: an input layer, an encoding layer, an information extraction layer, and a matching layer. Its structure is as follows: Figure 3 As shown.
[0148] (1) Input layer
[0149] The input layer operates on the original text to be matched, ensuring that the processed text representation conforms to the input requirements of the encoding layer. Suppose the sentence pair to be matched is {How to prevent and control rice bakanae disease, what are the prevention and control measures for rice bakanae disease?}, the sentence pair is segmented into characters and denoted as X = {x1, x2, ... x}. m}, Y = {y1, y2, ..., y n Then, the two sentences X and Y are concatenated using the special markers “[CLS]” and “[SEP]”, and the concatenation formula is shown in equation (4).
[0150] S = {[CLS], x1, x2, ..., x} m ,[SEP],y1,y2,...,y n ,[SEP]} (4)
[0151] Here, "[CLS]" can be used as a classification marker, the first "[SEP]" is used to separate X and Y, the second "[SEP]" is the end marker, m is the length of sentence X, and n is the length of sentence Y.
[0152] (2) Coding layer
[0153] The encoding layer uses the RoBERTa-wwm-ext model. After performing Token Embedding, Segment Embedding, and Position Embedding operations, it retains the [CLS] vectors of all even-numbered layers and the semantic vectors of tokens at positions other than [CLS] in the last layer, denoted as T. even T other See equations (5) and (6).
[0154] T even ={T cls2 ,T cls4 ,T cls6 ,T cls8 ,T cls10 ,T cls12} (5)
[0155] T other ={T x1 ,T x2 ,...,T sep ,T y1 ,T y2 ,...,T sep ,...} (6)
[0156] (3) Information extraction layer
[0157] In addition to [CLS], the last layer of the RoBERTa model outputs vectors at multiple other positions. This layer uses a BiGRU network model to extract semantic information from the vectors at other positions besides [CLS] in the last layer. The input of BiGRU is the vectors at other positions besides [CLS] output by the encoding layer, and its output is the output of the last time step in both directions, as shown in Equation (7).
[0158]
[0159] (4) Matching layer
[0160] The vector at the [CLS] position output by the even-numbered encoder layer and the output vectors in both directions of the BiGRU information extraction layer are concatenated. The concatenated feature matrix is denoted as V, as shown in Equation (8). Then, the feature matrix is fed into the TextCNN model, and after 1D convolution and 1D pooling, the text similarity is finally obtained through Softmax.
[0161]
[0162] Therefore, by constructing an intelligent question-and-answer system for the agricultural planting industry, individual agricultural growers can be helped to better solve planting and production problems, thereby reaping greater economic benefits. From a societal perspective, this system responds to the national call to enhance agricultural competitiveness through modern technology, promotes the improvement of agricultural technology, accelerates the transformation of traditional agriculture to smart agriculture, and speeds up the construction of a modern agricultural powerhouse.
[0163] In summary, the intelligent question-answering method provided in this application embodiment receives a target question sent by a target object, wherein the target question is related to agricultural planting; based on the target question, and combining a first model and a second model, N first questions are determined from a first question set in a knowledge base, wherein the knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question, wherein the first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers; the first question with the highest similarity to the target question is determined from the N first questions; based on the knowledge base, the target answer is determined and returned to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question, which solves the problem in related technologies that it is difficult to help agricultural planting personnel better solve planting and production problems, resulting in poor agricultural planting effects. By sending a target question based on the target object, and combining the first model and the second model, N first questions are determined from the first question set in the knowledge base. The first question with the highest similarity to the target question is then selected from the N first questions. Based on the knowledge base, the target answer corresponding to the first question with the highest similarity to the target question is determined, and the target answer is returned to the target object. This can help agricultural planters better solve planting and production problems, thereby improving the effect of agricultural planting.
[0164] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0165] This application also provides an intelligent question-answering device. It should be noted that the intelligent question-answering device of this application can be used to execute the intelligent question-answering method provided in this application. The intelligent question-answering device provided in this application is described below.
[0166] Figure 5 This is a schematic diagram of an intelligent question-answering device according to an embodiment of this application. For example... Figure 5 As shown, the device includes: a first receiving unit 501, a first determining unit 502, a second determining unit 503, and a first processing unit 504.
[0167] Specifically, the first receiving unit 501 is used to receive the target question sent by the target object, wherein the target question is a question related to agricultural planting;
[0168] The first determining unit 502 is used to determine N first questions from the first question set in the knowledge base based on the target question and in combination with the first model and the second model. The knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question. The first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers.
[0169] The second determining unit 503 is used to determine the first question that is most similar to the target question from N first questions;
[0170] The first processing unit 504 is used to determine the target answer based on the knowledge base and return the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0171] In summary, the intelligent question-answering device provided in this application embodiment receives a target question sent by a target object through a first receiving unit 501, wherein the target question is a question related to agricultural planting; a first determining unit 502 determines N first questions from a first question set in a knowledge base based on the target question and in combination with a first model and a second model, wherein the knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question, the first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers; a second determining unit 503 determines the first question with the highest similarity to the target question from the N first questions; and a first processing unit 504 determines the target answer based on the knowledge base and returns the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question, thus solving the problem in related technologies that it is difficult to help agricultural planting personnel better solve planting and production problems, resulting in poor agricultural planting effects. By sending a target question based on the target object, and combining the first model and the second model, N first questions are determined from the first question set in the knowledge base. The first question with the highest similarity to the target question is then selected from the N first questions. Based on the knowledge base, the target answer corresponding to the first question with the highest similarity to the target question is determined, and the target answer is returned to the target object. This can help agricultural planters better solve planting and production problems, thereby improving the effect of agricultural planting.
[0172] Optionally, in the intelligent question-answering device provided in this application embodiment, the first determining unit includes: a first conversion module, configured to convert a target question into a first vector through a first model, and convert M first questions into a first set through the first model, wherein the first set includes at least M second vectors; a first calculation module, configured to calculate the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; a second conversion module, configured to convert a target question into a third vector through a second model, and convert M first questions into a second set through the second model, wherein the second set includes at least M fourth vectors; a second calculation module, configured to calculate the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and a first determining module, configured to determine N first questions from a first question set in the knowledge base based on the first similarity set and the second similarity set.
[0173] Optionally, in the intelligent question-answering device provided in this application embodiment, the first determining module includes: a first determining submodule, used to determine the first weight corresponding to the first model and the second weight corresponding to the second model; a first calculation submodule, used to calculate the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; a first sorting submodule, used to sort the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base, and obtain a sorting result; and a second determining submodule, used to determine N first questions based on the sorting result.
[0174] Optionally, in the intelligent question-answering device provided in this application embodiment, the first conversion module includes: a first processing submodule, used to perform word segmentation processing on the target question to obtain K first words, where K is a positive integer; a third determining submodule, used to determine S stop words from the K first words, where K is greater than S and S is a positive integer; a first removal submodule, used to remove S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; and a first input submodule, used to input the T first words after removing stop words into a first model for vectorization processing to obtain a first vector.
[0175] Optionally, in the intelligent question-answering device provided in this application embodiment, the second determining unit includes: a first processing module, used to perform character segmentation processing on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; a second processing module, used to perform character segmentation processing on the target question to obtain P second characters, where P is a positive integer; a third processing module, used to perform concatenation processing on the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; a first input module, used to input each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vector is a vector in the target layer of the third model, the sixth vector is a vector corresponding to the target character, the target character is a character in the target position of the target statement, U and V are both greater than N, and U and V are both positive integers; and a second determining module, used to determine the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0176] Optionally, in the intelligent question-answering device provided in this application embodiment, the determining module includes: a second input submodule, used to input each sixth vector into a fourth model for processing to obtain Z seventh vectors and X eighth vectors, wherein the eighth vector is a vector with the opposite direction to the seventh vector, and Z and X are both positive integers; a second processing submodule, used to concatenate U fifth vectors, Z seventh vectors and X eighth vectors to obtain a target matrix set, wherein the target matrix set includes at least N target matrices; a third input submodule, used to input each target matrix into a fifth model for calculation processing to obtain N fourth similarities, wherein the fourth similarity is the similarity between the first question among the N first questions and the target question; a fourth determining submodule, used to determine the target similarity from the N fourth similarities and determine the first question corresponding to the target similarity from the N first questions, wherein the target similarity is the largest similarity among the N fourth similarities; and a fifth determining submodule, used to take the first question corresponding to the target similarity as the first question with the highest similarity to the target question.
[0177] Optionally, in the intelligent question-answering device provided in this application embodiment, the device further includes: a third determining unit, used to determine a target website before determining N first questions from the first question set of the knowledge base based on the target question and in combination with the first model and the second model, wherein the target website is a website related to agricultural planting; a first obtaining unit, used to obtain the URL information corresponding to the target webpage in the target website; a fourth determining unit, used to obtain Q first question-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; a first deleting unit, used to delete R first question-answer data and Y first question-answer data from the Q first question-answer data to obtain M deleted first question-answer data, wherein the first question-answer data in the R first question-answer data is null, the first question-answer data in the Y first question-answer data is question-answer data unrelated to agricultural planting, and the M deleted first question-answer data includes at least M first questions and the answer corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; and a first storage unit, used to store the M deleted first question-answer data to obtain a knowledge base.
[0178] Optionally, in the intelligent question-answering device provided in this application embodiment, the determining unit includes: a third determining module, used to determine the content information of the target webpage based on the URL information corresponding to the target webpage; a first obtaining module, used to obtain G first question-answer data and F address information corresponding to the first webpages based on the content information of the target webpage, wherein the first webpages are webpages other than the target webpage in the target website, G is less than Q, and G and F are both positive integers; a fourth determining module, used to determine a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; a second obtaining module, used to obtain H first question-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and a fourth processing module, used to summarize and process the G first question-answer data and H first question-answer data to obtain Q first question-answer data.
[0179] The intelligent question-answering device includes a processor and a memory. The first receiving unit 501, the first determining unit 502, the second determining unit 503, and the first processing unit 504 are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.
[0180] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can improve the effectiveness of agricultural planting.
[0181] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0182] This invention provides a computer-readable storage medium storing a program thereon, which, when executed by a processor, implements the intelligent question-answering method.
[0183] This invention provides a processor for running a program, wherein the program executes the intelligent question-answering method during runtime.
[0184] like Figure 6 As shown, this embodiment of the invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: receiving a target question sent by a target object, wherein the target question is a question related to agricultural planting; based on the target question, and in combination with a first model and a second model, determining N first questions from a first question set in a knowledge base, wherein the knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question, wherein the first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers; determining the first question with the highest similarity to the target question from the N first questions; determining the target answer according to the knowledge base, and returning the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0185] When the processor executes the program, it also performs the following steps: Based on the target problem, and combining the first model and the second model, determining N first problems from the first problem set in the knowledge base includes: converting the target problem into a first vector using the first model, and converting M first problems into a first set using the first model, wherein the first set includes at least M second vectors; calculating the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; converting the target problem into a third vector using the second model, and converting M first problems into a second set using the second model, wherein the second set includes at least M fourth vectors; calculating the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and determining N first problems from the first problem set in the knowledge base based on the first similarity set and the second similarity set.
[0186] When the processor executes the program, it also performs the following steps: determining N first questions from the first question set of the knowledge base based on the first similarity set and the second similarity set, including: determining the first weight corresponding to the first model and the second weight corresponding to the second model respectively; calculating the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; sorting the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base to obtain a sorting result; and determining N first questions based on the sorting result.
[0187] When the processor executes the program, it also performs the following steps: converting the target problem into a first vector through the first model includes: performing word segmentation on the target problem to obtain K first words, where K is a positive integer; determining S stop words from the K first words, where K is greater than S and S is a positive integer; removing the S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; and inputting the T first words after removing stop words into the first model for vectorization processing to obtain the first vector.
[0188] When the processor executes the program, it also performs the following steps: determining the first question with the highest similarity to the target question from N first questions includes: performing character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; performing character segmentation on the target question to obtain P second characters, where P is a positive integer; performing concatenation on the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; inputting each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vectors are vectors in the target layer of the third model, the sixth vectors are vectors corresponding to the target characters, the target characters are characters in the target positions of the target statements, U and V are both greater than N, and U and V are both positive integers; and determining the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0189] The processor, when executing the program, also performs the following steps: Based on U fifth vectors and V sixth vectors, determining the first problem with the highest similarity to the target problem from N first problems includes: inputting each sixth vector into a fourth model for processing to obtain Z seventh vectors and X eighth vectors, where the eighth vectors are vectors in the opposite direction to the seventh vectors, and Z and X are both positive integers; concatenating the U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, where the target matrix set includes at least N target matrices; inputting each target matrix into a fifth model for calculation to obtain N fourth similarities, where the fourth similarity is the similarity between the first problem among the N first problems and the target problem; determining the target similarity from the N fourth similarities, and determining the first problem corresponding to the target similarity from the N first problems, where the target similarity is the largest similarity among the N fourth similarities; and selecting the first problem corresponding to the target similarity as the first problem with the highest similarity to the target problem.
[0190] When the processor executes the program, it also performs the following steps: Before determining N first questions from the first question set of the knowledge base based on the target question and in combination with the first model and the second model, the method further includes: determining a target website, wherein the target website is a website related to agricultural planting; obtaining the URL information corresponding to the target webpage in the target website; obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; deleting R first question-and-answer data and Y first question-and-answer data from the Q first question-and-answer data to obtain M deleted first question-and-answer data, wherein the first question-and-answer data in the R first question-and-answer data are null values, the first question-and-answer data in the Y first question-and-answer data are question-and-answer data unrelated to agricultural planting, and the M deleted first question-and-answer data include at least M first questions and the answer corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; storing the M deleted first question-and-answer data to obtain the knowledge base.
[0191] The processor, when executing the program, also performs the following steps: obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage includes: determining the content information of the target webpage based on the URL information corresponding to the target webpage; obtaining G first question-and-answer data and F address information corresponding to the first webpages based on the content information of the target webpages, wherein the first webpages are webpages on the target website other than the target webpage, G is less than Q, and G and F are both positive integers; determining a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; obtaining H first question-and-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and summarizing the G first question-and-answer data and H first question-and-answer data to obtain Q first question-and-answer data.
[0192] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0193] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: receiving a target question sent by a target object, wherein the target question is a question related to agricultural planting; based on the target question, and in conjunction with a first model and a second model, determining N first questions from a first question set in a knowledge base, wherein the knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question, the first question set including at least M first questions, M being greater than or equal to N, and M and N being positive integers; determining the first question with the highest similarity to the target question from the N first questions; determining the target answer according to the knowledge base, and returning the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question.
[0194] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: Based on the target problem, and combining a first model and a second model, determining N first problems from a first problem set in the knowledge base includes: converting the target problem into a first vector using the first model, and converting M first problems into a first set using the first model, wherein the first set includes at least M second vectors; calculating the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; converting the target problem into a third vector using the second model, and converting M first problems into a second set using the second model, wherein the second set includes at least M fourth vectors; calculating the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; and determining N first problems from the first problem set in the knowledge base based on the first similarity set and the second similarity set.
[0195] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: determining N first questions from the first question set of the knowledge base based on the first similarity set and the second similarity set, including: determining the first weight corresponding to the first model and the second weight corresponding to the second model respectively; calculating the third similarity between the target question and each first question in the first question set of the knowledge base based on the first similarity set, the second similarity set, the first weight, and the second weight; sorting the M first questions in the knowledge base according to the target order based on the third similarity between the target question and each first question in the first question set of the knowledge base, and obtaining a sorting result; and determining N first questions based on the sorting result.
[0196] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: converting the target problem into a first vector through the first model includes: performing word segmentation on the target problem to obtain K first words, where K is a positive integer; determining S stop words from the K first words, where K is greater than S and S is a positive integer; removing the S stop words from the K first words to obtain T first words after removing stop words, where T is less than K and T is a positive integer; inputting the T first words after removing stop words into the first model for vectorization processing to obtain the first vector.
[0197] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: determining the first question with the highest similarity to the target question from N first questions includes: performing character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; performing character segmentation on the target question to obtain P second characters, where P is a positive integer; performing concatenation on the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; inputting each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vectors are vectors in the target layer of the third model, the sixth vectors are vectors corresponding to the target characters, the target characters are characters in the target positions of the target statements, U and V are both greater than N, and U and V are both positive integers; and determining the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors.
[0198] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: determining the first problem with the highest similarity to the target problem from N first problems based on U fifth vectors and V sixth vectors, including: inputting each sixth vector into a fourth model for processing to obtain Z seventh vectors and X eighth vectors, wherein the eighth vectors are vectors in the opposite direction to the seventh vectors, and Z and X are both positive integers; concatenating the U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, wherein the target matrix set includes at least N target matrices; inputting each target matrix into a fifth model for calculation to obtain N fourth similarities, wherein the fourth similarity is the similarity between the first problem among the N first problems and the target problem; determining the target similarity from the N fourth similarities, and determining the first problem corresponding to the target similarity from the N first problems, wherein the target similarity is the largest similarity among the N fourth similarities; and taking the first problem corresponding to the target similarity as the first problem with the highest similarity to the target problem.
[0199] When executed on a data processing device, it is also suitable to execute an initialization program with the following method steps: before determining N first questions from the first question set of the knowledge base based on the target question and in combination with the first model and the second model, the method further includes: determining a target website, wherein the target website is a website related to agricultural planting; obtaining the URL information corresponding to the target webpage in the target website; obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage, wherein Q is a positive integer; deleting R first question-and-answer data and Y first question-and-answer data from the Q first question-and-answer data to obtain M deleted first question-and-answer data, wherein the first question-and-answer data in the R first question-and-answer data are null values, the first question-and-answer data in the Y first question-and-answer data are question-and-answer data unrelated to agricultural planting, and the M deleted first question-and-answer data include at least M first questions and the answer corresponding to each first question, where R, Y, and M are all less than Q, and R and Y are both positive integers; storing the M deleted first question-and-answer data to obtain the knowledge base.
[0200] When executed on a data processing device, it is also suitable to execute an initialization program with the following steps: obtaining Q first question-and-answer data based on the URL information corresponding to the target webpage, including: determining the content information of the target webpage based on the URL information corresponding to the target webpage; obtaining G first question-and-answer data and F address information corresponding to the first webpages based on the content information of the target webpages, wherein the first webpages are webpages in the target website other than the target webpage, G is less than Q, and G and F are both positive integers; determining a content information set based on the address information corresponding to the F first webpages, wherein the content information set includes at least the content information of each first webpage; obtaining H first question-and-answer data based on the content information of each first webpage in the content information set, wherein H is less than Q and H is a positive integer; and summarizing the G first question-and-answer data and H first question-and-answer data to obtain Q first question-and-answer data.
[0201] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0202] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0203] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0204] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0205] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0206] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0207] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0208] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0209] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0210] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. An intelligent question-answering method, characterized in that, include: Receive a target question sent by the target object, wherein the target question is a question related to agricultural planting; Based on the target problem, and combining the first model and the second model, N first problems are determined from the first problem set in the knowledge base. The knowledge base is used to store M first problems related to agricultural planting and the answer to each first problem. The first problem set includes at least M first problems, M is greater than or equal to N, and M and N are both positive integers. From N first questions, determine the first question that has the highest similarity to the target question; Based on the knowledge base, a target answer is determined and returned to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question; Among them, the first question with the highest similarity to the target question from the N first questions includes: For each of the N first problems, perform character segmentation to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; The target problem is processed by word segmentation to obtain P second characters, where P is a positive integer; The W first characters and P second characters are concatenated to obtain a target statement set, wherein the target statement set includes at least N target statements; Each target statement is input into the third model for vectorization processing to obtain U fifth vectors and V sixth vectors. The fifth vectors are vectors in the target layer of the third model, and the sixth vectors are vectors corresponding to the target characters. The target characters are the characters in the target positions of the target statements. U and V are both greater than N, and U and V are both positive integers. Based on U fifth vectors and V sixth vectors, determine the first question with the highest similarity to the target question from N first questions; Based on U fifth vectors and V sixth vectors, the first questions with the highest similarity to the target question are determined from N first questions, including: Each sixth vector is input into the fourth model for processing to obtain Z seventh vectors and X eighth vectors, wherein the eighth vector is a vector with the opposite direction to the seventh vector, and Z and X are both positive integers; The U fifth vectors, Z seventh vectors, and X eighth vectors are concatenated to obtain a target matrix set, wherein the target matrix set includes at least N target matrices; Each target matrix is input into the fifth model for calculation and processing to obtain N fourth similarities, where the fourth similarity is the similarity between the first problem among the N first problems and the target problem; The target similarity is determined from the N fourth similarities, and the first question corresponding to the target similarity is determined from the N first questions, wherein the target similarity is the largest similarity among the N fourth similarities; The first question corresponding to the target similarity is taken as the first question with the highest similarity to the target question.
2. The method according to claim 1, characterized in that, Based on the target problem, and combining the first model and the second model, N first problems are determined from the first problem set in the knowledge base, including: The target problem is transformed into a first vector through the first model, and M first problems are transformed into a first set through the first model, wherein the first set includes at least M second vectors; Calculate the similarity between the first vector and each second vector to obtain a first similarity set, wherein the first similarity set includes at least M first similarities; The target problem is transformed into a third vector through the second model, and the M first problems are transformed into a second set through the second model, wherein the second set includes at least M fourth vectors; Calculate the similarity between the third vector and each fourth vector to obtain a second similarity set, wherein the second similarity set includes at least M second similarities; Based on the first similarity set and the second similarity set, N first questions are determined from the first question set of the knowledge base.
3. The method according to claim 2, characterized in that, Based on the first similarity set and the second similarity set, N first questions are determined from the first question set of the knowledge base, including: Determine the first weight corresponding to the first model and the second weight corresponding to the second model, respectively; Based on the first similarity set, the second similarity set, the first weight, and the second weight, a third similarity is calculated between the target question and each first question in the first question set of the knowledge base; Based on the third similarity between the target question and each first question in the first question set of the knowledge base, the M first questions in the knowledge base are sorted according to the target order to obtain the sorting result; Based on the sorting results, N first problems are determined.
4. The method according to claim 2, characterized in that, Transforming the target problem into a first vector using the first model includes: The target problem is segmented to obtain K first words, where K is a positive integer; Determine S stop words from K first words, where K is greater than S and S is a positive integer; Remove the S stop words from the K first words to obtain T first words after removing the stop words, where T is less than K and T is a positive integer; The first word after removing T stop words is input into the first model for vectorization processing to obtain the first vector.
5. The method according to claim 1, characterized in that, Before determining N first questions from the first question set of the knowledge base based on the target question and combining the first model and the second model, the method further includes: Identify target websites, wherein the target websites are websites related to agricultural planting; Obtain the URL information corresponding to the target webpage in the target website; Based on the URL information corresponding to the target webpage, Q first question-and-answer data are obtained, where Q is a positive integer; Remove R and Y first question and answer data points from Q first question and answer data points to obtain M deleted first question and answer data points. Among them, the first question and answer data points in the R first question and answer data points are null values, the first question and answer data points in the Y first question and answer data points are questions and answers data unrelated to agricultural planting, and the M deleted first question and answer data points include at least M first questions and the corresponding answers for each first question. R, Y, and M are all less than Q, and R and Y are both positive integers. The knowledge base is obtained by storing the first question and answer data after M deletions.
6. The method according to claim 5, characterized in that, Based on the URL information corresponding to the target webpage, Q first question-and-answer data are obtained, including: Based on the URL information corresponding to the target webpage, determine the content information of the target webpage; Based on the content information of the target webpage, obtain G first question and answer data and F address information corresponding to the first webpage, wherein the first webpage is a webpage in the target website other than the target webpage, G is less than Q, and G and F are both positive integers; Based on the address information corresponding to F first web pages, a content information set is determined, wherein the content information set includes at least the content information of each first web page; Based on the content information of each first webpage in the content information set, H first question and answer data are obtained, where H is less than Q and H is a positive integer; The G and H first question-and-answer data points are aggregated to obtain Q first question-and-answer data points.
7. An intelligent question-and-answer device, characterized in that, include: The first receiving unit is used to receive a target question sent by the target object, wherein the target question is a question related to agricultural planting; The first determining unit is used to determine N first questions from a first question set in a knowledge base based on the target question and in combination with a first model and a second model. The knowledge base is used to store M first questions related to agricultural planting and the answer corresponding to each first question. The first question set includes at least M first questions, M is greater than or equal to N, and M and N are both positive integers. The second determining unit is used to determine the first question that has the highest similarity to the target question from among N first questions; The first processing unit is configured to determine the target answer based on the knowledge base and return the target answer to the target object, wherein the target answer is the answer corresponding to the first question with the highest similarity to the target question; The second determining unit comprises: a first processing module, used to perform character segmentation on each of the N first questions to obtain a first character set, wherein the first character set includes at least W first characters, where W is a positive integer; a second processing module, used to perform character segmentation on the target question to obtain P second characters, where P is a positive integer; a third processing module, used to concatenate the W first characters and P second characters to obtain a target statement set, wherein the target statement set includes at least N target statements; a first input module, used to input each target statement into a third model for vectorization processing to obtain U fifth vectors and V sixth vectors, wherein the fifth vectors are vectors in the target layer of the third model, the sixth vectors are vectors corresponding to the target characters, the target characters are characters in the target positions of the target statements, U and V are both greater than N, and U and V are both positive integers; and a second determining module, used to determine the first question with the highest similarity to the target question from the N first questions based on the U fifth vectors and V sixth vectors. The determining module includes: a second input submodule, used to input each sixth vector into the fourth model for processing to obtain Z seventh vectors and X eighth vectors, wherein the eighth vector is a vector with the opposite direction to the seventh vector, and Z and X are both positive integers; a second processing submodule, used to concatenate U fifth vectors, Z seventh vectors, and X eighth vectors to obtain a target matrix set, wherein the target matrix set includes at least N target matrices; a third input submodule, used to input each target matrix into the fifth model for calculation to obtain N fourth similarities, wherein the fourth similarity is the similarity between the first question among the N first questions and the target question; a fourth determining submodule, used to determine the target similarity from the N fourth similarities and determine the first question corresponding to the target similarity from the N first questions, wherein the target similarity is the largest similarity among the N fourth similarities; and a fifth determining submodule, used to take the first question corresponding to the target similarity as the first question with the highest similarity to the target question.
8. A computer-readable storage medium, characterized in that, The storage medium stores a program, wherein the program executes the intelligent question-answering method according to any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the intelligent question-answering method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Electronic medical record question-answering method and system based on knowledge graph
CN111274373A
Intelligent question and answer matching method and system based on twin network BERT model
CN112667794A