Question answering method and apparatus, device, storage medium, and program product

By extracting metadata from query information and filtering relevant document fragments in the field of urban rail transit, the problem of insufficient retrieval accuracy and high noise in existing question-and-answer systems has been solved, achieving efficient and accurate answer generation and improving knowledge management efficiency.

WO2026232361A1PCT designated stage Publication Date: 2026-11-12TRAFFIC CONTROL TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/093308
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2026-11-12

AI Technical Summary

Technical Problem

Existing question-and-answer systems in the field of urban rail transit suffer from insufficient retrieval accuracy and excessive noise generation. Traditional information retrieval methods cannot effectively handle the contextual semantics of specialized documents, resulting in users being unable to quickly obtain accurate answers.

Method used

By extracting metadata from the query information, document fragments related to the query information are retrieved from a pre-set rail transit knowledge base. Based on the metadata and content, the relevance is determined, the most relevant document fragments are selected, and accurate response information, including response information and source information, is generated.

Benefits of technology

It improves the efficiency of knowledge management and problem-solving capabilities in urban rail transit systems, generates more accurate answers, reduces noise, and increases user trust in the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025093308_12112026_PF_FP_ABST
    Figure CN2025093308_12112026_PF_FP_ABST
Patent Text Reader

Abstract

The present application relates to a question answering method and apparatus, a device, a storage medium, and a program product. The method comprises: extracting metadata of query information; on the basis of the query information and the metadata, retrieving, from a preset rail transit knowledge base, a plurality of first document fragments relevant to the query information and meta information of the first document fragments, the meta information comprising at least source information of the document fragments; on the basis of content and the meta information of each first document fragment, determining the relevance between each first document fragment and the query information; on the basis of the relevance, determining, from among the plurality of first document fragments, K second document fragments most relevant to the query information; and generating and outputting target information of the query information on the basis of content and meta information of the K second document fragments, the target information comprising any one of the following: response information, and response information and source information of the response information.
Need to check novelty before this filing date? Find Prior Art

Description

Question answering methods, devices, equipment, storage media and program products Technical Field

[0001] This application relates to the field of urban rail transit, and in particular to a question-and-answer method, apparatus, equipment, storage medium, and program product. Background Technology

[0002] With the acceleration of urbanization, urban rail transit systems, as a crucial component of modern urban transportation, are rapidly expanding. These systems generate a large amount of complex and highly specialized documentation during their daily operation, maintenance, and management. This data covers a wide range of content, including technical regulations, operation manuals, equipment failure reports, and maintenance logs. As operating time increases and equipment is upgraded, the quantity and complexity of these documents continue to rise. This makes the ability to quickly and accurately obtain key technical information and operational guidelines in the face of sudden malfunctions or during routine management a core requirement for urban rail transit managers and maintenance personnel.

[0003] Traditional information retrieval methods, such as keyword-based search engines, while providing information to some extent, suffer from serious limitations due to the specialized and complex nature of documents in the rail transit field. Specifically, these documents often contain a large amount of technical terminology and domain-specific knowledge; keyword searches cannot effectively handle contextual semantics, easily retrieving irrelevant or redundant information, making it difficult for users to quickly find the answers they need in emergencies. Furthermore, as the system scales up and the amount of documents increases, retrieval efficiency continuously decreases.

[0004] In recent years, large-scale models based on Natural Language Processing (NLP) have made significant progress in question-answering systems. By learning from large amounts of text data, these models can understand the semantics and contextual relationships in natural language, demonstrating excellent performance in various general question-answering tasks. However, documents in the urban rail transit field are highly specialized and complex. Since large-scale models primarily rely on general knowledge gained from training data for question-answer generation, directly applying these models to a specialized field like urban rail transit often results in inaccurate or even incorrect answers. Furthermore, updating documents and technical specifications in the urban rail transit field requires fine-tuning of large-scale models. Traditional model fine-tuning methods are not only time-consuming but also require substantial computational resources, lacking the flexibility needed for real-world scenarios requiring rapid response.

[0005] To address these challenges, the industry has proposed a solution based on Retrieval-Augmented Generation (RAG). RAG combines information retrieval with a generative model, first retrieving the most relevant document fragments to the query, and then using the generative model to generate answers based on these retrieval results. However, while the RAG method has demonstrated good performance in general scenarios, its existing process design has not been optimized for highly specialized and dynamically changing domains such as urban rail transit, and still suffers from insufficient retrieval accuracy and high generation noise. Summary of the Invention

[0006] This application provides a question-and-answer method, apparatus, device, storage medium, and program product. It optimizes the RAG (Research and Answering) process for urban rail transit, enabling the generation of accurate answers to specific questions in the urban rail transit field, thereby improving knowledge management efficiency and problem-solving capabilities within the rail transit system.

[0007] Firstly, embodiments of this application provide a question-and-answer method, including:

[0008] Extract metadata from query information;

[0009] Based on query information and metadata, multiple first document fragments and their metadata are retrieved from a pre-set rail transit knowledge base. The rail transit knowledge base includes multiple document fragments and metadata for each document fragment. The metadata includes at least the source information of the document fragment.

[0010] Based on the content and metadata of each first document fragment, the relevance between each first document fragment and the query information is determined.

[0011] Based on relevance, identify the K most relevant second document fragments to the query information from multiple first document fragments, where K is a positive integer;

[0012] Based on the content and metadata of K second document fragments, generate and output the target information of the query information. The target information includes any one of the following: response information, response information and source information of response information.

[0013] Secondly, embodiments of this application provide a question-and-answer device, including:

[0014] The metadata extraction module is used to extract metadata from query information;

[0015] The retrieval module is used to retrieve multiple first document fragments and their metadata from a preset rail transit knowledge base based on query information and metadata. The rail transit knowledge base includes multiple document fragments and metadata for each document fragment, and the metadata includes at least the source information of the document fragment.

[0016] The retrieval module is also used to determine the relevance between each first document fragment and the query information based on the content and metadata of each first document fragment, respectively.

[0017] The retrieval module is also used to determine, based on relevance, the K most relevant second document fragments among multiple first document fragments to the query information, where K is a positive integer;

[0018] The generation module is used to generate and output the target information of the query information based on the content and meta-information of K second document fragments. The target information includes any one of the following: response information, response information and source information of response information.

[0019] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory storing computer program instructions;

[0020] When the processor executes the computer program instructions, it implements the method as described in the first aspect.

[0021] Fourthly, embodiments of this application provide a computer storage medium on which computer program instructions are stored, which, when executed by a processor, implement the method described in the first aspect.

[0022] Fifthly, embodiments of this application provide a computer program product in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the method described in the first aspect.

[0023] The question-answering method, apparatus, device, storage medium, and program product of this application extract metadata of the query information; based on the query information and metadata, retrieve multiple first document fragments and their metadata from a preset rail transit knowledge base; determine the relevance between each first document fragment and the query information based on the content and metadata of each first document fragment; based on the relevance, determine K second document fragments most relevant to the query information among the multiple first document fragments; and generate and output target information of the query information based on the content and metadata of the K second document fragments. The target information includes any one of the following: response information, response information, and source information of the response information. According to the embodiments of this application, by providing the metadata of the document fragments, the background of the document fragments can be better understood, thereby improving the accuracy of retrieval and answer generation, and thus generating more appropriate answers. Moreover, for questions in professional fields, clarifying the source of the answer can increase the user's trust in the answer.

[0024] Furthermore, in this embodiment, by processing each second document fragment separately when generating target information, multiple irrelevant or incomplete pieces of information can be avoided from being mixed together, effectively reducing the impact of noise on the generation result. The polling mechanism can immediately stop subsequent processing after the large model generates an accurate answer for the first time, avoiding processing irrelevant document fragments, thereby improving generation efficiency. Attached Figure Description

[0025] The features, advantages, and technical effects of exemplary embodiments of this application will now be described with reference to the accompanying drawings.

[0026] Figure 1 is a flowchart illustrating the question-and-answer method of some embodiments of this application;

[0027] Figure 2 is a schematic diagram of the structure of a question-and-answer device according to some embodiments of this application;

[0028] Figure 3 is a schematic diagram of the structure of an electronic device according to some embodiments of this application.

[0029] The accompanying drawings are not drawn to scale. Detailed Implementation

[0030] The embodiments of this application will be described in further detail below with reference to the accompanying drawings and examples. The detailed description of the following embodiments and the accompanying drawings are used to illustrate the principles of this application by way of example, but should not be used to limit the scope of this application, that is, this application is not limited to the described embodiments.

[0031] In the description of this application, it should be noted that, unless otherwise stated, "a plurality of" means two or more; the terms "upper," "lower," "left," "right," etc., indicating orientation or positional relationship are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation on this application. Furthermore, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0032] In the description of this application, it should also be noted that, unless otherwise expressly specified and limited, the terms "installation," "connection," and "joining" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in this application depending on the specific circumstances.

[0033] To improve the question-answering performance of the RAG process in the urban rail transit field, this application proposes a question-answering method to enhance the accuracy of large-scale model responses. This method is applicable to massive document data in the urban rail transit field, such as technical specifications, operation manuals, and troubleshooting records, helping users quickly obtain accurate answers. Through an efficient retrieval and generation process, the model can generate precise answers to specific questions in the rail transit field, thereby improving the knowledge management efficiency and problem-solving capabilities of the rail transit system. This application not only improves the question-answering accuracy of large-scale models in specific domains but also has good scalability, making it suitable for other complex document question-answering scenarios.

[0034] To better understand this application, the question-and-answer method, apparatus, device, storage medium, and program product according to embodiments of this application will be described in detail below with reference to Figures 1 to 3.

[0035] It should be noted that the question-and-answer method provided in this application embodiment can be executed by a question-and-answer device. This application embodiment uses a question-and-answer device executing the question-and-answer method as an example to illustrate the question-and-answer method provided in this application embodiment.

[0036] Referring to Figure 1, which is a flowchart of a question-and-answer method provided in an embodiment of this application, the method includes steps 110-150, which will be described in detail below.

[0037] Step 110. Extract the metadata of the query information.

[0038] In some embodiments of this application, the inquiry information includes queries input by users into the question-and-answer device in the field of urban rail transit, when facing sudden malfunctions or in daily management, to obtain key technical information and / or operational guidance, etc. Users include, but are not limited to, urban rail transit managers and maintenance personnel. Users can input inquiry information into the question-and-answer device through input methods such as voice input, keyboard input, mouse input, gesture input, and touch input.

[0039] In some embodiments of this application, the metadata of the query information refers to information of key significance within the query information, such as keywords and document names. In the field of urban rail transit, due to the large volume, complex content, and high degree of specialization of document data, directly searching based on the user's query information often leads to irrelevant or noisy search results, severely affecting the accuracy of the final answer. Therefore, in this embodiment, after obtaining the query information, the question-answering device uses a dedicated metadata extraction module to perform in-depth analysis of the user-input query information, extracting metadata related to the query information so that subsequent document retrieval can be performed based on the metadata. This enhances the targeting of subsequent searches, improves search effectiveness, and reduces interference from invalid information.

[0040] Step 120. Based on the query information and metadata, retrieve multiple first document fragments and their metadata from a pre-defined rail transit knowledge base. The rail transit knowledge base includes multiple document fragments and metadata for each document fragment. The metadata includes at least the source information of the document fragment.

[0041] In some embodiments of this application, the rail transit knowledge base is a knowledge base created based on documents in the field of urban rail transit prior to step 120 above. The rail transit knowledge base includes multiple document fragments determined based on documents in the field of urban rail transit and metadata for each document fragment. These documents in the field of urban rail transit include, but are not limited to, a large amount of complex and highly specialized document data generated during the daily operation, maintenance, and management of urban rail transit systems. This document data includes, but is not limited to, technical regulations, operation manuals, equipment fault reports, maintenance logs, etc.

[0042] In some embodiments of this application, the metadata of a document fragment is determined based on the document to which the document fragment belongs, and the metadata of the document fragment includes at least source information indicating the source of the document fragment. The source information includes, but is not limited to, the document name of the document to which the document fragment belongs.

[0043] In some embodiments of this application, the metadata of a document fragment may include not only source information, but also glossary, terminology explanation, and other information that can help understand the content of the document fragment.

[0044] In some embodiments of this application, after extracting metadata from the query information, the question-answering device uses a retrieval module to search a pre-created rail transit knowledge base based on the query information and metadata, thereby obtaining multiple document fragments related to the query information. For ease of distinction, the retrieved document fragments are referred to as first document fragments. In the rail transit knowledge base, there is a correlation between document fragments and corresponding metadata. Based on this, after obtaining multiple first document fragments, the metadata of each first document fragment can be obtained based on the correlation between the document fragments and the metadata.

[0045] Step 130. Determine the relevance between each first document fragment and the query information based on the content and metadata of each first document fragment.

[0046] In some embodiments of this application, multiple first document fragments related to the query information can be obtained through step 120 described above. Since the number of these first document fragments is large, directly generating the answer corresponding to the query information based on these multiple first document fragments would consume significant time and resources, resulting in poor real-time performance. Furthermore, the multiple first document fragments may contain noisy data with low relevance to the query information; directly generating the answer based on these fragments could lead to inaccurate results. Therefore, to improve the accuracy and real-time performance of the generated answer, after obtaining multiple first document fragments, the relevance between each first document fragment and the query information is determined, allowing for the filtering of the multiple first document fragments based on their relevance.

[0047] In some embodiments of this application, for each first document fragment, the relevance between the first document fragment and the query information can be determined using a ranking model based on the content and metadata of the first document fragment and the query information. The ranking model may include, but is not limited to, simple correlation coefficient ranking models, regression-based ranking models, machine learning ranking models, etc., and this embodiment does not specifically limit the ranking model used.

[0048] In some embodiments of this application, for each first document fragment, the relevance between the first document fragment and the query information can be determined by the following steps 1301-1303.

[0049] Step 1301. Based on the metadata of the first document fragment, expand the content of the first document fragment to obtain the extended context of the first document fragment. The extended context includes the content and metadata of the first document fragment.

[0050] In some embodiments of this application, an outline of the extended context can be prepared in advance according to the actual situation. Then, when the content of the first document fragment is expanded based on the meta-information of the first document fragment, the meta-information and content of the first document fragment are filled into each part of the outline according to the outline to form a complete text, and the formed text is used as the extended context of the first document fragment.

[0051] For example, if the metadata includes source information, the outline of the extended context can be: the paragraph content from (the source information in the metadata) is (the content of the first document fragment). Thus, when expanding the content of the first document fragment based on its metadata, the source information contained in the metadata is filled into the first set of parentheses, and the content of the first document fragment is filled into the second set of parentheses, resulting in an extended context that includes both the content of the first document fragment and the metadata. For instance, if the content of the first document paragraph is "The scrapping standard for rail expansion joints is...", and the source of the first document paragraph is the "Qingdao Metro Maintenance Regulations", then the extended context of this first document paragraph is: the paragraph content from the Qingdao Metro Maintenance Regulations is "The scrapping standard for rail expansion joints is...".

[0052] For example, if the metadata includes source information and glossary entries, the outline of the extended context can be: the paragraph content from (the source information in the metadata) is (the content of the first document fragment), and the glossary entries therein include (the glossary entries in the metadata). Thus, when expanding the content of the first document fragment based on its metadata, the source information contained in the metadata is filled into the first set of parentheses, the content of the first document fragment is filled into the second set of parentheses, and the glossary entries from the metadata are filled into the third set of parentheses, thereby obtaining an extended context that includes both the content of the first document fragment and the metadata.

[0053] The above method can be used to obtain an extended context that includes the content and metadata of the first document fragment, and the coherence of the extended context is guaranteed.

[0054] Step 1302. Determine the relevance between the extended context and the query information.

[0055] In some embodiments of this application, for each first document fragment, the extended context and query information of the first document fragment are combined into a data pair. This data pair is then input into a ranking model to obtain a relevance score for the data pair output by the ranking model. The relevance score is used to characterize the degree of relevance between the extended context and the query information. A higher relevance score indicates a greater relevance between the extended context and the query information, while a lower relevance score indicates a smaller relevance between the extended context and the query information.

[0056] Step 1303. Determine the relevance between the extended context and the query information as the relevance between the first document fragment and the query information.

[0057] In some embodiments of this application, the extended context is generated based on the content and metadata of the first document fragment, and it is closely related to the first document fragment. Therefore, the relevance between the extended context and the query information represents the relevance between the first document fragment and the query information. Thus, for each first document fragment, the relevance between the extended context of the first document fragment and the query information is determined as the relevance between the first document fragment and the query information.

[0058] Traditional methods for determining the relevance between a first document fragment and query information based on ranking models typically involve inputting the query information and contextual data derived from the content of the first document fragment into the ranking model for relevance scoring. However, due to the complexity of user questions in the rail transit field, this approach may lead to inaccurate relevance determinations. In this embodiment, the content of the first document fragment is expanded based on its metadata. This allows the ranking model to consider not only the content of the first document fragment but also metadata such as its source when determining relevance. This enables the ranking model to better understand the importance and relevance of the first document fragment, resulting in a more accurate relevance score.

[0059] Step 140. Based on relevance, determine the K second document fragments that are most relevant to the query information from among the multiple first document fragments, where K is a positive integer.

[0060] In some embodiments of this application, to improve the accuracy of the final answer, when filtering multiple first document fragments based on relevance, the K document fragments most relevant to the query information are selected as the final document fragments used to generate the answer. For ease of distinction, the document fragments used to generate the answer are referred to as second document fragments. Here, K is a positive integer, and the value of K is typically in the range [1, 5]. The specific value of K can be determined according to the actual situation.

[0061] In some embodiments of this application, after obtaining the relevance between each first document fragment and the query information, the multiple first document fragments are sorted in descending order of relevance. Based on the sorting result, the top K first document fragments are extracted from the multiple first document fragments as K second document fragments. In this way, the K second document fragments most relevant to the query information are obtained.

[0062] Step 150. Based on the content and meta-information of the K second document fragments, generate and output the target information of the query information. The target information includes any one of the following: response information, response information and source information of the response information.

[0063] Here, the target information of the query is the information output by the question-and-answer device in response to the query. The target information includes at least the response information, which is the information used to reply to the query, typically the answer to the query. In addition to the response information, the target information may also include the source information of the response. The source information of the response indicates the origin of the response, specifying which documents the response originates from, such as an official document, procedure, or technical manual. The source information of the response can be determined based on the source information of the second document fragment used to generate the response. For questions in specialized fields, clearly identifying the source of the answer can increase user trust in the answer.

[0064] In some embodiments of this application, after obtaining K second document fragments, the question-answering device can use a generation module to generate target information for the query based on the content and metadata of the K second document fragments using a pre-trained large model. After obtaining the target information, the device outputs the target information, thereby completing the response to the query.

[0065] This embodiment does not specifically limit the large model used when generating target information. For example, an open-source large model or a self-developed large model can be used.

[0066] The question-answering method provided in this application extracts metadata of the query information; based on the query information and metadata, it retrieves multiple first document fragments and their metadata from a preset rail transit knowledge base, each related to the query information; based on the content and metadata of each first document fragment, it determines the relevance between each first document fragment and the query information; based on the relevance, it identifies K second document fragments most relevant to the query information from among the multiple first document fragments; based on the content and metadata of the K second document fragments, it generates and outputs target information of the query information, which includes any one of the following: response information, response information, and source information of the response information. According to this application embodiment, by providing metadata of document fragments, the background of the document fragments can be better understood, thereby improving the accuracy of retrieval and answer generation, and thus generating more relevant target information. In addition, for questions in professional fields, clarifying the source of the answer can increase the user's trust in the answer.

[0067] In some embodiments, prior to step 120 above, a rail transit knowledge base may be created through steps 210-250 below.

[0068] Step 210. Obtain documentation in the field of rail transit.

[0069] In some embodiments of this application, a large amount of document data generated during the daily operation, maintenance, and management of urban rail transit systems can be obtained as documents in the rail transit field. This document data includes, but is not limited to, technical specifications, operation manuals, equipment fault reports, maintenance logs, etc.

[0070] Step 220. Divide each document into one or more document fragments using a preset partitioning method.

[0071] In some embodiments of this application, when creating a rail transit knowledge base, documents can be divided using a structural partitioning method. Structural partitioning includes dividing documents based on their structure, such as titles, numbering, chapters, and paragraphs. For example, in an operation manual, each chapter or important section can be treated as a document fragment.

[0072] In other embodiments of this application, when creating a rail transit knowledge base, documents can be segmented using semantic segmentation. Semantic segmentation includes determining the topic distribution in a document using natural language processing techniques, such as Latent Dirichlet Allocation (LDA), and segmenting the document according to the topics. For example, in a document containing content on subway operation management, railway signaling systems, and high-speed train manufacturing, an LDA model can identify three topics: subway operation management, railway signaling systems, and high-speed train manufacturing. Content related to these three topics can then be segmented into document fragments. Semantic segmentation can also include calculating the semantic similarity between different paragraphs in a document and grouping paragraphs with high semantic similarity into a single document fragment. For example, a cosine similarity algorithm can be used to calculate the semantic similarity between paragraphs, and paragraphs with similarity exceeding a certain threshold can be grouped into a single document fragment.

[0073] In other embodiments of this application, when creating a rail transit knowledge base, documents can be manually divided. Manual division involves personnel in the relevant field determining the boundaries of document fragments based on their knowledge and experience. Manual division ensures the accuracy and usability of the document fragments.

[0074] It should be noted that, in addition to the above-mentioned structural division, semantic division and manual division methods for dividing documents, other division methods can also be used to divide documents according to the actual situation. This embodiment does not make specific limitations on this.

[0075] Step 223. For each document fragment, create metadata for that document fragment based on the document to which it belongs.

[0076] In some embodiments of this application, the metadata of a document fragment includes at least the source information of the document fragment. For each document fragment, the document name of the document to which the document fragment belongs can be used as the source information of the document fragment. In addition to the source information, the metadata may also include glossary entries, terminology explanations, etc., for explaining the nouns and / or terms contained in the document fragment. The glossary entries and terminology explanations can be obtained from the document to which the document fragment belongs.

[0077] Step 240. Based on all the document fragments obtained from the segmentation and the metadata of each document fragment, a rail transit knowledge base is formed.

[0078] In some embodiments of this application, all document fragments and the metadata of each document fragment can be stored in a knowledge base, and the association between each document fragment and its corresponding metadata in the knowledge base can be established, thereby obtaining a rail transit knowledge base.

[0079] In some embodiments of this application, as the operating time of urban rail transit systems increases and equipment is upgraded, documents in the field of urban rail transit are constantly updated. In order to improve the accuracy of retrieval, the rail transit knowledge base is updated along with the updates of documents in the field of urban rail transit.

[0080] In some embodiments, the metadata of the query information includes keywords and the target document name. Based on this, in step 110 above, the following steps 1101-1102 can be used to extract the metadata of the query information.

[0081] Step 1101. Extract keywords of preset types from the query information. The preset types include at least one of the following: city name, system name, device name, and technical terminology.

[0082] In some embodiments of this application, keywords are one of the core components of the metadata extraction module. By semantically parsing the query information, the most representative words in the query information are identified and used as keywords. Typically, core words appearing in the query information can effectively narrow the search scope. In the field of urban rail transit, keywords often involve equipment names, technical terms, and proper nouns related to the city or system. For example, for the query "According to the Qingdao Metro maintenance regulations, what is the scrapping standard for rail expansion joints?", the extracted keywords include: "Qingdao," "rail expansion joint," and "scrapping standard." Here, "Qingdao" is a city-related place name, "rail expansion joint" is a specific equipment name, and "scrapping standard" is a term related to the operation or standard. Based on this, when extracting keywords from the query information, words such as city names, system names, equipment names, and technical terms are extracted as keywords. These keywords can help the question-and-answer device quickly locate document fragments related to the query information in the field of urban rail transit, thus narrowing the search scope.

[0083] Step 1102. Based on the fuzzy matching algorithm, extract the target document name that matches the query information from the preset document name set. The document name set includes multiple document names related to urban rail transit.

[0084] In some embodiments of this application, in the field of urban rail transit, user-inputted queries are often closely related to specific technical documents, procedures, or operation manuals. However, due to the complexity of document names, users may not be able to remember the complete document names, making the document names in their input queries potentially inaccurate. Therefore, embodiments of this application employ a fuzzy document name extraction mechanism. Based on a fuzzy matching algorithm, it extracts the target document name that matches the query from a preset set of document names. For example, in the query "According to the Qingdao Metro Maintenance Regulations, what is the scrapping standard for rail expansion joints?", "Qingdao Metro Maintenance Regulations" is a fuzzy document name mentioned by the user. The metadata extraction module of the question-and-answer device uses a fuzzy matching algorithm to match the document name closest to this fuzzy document name from the set of document names, such as "Qingdao Metro Equipment Maintenance Regulations" or "Qingdao Metro Equipment Maintenance Standards," as the target document name. This allows the target document name to be used as the primary source of document fragments for subsequent searches, helping the question-and-answer device quickly locate the document fragment most relevant to the question and narrowing the search scope.

[0085] In some embodiments, because documents in the field of urban rail transit are regional and proprietary—for example, technical regulations may differ between cities—a full-text search of the rail transit knowledge base without filtering would result in a large amount of irrelevant content in the results, severely affecting the generation of the final answer. Therefore, before step 120 above, the rail transit knowledge base can be filtered using the following steps:

[0086] Filter out document fragments in the rail transit knowledge base that do not contain metadata to obtain a set of candidate document fragments.

[0087] Accordingly, in step 120 above, based on the query information and metadata, multiple first document fragments related to the query information are retrieved from a preset rail transit knowledge base, including:

[0088] Based on the query information and metadata, multiple first document fragments related to the query information are retrieved from a set of candidate document fragments.

[0089] In this embodiment, a metadata-based filtering mechanism is used to initially screen the rail transit knowledge base. Core information provided by the metadata extraction module, such as city name, equipment name, and regulation type, is used to filter document fragments within the knowledge base. For example, for the question "According to the Qingdao Metro maintenance regulations, what are the scrapping standards for rail expansion joints?", the question-and-answer device first filters out document fragments unrelated to "Qingdao," retaining only document fragments related to regulations concerning the Qingdao Metro. This filtering step effectively reduces irrelevant noise in subsequent searches and improves search efficiency.

[0090] In some embodiments, at least two different retrieval methods can be used to search the rail transit knowledge base in step 120 above, thereby obtaining at least two search results. Then, based on the at least two search results, multiple first document fragments related to the query information are determined. This can improve the diversity of search results.

[0091] In some embodiments of this application, multiple first document fragments can be obtained in step 120 above through the following steps 1201-1204.

[0092] Step 1201. Based on metadata, perform keyword fuzzy matching search on the rail transit knowledge base to obtain the first search result.

[0093] In some embodiments of this application, to address potential spelling errors, non-standard expressions, or other ambiguities in user-input queries, the retrieval module employs a keyword fuzzy matching retrieval mechanism to search the rail transit knowledge base. This mechanism, through fault-tolerant matching, ensures that relevant content can be retrieved even when information is ambiguous. The fuzzy matching algorithm uses Levenshtein Distance or other fuzzy matching algorithms to retrieve document fragments related to the query information, obtaining the first retrieval result.

[0094] Step 1202. Perform sparse vector retrieval on the rail transit knowledge base based on the query information to obtain the second retrieval result.

[0095] In some embodiments of this application, the retrieval module also incorporates sparse vector retrieval technology, which retrieves document fragments based on the sparse representation of the query information. This method has advantages in handling exact matching of specific technical terms or keywords.

[0096] In some embodiments of this application, step 1202 described above can be implemented by steps 310-340 as follows.

[0097] Step 310. Using the bag-of-words model, the query information is converted into a sparse vector to obtain the target sparse vector.

[0098] In the bag-of-words model, the dimension of a vector is equal to the size of the vocabulary, and the value of each dimension represents the number of times the corresponding word appears in the text.

[0099] Step 320. Using the bag-of-words model, each document fragment in the rail transit knowledge base is converted into a sparse vector to obtain a set of sparse vectors.

[0100] Step 330. Calculate the similarity between the target sparse vector and each sparse vector in the sparse vector set.

[0101] In some embodiments of this application, the similarity between the target sparse vector and each sparse vector in the sparse vector set can be calculated using algorithms such as Cosine Similarity and Jaccard Similarity.

[0102] Step 340. Take the document fragments corresponding to the sparse vectors in the sparse vector set whose similarity satisfies the first preset condition as the second search result.

[0103] In some embodiments of this application, the first preset condition is a condition set in advance based on actual conditions, used to select document fragments with high relevance to the query information from the rail transit knowledge base. For example, the first preset condition includes the highest similarity. Based on this, in step 340 above, the sparse vectors in the sparse vector set are sorted in descending order of similarity, and based on the sorting result, the document fragment corresponding to the sparse vector with the highest similarity is taken as the second search result.

[0104] Step 1203. Perform dense vector retrieval on the rail transit knowledge base based on the query information to obtain the third retrieval result.

[0105] In some embodiments of this application, dense vector retrieval is a semantic similarity-based retrieval technique that understands the contextual meaning in natural language, rather than relying solely on surface-level word matching. In this way, the retrieval module can understand the semantic intent behind the query and retrieve the document fragments that are semantically most relevant to the query.

[0106] In some embodiments of this application, step 1203 described above can be implemented by steps 410-440 as follows.

[0107] Step 410. By using an embedding model, the query information is converted into a dense vector to obtain the target dense vector.

[0108] In some embodiments of this application, the embedding model includes, but is not limited to, BERT or other Transformer-based models. The embedding model can map query information into a high-dimensional semantic space.

[0109] Step 420. By using the embedding model, each document fragment in the rail transit knowledge base is converted into a dense vector, resulting in a set of dense vectors.

[0110] Embedding models can map document fragments into a high-dimensional semantic space.

[0111] Step 430. Calculate the similarity between the target dense vector and each dense vector in the set of dense vectors.

[0112] In some embodiments of this application, similarity algorithms such as cosine similarity algorithm and Euclidean distance algorithm can be used to calculate the similarity between the target dense vector and each dense vector in the dense vector set. This embodiment does not specifically limit this.

[0113] Step 440. Take the document fragments corresponding to the dense vectors in the dense vector set whose similarity satisfies the second preset condition as the third search result.

[0114] In some embodiments of this application, the second preset condition is a condition set in advance based on actual conditions, used to select document fragments with high relevance to the query information from the rail transit knowledge base. For example, the second preset condition includes the highest similarity. Based on this, in step 440 above, the dense vectors in the dense vector set are sorted in descending order of similarity, and based on the sorting result, the document fragment corresponding to the dense vector with the highest similarity is taken as the third search result.

[0115] Step 1204. Based on the first search result, the second search result, and the third search result, identify multiple first document fragments related to the query information.

[0116] In some embodiments of this application, after obtaining the first search result, the second search result, and the third search result, all document fragments contained in the first search result, the second search result, and the third search result can be identified as the first document fragment.

[0117] In some other embodiments of this application, the first search result, the second search result, and the third search result may contain a large number of document fragments. Since multiple first document fragments need to be filtered through steps 130 and 140 above after obtaining them, if the number of first document fragments is too large, steps 130 and 140 will take a long time, thus affecting the real-time performance of the question-and-answer process. Therefore, in step 1204 above, multiple first document fragments can be determined through the following steps:

[0118] Based on a preset ranking and fusion algorithm, the document fragments contained in the first, second, and third search results are sorted in descending order of relevance to the query information to obtain the ranking results. Based on the ranking results, the document fragments ranked in the top N positions are identified as multiple first document fragments related to the query information. N is a positive integer set according to the actual situation, and the value of N is usually greater than the value of K.

[0119] Here, the ranking fusion algorithm is an algorithm used to merge and rank search results from different retrieval technologies. Ranking fusion algorithms include, but are not limited to, methods such as RRF (Relevance Rank Fusion). Compared to filtering using a ranking model, filtering using a ranking fusion algorithm requires less time. Therefore, performing preliminary filtering in the above manner before filtering through steps 130 and 140 can reduce the number of first document fragments, shorten the time required to filter second document fragments, and thus improve the real-time performance of question answering.

[0120] In some embodiments, after obtaining K second document fragments, the target information corresponding to the query information can be generated based on the K second document fragments, that is, the corresponding answer can be generated. In traditional RAG methods, a common answer generation approach is to integrate multiple retrieved document fragments into a large document fragment, and then input this integrated document fragment along with the query information into a large model for generating the answer. However, this method has the following problems:

[0121] Information noise exists. When multiple retrieved paragraphs are simply concatenated and input into the generation model, redundant or irrelevant content between paragraphs may lead to the generated answers being chaotic, irrelevant, or even incorrect.

[0122] Context mismatch: different paragraphs may come from different documents or contexts. When these paragraphs are forcibly combined, the generative model has difficulty accurately identifying the most relevant information.

[0123] Therefore, simply merging multiple retrieved document fragments and inputting them into a large model will significantly reduce the quality of the generated answers, especially for questions in specialized fields, where the answers are usually concentrated in a specific document fragment rather than scattered across multiple document fragments.

[0124] In view of this, to solve the above problems, this application introduces a segment-by-segment polling generation mechanism. This mechanism generates answers by inputting each of the K second document segments into the large model one by one, until the model successfully generates an answer that meets the query information requirements. Based on this, in step 150 above, the target information can be generated and output through steps 510-540 as follows.

[0125] Step 510. Select the second document fragment with the highest relevance to the query information from the K second document fragments as the target document fragment.

[0126] In some embodiments of this application, the target document fragment is the document fragment currently used as input to the large model for answer generation. When generating target information, the question-answering device selects one second document fragment as the target document fragment in a round-robin fashion, based on a ranking of K second document fragments according to their similarity. Therefore, the second document fragment with the highest relevance is selected first as the target document fragment.

[0127] Step 520. Input the target document fragment and the query information into the pre-trained large model to obtain the answer corresponding to the target document fragment.

[0128] In some embodiments of this application, after the target document fragment and the query information are input into the large model, the large model can use its pre-trained language knowledge and generation capabilities to generate an answer related to the query information, and use this answer as the answer corresponding to the target document fragment.

[0129] Step 530. If the answer meets the third preset condition, the answer is used as the response information to the query, and the source information of the target document fragment is used as the source information of the response information.

[0130] In some embodiments of this application, the third preset condition can be set according to actual conditions. For example, the third preset condition includes that the answer accurately addresses the query information. Based on this, after generating the answer, the large model can check the completeness and relevance of the answer to determine whether the answer accurately addresses the query information. If the answer accurately addresses the user's input query information, it is determined that the answer meets the third preset condition. At this point, the polling stops, and the currently obtained answer is determined as the response information to the query information. The source information of the current target document fragment is determined as the source information of the response information, and the response information and its source information are output as target information.

[0131] Step 540. If the answer does not meet the third preset condition, in order of decreasing relevance between the K second document fragments and the query information, take the next second document fragment as the target document fragment, and return to execute the step of inputting the target document fragment and the query information into the pre-trained large model to obtain the answer corresponding to the target document fragment, until the polling stop condition is met.

[0132] In some embodiments of this application, if the answer currently generated by the large model does not meet the third preset condition, it means that the currently generated answer cannot accurately answer the user's input query information. At this time, according to the sorting result of K second document fragments, the next second document fragment is selected as the target document fragment, and the above steps 520 and 530 are repeated in this way until the preset polling stop condition is met.

[0133] In some embodiments of this application, the polling stop conditions include, but are not limited to, obtaining an answer that meets a third preset condition, or obtaining an answer corresponding to the last second document fragment. Based on the above polling stop conditions, if an answer that meets the third preset condition is obtained during the polling process, the obtained answer that meets the third preset condition is determined as the response information to the query, and the source information of the target document fragment used to generate the answer is determined as the source information of the response information and output, and the polling stops. If no answer that meets the third preset condition is obtained during the polling process, the polling stops after obtaining the answer corresponding to the last second document fragment.

[0134] By employing the aforementioned polling generation mechanism, each second document fragment is processed individually, avoiding the mixing of multiple irrelevant or incomplete pieces of information and effectively reducing the impact of noise on the generated results. The polling mechanism stops subsequent processing immediately after the large model generates an accurate answer for the first time, avoiding the processing of irrelevant document fragments and thus improving generation efficiency.

[0135] In some embodiments, the target information for generating and outputting the query information based on the content and meta-information of K second document fragments may further include:

[0136] If the answer to the last second document fragment out of K second document fragments is obtained, and the answer does not meet the third preset condition, the prompt message will be output as the response message, which indicates that the query cannot be answered.

[0137] In some embodiments of this application, if no answer meeting the third preset condition is obtained after polling all the second document fragments, it is considered that the query cannot be answered at present. In this case, a prompt message is output as the response message to inform the user that the query cannot be answered at present. The content of the prompt message can be preset according to the actual situation. For example, the prompt message can be "Sorry, I cannot answer this question".

[0138] By using the methods described above, we can ensure that every query entered by the user receives a corresponding response, thereby improving the user experience.

[0139] Based on the question-and-answer method provided in the above embodiments, this application also provides specific implementations of the question-and-answer device. Please refer to the following embodiments.

[0140] Referring to Figure 2, which is a schematic diagram of a question-and-answer device provided in an embodiment of this application, as shown in Figure 2, the device 200 includes the following modules:

[0141] Metadata extraction module 210 is used to extract metadata from query information;

[0142] The retrieval module 220 is used to retrieve multiple first document fragments and their metadata from a preset rail transit knowledge base based on query information and metadata. The rail transit knowledge base includes multiple document fragments and metadata for each document fragment. The metadata includes at least the source information of the document fragment.

[0143] The retrieval module 220 is also used to determine the relevance between each first document fragment and the query information based on the content and meta-information of each first document fragment respectively;

[0144] The retrieval module 220 is also used to determine, based on relevance, the K most relevant second document fragments among multiple first document fragments to the query information, where K is a positive integer;

[0145] The generation module 230 is used to generate and output the target information of the query information based on the content and meta-information of K second document fragments. The target information includes any one of the following: response information, response information and source information of response information.

[0146] The question-answering device provided in this application extracts metadata of the query information; based on the query information and metadata, it retrieves multiple first document fragments and their metadata from a preset rail transit knowledge base, each related to the query information; based on the content and metadata of each first document fragment, it determines the relevance between each first document fragment and the query information; based on the relevance, it determines K second document fragments most relevant to the query information among the multiple first document fragments; based on the content and metadata of the K second document fragments, it generates and outputs target information of the query information, which includes any one of the following: response information, response information, and source information of the response information. According to this application embodiment, by providing metadata of document fragments, the background of the document fragments can be better understood, thereby improving the accuracy of retrieval and answer generation, and thus generating more relevant target information. In addition, for questions in professional fields, clarifying the source of the answer can increase the user's trust in the answer.

[0147] In some embodiments, the retrieval module 220 is specifically used for:

[0148] Perform the following steps for each first document fragment:

[0149] Based on the metadata of the first document fragment, the content of the first document fragment is expanded to obtain the extended context of the first document fragment. The extended context includes the content and metadata of the first document fragment.

[0150] Determine the relevance between the extended context and the query information;

[0151] The relevance between the extended context and the query information is determined as the relevance between the first document fragment and the query information.

[0152] In some embodiments, the generation module 230 is specifically used for:

[0153] The second document fragment with the highest relevance to the query information among the K second document fragments is selected as the target document fragment;

[0154] The target document fragment and the query information are input into a pre-trained large model to obtain the answer corresponding to the target document fragment.

[0155] If the answer meets the third preset condition, the answer will be used as the response information to the query, and the source information of the target document fragment will be used as the source information of the response information.

[0156] If the answer does not meet the third preset condition, the next second document fragment is taken as the target document fragment according to the order of high to low relevance between the K second document fragments and the query information. Then, the process of inputting the target document fragment and the query information into the pre-trained large model to obtain the answer corresponding to the target document fragment is returned until the polling stopping condition is met.

[0157] In some embodiments, the generation module 230 is specifically used for:

[0158] If the answer to the last second document fragment out of K second document fragments is obtained, and the answer does not meet the third preset condition, the prompt message will be output as the response message, which indicates that the query cannot be answered.

[0159] In some embodiments, the metadata includes keywords and the target document name. The metadata extraction module 210 is specifically used for:

[0160] Extract keywords of preset types from the query information. The preset types include at least one of the following: city name, system name, device name, and technical terminology.

[0161] Based on the fuzzy matching algorithm, target document names that match the query information are extracted from a preset set of document names. The set of document names includes multiple document names related to urban rail transit.

[0162] In some embodiments, the retrieval module 220 is further configured to:

[0163] Based on the query information and metadata, before retrieving multiple first document fragments related to the query information from the preset rail transit knowledge base, document fragments that do not contain metadata in the rail transit knowledge base are filtered out to obtain a set of candidate document fragments;

[0164] retrieval module 220 is specifically used for:

[0165] Based on the query information and metadata, multiple first document fragments related to the query information are retrieved from a set of candidate document fragments.

[0166] In some embodiments, the retrieval module 220 is specifically used for:

[0167] Based on metadata, a keyword fuzzy matching search was performed on the rail transit knowledge base to obtain the first search result;

[0168] Based on the query information, a sparse vector search is performed on the rail transit knowledge base to obtain the second search result;

[0169] A dense vector search is performed on the rail transit knowledge base based on the query information to obtain the third search result;

[0170] Based on the first search result, the second search result, and the third search result, multiple first document fragments related to the query information were identified.

[0171] In some embodiments, the retrieval module 220 is specifically used for:

[0172] The bag-of-words model is used to convert query information into sparse vectors to obtain the target sparse vector.

[0173] By using the bag-of-words model, each document fragment in the rail transit knowledge base is converted into a sparse vector, resulting in a set of sparse vectors.

[0174] Calculate the similarity between the target sparse vector and each sparse vector in the sparse vector set;

[0175] The document fragments corresponding to sparse vectors in the sparse vector set whose similarity satisfies the first preset condition are used as the second search results.

[0176] In some embodiments, the retrieval module 220 is specifically used for:

[0177] By using an embedding model, the query information is converted into a dense vector, and the target dense vector is obtained.

[0178] By using an embedding model, each document fragment in the rail transit knowledge base is converted into a dense vector, resulting in a set of dense vectors.

[0179] Calculate the similarity between the target dense vector and each dense vector in the dense vector set;

[0180] The document fragments corresponding to the dense vectors in the dense vector set whose similarity satisfies the second preset condition are used as the third search results.

[0181] In some embodiments, the retrieval module 220 is specifically used for:

[0182] Based on a preset ranking and fusion algorithm, the document fragments contained in the first, second, and third search results are sorted in descending order of relevance to the query information to obtain the ranking result.

[0183] Based on the sorting results, the top N document fragments are identified as multiple first document fragments related to the query information, where N is a positive integer.

[0184] The question-and-answer device provided in this application embodiment can implement the various processes implemented in the method embodiment of FIG1. ​​To avoid repetition, it will not be described again here.

[0185] Figure 3 shows a schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application.

[0186] Electronic device 300 may include processor 301 and memory 302 storing computer program instructions.

[0187] Specifically, the processor 301 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0188] Memory 302 may include mass storage for data or instructions. For example, and not limitingly, memory 302 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 302 may include removable or non-removable (or fixed) media. Where appropriate, memory 302 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 302 is non-volatile solid-state memory.

[0189] Memory 302 may include read-only memory (ROM), random access memory (RAM), disk storage media device, optical storage media device, flash memory device, electrical, optical, or other physical / tangible memory storage device. Therefore, typically, memory 302 includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it can perform the operations described in any of the question-and-answer methods in the above embodiments.

[0190] The processor 301 implements any of the question-and-answer methods described in the above embodiments by reading and executing computer program instructions stored in the memory 302.

[0191] In one example, the electronic device 300 may also include a communication interface 303 and a bus 310. As shown in Figure 3, the processor 301, memory 302, and communication interface 303 are connected via the bus 310 and communicate with each other.

[0192] The communication interface 303 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0193] Bus 310 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 310 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0194] Furthermore, in conjunction with the question-and-answer methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the question-and-answer methods in the above embodiments.

[0195] This application also provides a computer program product, including a computer program, which, when executed, implements any of the question-and-answer methods described in the above embodiments.

[0196] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0197] The functional blocks shown in the above-described structural diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0198] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0199] The aspects of this disclosure have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block in 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, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by special-purpose hardware performing the specified functions or actions, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0200] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. A question-and-answer method, comprising: Extract metadata from query information; Based on the query information and the metadata, multiple first document fragments related to the query information and the metadata of the first document fragments are retrieved from a preset rail transit knowledge base. The rail transit knowledge base includes multiple document fragments and metadata of each document fragment. The metadata includes at least the source information of the document fragment. Based on the content and metadata of each first document fragment, the relevance between each first document fragment and the query information is determined. Based on the relevance, K second document fragments that are most relevant to the query information among the plurality of first document fragments are determined, where K is a positive integer; Based on the content and metadata of the K second document fragments, target information of the query information is generated and output, and the target information includes any one of the following: response information, response information and source information of the response information.

2. The method according to claim 1, wherein, The step of determining the relevance between each first document fragment and the query information based on the content and metadata of each first document fragment includes: Perform the following steps for each of the first document fragments: Based on the metadata of the first document fragment, the content of the first document fragment is expanded to obtain the extended context of the first document fragment, wherein the extended context includes the content and metadata of the first document fragment; Determine the relevance between the extended context and the query information; The relevance between the extended context and the query information is determined as the relevance between the first document fragment and the query information.

3. The method according to claim 1, wherein, The step of generating and outputting the target information of the query information based on the content and meta-information of the K second document fragments includes: The second document fragment with the highest relevance to the query information among the K second document fragments is taken as the target document fragment; The target document fragment and the query information are input together into a pre-trained large model to obtain the answer corresponding to the target document fragment. If the answer meets the third preset condition, the answer will be used as the response information to the query, and the source information of the target document fragment will be used as the source information of the response information. If the answer does not meet the third preset condition, the next second document fragment is selected as the target document fragment according to the order of high to low relevance between the K second document fragments and the query information. The process then returns to the step of inputting the target document fragment and the query information into the pre-trained large model to obtain the answer corresponding to the target document fragment, until the polling stop condition is met.

4. The method according to claim 3, wherein, The step of generating and outputting the target information of the query information based on the content and meta-information of the K second document fragments further includes: If the answer corresponding to the last second document fragment among the K second document fragments is obtained, and the answer does not meet the third preset condition, a prompt message will be output as the response message, which is used to indicate that the query information cannot be answered.

5. The method according to any one of claims 1-4, wherein, The metadata includes keywords and the target document name; the metadata for extracting query information includes: Extract keywords of a preset type from the query information. The preset type includes at least one of the following: city name, system name, device name, and technical terminology. Based on a fuzzy matching algorithm, target document names that match the query information are extracted from a preset set of document names, which includes multiple document names related to urban rail transit.

6. The method according to claim 5, wherein, Before retrieving multiple first document fragments related to the query information from a preset rail transit knowledge base based on the query information and the metadata, the method further includes: Filter out document fragments in the rail transit knowledge base that do not contain the metadata to obtain a set of candidate document fragments; The step of retrieving multiple first document fragments related to the query information from a preset rail transit knowledge base based on the query information and the metadata includes: Based on the query information and the metadata, multiple first document fragments related to the query information are retrieved from the set of candidate document fragments.

7. The method according to any one of claims 1-4, wherein, The step of retrieving multiple first document fragments related to the query information from a preset rail transit knowledge base based on the query information and the metadata includes: Based on the metadata, a keyword fuzzy matching search is performed on the rail transit knowledge base to obtain the first search result; Based on the query information, a sparse vector search is performed on the rail transit knowledge base to obtain a second search result; Based on the query information, a dense vector search is performed on the rail transit knowledge base to obtain a third search result; Based on the first search result, the second search result, and the third search result, multiple first document fragments related to the query information are identified.

8. The method according to claim 7, wherein, The second search result obtained by performing sparse vector retrieval on the rail transit knowledge base based on the query information includes: The query information is converted into a sparse vector using the bag-of-words model to obtain the target sparse vector. Using the bag-of-words model, each document fragment in the rail transit knowledge base is converted into a sparse vector, resulting in a set of sparse vectors. Calculate the similarity between the target sparse vector and each sparse vector in the sparse vector set; The document fragments corresponding to the sparse vectors in the sparse vector set whose similarity satisfies the first preset condition are used as the second search results.

9. The method according to claim 7, wherein, The process of performing a dense vector search on the rail transit knowledge base based on the query information to obtain a third search result includes: By using an embedding model, the query information is converted into a dense vector to obtain the target dense vector; Using the embedding model, each document fragment in the rail transit knowledge base is converted into a dense vector, resulting in a set of dense vectors; Calculate the similarity between the target dense vector and each dense vector in the set of dense vectors; The document fragments corresponding to the dense vectors in the set of dense vectors whose similarity satisfies the second preset condition are used as the third search results.

10. The method according to claim 7, wherein, The step of determining multiple first document fragments related to the query information based on the first search result, the second search result, and the third search result includes: Based on a preset sorting and fusion algorithm, the document fragments contained in the first search result, the second search result, and the third search result are sorted in descending order of relevance to the query information to obtain the sorting result; Based on the sorting result, the document fragments ranked in the top N positions are identified as multiple first document fragments related to the query information, where N is a positive integer.

11. A question-and-answer device, comprising: The metadata extraction module is used to extract metadata from query information; The retrieval module is used to retrieve, based on the query information and the metadata, multiple first document fragments and the metadata of the first document fragments related to the query information from a preset rail transit knowledge base. The rail transit knowledge base includes multiple document fragments and the metadata of each document fragment, and the metadata includes at least the source information of the document fragment. The retrieval module is further configured to determine the relevance between each first document fragment and the query information based on the content and metadata of each first document fragment. The retrieval module is further configured to determine, based on the relevance, the K most relevant second document segments among the plurality of first document segments to the query information, where K is a positive integer; The generation module is used to generate and output the target information of the query information based on the content and meta-information of the K second document fragments. The target information includes any one of the following: response information, response information and source information of the response information.

12. An electronic device, characterized in that, The electronic device includes: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the question-and-answer method as described in any one of claims 1-10.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, implement the question-and-answer method as described in any one of claims 1-10.

14. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the electronic device, the electronic device performs the question-and-answer method as described in any one of claims 1-10.