Text-based question and answer method and related equipment
By identifying question categories and extracting features, recalling relevant text slices and using models for text retrieval, the problem of low answer generation efficiency in document question answering systems is solved, and more efficient and accurate answer generation is achieved.
Patent Information
- Application Number
- CN202510954535.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-10-17
AI Technical Summary
Due to the large number of documents, direct retrieval in existing document question answering systems is prone to many interference items, resulting in low answer generation efficiency and high noise.
By identifying the category of the question and extracting its features, we obtain the feature vector of the question. Based on the category and feature vector of the question, we recall the text slices of the preset document, use the preset model to perform text retrieval, and generate question-answering results.
It improves the efficiency and accuracy of answer generation, reduces the recall of text slices irrelevant to the question, and improves retrieval efficiency.
Smart Images

Figure CN120804266A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information retrieval, in particular to a text-based question answering method and related equipment. BACKGROUND
[0002] The document question answering system is widely used in intelligent customer service, information query, technical support and other fields because it has the functions of improving the efficiency of obtaining information and reducing the time and energy of manual search. In related technologies, the implementation scheme of the document question answering system is to directly search the paragraphs through the question. However, due to the large number of documents, direct search is easy to have more interference items, and there are more noises in the search recall content, resulting in low answer generation efficiency. SUMMARY
[0003] In view of the above, it is necessary to provide a text-based question answering method, an electronic device and a storage medium to solve the technical problem of low answer generation efficiency.
[0004] In the first aspect, the present application provides a text-based question answering method, which comprises: in response to a received question, identifying the category of the question, and performing feature extraction on the question to obtain a first feature vector of the question; according to the category of the question and the first feature vector, recalling text slices of a preset document to obtain target text slices; based on the target text slices and the question, performing text search using a preset model to obtain a question answering result.
[0005] In some embodiments of the present application, the recalling of the text slices of the preset document according to the category of the question and the first feature vector to obtain the target text slices comprises: determining the similarity between the question and the text slices according to the category of the question, the first feature vector of the question and the second feature vector of the text slices; sorting the text slices according to the similarity, and taking the preset number of text slices with high sorting as the target text slices.
[0006] In some embodiments of the present application, the determining of the similarity between the question and the text slices according to the category of the question, the first feature vector of the question and the second feature vector of the text slices comprises: identifying the category of the document; screening the text slices according to the category of the question, and determining the second feature vector of the screened text slices; determining the similarity between the screened text slices and the question according to the second feature vector of the screened text slices and the first feature vector of the question.
[0007] In some embodiments of the present application, the similarity between the question and the text slice is determined according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice, which includes: obtaining the predicted probability of the category of the question; calculating the similarity between the second feature vector of the text slice and the first feature vector of the question; and updating the similarity corresponding to the text slice using the predicted probability of the category of the question that is consistent with the category of the text slice.
[0008] In some embodiments of the present application, the similarity between the question and the text slice is determined according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice, which includes: extracting features of the category of the question to obtain a third feature vector of the question; obtaining a fourth feature vector of the question according to the third feature vector of the question and the first feature vector of the question; and calculating the similarity between the second feature vector of the text slice and the fourth feature vector of the question.
[0009] In some embodiments of the present application, the similarity between the second feature vector of the text slice and the fourth feature vector of the question is calculated, which includes: calculating the cosine distance or Euclidean distance between the second feature vector of the text slice and the fourth feature vector of the question to obtain the similarity between the second feature vector of the text slice and the fourth feature vector of the question.
[0010] In some embodiments of the present application, the text retrieval is performed based on the target text slice and the question using a preset model to obtain a question and answer result, which includes: inputting the target text slice and the question into an answer generation model, predicting the start position and the end position of the answer in a paragraph based on the target text slice and the question using the answer generation model; and taking the text content in the paragraph between the start position and the end position as the answer result, wherein the paragraph can be generated based on the target text slice.
[0011] In some embodiments of the present application, the text retrieval is performed based on the target text slice and the question using a preset model to obtain a question and answer result, which includes: filling the target text slice and the question into a preset prompt word template to generate a prompt text, inputting the prompt text into a large model, and processing the prompt text using the large model to generate a question and answer result.
[0012] In a second aspect, the present application provides an electronic device, comprising a memory and a processor, wherein the memory is configured to store program instructions, and the processor is configured to read and execute the program instructions stored in the memory, so as to enable the electronic device to perform the text-based question-answering method.
[0013] In a third aspect, the present application provides a computer storage medium, which stores program instructions, and when the program instructions are executed on an electronic device, the electronic device is enabled to perform the text-based question-answering method.
[0014] According to the category of the question and the first feature vector, the text slice of the preset document can be recalled to obtain a target text slice, and the text retrieval is performed based on the target text slice and the question by using a preset model to obtain a question-answering result. In this way, the text slice related to the question can be accurately recalled according to the category of the question and the first feature vector, and the text retrieval is performed based on the recalled text slice and the question by using the preset model to obtain the question-answering result, so that the generation efficiency and accuracy of the answer are improved. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 An application scenario diagram of the text-based question-answering method provided by some embodiments of the present application is shown.
[0016] Figure 2 A flowchart of the text-based question-answering method provided by some embodiments of the present application is shown.
[0017] Figure 3 A flowchart of the method for determining the similarity between the question and the text slice in some embodiments of the present application is shown.
[0018] Figure 4 A flowchart of the method for determining the similarity between the question and the text slice in some embodiments of the present application is shown.
[0019] Figure 5 A flowchart of the method for determining the similarity between the question and the text slice in some embodiments of the present application is shown.
[0020] Figure 6 A functional module diagram of the text question-answering device provided by some embodiments of the present application is shown.
[0021] Figure 7 A structural schematic diagram of the electronic device provided by some embodiments of the present application is shown. DETAILED DESCRIPTION
[0022] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application will be described in detail below with reference to the drawings and specific embodiments.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing embodiments in one embodiment only and are not intended to limit this application.
[0024] It should be noted that the terms "first," "second," "third," "fourth," etc. (if any) in the specification, claims, and drawings of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being more preferred or more advantageous than other embodiments or design. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0025] It should also be noted that the methods disclosed in the embodiments of this application or the methods shown in the flowcharts include one or more steps for implementing the methods. Without departing from the scope of the claims, the order of executing multiple steps can be interchanged with each other, and some steps can also be deleted. Some embodiments will be described below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other unless there is a conflict.
[0026] Document question-answering systems are widely used in intelligent customer service, information query, technical support, and other fields because they improve information acquisition efficiency and reduce the time and effort of manual searches. Related technologies often implement document question-answering systems by directly searching for solutions in paragraphs using questions. However, due to the large number of documents, direct searches are prone to numerous interference items, resulting in a high level of noise in the retrieved content, leading to low answer generation efficiency.
[0027] To solve the above technical problems, the present application provides a text-based question-answering method. Figure 1 The figure shows an application scenario diagram of the text-based question-answering method provided in some embodiments of the present application. The text-based question-answering method is applied in Figure 1 In the network architecture shown in Figure 1In the illustrated network architecture, the background processing system 10 is deployed in the Internet to provide corresponding services to its users, and the first devices 20 of the merchant users and the second devices 30 of the consumer users of the background processing system 10 are also connected to the Internet to use the services provided by the background processing system. In some embodiments of the present application, the background processing system 10 can be an e-commerce platform (such as a customer service system of an e-commerce platform), a document question and answer system, an information retrieval system, an answer generation system, or an artificial intelligence system. The text-based question and answer method of the present application is described below by taking the background processing system as an e-commerce platform as an example.
[0028] An exemplary e-commerce platform provides product and / or service matching for the public through Internet infrastructure, in which the product and / or service is provided as commodity information. For simplicity of description, the concepts of commodity, product, etc. are used in the present application to refer to the product and / or service in the e-commerce platform, which can be physical products, digital products, tickets, service subscriptions, other offline services, etc.
[0029] In reality, various entities can access the e-commerce platform as users to use various online services provided by the e-commerce platform to achieve the purpose of participating in the business activities implemented by the e-commerce platform. These entities can be natural persons, legal persons, or social organizations, etc. Corresponding to the two types of entities of merchants and consumers in business activities, the e-commerce platform correspondingly has two types of users, merchant users and consumer users. The entities in the product circulation chain in business activities, including manufacturers, sellers, retailers, logistics providers, etc., can use online services in the e-commerce platform as merchant users, while consumers in business activities, including real or potential consumers, can use online services in the e-commerce platform as their corresponding consumer users. In actual business activities, the same entity can act as a merchant user and as a consumer user, which should be flexibly and variably understood.
[0030] The infrastructure for deploying the e-commerce platform mainly includes a background architecture and front-end devices. The background architecture runs various online services through a service cluster, including middleware or front-end services for platform parties, services for consumers, services for merchants, etc., to enrich and perfect its service functions; the front-end devices mainly cover terminal devices used by users to access the e-commerce platform as clients, including but not limited to various mobile terminals, personal computers, point-of-sale devices, etc.
[0031] For example, a merchant user can input a document, such as an operation guide document, for his online store through the first device 20. The e-commerce platform can process the document input by the first device 20 and store the document in the database. A consumer user can input a question through the second device 30. The e-commerce platform receives the question input by the second device 30, retrieves the matching document content from the document in the database, generates an answer according to the retrieved document content and the question, and returns the answer to the second device 30 for display.
[0032] In some embodiments of the present application, the first device 20 runs a document administrator system. The second device 30 runs a chat system. The document administrator system includes a document uploading module and a document management module. The e-commerce platform includes a document processing module, a database, a document recall module, and an answer generation module. The chat system includes a question consulting module and a reply module.
[0033] The document uploading module is configured to receive a document input by a user and upload the document to the e-commerce platform. In some embodiments of the present application, the document uploading module provides a document uploading interface through which the user uploads the document. In some other embodiments of the present application, the user modifies the document through the document uploading module.
[0034] The document processing module of the e-commerce platform is configured to receive the document and pre-process the document. In some embodiments of the present application, the pre-processing of the document includes identifying the category of the document, slicing the document to obtain text slices, and extracting features of the text slices to obtain feature vectors of the text slices. The document processing module determines the category of the corresponding text slice according to the category of the document, and stores the corresponding relationship between the category of the text slice, the text slice, and the feature vector of the text slice in the database.
[0035] In some embodiments of the present application, the document management module is configured to display the processing result of the document by the document processing module, so as to feed back the processing result of the document to the user.
[0036] In some embodiments of the present application, the question consulting module of the e-commerce platform is configured to receive a question input by a user. In some embodiments of the present application, the question consulting module provides a search interface through which the user inputs the question. The document recall module receives the question input by the user and pre-processes the question. In some embodiments of the present application, the pre-processing of the question includes noise reduction of the question, identification of the category of the question, and feature extraction of the question to obtain a feature vector of the question. In some embodiments of the present application, the document recall module recalls the text slices in the database according to the category of the question and the feature vector of the question, and inputs the text slices and the question into the answer generation module. The answer generation module inputs the target text slice and the question into a preset model, performs document question and answer on the target text slice and the question through the preset model, and obtains a question and answer result.
[0037] In some embodiments of the present application, the reply module is configured to receive the question and answer result sent by the answer generation module, and display the question and answer result for the user to view.
[0038] In some embodiments, the e-commerce platform can be implemented by a processing facility including a processor and a memory, which stores a set of instructions that, when executed, cause the e-commerce platform to perform the customer service support functions, e-commerce or support functions involved in the present application. The processing facility can be part of a server, a client, a network infrastructure, a mobile computing platform, a cloud computing platform, a fixed computing platform or other computing platform, and provides electronic components of the e-commerce platform, merchant devices, payment gateways, application developers, marketing channels, transportation providers, customer devices, point-of-sale devices, etc.
[0039] The e-commerce platform can be implemented as a cloud computing service, software as a service (SaaS), infrastructure as a service (IaaS), platform as a service (PaaS), desktop as a service (DaaS), hosted software as a service, mobile backend as a service (MBaaS), information technology management as a service (ITMaaS), etc. Online services. In some embodiments, various functional components of the e-commerce platform can be implemented to be suitable for operation on various platforms and operating systems, for example, for an online store, its administrator users enjoy the same or similar functions in various embodiments such as iOS TM、 Android TM , HomonyOS TM , or web pages, etc.
[0040] The e-commerce platform can implement its corresponding independent station for each merchant to run its corresponding online store, and provide the merchant with a corresponding business management engine instance for the merchant to establish, maintain and run one or more online stores in one or more independent stations. The business management engine instance can be used for content management, task automation and data management of one or more online stores, and various specific business processes of the online store can be configured through interfaces or built-in components to support the implementation of business activities. The independent station is the infrastructure of the e-commerce platform with cross-border service functions, and the merchant can maintain its online store more centrally and independently based on the independent station. The independent station usually has a domain name and storage space dedicated to the merchant, and different independent stations have relative independence. The e-commerce platform can provide standardized or personalized technical support for a large number of independent stations, so that the merchant user can customize a business management engine instance suitable for itself, and use this business management engine instance to maintain one or more online stores owned by the merchant.
[0041] In some embodiments of the present application, the text-based question answering method responds to a received question, identifies the category of the question, and performs feature extraction on the question to obtain a first feature vector of the question. According to the category of the question and the first feature vector, the text slices in the database are recalled to obtain target text slices. Based on the target text slices and the question, a preset model is used for text retrieval to obtain a question answering result. In this way, the text slices can be recalled according to the category of the question and the first feature vector, which can reduce the recall of text slices irrelevant to the category of the question and improve the answer generation efficiency.
[0042] The text-based question answering method provided by the present application can be programmed as a computer program product and deployed in a client or a server for running and implementation. For example, in the exemplary application scenario of the present application, the method can be deployed and implemented in the server of an e-commerce customer service platform. Thus, the interface opened after the computer program product is run can be accessed, and the process of the computer program product can be interacted with through a graphical user interface to execute the method.
[0043] Reference Figure 2 As shown in the figure, the flowchart of the text-based question answering method provided by some embodiments of the present application. The text-based question answering method is applied in an e-commerce platform. The method includes the following steps. Figure 2 The exemplary method includes one or more steps, but does not constitute a limitation on the present application. In addition, the order of the steps of the method is only an example, and the order of the steps can be changed. Additional steps can be added or steps can be reduced without departing from the disclosure of the present application. The method includes the following steps.
[0044] Step S201, in response to a received question, identifying the category of the question, and performing feature extraction on the question to obtain a first feature vector of the question.
[0045] In some embodiments of the present application, the second device displays a search interface. The search interface includes a search field. The user of the second device inputs a question through the search field. The e-commerce platform (such as the customer service system of the e-commerce platform) responds to the question input by the user and identifies the category of the question through a semantic classification model. In some embodiments of the present application, the semantic classification model is an artificial intelligence (AI) model based on natural language processing (NLP), which assigns text to a predefined category by understanding the deep meaning (semantics) of the text rather than the surface words.
[0046] In some embodiments of the present application, the semantic classification model determines the category of the question through the keywords of the question. For example, the question of the user is “How do I ship it?”. The semantic classification model can determine that the type of the question is a logistics question through the keyword “ship” in “How do I ship it?”.
[0047] In some embodiments of the present application, the category of the question can be a single-level label, such as a logistics question, a payment question, or a commodity question, or the category of the question can also be a multi-level label, such as “logistics->shipping->shipping process” or “logistics->shipping->attention”.
[0048] In some embodiments of the present application, the e-commerce platform extracts features of the question to obtain a first feature vector of the question. Feature extraction is a step of converting text data into a numerical representation that can be understood by a machine learning model. In some embodiments of the present application, a pre-trained deep neural network can be used to extract features of the question to obtain a first feature vector of the question.
[0049] In step S202, according to the category of the question and the first feature vector, the text slices of the preset document are recalled to obtain target text slices.
[0050] In some embodiments of the present application, the first device displays a document upload interface, and the user of the first device end uploads a document through the document upload interface. The e-commerce platform receives the document input by the user, and identifies the category of the document through the semantic classification model. In some embodiments of the present application, the semantic classification model can determine the category of the question through the keywords of the document. In other embodiments of the present application, the document can also be manually classified and labeled to obtain the classification result of the document.
[0051] In some embodiments of the present application, the document can be a document input by the user through the search interface. For example, when the user inputs a question through the search interface, the document is input.
[0052] In some embodiments of the present application, the e-commerce platform can slice the document according to a preset slicing method to obtain text slices. In some embodiments of the present application, the document can be sliced according to a fixed text size to obtain text slices of the document. In some embodiments of the present application, the fixed text size is represented as a text word threshold, for example, the fixed text size can be 200 text words. Specifically, the document can be sliced according to 200 text words to obtain text slices.
[0053] In some embodiments of the present application, the document can be sliced according to a document structure to obtain a text slice of the document. In some embodiments of the present application, the document structure is at least one of a title, a chapter, a paragraph, or a sentence. For example, the document can be sliced according to at least one of a title, a chapter, a paragraph, or a sentence to obtain a text slice.
[0054] In some embodiments of the present application, the document can be sliced according to semantics to obtain a text slice of the document. In some embodiments of the present application, the semantics is a correlation degree between paragraphs or sentences of the document. For example, the paragraphs or sentences of the document with a correlation degree higher than a preset correlation threshold can be divided to obtain a text slice. The preset correlation threshold can be set according to actual application needs, which is not limited in the present application.
[0055] In some embodiments of the present application, the text slice is subjected to feature extraction to obtain a second feature vector of the text slice. In an embodiment of the present application, the text slice of the document, the second feature vector of the text slice, and the category of the text slice are associated and stored in a storage library. In this way, the text slice of the document and the second feature vector of the text slice are associated with the category of the corresponding text slice. In some embodiments of the present application, the category of the text slice is determined according to the category of the document corresponding to the text slice. For example, if the category of the document is logistics, the category of the text slice obtained by slicing the document is also logistics.
[0056] In some embodiments of the present application, according to the category of the question and the first feature vector, the text slices of the preset document are recalled to obtain target text slices, including: determining the similarity between the question and the text slice according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice; sorting the text slices according to the similarity, and taking the top preset number of text slices as the target text slices. In some embodiments of the present application, the similarity can be represented as a cosine distance or a Euclidean distance between the text slice and the question.
[0057] In step S203, based on the target text slice and the question, a text retrieval is performed by using a preset model to obtain a question and answer result.
[0058] In some embodiments of the present application, the preset model can be an answer generation model, such as a system model of templates and rules, an n-gram language model, or a recurrent neural network language model (RNN-LM). The text retrieval using the preset model based on the target text slice and the question to obtain the question and answer result includes: inputting the target text slice and the question into the answer generation model, predicting the start position and the end position of the answer in the paragraph according to the target text slice and the question using the answer generation model, and taking the text content between the start position and the end position in the paragraph as the answer result, wherein the paragraph can be generated according to the target text slice. In the embodiments of the present application, the start position and the end position of the answer in the paragraph are predicted according to the target text slice and the question using the answer generation model, and the text content between the start position and the end position in the paragraph is taken as the answer result, so that the recalled text slice can be processed to obtain the final answer result.
[0059] In some embodiments of the present application, the method further includes displaying the question and answer result. In the embodiments of the present application, the e-commerce platform can display the generated question and answer result on the second device for the user to view.
[0060] In some embodiments of the present application, the preset model can be a large model. The large model is a trained large language model (LLM), which is an advanced natural language processing model that can understand and generate natural language text. The large model is usually a variant of a deep neural network, which consists of millions to billions of parameters. In some embodiments of the present application, the text retrieval using the preset model based on the target text slice and the question to obtain the question and answer result includes: filling the target text slice and the question into a preset prompt word template to generate a prompt text, inputting the prompt text into the large model, and processing the prompt text using the large model to generate the question and answer result. In the embodiments of the present application, the target text slice and the question are filled into the preset prompt word template to generate the prompt text, the prompt text is input into the large model, and the large model is used to process the prompt text to generate the question and answer result, which can realize answer extraction on the text slice recalled by the recall module to obtain the answer result, thereby improving the accuracy of document retrieval by the large model.
[0061] Reference Figure 3 As shown in the figure, it is a method flowchart for determining the similarity between the question and the text slice in some embodiments of the present application. Specifically, it includes the following steps.
[0062] Step S301, identify the category of the document.
[0063] In some embodiments of the present application, the document is stored in a database of an e-commerce platform, and the e-commerce platform obtains the category of the document from the database.
[0064] In some embodiments of the present application, the user inputs the document through a second device, the e-commerce platform obtains the document from the second device, and identifies the category of the document through a semantic classification model. For example, if the document is a text of a merchant delivery instruction, the category of the document can be identified through the semantic classification model.
[0065] In step S302, the text slice is filtered according to the category of the question, and a second feature vector of the filtered text slice is determined.
[0066] In some embodiments of the present application, the e-commerce platform filters the text slice in the database according to the category of the question and the category of the document to obtain a text slice consistent with the category of the question. The text slice consistent with the category of the question means that the category of the text slice is the same as or similar to the category of the question. In some embodiments of the present application, the e-commerce platform obtains the second feature vector of the text slice from the database.
[0067] In step S303, the similarity between the filtered text slice and the question is determined according to the second feature vector of the filtered text slice and the first feature vector of the question.
[0068] In some embodiments of the present application, the cosine distance or Euclidean distance between the first feature vector and the second feature vector is calculated according to the second feature vector of the filtered text slice and the first feature vector of the question, and the similarity between the filtered text slice and the question is obtained.
[0069] In the embodiments of the present application, the target document is obtained by filtering the document according to the category of the question and the category of the document, the text slice of the target document is obtained as the filtered text slice, the second feature vector of the filtered text slice is obtained, and the similarity between the filtered text slice and the question is determined according to the second feature vector of the filtered text slice and the first feature vector of the question. In this way, the documents irrelevant to the category of the question can be filtered out, so as to narrow the search range and improve the search efficiency.
[0070] Reference Figure 4 As shown in the figure, it is a flow chart of a method for determining the similarity between a question and a text slice in some embodiments of the present application. Specifically, it includes the following steps.
[0071] In step S401, the prediction probability of the category of the question is obtained.
[0072] In some embodiments of the present application, the e-commerce platform predicts the probability of the category of the question through the semantic classification model. For example, the probability of predicting that the category of the question is category A is 0.9, and the probability of predicting that the category of the question is category B is 0.9.
[0073] Step S402, calculate the similarity between the second feature vector of the text slice and the first feature vector of the question.
[0074] In some embodiments of the present application, the cosine distance or Euclidean distance between the second feature vector of the text slice and the first feature vector of the question is calculated to obtain the similarity between the text slice and the question.
[0075] Step S403, update the similarity corresponding to the text slice using the predicted probability of the category of the question consistent with the category of the text slice.
[0076] In some embodiments of the present application, the predicted probability of the category of the question consistent with the category of the text slice is multiplied by the similarity, and the product result is taken as the updated similarity. For example, the similarity between the text slice of category A and the question is multiplied by the predicted probability of category A of the question (0.9), and the product result is taken as the updated similarity of the text slice of category A; the similarity between the text slice of category B and the question is multiplied by the predicted probability of category B of the question (0.6), and the product result is taken as the updated similarity of the text slice of category B.
[0077] In the embodiments of the present application, after calculating the similarity between the second feature vector of the text slice and the first feature vector of the question, the similarity is updated according to the predicted probability of the category of the question consistent with the category of the text slice, so that the text slice can be screened according to the category of the question, and the retrieval efficiency of the text slice is improved.
[0078] Reference Figure 5 As shown in the figure, it is a method flow chart for determining the similarity between the question and the text slice in some embodiments of the present application. Specifically, it includes the following steps.
[0079] Step S501, feature extraction is performed on the category of the question to obtain a third feature vector of the question.
[0080] In some embodiments of the present application, the e-commerce platform performs feature extraction on the category of the question to obtain a third feature vector of the question.
[0081] Step S502, obtain a fourth feature vector of the question according to the third feature vector of the question and the first feature vector of the question.
[0082] In some embodiments of the present application, the e-commerce platform adds the third feature vector of the question to the first feature vector of the question to obtain a fourth feature vector of the question.
[0083] In step S503, the similarity between the second feature vector of the text slice and the fourth feature vector of the question is calculated.
[0084] In some embodiments of the present application, the e-commerce platform calculates the cosine distance or Euclidean distance between the second feature vector of the text slice and the fourth feature vector of the question to obtain the similarity between the second feature vector of the text slice and the fourth feature vector of the question.
[0085] The question answering method based on the current department in the embodiments of the present application recalls the target text slice according to the category of the question and the first feature vector, performs text retrieval based on the target text slice and the question by using a preset model to obtain a question answering result. In this way, the present application can accurately recall the text slice related to the question according to the category of the question and the first feature vector, and perform text retrieval based on the recalled text slice and the question by using a preset model to obtain a question answering result, thereby improving the generation efficiency and accuracy of the answer.
[0086] Reference Figure 6 As shown in FIG. 6, a functional module diagram of a text question answering device provided by some embodiments of the present application is shown. The text question answering device 61 comprises an identification unit 610, a recall unit 611 and a generation unit 612. The module / unit referred to in the present application refers to a series of computer readable instruction segments capable of being acquired by a processor (for example, the processor 72 shown in FIG. 7) and capable of completing a fixed function, which is stored in a memory (for example, the memory 71 shown in FIG. 7). Figure 7 As shown in FIG. 7, the processor 72 can acquire the series of computer readable instruction segments stored in the memory 71 and execute the series of computer readable instruction segments to complete the functions of the identification unit 610, the recall unit 611 and the generation unit 612. Figure 7 As shown in FIG. 7, the memory 71 can store the series of computer readable instruction segments.
[0087] The identification unit 610 is configured to identify the category of the question in response to the received question, and perform feature extraction on the question to obtain a first feature vector of the question.
[0088] The recall unit 611 is configured to recall a target text slice from a text slice of a preset document according to the category of the question and the first feature vector.
[0089] The generation unit 612 is configured to perform text retrieval by using a preset model based on the target text slice and the question to obtain a question answering result.
[0090] In some embodiments of the present application, the recall unit 611 is configured to determine a similarity between the question and the text slice according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice; rank the text slices according to the similarity, and select a preset number of text slices with high ranks as the target text slices. In some embodiments of the present application, the similarity can be represented as a cosine distance or a Euclidean distance between the text slice and the question.
[0091] In some embodiments of the present application, the recall unit 611 is further configured to identify the category of the document; filter the text slices according to the category of the question, and determine the second feature vector of the filtered text slices; and determine the similarity between the filtered text slices and the question according to the second feature vector of the filtered text slices and the first feature vector of the question.
[0092] In some embodiments of the present application, the recall unit 611 is further configured to identify the category of the document; filter the text slices according to the category of the question to obtain target text slices, and determine the second feature vector of the target text slices; and determine the similarity between the target text slices and the question according to the second feature vector of the target text slices and the first feature vector of the question.
[0093] In some embodiments of the present application, the recall unit 611 is further configured to obtain the predicted probability of the category of the question; calculate the similarity between the second feature vector of the text slice and the first feature vector of the question; and update the similarity corresponding to the text slice by using the predicted probability of the category of the question that is consistent with the category of the text slice.
[0094] In some embodiments of the present application, the recall unit 611 is further configured to perform feature extraction on the category of the question to obtain a third feature vector of the question; obtain a fourth feature vector of the question according to the third feature vector of the question and the first feature vector of the question; and calculate the similarity between the second feature vector of the text slice and the fourth feature vector of the question.
[0095] In some embodiments of the present application, the generation unit 612 is further configured to input the target text slice and the question into an answer generation model, predict the start position and the end position of the answer in the paragraph according to the target text slice and the question by using the answer generation model, and take the text content in the paragraph between the start position and the end position as the answer result, wherein the paragraph can be generated according to the target text slice.
[0096] In some embodiments of the present application, the generation unit 612 is further configured to fill the target text slice and the question into a preset prompt word template to generate a prompt text, input the prompt text into a large model, and process the prompt text by using the large model to generate a question and answer result.
[0097] The text question and answer device in the embodiments of the present application recalls a target text slice from a preset document text slice according to the category of the question and the first feature vector, performs text retrieval based on the target text slice and the question by using a preset model to obtain a question and answer result. In this way, the text slice related to the question can be accurately recalled according to the category of the question and the first feature vector, and the preset model is used to perform text retrieval based on the recalled text slice and the question to obtain a question and answer result, thereby improving the generation efficiency and accuracy of the answer.
[0098] Please refer to Figure 7 As shown in FIG. 7, the electronic device provided by some embodiments of the present application is a structure schematic diagram of an electronic device.
[0099] The electronic device 70 can include at least one memory 71, a processor 72, and a communication unit 73. The memory 71 includes a computer readable storage medium for storing computer programs, such as a plurality of logic instructions. The communication unit 73 is configured to communicate with the electronic device 70 or a server. The processor 72 can execute the logic instructions to perform the above-mentioned text-based question and answer method.
[0100] It can be understood that, in some embodiments, the communication unit 73 includes a network module or other module having a communication function, which is not limited in the present application.
[0101] The logic instructions in the computer readable storage medium described above can be implemented in the form of a software function unit and sold or used as an independent product. In this case, the logic instructions can be stored in a computer readable storage medium.
[0102] The computer readable storage medium can be configured to store software programs, computer executable programs, such as program instructions corresponding to the text-based question and answer method in the embodiments of the present application. The processor 72 executes the software programs, instructions or modules stored in the computer readable storage medium, thereby performing the function application and image processing, i.e., implementing the text-based question and answer method in the above-mentioned embodiments.
[0103] In the embodiments of the present application, the computer readable storage medium includes a non-volatile computer readable memory, such as a disk, a memory, and the like. It can be understood that the computer readable storage medium can also include other non-volatile computer readable memories, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one flash memory device, and / or other non-volatile solid-state memory devices.
[0104] In the embodiments of the present application, the processor 72 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, and the like. The processor 72 is the control center of the electronic device 70, and can be connected to other external devices and / or systems / modules / units by various interfaces and lines to provide text-based question and answer method functions to applications of other external devices and / or systems / modules / units.
[0105] The present embodiment also provides a computer program product, which, when running on a computer, causes the computer to execute the above related steps to implement the text-based question and answer method in the above embodiments.
[0106] Among them, the electronic device, computer storage medium, computer program product or chip provided by the embodiment are all used to execute the corresponding method provided above, so the beneficial effects they can achieve can refer to the beneficial effects in the corresponding method provided above, which will not be repeated here.
[0107] Through the description of the above embodiments, those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of functional modules is taken as an example for illustration, and in actual application, the above functions can be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0108] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the modules or units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another apparatus, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.
[0109] The units described as separate components can or can not be physically separate, and the components shown as units can be one physical unit or a plurality of physical units, that is, can be located in one place, or can be distributed to a plurality of different places. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0110] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0111] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application essentially or the parts that make contributions to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing an apparatus or a processor to perform all or part of the steps of the methods of the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program code storage media.
[0112] The above embodiments are only used to illustrate the technical solutions of the present application and not to limit, although the present application is described in detail with reference to the above preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A text-based question-answering method, characterized in that: The method comprises: In response to the received question, identifying the category of the question, and performing feature extraction on the question to obtain a first feature vector of the question; Recalling a preset text slice of the document according to the category of the question and the first feature vector to obtain a target text slice; Based on the target text slice and the question, a preset model is used to perform text retrieval to obtain question-answering results.
2. The text-based question-answering method according to claim 1, wherein: The step of recalling a preset text slice of the document according to the category of the question and the first feature vector to obtain a target text slice includes: Determining the similarity between the question and the text slice according to the category of the question, the first eigenvector of the question, and the second eigenvector of the text slice; The text slices are sorted according to the similarity, and a preset number of text slices at the top of the sort are used as the target text slices.
3. The text-based question-answering method according to claim 2, wherein: Determining the similarity between the question and the text slice according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice includes: identifying a category of the document; Filtering the text slice according to the category of the question, and determining a second feature vector of the filtered text slice; The similarity between the filtered text slice and the question is determined based on the second feature vector of the filtered text slice and the first feature vector of the question.
4. The text-based question-answering method according to claim 2, wherein: Determining the similarity between the question and the text slice according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice includes: Obtaining the predicted probability of the class of the question; Calculating the similarity between the second eigenvector of the text slice and the first eigenvector of the question; The similarity corresponding to the text slice is updated using the predicted probability of the category of the question that is consistent with the category of the text slice.
5. The text-based question-answering method according to claim 2, wherein: Determining the similarity between the question and the text slice according to the category of the question, the first feature vector of the question, and the second feature vector of the text slice includes: Performing feature extraction on the category of the problem to obtain a third feature vector of the problem; Obtaining a fourth eigenvector of the problem based on the third eigenvector of the problem and the first eigenvector of the problem; The similarity between the second eigenvector of the text slice and the fourth eigenvector of the question is calculated.
6. The text-based question-answering method according to claim 5, wherein: Calculating the similarity between the second eigenvector of the text slice and the fourth eigenvector of the question includes: The cosine distance or the Euclidean distance between the second eigenvector of the text slice and the fourth eigenvector of the question is calculated to obtain the similarity between the second eigenvector of the text slice and the fourth eigenvector of the question.
7. The text-based question-answering method according to claim 1, wherein: The text retrieval is performed based on the target text slice and the question using a preset model to obtain question-answering results including: Inputting the target text slice and the question into an answer generation model, and using the answer generation model to predict the starting position and the ending position of the answer in the paragraph based on the target text slice and the question; The text content between the starting position and the ending position in the paragraph is used as the answer result, wherein the paragraph can be generated according to the target text slice.
8. The text-based question-answering method according to claim 1, wherein: The text retrieval is performed based on the target text slice and the question using a preset model to obtain question-answering results including: The target text slice and the question are filled into a preset prompt word template to generate a prompt text, the prompt text is input into a large model, and the prompt text is processed by the large model to generate a question-and-answer result.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor: The memory is used to store program instructions; The processor is configured to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device executes the text-based question-answering method according to any one of claims 1 to 8.
10. A computer storage medium, characterized in that The computer storage medium stores program instructions, and when the program instructions are executed on an electronic device, the electronic device is caused to execute the text-based question-answering method according to any one of claims 1 to 8.