Question and answer processing method, electronic equipment, storage medium and program product
By combining knowledge graphs and text databases in the question-and-answer generation system, evidence clues are automatically filtered and allocated, solving the problem of low accuracy in evidence allocation caused by human experience, and achieving more stable and adaptable question-and-answer generation results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA UNITED NETWORK COMM GRP CO LTD
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-21
Smart Images

Figure CN121901367A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a question-and-answer processing method, electronic device, storage medium, and program product. Background Technology
[0002] Against the backdrop of rapid development in artificial intelligence and natural language processing technologies, user-oriented question-and-answer generation has become an important method for human-computer interaction and knowledge services. Users typically submit queries using natural language, and the system returns semantically clear, reliable, and traceable answers within a short period of time, thereby reducing information acquisition costs and improving business processing efficiency.
[0003] Existing question-answering generation typically employs a framework based on question understanding, information retrieval, and answer generation. In the question understanding stage, semantic analysis is performed on the user-input natural language question to identify the objects, constraints, and semantic relationships involved, converting the natural language representation into an intermediate representation suitable for subsequent processing. In the information retrieval stage, based on this intermediate representation, relevant factual and contextual information is retrieved from structured knowledge stores or document knowledge bases, and this retrieved information serves as evidence clues for subsequent answer generation. In the answer generation stage, the information and text fragments corresponding to the evidence clues are organized and integrated, and this information is input into the generation model, which then outputs a user-facing natural language answer, achieving automated question-answering services.
[0004] However, the methods for selecting and allocating evidence clues typically rely on human experience and strategies for configuration. This includes manually setting the scope and priority of different data sources and manually determining which evidence clues are input into the generation model. Because different individuals have varying understandings of the semantics of the question and the importance of the evidence, manually configured evidence selection and allocation are difficult to guarantee in terms of consistency and adaptability, easily leading to low accuracy in evidence allocation and consequently affecting the stability of the question-and-answer generation results. Summary of the Invention
[0005] This application provides a question-and-answer processing method, electronic device, storage medium, and program product to improve the stability of question-and-answer generation results.
[0006] In a first aspect, embodiments of this application provide a question-and-answer processing method, including:
[0007] Receive user input of a problem to be processed, and extract at least one problem entity corresponding to the problem to be processed;
[0008] Based on the at least one question entity, a pre-set knowledge graph database is retrieved to obtain candidate paths corresponding to the question entity, and path strings corresponding to each candidate path are generated according to preset string generation rules.
[0009] Based on the problem to be solved and each of the path strings, a pre-trained correlation analysis model is used to perform relative analysis, and a set of target paths is selected.
[0010] Based on the target path information in the target path set, a first set of text fragments is obtained from the text database, and based on the problem to be processed, the text database is searched to obtain a second set of text fragments.
[0011] The first set of text fragments and the second set of text fragments are combined to form a target context, and the question to be processed and the target context are input into a pre-trained large language model to obtain the answer result.
[0012] In one possible implementation, extracting at least one problem entity corresponding to the problem to be processed includes:
[0013] The preset entity extraction task description information is concatenated with the problem to be processed to obtain the prompt information;
[0014] The prompt information is input into a pre-trained large language model to obtain structured text information including entity entries and relation entries;
[0015] Parse the structured text information to obtain at least one question entity.
[0016] In one possible implementation, the step of retrieving a preset knowledge graph database based on the at least one question entity to obtain candidate paths corresponding to the question entity includes:
[0017] In a pre-built knowledge graph database, the entity node corresponding to the question entity is located based on the entity name field of the question entity; wherein, the knowledge graph is stored in the knowledge graph database in the form of entity nodes and relation edges;
[0018] Based on a preset hop count threshold, the entity node is taken as the starting node, and the entity nodes and relation edges connecting the starting node are traversed to obtain a candidate path composed of multiple entity nodes and relation edges between adjacent entity nodes.
[0019] Read the text identifiers carried by entity nodes and / or relation edges from the candidate paths, and associate the text identifiers with the candidate paths.
[0020] In one possible implementation, generating the path string corresponding to each candidate path according to a preset string generation rule includes:
[0021] Based on the candidate path, the entity name of the entity node and the relationship name of the relationship edge between adjacent entity nodes are read sequentially.
[0022] Insert a first separator between the entity name and the corresponding relation name, insert a second separator between the relation name and the next entity name, and concatenate them in the order of entity name, first separator, relation name, second separator, and next entity name to obtain the path string corresponding to the candidate path;
[0023] The first separator is a hyphen, and the second separator is an arrow symbol.
[0024] In one possible implementation, the step of performing relative analysis using a pre-trained correlation analysis model based on the problem to be processed and each of the path strings, and selecting a set of target paths, includes:
[0025] Obtain the preset correlation analysis task description information, and concatenate the correlation analysis task description information, the problem to be processed, and each of the path strings to form the input information to be analyzed;
[0026] The input information to be analyzed is input into a pre-trained correlation analysis model to obtain the scoring results of each candidate path;
[0027] Based on the score values in the scoring results, the candidate paths are sorted from high to low, and a preset number of candidate paths are selected from high to low as the target path set;
[0028] Accordingly, based on the target path information in the target path set, a first set of text fragments is obtained from the text database, including:
[0029] Read the text identifiers associated with the target path in the target path set, retrieve the text fragments corresponding to the text identifiers in the text database, and add the retrieved text fragments to the first text fragment set.
[0030] In one possible implementation, the step of retrieving the text database and obtaining a second set of text fragments based on the problem to be processed includes:
[0031] The problem to be processed is subjected to feature vectorization to obtain a problem vector;
[0032] Based on the question vector, a similarity search is performed in the text database. Based on the similarity, a preset number of text segments are selected from high to low and added to the second text segment set.
[0033] In one possible implementation, combining the first set of text fragments and the second set of text fragments to form a target context includes:
[0034] The problem to be processed is identified by type to determine whether it is a simple problem type or a complex problem type.
[0035] If the type identification result of the problem to be processed is a simple problem type, then the second text fragment set and the first text fragment set are concatenated according to the order of the second text fragment set first and the first text fragment set last to obtain the target context;
[0036] Alternatively, if the type identification result of the problem to be processed is a complex problem type, then the first text fragment set and the second text fragment set are concatenated according to the order of the first text fragment set first and the second text fragment set last to obtain the target context;
[0037] Accordingly, the problem to be processed and the target context are input into a pre-trained large language model to obtain the answer result, including:
[0038] Obtain preset question-and-answer generation task description information, and concatenate the question-and-answer generation task description information, the question to be processed, and the target context to form model input text;
[0039] The input text is fed into a pre-trained large language model to obtain the answer to the question to be processed.
[0040] Secondly, embodiments of this application provide a question-and-answer processing apparatus, including:
[0041] The data processing module is used to receive user input of a problem to be processed and extract at least one problem entity corresponding to the problem to be processed;
[0042] The data processing module is also used to retrieve a preset knowledge graph database based on the at least one question entity, obtain candidate paths corresponding to the question entity, and generate path strings corresponding to each candidate path according to preset string generation rules.
[0043] The information analysis module is used to perform relative analysis using a pre-trained correlation analysis model based on the problem to be processed and each of the path strings, and to select and obtain a set of target paths.
[0044] The text retrieval module is used to obtain a first set of text fragments from the text database based on the target path information in the target path set, and to retrieve a second set of text fragments from the text database based on the question to be processed.
[0045] The result output module is used to combine the first set of text fragments and the second set of text fragments to form a target context, and input the question to be processed and the target context into a pre-trained large language model to obtain the answer result.
[0046] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0047] The memory stores computer-executed instructions;
[0048] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0049] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0050] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0051] This application provides a question-answering processing method, electronic device, storage medium, and program product. By setting a candidate path filtering and multi-source text fragment fusion mechanism based on path strings in the question-answering generation process, it achieves unified processing of complex and simple questions. Specifically, question entities are extracted from the question to be processed, and candidate paths are retrieved from a knowledge graph database based on the question entities. The candidate paths are converted into path strings according to preset rules, thereby participating in subsequent relevance analysis with a more compact structured representation. Subsequently, a pre-trained relevance analysis model is used to analyze the question to be processed and each path string to filter out a target path set, reducing the number of paths and the scale of irrelevant information entering the subsequent processing stage. On this basis, on the one hand, a first set of text fragments is extracted from a text database based on the path information associated with the target path set, and on the other hand, a second set of text fragments is retrieved from the text database based on the question to be processed. The two types of text fragments are combined to form a target context for a pre-trained large language model to generate an answer. Therefore, this application can maintain the association analysis capability based on knowledge graphs while setting up supplementary text retrieval information for questions, so that the context content entering the large language model is more focused on information related to the question, thereby improving the effective information density and the completeness of evidence coverage in the answer generation stage, and thus improving the stability and adaptability of the question-and-answer results. Attached Figure Description
[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0053] Figure 1 A flowchart illustrating the question-and-answer processing method provided in an embodiment of this application;
[0054] Figure 2 A schematic diagram of a method for obtaining candidate paths corresponding to problem entities provided in an embodiment of this application;
[0055] Figure 3 This is a schematic diagram of the method for obtaining the target context provided in an embodiment of this application;
[0056] Figure 4 This is a schematic diagram of the question-and-answer processing device provided in the embodiments of this application;
[0057] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0058] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0059] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0060] The inventive concept of this application lies in addressing the problem that the screening and allocation of evidence clues in existing question-and-answer generation processes rely on human experience, leading to low accuracy in evidence allocation. This invention constructs an automated evidence acquisition and organization chain driven by the question to be processed, enabling evidence clues to be screened and input into the generation model on a controllable scale and based on comparable relevance. This application first receives the question to be processed input by the user and extracts at least one question entity corresponding to the question. Candidate paths corresponding to the question entities are then retrieved from a pre-set knowledge graph database, thereby obtaining a structured set of clues that can be used for multi-entity association analysis. Considering that the structural information and related content directly carried by the candidate paths may be redundant, each candidate path is further converted into a path string according to a preset string generation rule. This allows the candidate paths to participate in subsequent analysis in a unified text sequence form, thus providing a compact and processable expression carrier for path-level screening.
[0061] After candidate paths are textualized into path strings, a pre-trained relevance analysis model is used to perform relative analysis between the problem to be addressed and each path string, and a target path set is selected accordingly. The relative analysis setting ensures that candidate path selection does not rely on fixed manual thresholds or rules, but rather compares the relevance of multiple paths within the same problem context using the model, establishing path priorities and selecting a target path set that better matches the problem to be addressed. Subsequently, based on the target path information in the target path set, a first set of text fragments is retrieved from a text database to obtain textual evidence corresponding to the structured path clues; simultaneously, a second set of text fragments is retrieved from the text database for the problem to be addressed to obtain supplementary evidence directly related to the problem's semantics. By constructing two types of text fragment sets in parallel, the structured analysis clues and text retrieval evidence are organized uniformly within the same framework, reducing the reliance on manual configuration strategies for evidence selection and allocation.
[0062] Finally, the first and second sets of text fragments are combined to form the target context. The question to be processed and the target context are then input into a pre-trained large language model to generate the answer. This allows the pre-trained large language model to complete understanding and generation within a controlled range of evidence. This automates and structures the acquisition, screening, and allocation of evidence clues, making the evidence entering the generation model more relevant to the question and maintaining a controllable scale. This, in turn, helps improve the accuracy of evidence allocation and enhances the stability of the question-and-answer generation results.
[0063] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0064] Figure 1 This is a flowchart illustrating the question-and-answer processing method provided in the embodiments of this application, as shown below. Figure 1 As shown, the method includes:
[0065] S11, receive the user input of the problem to be processed, and extract at least one problem entity corresponding to the problem to be processed.
[0066] Specifically, the problem to be processed can be a single sentence or multiple sentences of natural language text, which may contain synonyms, abbreviations, aliases, and information such as time ranges and quantity ranges. Basic normalization processing is performed on the problem to be processed, such as standardizing character encoding, removing redundant symbols irrelevant to semantics, merging consecutive whitespace, and maintaining format regularity while preserving the original semantics, to ensure that subsequent extraction processes are conducted under stable input. By receiving and parsing the problem to be processed, a unified entry point for the subsequent knowledge acquisition process is achieved, reducing the interference of input noise on the recognition results.
[0067] After parsing the problem to be processed, at least one problem entity is extracted from it. The problem entity characterizes the core object to which the problem refers and serves as the basis for subsequent locating the search scope in the knowledge graph database. Based on the semantic context of the problem, object expressions with clear referents are identified, and the identification results are processed for consistency, ensuring that different expressions of the same object remain consistent at the output level. Simultaneously, duplicate identified objects are deduplicated, and generalized words without referential meaning are removed, resulting in a set of problem entities that meet the needs of subsequent retrieval. By extracting problem entities, natural language questions are mapped to object anchors that can be used for structured retrieval, thereby providing a clear starting point for subsequent candidate path retrieval and narrowing the search space.
[0068] S12, based on at least one question entity, retrieve the pre-set knowledge graph database, obtain the candidate path corresponding to the question entity, and generate the path string corresponding to each candidate path according to the preset string generation rules.
[0069] In this embodiment, a pre-built knowledge graph database is used to express the relationships between knowledge elements through connections between entities. Candidate paths are connection sequences retrieved from the knowledge graph database around the question entity, describing the set of relational clues formed between the question entity and other entities. During the retrieval process, the question entity is used as the retrieval anchor point to locate the entity object corresponding to the question entity in the knowledge graph database, and path results associated with that entity object are obtained within the retrieval scope, ensuring that candidate paths cover the related information that the question may involve. By obtaining candidate paths based on the question entity in the knowledge graph database, it is possible to extract relational clues related to the question from structured knowledge, providing a candidate set for subsequent analysis and screening of path relevance.
[0070] After obtaining candidate paths, each candidate path is converted into a path string. String generation rules define the linear representation of entities and relationships within the candidate paths, ensuring that the paths are represented as a text sequence in a unified format while maintaining connection order and pointing relationships. The path strings compress the structural information of the candidate paths into serialized content that can be directly input into the analysis model, facilitating subsequent comparison and selection of multiple candidate paths. By generating corresponding path strings for candidate paths, standardized encoding and expression of path information are achieved, reducing the impact of path structural redundancy on processing efficiency.
[0071] S13. Based on the problem to be processed and each path string, a pre-trained correlation analysis model is used to perform relative analysis and select the target path set.
[0072] Specifically, the pre-trained relevance analysis model is used to understand the semantic constraints of the problem to be processed and compare the matching degree of each path string with the problem to be processed, forming a relative priority relationship between different path strings within the same problem context. By comparing multiple path strings in a unified context, a comparable expression of path relevance is achieved, providing a consistent basis for subsequent path selection.
[0073] Based on the priority relationships obtained from relative analysis, a target path set is selected from the paths corresponding to each path string. This target path set is used to retain paths with a higher degree of relevance to the question being addressed, reducing the probability of less relevant paths entering subsequent text extraction and context construction stages. By filtering to form the target path set, the size of the paths is controlled, and irrelevant paths are suppressed. This allows subsequent text fragment retrieval from the text database and the construction of the target context to revolve around more relevant path clues, thereby improving the stability and usability of the question-answering process.
[0074] S14. Based on the target path information in the target path set, obtain the first text fragment set from the text database, and based on the problem to be processed, retrieve the second text fragment set from the text database.
[0075] In this embodiment, based on the target path set, the information of each target path in the target path set is read, and the target path information is used as the retrieval basis to obtain the text content corresponding to the target path in the text database, forming a first text fragment set. The first text fragment set is used to carry text information consistent with the target path set, so that the entity association clues represented by the target path set have supporting content at the text level that can be understood and generated subsequently. By obtaining the first text fragment set from the text database according to the target path set, the correspondence between structured path clues and text evidence is realized, enabling the subsequent construction of the target context to revolve around the target path that is more relevant to the problem to be addressed, and reducing text noise introduced by irrelevant paths.
[0076] Simultaneously, for the question to be processed, a search is performed directly in the text database to obtain text content related to the question, forming a second set of text fragments. This second set of text fragments provides textual evidence directly related to the semantics of the question, supplementing any gaps in evidence caused by background information or differences in expression that the first set of text fragments might not have covered. By retrieving the first and second sets of text fragments in parallel from the same text database, the synchronous supply of path-related evidence based on the target path set and question-related evidence based on the question to be processed is achieved. This provides a more complete and controllable source of evidence for subsequent combination to form the target context, thereby improving the stability and adaptability of the question-answering process.
[0077] S15, combine the first set of text fragments and the second set of text fragments to form the target context, and input the question to be processed and the target context into the pre-trained large language model to obtain the answer result.
[0078] In this embodiment, the target context is the contextual information used to drive the pre-trained large language model to generate the answer result. It includes textual evidence related to the question to be processed, enabling the pre-trained large language model to refer to factual and contextual information related to the question during the generation process. By combining the two types of text fragment sets, a unified organization of textual evidence from different retrieval paths is achieved, resulting in more complete evidence coverage for subsequent model inputs and reducing input inconsistencies caused by evidence dispersion.
[0079] After forming the target context, the question to be processed and the target context are jointly input into a pre-trained large language model. The pre-trained large language model jointly understands and synthesizes the text content of the question to be processed and the target context, and outputs the answer corresponding to the question to be processed. The pre-trained large language model can complete semantic induction and answer expression within the evidence limited by the target context, so that the answer is generated based on the evidence provided in the target context. By using the question to be processed and the target context as unified input to obtain the answer, the centralized processing and consistent generation of evidence and questions are achieved. This allows the answer to be output with the joint support of path-related evidence and question-related evidence, which helps to improve the stability and usability of question-answering results.
[0080] In one embodiment, the extraction of the problem entity in step S11 above will be further explained here. Based on the above embodiment, it includes:
[0081] S111, the preset entity extraction task description information is concatenated with the problem to be processed to obtain the prompt information;
[0082] S112, input the prompt information into the pre-trained large language model to obtain structured text information including entity entries and relation entries;
[0083] S113, parse the structured text information to obtain at least one question entity.
[0084] In this embodiment, entity extraction task description information is pre-set to regulate the processing behavior of the pre-trained large language model when receiving input. The entity extraction task description information may include a description of the task objective, analysis requirements for the problem to be processed, and content regarding the output format. This information instructs the pre-trained large language model to identify words describing specific objects and words describing the relationships between objects according to specified rules when processing the problem, and output them as entity entries and relation entries, respectively. The entity extraction task description information is concatenated with the problem to be processed to obtain prompt information, enabling the pre-trained large language model to simultaneously obtain general task instructions and specific problem content from the same input, thereby completing the entity and relation recognition process within a unified context. By attaching entity extraction task description information before or after the problem to be processed, the behavior of the pre-trained large language model is guided.
[0085] Next, the prompt information is input into a pre-trained large language model. Based on the task description and semantic content of the problem to be processed in the prompt information, the pre-trained large language model understands and analyzes the problem text, and generates structured text information including entity entries and relation entries according to the requirements of entity extraction task description information. The structured text information can be represented using a clearly marked text format, such as distinguishing entity entries and relation entries through preset tags, separators, or hierarchical structures. By using a pre-trained large language model to process the prompt information, targeted entity and relation extraction of the problem to be processed is achieved without relying on a large number of manual rules, ensuring that the output content meets the formal requirements of subsequent parsing.
[0086] After obtaining structured text information, the portions belonging to entity entries are identified from the structured text information, and these portions are extracted as question entities to form at least one question entity. The parsing process may include segmenting the structured text information, extracting entity entries by tags or by key identifiers, and performing deduplication, format standardization, and character filtering on the extracted entity entries to ensure that the question entities can be directly used in subsequent knowledge graph database retrieval steps. By parsing the structured text information and extracting question entities, the transformation from natural language questions to knowledge graph identifiable object identifiers is realized. This provides a clear and standardized input foundation for subsequent retrieval of candidate paths in the knowledge graph based on question entities, reducing the impact of manually configured vocabularies or manually defined rules on the overall behavior.
[0087] In one embodiment, Figure 2 This is a schematic flowchart illustrating a method for obtaining candidate paths corresponding to problem entities, provided in an embodiment of this application. Step S12 above will be further explained here. Based on the above embodiment, as... Figure 2 As shown, it includes:
[0088] S21, In the pre-built knowledge graph database, locate the entity node corresponding to the question entity based on the entity name field of the question entity; wherein, the knowledge graph is stored in the knowledge graph database in the form of entity nodes and relation edges;
[0089] S22, based on the preset hop count threshold, take the entity node as the starting node, traverse the entity nodes and relation edges connecting the starting node, and obtain the candidate path composed of multiple entity nodes and relation edges between adjacent entity nodes.
[0090] S23, Read the text identifiers carried by entity nodes and / or relation edges from the candidate paths, and associate the text identifiers with the candidate paths.
[0091] In this embodiment, a knowledge graph is pre-built and stored in a knowledge graph database (such as Neo4j). The knowledge graph represents knowledge elements within a domain and their interrelationships in the form of entity nodes and relation edges. Entity nodes represent specific objects or concepts, and relation edges represent the relationships between entity nodes. Entity nodes include an entity name field to identify the entity. After receiving at least one question entity, the text content of the question entity can be matched with the entity name field to locate the corresponding entity node in the knowledge graph database. This entity name-based location method allows for the rapid determination of the starting position associated with the question in the structured graph data, providing a clear graph structure entry point for subsequent path expansion around the question entity.
[0092] After locating the entity node corresponding to the problem entity, this entity node is used as the starting node for path traversal, and path expansion is performed in the knowledge graph based on a preset hop count threshold. The preset hop count threshold limits the maximum number of relational edges that can be traversed starting from the starting entity node, thereby limiting the path length and reducing the generation of excessively long or numerous paths in complex graph structures. During traversal, adjacent entity nodes are visited sequentially along the relational edges connecting the starting entity node, and the information of nodes and edges is recorded according to the connection order of the relational edges between entity nodes and adjacent entity nodes, forming a candidate path set composed of multiple entity nodes and relational edges between adjacent entity nodes. By using a traversal strategy based on the hop count threshold, the number and length of candidate paths are controlled, ensuring coverage of clues related to the problem entity while reducing interference from irrelevant or excessively deep paths to subsequent analysis and processing.
[0093] After obtaining candidate paths, the text identifiers carried by entity nodes and / or relation edges on each path are read one by one, and these text identifiers are associated with the corresponding candidate paths. The text identifiers are used to locate text fragments associated with entity nodes or relation edges in the text database; they can be unique identifiers, index numbers, or other marking information that uniquely points to the target text. By establishing a correspondence between candidate paths and text identifiers, the candidate paths not only contain structural information about entity nodes and relation edges but also have the ability to access relevant text fragments in the text database. By associating candidate paths with text identifiers, an effective mapping between the knowledge graph structure information and the knowledge content in the external text database is achieved. This provides a direct and reliable index for subsequently obtaining the first set of text fragments from the text database based on the target path set, improving the targeting and efficiency of text evidence extraction.
[0094] Next, in one embodiment, according to a preset string generation rule, a path string corresponding to each candidate path is generated, including:
[0095] S121, based on the candidate path, sequentially read the entity name of the entity node and the relationship name of the relationship edge between adjacent entity nodes;
[0096] S122, insert a first separator between the entity name and the corresponding relation name, insert a second separator between the relation name and the next entity name, and concatenate them in the order of entity name, first separator, relation name, second separator and next entity name to obtain the path string corresponding to the candidate path; wherein, the first separator is a hyphen and the second separator is an arrow symbol.
[0097] In this embodiment, based on the candidate path, to convert the structured path information into a linear text format suitable for the input model, the entity names of each entity node on the candidate path and the relationship names of the edges between adjacent entity nodes are read sequentially. By reading the entity names and relationship names in the order of path traversal, the entities and relationships involved in the path can be completely extracted without losing the path structure information, providing an ordered sequence of elements for subsequent string concatenation. By sequentially reading the entity names and relationship names based on the candidate path, the graph structure information is decomposed into serializable units, laying the foundation for the construction of the path string.
[0098] After obtaining the entity names and their relationship names in the candidate path, these names are combined into a path string according to a preset concatenation rule. Specifically, a first separator is inserted between the entity name and its corresponding relationship name, and a second separator is inserted between the relationship name and the next entity name. The concatenation is performed in the order of entity name, first separator, relationship name, second separator, and next entity name, sequentially completing the concatenation operation for all entity names and relationship names along the path direction. The first separator is a hyphen used to tightly connect the entity name with its subsequent relationship name; the second separator is an arrow symbol used to indicate the pointing relationship between the relationship name and the next entity name. This format of separator insertion clearly presents the order and connection direction of entities and relationships in the path string in text form. By using different separators for regular concatenation between entity names and relationship names, a unified text encoding for the candidate path is achieved, ensuring that the path string retains the topological structure characteristics of the path while possessing good readability and parsability.
[0099] Applying the above concatenation process to candidate paths yields path strings that correspond one-to-one with each candidate path. These path strings serve as text representations of the candidate paths and can be used as input to the subsequent pre-trained relevance analysis model. By generating path strings corresponding to candidate paths, the graph structure information, originally stored as entity nodes and relation edges, is compressed into a text sequence of controllable length. This reduces the computational resource consumption of redundant structural details in the subsequent model analysis stage, improves the efficiency of relevance comparison and selection among candidate paths, and facilitates batch processing in a unified text format across large-scale candidate path sets.
[0100] In one embodiment, step S13 is implemented as follows: Based on the above embodiment, a pre-trained correlation analysis model is used to perform relative analysis to obtain a set of target paths, including:
[0101] S131, Obtain the preset correlation analysis task description information, and concatenate the correlation analysis task description information, the problem to be processed, and each path string to form the input information to be analyzed;
[0102] S132, Input the input information to be analyzed into the pre-trained correlation analysis model to obtain the scoring results of each candidate path;
[0103] S133, based on the score values in the scoring results, sort the candidate paths from high to low, and select a preset number of candidate paths from high to low as the target path set.
[0104] In this embodiment, pre-defined relevance analysis task description information is obtained to standardize the processing logic of the pre-trained relevance analysis model when performing relevance analysis. The relevance analysis task description information is a text instruction that drives the model's behavior, which may include a description of the analysis task objective, requirements for judging the association between the problem to be processed and the path strings, and constraints on the output format. For example, the relevance analysis task description information may instruct the pre-trained relevance analysis model to comprehensively judge whether each path string can provide entity association clues or processing basis related to the problem to be processed based on the semantic content of the problem to be processed, and output the scoring result for each candidate path in a unified format. By concatenating the relevance analysis task description information with the problem to be processed and each path string to form the input information to be analyzed, the pre-trained relevance analysis model can simultaneously obtain the task-level instructions, the user question, and the complete set of candidate paths during processing, thereby comparing and analyzing the relevance between each candidate path and the problem to be processed in a unified context. By appending the relevance analysis task description information before and after the problem to be processed and the path strings, the analysis behavior of the pre-trained relevance analysis model is guided, which helps to improve the semantic consistency and interpretability of the scoring results.
[0105] Then, the input information to be analyzed is fed into a pre-trained relevance analysis model. The pre-trained relevance analysis model is a large language model or other deep learning model used for analyzing text relevance. This model already possesses the ability to understand natural language semantics and determine similarity during the pre-training stage. After receiving the input information, the model jointly analyzes the semantic content of the problem to be processed and the entity and relational connection structure expressed by each path string. Based on the rules given in the relevance analysis task description, it generates scoring results for each candidate path. The scoring results include at least the score value corresponding to each candidate path, used to characterize the degree of matching between the candidate path and the problem to be processed; the scoring results may also contain intermediate analysis information or structured tags for subsequent sorting and filtering based on the score values. By using the pre-trained relevance analysis model to process the input information, a unified quantitative description of the relevance between multiple candidate paths and the problem to be processed is achieved, providing basic data for subsequent path filtering based on score values.
[0106] Based on the scores in the evaluation results, candidate paths are sorted from highest to lowest, and a preset threshold number of candidate paths are selected as the target path set. Candidate paths with higher scores are more relevant to the question and are prioritized during sorting, while those with lower scores are ranked lower. The preset threshold specifies the upper limit for the number of candidate paths selected into the target path set. This allows for the retention of only those candidate paths with higher scores in subsequent text fragment extraction and answer generation processes when the total number of candidate paths is large. This method of sorting by score combined with a preset threshold effectively controls the size of the target path set while prioritizing paths relevant to the question, reducing redundant information and additional computational overhead introduced by too many paths. By sorting candidate paths and selecting the target path set, simplification and optimization at the path level are achieved. This provides a structural foundation for focusing on highly relevant paths when retrieving the first set of text fragments from the text database, thereby improving the efficiency and stability of question-and-answer processing.
[0107] In one embodiment, obtaining a first set of text fragments from a text database includes: reading text identifiers associated with target paths in a target path set, retrieving text fragments corresponding to the text identifiers from the text database, and adding the retrieved text fragments to the first set of text fragments.
[0108] In this embodiment, for each target path in the target path set, the text identifier associated with that target path is read. The text identifier indicates the location of the associated text in the text database and may correspond to one or more text fragments. By establishing and utilizing the association between the target path set and the text identifier, the structured path information in the knowledge graph can be accurately mapped to specific text fragments in the text database, reducing the uncertainty caused by repeated retrieval in the text database using keywords or fuzzy matching.
[0109] After obtaining the text identifiers associated with the target path, a retrieval operation is performed in the text database based on these identifiers to locate the text fragments corresponding to each identifier. The text database can pre-store multiple text fragments, each assigned a unique text identifier. During retrieval, the corresponding text content can be directly accessed based on the text identifier without additional semantic matching or content comparison, thereby improving the certainty and efficiency of text extraction. For each target path, the corresponding text fragments can be sequentially retrieved from the text database using the text identifiers associated with that target path, and these retrieved text fragments serve as textual evidence for that target path. This text identifier-based retrieval method ensures that the text fragments obtained from the text database are semantically and structurally consistent with the target path, which is beneficial for maintaining consistency between the path analysis chain and the textual evidence.
[0110] After retrieving text fragments for each target path in the target path set, all retrieved text fragments are added one by one to the first text fragment set, forming a text evidence set corresponding to the target path set. The text content contained in the first text fragment set centrally reflects the background information, attribute descriptions, or association explanations of the entities and relationships involved in the target path set, providing structured textual support for subsequent target context construction and response generation. The text content in the first text fragment set can be directly referenced when constructing the target context, improving the completeness and usability of the path-related evidence organization.
[0111] In one embodiment, the acquisition of the second set of text fragments in step S14 above is provided as an implementation method. Based on the above embodiment, it includes:
[0112] S141, Perform feature vectorization on the problem to be processed to obtain the problem vector;
[0113] S142, Based on the question vector, perform a similarity search in the text database, and select a preset number of text segments from high to low similarity to add to the second text segment set.
[0114] In this embodiment, the problem to be processed is vectorized into features, which transforms the original natural language problem into a numerical representation that facilitates similarity calculation. Feature vectorization encodes the text content of the problem using a feature extraction model, mapping the problem to a problem vector in the semantic space, so that semantically similar problems are closer in the vector space. The feature vector can be a fixed-dimensional real-number vector that comprehensively reflects the keywords, contextual semantics, and intent information contained in the problem. In this way, natural language content that is originally difficult to compare directly numerically is converted into a vector representation that supports distance or similarity measurement, providing a foundation for subsequent similarity retrieval in the text database. By vectorizing the problem into features, the semantic information of the problem is quantitatively expressed, enabling similarity analysis between the problem and candidate text fragments in a unified feature representation form.
[0115] After obtaining the question vector, a similarity search is performed in a text database based on the question vector to select text content with high relevance to the question from a large number of text fragments. The text database can pre-generate and store corresponding feature vectors for each text fragment. During the search, the question vector is used as the query vector, and the similarity between the question vector and the feature vectors of each text fragment is calculated. Similarity can be calculated using distance metrics or similarity functions; a higher similarity value indicates that the text fragment is semantically closer to the question. After similarity calculation, the text fragments are sorted from highest to lowest similarity, and a preset threshold number of text fragments are selected and added to a second text fragment set. The preset threshold limits the number of text fragments added to the second text fragment set, focusing on the text fragments most closely related to the question while reducing input redundancy caused by too many text fragments. By performing a similarity search in the text database based on the question vector and selecting text fragments with high similarity, the effect of obtaining highly relevant textual evidence related to the question is achieved. This provides textual support directly corresponding to the question's semantics for the subsequent construction of the target context, helping to improve the matching degree between the answer results and the user's question.
[0116] In another embodiment, regarding the process of retrieving a second set of text fragments from a text database based on the question to be addressed, in order to further improve the accuracy of text fragment ranking while maintaining the recall scope, the candidate text fragments can be re-ranked after similarity retrieval. Specifically, the number of text fragments in the candidate text fragment set can be greater than a preset upper limit for the number of text fragments in the second text fragment set, so as to ensure sufficient coverage during the recall phase and reduce the loss of potentially high-value text fragments during the initial similarity retrieval phase.
[0117] Next, the question to be processed and the set of candidate text fragments are input into the re-ranking model. The re-ranking model is used to perform a more refined analysis of the semantic relevance between the question to be processed and each candidate text fragment. The re-ranking model can be a relevance discrimination model built on a pre-trained large language model, or a ranking model trained for question-answering scenarios. The model receives the text content of the question to be processed and each candidate text fragment, and outputs a relevance score for each candidate text fragment. Compared with the initial retrieval based on vector similarity, the re-ranking model can comprehensively consider the semantic constraints in the question, contextual relationships, and the semantic integrity within the text fragments, making a more detailed distinction between candidate text fragments. By setting the re-ranking model to re-rank the candidate text fragments, a fine-grained ranking process based on recall is achieved, making the text fragments that ultimately participate in constructing the target context more semantically relevant to the question to be processed.
[0118] After re-ranking, based on the relevance scores in the re-ranking results, a predetermined number of text fragments are selected from the candidate text fragment set in descending order of relevance score. These selected text fragments are then added to the second text fragment set. The predetermined number can be determined based on factors such as the acceptable input length of the pre-trained large language model and the ratio between the first and second text fragment sets in the target context, in order to retain the most relevant text evidence to the question while controlling the input size. By employing a re-ranking model on the candidate text fragment set and selecting a predetermined number of high-scoring text fragments, a second text fragment set is constructed to supplement the target context. This second text fragment set, while originating from a text database, possesses both good recall breadth and high relevance accuracy, which is beneficial for supporting the generation of subsequent answer results together with the first text fragment set.
[0119] Figure 3 This is a schematic flowchart illustrating a method for obtaining a target context provided in an embodiment of this application. Based on the above embodiments, as follows... Figure 3 As shown, the first set of text fragments and the second set of text fragments are combined to form the target context, including:
[0120] S31, perform type identification on the problem to be processed to obtain the simple problem type or the complex problem type.
[0121] In this embodiment, the problem to be processed undergoes type identification to distinguish whether it belongs to a simple or complex problem type. Type identification can analyze the text content of the problem to be processed using a type identification model to determine the problem structure and analysis requirements. Simple problem types typically correspond to questions that can be answered directly from a small number of text fragments, such as questions that can be answered by a single-step query or a single entity attribute. Complex problem types typically correspond to questions that require multi-entity, multi-relationship, or multi-step logical analysis to obtain an answer, such as questions that require comprehensive judgment along multiple related clues. By identifying the type of the problem to be processed, the priority order of text fragments from different sources can be adjusted according to the complexity of the problem during the target context construction stage, thereby making the organization of the target context more compatible with the characteristics of the problem. By identifying the type of the problem to be processed, a basis for adaptive adjustment of the subsequent text fragment splicing strategy is established.
[0122] S32, if the type identification result of the problem to be processed is a simple problem type, then the second text fragment set and the first text fragment set are concatenated according to the order of the second text fragment set first and the first text fragment set last to obtain the target context.
[0123] Specifically, the second set of text fragments consists of text fragments directly retrieved from the text database related to the question to be processed, focusing more on direct semantic matching with the question. In simple question scenarios, these text fragments often already contain enough key information to generate an answer. Placing the second set of text fragments at the beginning of the target context allows the pre-trained large language model to prioritize direct evidence that highly matches the question during answer generation, while placing the first set of text fragments from the target path set at the end as a supplement helps reduce the interference of introducing too much path analysis-related content into the model's attention in simple question scenarios. By prioritizing the use of the second set of text fragments to construct the target context in simple question types, the evidence in the answer generation process is simplified and the key points are highlighted, which is beneficial to improving the efficiency and stability of answering simple questions.
[0124] S33, if the type identification result of the problem to be processed is a complex problem type, then the first text fragment set and the second text fragment set are concatenated according to the order of the first text fragment set first and the second text fragment set last to obtain the target context.
[0125] Specifically, the first set of text fragments, extracted from the text database based on the target path set, reflects the association paths around the question entity in the knowledge graph and their corresponding textual descriptions. For questions requiring multi-step analysis or path-level inference, the first set of text fragments can provide the main evidence needed for a structured analysis chain. By placing the first set of text fragments at the beginning of the target context in complex question types, the pre-trained large language model can prioritize using textual evidence organized along the path during the response process, while placing the second set of text fragments as supplementary information at the end to compensate for the insufficient semantic coverage of the overall question by path-related text fragments. By prioritizing the use of the first set of text fragments to construct the target context in complex question types, the structured utilization of evidence in multi-hop analysis scenarios is enhanced, improving the processing coherence and accuracy of complex question responses while maintaining information sufficiency.
[0126] In one embodiment, based on the above embodiments, the problem to be processed and the target context are input into a pre-trained large language model to obtain the answer result, including:
[0127] S151, Obtain the preset question-and-answer generation task description information, and concatenate the question-and-answer generation task description information, the question to be processed, and the target context to form the model input text;
[0128] S152, input the input text into the pre-trained large language model to obtain the answer to the question to be processed.
[0129] In this embodiment, a question-answering generation task description is pre-acquired to guide the behavior of the pre-trained large language model when generating answers. The question-answering generation task description can be a text instruction explaining the question-answering objective, answering style, and how evidence information is used. It typically includes requirements such as instructing the pre-trained large language model to answer the question based on information from the target context and to provide appropriate feedback when a clear conclusion cannot be obtained from the target context. By concatenating the question-answering generation task description, the question, and the target context to form the model input text, the pre-trained large language model simultaneously obtains task-level constraints, the specific question posed by the user, and multi-source textual evidence related to the question within the same input. Introducing the question-answering generation task description into the model input text guides the output behavior of the pre-trained large language model, helping to improve the consistency and controllability of the answer results in terms of content scope, expression form, and evidence dependence.
[0130] After constructing the model input text, it is fed into a pre-trained large language model. The pre-trained large language model encodes and understands the input text, comprehensively considering the evidence provided by the first and second text fragment sets in the target context, and combining this with the semantic content of the question to generate an answer. The pre-trained large language model can leverage its language understanding and generation capabilities learned during pre-training to jointly process the task description, question description, and contextual information in the input text, thereby providing a natural language answer that conforms to semantic logic within the scope of the target context. By using the model input text as a unified input to drive the pre-trained large language model to generate answer results, question-answering output based on both structured path evidence and text retrieval evidence is achieved. This ensures that the answer results are relevant while also being adaptable to both complex analytical questions and simple retrieval questions, improving the reliability and practicality of the overall question-answering process.
[0131] Figure 4 This is a schematic diagram of the structure of the question-and-answer processing device provided in the embodiments of this application, as shown below. Figure 4 As shown, the question-and-answer processing device 40 provided in this embodiment includes:
[0132] The data processing module 401 is used to receive the user input of the problem to be processed and extract at least one problem entity corresponding to the problem to be processed;
[0133] The data processing module 401 is also used to retrieve a pre-set knowledge graph database based on at least one question entity, obtain candidate paths corresponding to the question entity, and generate path strings corresponding to each candidate path according to a preset string generation rule.
[0134] The information analysis module 402 is used to perform relative analysis based on the problem to be processed and each path string, using a pre-trained correlation analysis model, and to select the target path set.
[0135] The text retrieval module 403 is used to obtain a first set of text fragments from the text database based on the target path information in the target path set, and to retrieve a second set of text fragments from the text database based on the problem to be processed.
[0136] The output module 404 is used to combine the first set of text fragments and the second set of text fragments to form the target context, and input the question to be processed and the target context into the pre-trained large language model to obtain the answer result.
[0137] In one possible implementation, the data processing module 401 is specifically used to concatenate the preset entity extraction task description information with the problem to be processed to obtain prompt information; input the prompt information into a pre-trained large language model to obtain structured text information including entity entries and relation entries; and parse the structured text information to obtain at least one problem entity.
[0138] In one possible implementation, the data processing module 401 is further specifically used to locate the entity node corresponding to the problem entity in a pre-set knowledge graph database based on the entity name field of the problem entity; wherein, the knowledge graph is stored in the knowledge graph database in the form of entity nodes and relation edges; based on a preset hop count threshold, the entity node is used as the starting node, and the entity nodes and relation edges connecting the starting node are traversed to obtain a candidate path composed of multiple entity nodes and relation edges between adjacent entity nodes; the text identifiers carried by the entity nodes and / or relation edges are read from the candidate path, and the text identifiers are associated with the candidate path.
[0139] In one possible implementation, the data processing module 401 is further specifically used to read the entity name of the entity node and the relation name of the relation edge between adjacent entity nodes in sequence based on the candidate path; insert a first separator between the entity name and the corresponding relation name, insert a second separator between the relation name and the next entity name, and concatenate them in the order of entity name, first separator, relation name, second separator, and next entity name to obtain the path string corresponding to the candidate path; wherein the first separator is a hyphen and the second separator is an arrow symbol.
[0140] In one possible implementation, the information analysis module 402 is specifically used to obtain the preset relevance analysis task description information, concatenate the relevance analysis task description information, the problem to be processed, and each path string to form the input information to be analyzed; input the input information to be analyzed into a pre-trained relevance analysis model to obtain the scoring results of each candidate path; sort the candidate paths from high to low according to the scoring values in the scoring results, and select a preset number of candidate paths from high to low as the target path set;
[0141] In one possible implementation, the text retrieval module 403 is specifically used to read the text identifiers associated with the target path in the target path set, retrieve the text fragments corresponding to the text identifiers in the text database, and add the retrieved text fragments to the first text fragment set.
[0142] In one possible implementation, the text retrieval module 403 is further specifically used to perform feature vectorization processing on the problem to be processed to obtain a problem vector; based on the problem vector, perform similarity retrieval in the text database; and based on the similarity, select a preset number of text segments from high to low and add them to the second text segment set.
[0143] In one possible implementation, the result output module 404 is specifically used to perform type identification on the problem to be processed, to obtain a simple problem type or a complex problem type; if the type identification result of the problem to be processed is a simple problem type, then the second text fragment set and the first text fragment set are concatenated according to the order of the second text fragment set first and the first text fragment set last to obtain the target context; if the type identification result of the problem to be processed is a complex problem type, then the first text fragment set and the second text fragment set are concatenated according to the order of the first text fragment set first and the second text fragment set last to obtain the target context.
[0144] In one possible implementation, the result output module 404 is specifically used to obtain the preset question-and-answer generation task description information, concatenate the question-and-answer generation task description information, the question to be processed, and the target context to form the model input text; input the model input text into a pre-trained large language model to obtain the answer result of the question to be processed.
[0145] The question-and-answer processing device 40 provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0146] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 50 provided in this embodiment includes at least one processor 501 and a memory 502. Optionally, the electronic device 50 further includes a communication component 503. The processor 501, memory 502, and communication component 503 are connected via a bus 504.
[0147] In a specific implementation, at least one processor 501 executes computer execution instructions stored in memory 502, causing at least one processor 501 to perform the above-described method.
[0148] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0149] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0150] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0151] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0152] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0153] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0154] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0155] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0156] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A question-and-answer processing method, characterized in that, include: Receive user input of a problem to be processed, and extract at least one problem entity corresponding to the problem to be processed; Based on the at least one question entity, a pre-set knowledge graph database is retrieved to obtain candidate paths corresponding to the question entity, and path strings corresponding to each candidate path are generated according to preset string generation rules. Based on the problem to be solved and each of the path strings, a pre-trained correlation analysis model is used to perform relative analysis, and a set of target paths is selected. Based on the target path information in the target path set, a first set of text fragments is obtained from the text database, and based on the problem to be processed, the text database is searched to obtain a second set of text fragments. The first set of text fragments and the second set of text fragments are combined to form a target context, and the question to be processed and the target context are input into a pre-trained large language model to obtain the answer result.
2. The method according to claim 1, characterized in that, The extraction of at least one problem entity corresponding to the problem to be processed includes: The preset entity extraction task description information is concatenated with the problem to be processed to obtain the prompt information; The prompt information is input into a pre-trained large language model to obtain structured text information including entity entries and relation entries; Parse the structured text information to obtain at least one question entity.
3. The method according to claim 1, characterized in that, The step of retrieving a pre-set knowledge graph database based on the at least one question entity to obtain candidate paths corresponding to the question entity includes: In a pre-built knowledge graph database, the entity node corresponding to the question entity is located based on the entity name field of the question entity; wherein, the knowledge graph is stored in the knowledge graph database in the form of entity nodes and relation edges; Based on a preset hop count threshold, the entity node is taken as the starting node, and the entity nodes and relation edges connecting the starting node are traversed to obtain a candidate path composed of multiple entity nodes and relation edges between adjacent entity nodes. Read the text identifiers carried by entity nodes and / or relation edges from the candidate paths, and associate the text identifiers with the candidate paths.
4. The method according to claim 3, characterized in that, The step of generating path strings corresponding to each candidate path according to preset string generation rules includes: Based on the candidate path, the entity name of the entity node and the relationship name of the relationship edge between adjacent entity nodes are read sequentially. Insert a first separator between the entity name and the corresponding relation name, insert a second separator between the relation name and the next entity name, and concatenate them in the order of entity name, first separator, relation name, second separator, and next entity name to obtain the path string corresponding to the candidate path; The first separator is a hyphen, and the second separator is an arrow symbol.
5. The method according to claim 1, characterized in that, The step involves performing relative analysis using a pre-trained correlation analysis model based on the problem to be processed and each of the path strings, and selecting a set of target paths, including: Obtain the preset correlation analysis task description information, and concatenate the correlation analysis task description information, the problem to be processed, and each of the path strings to form the input information to be analyzed; The input information to be analyzed is input into a pre-trained correlation analysis model to obtain the scoring results of each candidate path; Based on the score values in the scoring results, the candidate paths are sorted from high to low, and a preset number of candidate paths are selected from high to low as the target path set; Accordingly, based on the target path information in the target path set, a first set of text fragments is obtained from the text database, including: Read the text identifiers associated with the target path in the target path set, retrieve the text fragments corresponding to the text identifiers in the text database, and add the retrieved text fragments to the first text fragment set.
6. The method according to claim 1, characterized in that, The step of retrieving a second set of text fragments from the text database based on the problem to be processed includes: The problem to be processed is subjected to feature vectorization to obtain a problem vector; Based on the question vector, a similarity search is performed in the text database. Based on the similarity, a preset number of text segments are selected from high to low and added to the second text segment set.
7. The method according to any one of claims 1 to 6, characterized in that, The step of combining the first set of text fragments and the second set of text fragments to form a target context includes: The problem to be processed is identified by type to determine whether it is a simple problem type or a complex problem type. If the type identification result of the problem to be processed is a simple problem type, then the second text fragment set and the first text fragment set are concatenated according to the order of the second text fragment set first and the first text fragment set last to obtain the target context; Alternatively, if the type identification result of the problem to be processed is a complex problem type, then the first text fragment set and the second text fragment set are concatenated according to the order of the first text fragment set first and the second text fragment set last to obtain the target context; Accordingly, the problem to be processed and the target context are input into a pre-trained large language model to obtain the answer result, including: Obtain preset question-and-answer generation task description information, and concatenate the question-and-answer generation task description information, the question to be processed, and the target context to form model input text; The input text is fed into a pre-trained large language model to obtain the answer to the question to be processed.
8. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method of any one of claims 1 to 7.