Question query processing method and electronic equipment

By obtaining context information, rewriting query problems and calculating similarity, and generating new context information, the query result deviation problem caused by fixed rewriting strategy is solved, and the query accuracy of large language models is improved.

CN120256587AActive Publication Date: 2025-07-04INSPUR SUZHOU INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202510705517.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-07-04
Estimated Expiration
2045-05-29

AI Technical Summary

Technical Problem

The method of generating a single rewrite query problem using a fixed rewrite strategy in the prior art causes the query results of large language model to deviate from the user's real needs.

Method used

By receiving user query problems, obtaining context information, rewriting and generating multiple rewritten query problems, and searching similarity from the preset knowledge base to calculate reference text blocks and semantics, generating new context information, and inputting the preset language model for query processing.

Benefits of technology

It improves the accuracy of query results, makes it more in line with the real needs of users, and enhances the semantic matching of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256587A_ABST
    Figure CN120256587A_ABST
Patent Text Reader

Abstract

The invention discloses a question query processing method and electronic equipment, and relates to the technical field of data processing, and the method comprises the following steps: obtaining context information from a historical dialogue according to a query question; rewriting the query problem according to the context information to obtain a plurality of rewritten query problems; retrieving each first reference text block and a plurality of reference semantics of any rewritten query problem; calculating a first similarity between each first reference text block and the rewritten query problem; calculating a second similarity between each reference semantic and the rewritten query problem; generating new context information according to the first similarities, the second similarities, the first reference text blocks and the second reference text blocks corresponding to the reference semantics; according to the method, the query question and the new context information are input into the preset language model to obtain the query result, and the context information and the new context information are obtained and used for assisting query of the query question, so that the query result better meets real requirements of a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and particularly to a method for query problem processing and an electronic device. Background Art

[0002] A large language model is an artificial intelligence system based on deep learning technology. It obtains general language understanding and generation capabilities through pre-training on a large amount of text data for use in user query problems. However, large language models usually have problems such as noise, semantic ambiguity, and implicit requirements. When directly performing user queries, the semantic matching degree between the query problem and the target document paragraph will be insufficient. Therefore, it is usually necessary to rewrite the query problem to initially improve the accuracy of the large language model.

[0003] In related technologies, the current rewriting of user query problems usually uses corresponding fixed rewriting strategies to generate a single rewritten query problem, and inputs the single rewritten query problem into the large language model for query processing to obtain query results. However, in related technologies, the rewriting method of using a fixed rewriting strategy to generate a single rewritten query problem and the processing method of inputting the single rewritten query problem into the large language model for query are likely to cause the query results to deviate from the true needs of users. Summary of the Invention

[0004] This application provides a method for query problem processing and an electronic device to at least solve the problem that in related technologies, the rewriting method of using a fixed rewriting strategy to generate a single rewritten query problem and the processing method of inputting the single rewritten query problem into the large language model for query are likely to cause the query results to deviate from the true needs of users.

[0005] This application provides a method for query problem processing, including:

[0006] Receiving a query problem sent by a user terminal;

[0007] Obtaining corresponding context information from multiple historical conversations according to the query problem;

[0008] Rewriting the query problem according to the context information to obtain multiple rewritten query problems;

[0009] For any rewritten query problem, retrieving multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query problem from a preset knowledge base, where the reference semantics correspond to second reference text blocks;

[0010] Calculating a first similarity between each first reference text block and the rewritten query problem;

[0011] Calculating a second similarity between each reference semantics and the rewritten query problem;

[0012] Generate new context information based on each first similarity, each second similarity, and multiple reference text blocks, where the multiple reference text blocks include each first reference text block and each second reference text block;

[0013] Input the query question and the new context information into a preset language model for query processing to generate a query result;

[0014] Output the query result to the user terminal.

[0015] This application also provides an electronic device, including: a memory for storing a computer program; a processor for implementing the steps of any of the above problem query processing methods when executing the computer program.

[0016] This application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above problem query processing methods are implemented.

[0017] This application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of any of the above problem query processing methods are implemented.

[0018] The problem query processing method and the electronic device provided by the embodiments of this application receive a query question sent by a user terminal; obtain corresponding context information from a historical conversation according to the query question; rewrite the query question according to the context information to obtain multiple rewritten query questions; for any rewritten query question, retrieve multiple reference text blocks corresponding to the rewritten query question from a preset knowledge base; calculate the first similarity between each first reference text block and the rewritten query question; calculate the second similarity between each reference semantics and the rewritten query question; generate new context information based on each first similarity, each second similarity, and the multiple reference text blocks; input the query question and the new context information into a preset language model for query processing to generate a query result and output it to the user terminal. By obtaining context information and new context information to assist the language model in querying the query question, the query result is made more in line with the user's true needs. Brief Description of the Drawings

[0019] To more clearly illustrate the embodiments of this application, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of this application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 It is a schematic diagram of the application scenario of the problem query processing method provided by the embodiments of this application;

[0021] Figure 2 Schematic flowchart of the problem query processing method provided by the embodiment of the present application Figure 1 ;

[0022] Figure 3 Schematic flowchart of the problem query processing method provided by the embodiment of the present application Figure 2 ;

[0023] Figure 4 Schematic structural diagram of the problem query processing device provided by the embodiment of the present application;

[0024] Figure 5 Schematic hardware structure diagram of the electronic device provided by the embodiment of the present application. Detailed implementation manners

[0025] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0026] It should be noted that in the description of the present application, the terms "include", "comprise" or any other variation thereof are intended to cover a non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements but also other elements not explicitly listed, or further includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in the present application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0027] Large language models are a natural language processing technology based on deep learning. Through training with a vast amount of text data, they have the ability to understand and generate human language, and are widely used in various tasks such as text generation, translation, and question answering, and can be used for users to query questions. However, large language models usually have situations such as noise, semantic ambiguity, and implicit requirements. When directly performing user queries, it will lead to insufficient semantic matching between the query question and the target document paragraphs. Therefore, it is usually necessary to rewrite the query question to initially improve the accuracy of the large language model. In related technologies, the current rewriting of user query questions usually uses corresponding fixed rewriting strategies to generate a single rewritten query question, and inputs the single rewritten query question into the large language model for query processing to obtain query results. However, in related technologies, the rewriting method of using a fixed rewriting strategy to generate a single rewritten query question and the processing method of inputting the single rewritten query question into the large language model for query are likely to cause the query results to deviate from the user's true needs.

[0028] To solve the above technical problems, the embodiments of this application propose the following technical concept: The inventor considers the query question sent by the user, obtains the context information based on the query question, and rewrites the query question according to the context information to obtain each rewritten query question. According to any rewritten query question, obtain the corresponding first reference text blocks and reference semantics, where the reference semantics correspond to the second reference text blocks. Calculate the first similarity of the rewritten query question according to each first reference text block, calculate the second similarity of the rewritten query question according to each reference semantic block, use each first similarity, each second similarity, each first reference text block, and each first reference text block to generate new context information, input the query question and the new context information into a preset language model for query processing to generate query results, and use the obtained context information and new context information to assist in querying the query question, so that the query results are more in line with the user's true needs.

[0029] To enable those skilled in the art of this technology to better understand the solution of this application, the following further elaborates on this application in conjunction with the accompanying drawings and specific implementation manners.

[0030] Combined with the specific application environment architecture or specific hardware architecture on which the execution of the problem query processing method depends, the specific application environment architecture or specific hardware architecture is described herein. Refer to Figure 1 , Figure 1 FIG. is a schematic diagram of the application scenario of the problem query processing method.

[0031] As Figure 1 shown, the application scenario of this problem query processing method includes: a user terminal 101 and an electronic device 102.

[0032] The client 101 can be a display terminal or the user's mobile terminal.

[0033] The electronic device 102 can be a computer device or other devices.

[0034] The client 101 sends the query problem to the electronic device 102 via a wireless network. The electronic device 102 obtains the corresponding context information from multiple historical conversations according to the query problem; rewrites the query problem according to the context information to obtain multiple rewritten query problems; for any rewritten query problem, retrieves multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query problem from a preset knowledge base, where the reference semantics correspond to second reference text blocks; calculates the first similarity between each first reference text block and the rewritten query problem; calculates the second similarity between each reference semantics and the rewritten query problem; generates new context information according to each first similarity, each second similarity, each first reference text block and each second reference text block; inputs the query problem and the new context information into a preset language model for query processing to generate a query result; and outputs the query result to the client 101.

[0035] Figure 2 It is a flowchart of the problem query processing method provided by the embodiment of the present application Figure 1 , such as Figure 2 shown, an embodiment of the present application provides a problem query processing method, and the method is described in detail as follows:

[0036] S201: Receive the query problem sent by the client.

[0037] In this embodiment, the query problem includes role information.

[0038] Among them, the query problem is Query; the role information is doctor, scientist or other roles.

[0039] S202: Obtain the corresponding context information from multiple historical conversations according to the query problem.

[0040] Specifically, step S202 specifically includes:

[0041] S2021: Obtain short-term conversations of a preset number of rounds within a preset time according to the query problem and multiple historical conversations, and determine the short-term conversations of the preset number of rounds as short-term memory.

[0042] Specifically, according to the query problem and multiple historical conversations, use the sliding window mechanism to obtain short-term conversations of a preset number of rounds within a preset time.

[0043] Among them, the size of the sliding window in the sliding window mechanism is set to 800 tokens.

[0044] Among them, the preset number of rounds can be any one of 1, 2, or 3, or it can be other numbers of rounds.

[0045] S2022: Extract the domain keywords of the query question.

[0046] S2023: Retrieve one or more domain-related conversations corresponding to the domain keywords in multiple historical conversations, and determine the one or more domain-related conversations as domain memories.

[0047] Specifically, through the BM25 algorithm, retrieve one or more domain-related conversations corresponding to the domain keywords in multiple historical conversations, and determine the one or more domain-related conversations as domain memories.

[0048] Among them, the BM25 algorithm is a scoring model for information retrieval, mainly used to calculate the relevance between a query and a document.

[0049] S2024: Obtain multiple remaining historical conversations except for short-term memories within a preset time according to the query question and multiple historical conversations, and determine the multiple remaining historical conversations as long-term memories.

[0050] S2025: Perform a fusion process on the query question, short-term memory, domain memory, and long-term memory to obtain a first prompt word.

[0051] S2026: Input the first prompt word into a preset language model for processing to generate context information for the query question.

[0052] In this embodiment, the preset language model can be the DeepSeek R1 large model, ChatGLM, or other language models.

[0053] In this embodiment, the storage process of multiple historical conversations includes: collecting multiple historical conversations between the user on the user side and the preset language model, and classifying and storing the multiple historical conversations according to different topics.

[0054] Specifically, collect multiple historical conversations between the user on the user side and the preset language model, and classify and store the multiple historical conversations according to the user, time, and topic.

[0055] Exemplarily, in May 2025, Zhang San had 5 topic conversations with the language model. The first topic conversation had 3 rounds of conversations, and the second topic conversation had 10 rounds of conversations.

[0056] S203: Rewrite the query question according to the context information to obtain multiple rewritten query questions.

[0057] Specifically, step S203 specifically includes:

[0058] S2031: Input the context information, query question, multiple pre-configured rewriting strategies, and a preset second prompt word into a preset language model for processing, and perform the following steps:

[0059] Specifically, the configuration process of the multiple rewriting strategies in step S2031 specifically includes:

[0060] S20311: Determine each initial rewriting strategy.

[0061] In this embodiment, each initial rewriting strategy is an initial general query rewriting strategy, an initial keyword rewriting strategy, an initial language model pseudo-answer rewriting strategy, an initial sub-question rewriting strategy, and an initial core content extraction strategy.

[0062] S20312: Perform functional configuration on each initial rewriting strategy to obtain each configured rewriting strategy.

[0063] Specifically, step S20312 is specifically:

[0064] S203121: Determine the function of each initial rewriting strategy.

[0065] Specifically, determining the function of the initial general query rewriting strategy is: eliminating noise and refining content; determining the function of the initial keyword rewriting strategy is: eliminating noise and retaining key information; determining the function of the initial language model pseudo-answer rewriting strategy is: generating a pseudo-answer to expand more information for the query; determining the function of the initial sub-question rewriting strategy is: performing sub-question rewriting on the original question containing multi-level information; determining the function of the core content extraction strategy is: extracting the core content from the user's original question containing too many details to simplify the question and highlight the key points.

[0066] S203122: Perform functional configuration on the corresponding initial rewriting strategy according to each function to obtain each configured rewriting strategy.

[0067] Specifically, based on step S203121, perform functional configuration on the corresponding initial rewriting strategy according to each function to obtain each configured rewriting strategy as: the configured general query rewriting strategy, the configured keyword rewriting strategy, the configured language model pseudo-answer rewriting strategy, the configured initial sub-question rewriting strategy, and the configured core content extraction strategy.

[0068] S20313: Perform usage guide configuration on each configured rewriting strategy to obtain multiple rewriting strategies.

[0069] In this embodiment, the usage guide is the corresponding rewriting example.

[0070] For example, the usage guide of the general query rewriting strategy is: the original query: "I want to know how to effectively improve sleep quality without using drugs, especially whether there are any natural remedies for people with long-term insomnia?" is rewritten as: "Natural remedies to improve long-term insomnia."

[0071] The guide to using the keyword rewriting strategy is: Original query: "Are there any part-time jobs recommended, with flexible hours and can help me improve my communication skills?" After rewriting: "Part-time jobs recommended, with flexible hours and can help me improve my communication skills."

[0072] The language model pseudo-answer rewriting strategy allows the query to expand more information. The usage guide is: Original query: "What are the advantages of physical computing?" After rewriting: "Advantages of physical computing: parallel computing, encryption security, and solving complex problems."

[0073] The guide to using the subquestion rewriting strategy is: Original query: "On GitHub, which framework has more stars, LangChain or LlamaIndex?" Rewritten: "How many stars does LangChain have on GitHub?" and "How many stars does LlamaIndex have on GitHub?"

[0074] The guide to using the core content extraction strategy is: Original query: "I need to know the park's ticket price, opening hours, waiting time for popular programs, and tour route plans." Rewritten: "Park ticket price, opening hours, popular programs, and tour routes."

[0075] Among them, the multiple rewriting strategies include one or more of the following strategies: general query rewriting strategy, keyword rewriting strategy, language model pseudo-answer rewriting strategy, sub-question rewriting strategy and core content extraction strategy.

[0076] S2032: Supplement the query question according to the context information to obtain the query question.

[0077] S2033: Determine a general query rewriting strategy and a keyword rewriting strategy from a plurality of rewriting strategies according to the query question and the second prompt word.

[0078] Exemplarily, one or more rewriting strategies are determined from a plurality of rewriting strategies according to the query question and the second prompt word through a language model.

[0079] The second prompt word may be: the language model receives a user question that needs to be answered by retrieving relevant content from the enterprise knowledge base. There are {5} rewriting strategies {general query rewriting strategy, keyword rewriting strategy, language model pseudo-answer rewriting strategy, sub-question rewriting strategy and core content extraction strategy}. Please select an appropriate strategy to rewrite the query according to the characteristics of the query.

[0080] S2034: Obtain the usage guides for one or more rewriting strategies.

[0081] S2035: Rewrite the query problem according to each usage guide to obtain multiple rewritten query problems.

[0082] S204: For any rewritten query problem, retrieve multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query problem from a preset knowledge base, where the reference semantics correspond to second reference text blocks.

[0083] In this embodiment, the reference semantics are semantic vectors; correspondingly, step S204 specifically includes:

[0084] S2041: Perform keyword retrieval on the preset knowledge base according to the rewritten query problem to obtain multiple first reference text blocks.

[0085] S2042: Convert the rewritten query problem into a corresponding problem vector.

[0086] S2043: Perform vector retrieval on the preset knowledge base according to the problem vector to obtain multiple reference semantics.

[0087] In addition, before step S204, steps a to d are further included:

[0088] Step a: Collect multiple knowledge documents in a preset format.

[0089] In this embodiment, the preset format can be common document formats such as PDF, WORD, and TXT.

[0090] Step b: Perform preprocessing on each knowledge document to obtain multiple reference text blocks.

[0091] Specifically, step b specifically includes:

[0092] Step b1: Perform parsing processing on each knowledge document to extract corresponding multi-type text contents.

[0093] Specifically, perform parsing processing on each knowledge document to extract text contents of corresponding text types, table types, and picture types.

[0094] Step b2: Perform chunking processing on each type of text content according to a preset text length to obtain multiple reference text blocks.

[0095] In this embodiment, the preset text length can be set to 1 to 2048 tokens, and is generally set to 256 tokens.

[0096] Step c: Convert each reference text block into a corresponding reference semantics.

[0097] Specifically, each reference text block is transformed into a corresponding reference semantics through Eembedding.

[0098] Among them, Eembedding refers to a technology that uses a large-scale language model to convert text into high-dimensional vectors. Generally, bge-large-zh-v1.5 is selected.

[0099] Step d: Store each reference text block and each reference semantics in a preset knowledge base.

[0100] In this embodiment, the preset knowledge base can be an ElasticSearch database or other databases.

[0101] Among them, the ElasticSearch database is an open-source distributed search and analysis engine, an extensible data storage, and a vector database.

[0102] S205: Calculate the first similarity between each first reference text block and the rewritten query question.

[0103] Specifically, step S205 specifically includes:

[0104] S2051: Obtain multiple words in the rewritten query question.

[0105] S2052: Calculate the inverse document frequency of each word according to the number of multiple first reference text blocks.

[0106] In this embodiment, the calculation formula for calculating the inverse document frequency of each word according to the number of reference text blocks includes:

[0107]

[0108] In the formula, is the inverse document frequency of any word; N is the number of first reference text blocks, is the number of document blocks containing any word.

[0109] S2053: Determine the word frequency of each word in the corresponding first reference text block.

[0110] S2054: Determine the length of each first reference text block and the average length of each first reference text block.

[0111] S2055: Calculate the first similarity between each first reference text block and the rewritten query question according to each inverse document frequency, each word frequency, the length of each first reference text block, and the average length of each first reference text block.

[0112] In this embodiment, the formula for calculating the first similarity between each first reference text block and the rewritten query problem according to each inverse document frequency, each term frequency, the length of each first reference text block, and the average length of each first reference text block includes:

[0113]

[0114] In the formula, is the first similarity between the first reference text block and the rewritten query problem; is the rewritten query problem; d is any first reference text block; n is the number of each word; is any word q i 's inverse document frequency; f(q i , d) is the term frequency of any word q i in the first reference text block d; is the length of the first reference text block d; is the average length of each first reference text block; k1 and b are adjustable parameters, k1 is usually between 1.2 and 2, and b is usually set to 0.75.

[0115] S206: Calculate the second similarity between each reference semantics and the rewritten query problem.

[0116] In this embodiment, the formula for calculating the second similarity between each reference semantics and the rewritten query problem includes:

[0117]

[0118] In the formula, is the second similarity between any reference semantics and the rewritten query problem; is the vector corresponding to the rewritten query problem, ; is the vector corresponding to any reference semantics, .

[0119] S207: Generate new context information according to each first similarity, each second similarity, and multiple reference text blocks, where the multiple reference text blocks include each first reference text block and each second reference text block.

[0120] S208: Input the query problem and the new context information into a preset language model for query processing to generate a query result.

[0121] S209: Output the query result to the client.

[0122] In summary, the problem query processing method provided in this embodiment receives a query problem sent by a user terminal; obtains corresponding context information from multiple historical conversations according to the query problem; rewrites the query problem according to the context information to obtain multiple rewritten query problems; for any rewritten query problem, retrieves multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query problem from a preset knowledge base, where the reference semantics correspond to second reference text blocks; calculates a first similarity between each first reference text block and the rewritten query problem; calculates a second similarity between each reference semantics and the rewritten query problem; generates new context information according to each first similarity, each second similarity, and multiple reference text blocks; inputs the query problem and the new context information into a preset language model for query processing to generate a query result and outputs it to the user terminal. By obtaining context information to assist the language model in querying the query problem, the query result better meets the user's real needs.

[0123] In addition, the problem query processing method provided in this embodiment inputs context information, a query problem, multiple preset rewriting strategies, and a preset second prompt word into a preset language algorithm for processing, and performs the following steps: supplement the query problem according to the context information to obtain a query problem; determine one or more rewriting strategies from multiple rewriting strategies according to the query problem and the second prompt word; obtain usage guides for one or more rewriting strategies; rewrite the query problem according to each usage guide to obtain multiple rewritten query problems. By rewriting the query problem through one or more rewriting strategies to obtain multiple rewritten query problems, the subsequent retrieved reference text blocks are diverse and relevant, ensuring the accuracy and recall rate of text block retrieval.

[0124] In addition, the problem query processing method provided in this embodiment can also pre-set different rewriting strategies, support custom expansion, and have good openness, thereby ensuring the improvement of the overall performance of the problem query processing system.

[0125] Figure 3 Schematic flow of the information collection and processing method provided in the embodiments of the present application Figure 2 In the embodiments of the present application, on the basis of the embodiments provided in Figure 2 a detailed description is given of the specific implementation method of generating new context information according to each first similarity, each second similarity, and multiple reference text blocks in step S207. As Figure 3 shown, the method includes:

[0126] S301: Sort each first reference text block according to each first similarity to obtain a first sequence.

[0127] S302: Sort each second reference text block according to each second similarity to obtain a second sequence.

[0128] S303: Obtain the second reference text blocks that are the same as one or more first reference text blocks.

[0129] In this embodiment, there will be partial overlap between each first reference text block and each second reference text block.

[0130] S304: Determine the first serial numbers of one or more first reference text blocks in the first sequence, and determine the second serial numbers of the corresponding second reference text blocks in the second sequence.

[0131] S305: Perform reverse sorting and fusion processing according to the first serial number and the second serial number to obtain the first reverse sorting value of one or more first reference text blocks.

[0132] In this embodiment, the calculation formula for performing reverse sorting and fusion processing according to the first serial number and the second serial number to obtain the first reverse sorting value of one or more first reference text blocks includes:

[0133]

[0134] In the formula, is the first reverse sorting value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; is the first serial number of the first reference text block d , R1 represents the first sequence; is the second serial number of the second reference text block corresponding to the first reference text block d, , R2 represents the second sequence.

[0135] S306: Calculate the second reverse sorting values of the remaining first reference text blocks, and calculate the third reverse sorting values of the remaining second reference text blocks.

[0136] S307: Sort each first reverse sorting value, each second reverse sorting value, and each third reverse sorting value to obtain a reverse fusion sequence.

[0137] S308: Determine a first preset number of target reference text blocks from each first reference text block and each second reference text block according to the reverse fusion sequence.

[0138] S309: Obtain the first target similarity and / or the second target similarity corresponding to each target reference text block from each first similarity and each second similarity.

[0139] S310: Calculate the hybrid similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity.

[0140] In this embodiment, the calculation formula for calculating the hybrid similarity corresponding to each first target reference text block according to each first target similarity and each second target similarity includes:

[0141]

[0142] In the formula, is the hybrid similarity corresponding to any target reference text block; ; is the first target similarity of the target reference text block ; is the second target similarity of the target reference text block .

[0143] S311: Sort each hybrid similarity to obtain the reciprocal hybrid similarity sequence corresponding to each target reference text.

[0144] S312: Determine a second preset number of target reference text blocks from each target reference text block according to the hybrid similarity sequence.

[0145] In this embodiment, the second preset number ≤ the first preset number.

[0146] S313: Determine the second preset number of target reference text blocks as the new context information.

[0147] In summary, for the problem query processing method provided in this embodiment, by sorting each first reference text block according to each first similarity to obtain a first sequence; sorting each second reference text block according to each second similarity to obtain a second sequence; obtaining second reference text blocks that are the same as one or more first reference text blocks; determining the first serial numbers of one or more first reference text blocks in the first sequence, and determining the second serial numbers of the corresponding second reference text blocks in the second sequence; performing reverse sorting fusion processing according to the first serial numbers and the second serial numbers to obtain the first reverse sorting values of one or more first reference text blocks; calculating the second reverse sorting values of the remaining first reference text blocks, and calculating the third reverse sorting values of the remaining second reference text blocks; sorting each first reverse sorting value, each second reverse sorting value, and each third reverse sorting value to obtain a reverse fusion sequence; determining a first preset number of target reference text blocks from each first reference text block and each second reference text block according to the reverse fusion sequence; obtaining the first target similarity and / or the second target similarity corresponding to each target reference text block from each first similarity and each second similarity; calculating the mixed similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity; sorting each mixed similarity to obtain a reverse mixed similarity sequence corresponding to each target reference text; determining a second preset number of target reference text blocks from each target reference text block according to the mixed similarity sequence; determining the second preset number of target reference text blocks as new context information, and by determining the new context information, it is used to assist the subsequent language model in querying the query problem, so that the query result better meets the real needs of the user.

[0148] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware, but in many cases, the former is a better implementation method.

[0149] Figure 4 It is a structural schematic diagram of a problem query processing device provided in an embodiment of the present application. As Figure 4 shown, an embodiment of the present application also provides a problem query processing device, including: a receiving module 401, an obtaining module 402, a rewriting module 403, a retrieval module 404, a first calculation module 405, a second calculation module 406, a generating module 407, an input module 408, and an output module 409.

[0150] The receiving module 401 is configured to receive a query problem sent by a user terminal;

[0151] The obtaining module 402 is configured to obtain corresponding context information from multiple historical conversations according to the query problem;

[0152] The rewriting module 403 is used to rewrite the query question according to the context information to obtain multiple rewritten query questions;

[0153] The retrieval module 404 is used to retrieve, for any rewritten query question, multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query question from a preset knowledge base, where the reference semantics correspond to second reference text blocks;

[0154] The first calculation module 405 is used to calculate the first similarity between each first reference text block and the rewritten query question;

[0155] The second calculation module 406 is used to calculate the second similarity between each reference semantics and the rewritten query question;

[0156] The generation module 407 is used to generate new context information according to each first similarity, each second similarity and multiple reference text blocks, where the multiple reference text blocks include each first reference text block and each second reference text block;

[0157] The input module 408 is used to input the query question and the new context information into a preset language model for query processing to generate a query result;

[0158] The output module 409 is used to output the query result to the user side.

[0159] In a possible implementation manner, the obtaining module 402 specifically includes:

[0160] The first obtaining unit is used to obtain short-term conversations with a preset number of rounds within a preset time according to the query question and multiple historical conversations, and determine the short-term conversations with the preset number of rounds as short-term memories;

[0161] The extraction unit is used to extract the domain keywords of the query question;

[0162] The retrieval unit is used to retrieve one or more domain-related conversations corresponding to the domain keywords from multiple historical conversations, and determine the one or more domain-related conversations as domain memories;

[0163] The second obtaining unit is used to obtain multiple remaining historical conversations except the short-term memories within a preset time according to the query question and multiple historical conversations, and determine the multiple remaining historical conversations as long-term memories;

[0164] The fusion unit is used to perform fusion processing on the query question, short-term memory, domain memory and long-term memory to obtain a first prompt word;

[0165] The input unit is used to input the first prompt word into a preset language model for processing to generate the context information of the query question.

[0166] In a possible implementation, where the reference semantics is a semantic vector; correspondingly, the first retrieval module 404 specifically includes:

[0167] A first retrieval unit, configured to perform keyword retrieval on a preset knowledge base according to the rewritten query question to obtain a plurality of first reference text blocks;

[0168] A conversion unit, configured to convert the rewritten query question into a corresponding question vector;

[0169] A second retrieval unit, configured to perform vector retrieval on a preset knowledge base according to the question vector to obtain a plurality of reference semantics.

[0170] In a possible implementation, the rewriting module 403 specifically includes:

[0171] An input unit, configured to input context information, a query question, a plurality of preset rewriting strategies, and a preset second prompt word into a preset language algorithm for processing, and perform the following steps:

[0172] A supplement unit, configured to supplement the query question according to the context information to obtain a query question;

[0173] A determination unit, configured to determine one or more rewriting strategies from a plurality of rewriting strategies according to the query question and the second prompt word;

[0174] An acquisition unit, configured to acquire usage guides for one or more rewriting strategies;

[0175] A rewriting unit, configured to rewrite the query question according to each usage guide to obtain a plurality of rewritten query questions.

[0176] In a possible implementation, the apparatus further includes:

[0177] A determination module, configured to determine each initial rewriting strategy;

[0178] A first configuration module, configured to perform functional configuration on each initial rewriting strategy to obtain each configured rewriting strategy;

[0179] A second configuration module, configured to perform usage guide configuration on each configured rewriting strategy to obtain a plurality of rewriting strategies.

[0180] In a possible implementation, the plurality of rewriting strategies include one or more of the following strategies:

[0181] General query rewriting strategy, keyword rewriting strategy, language model pseudo-answer rewriting strategy, sub-question rewriting strategy, and core content extraction strategy.

[0182] In a possible implementation, the first calculation module 405 specifically includes:

[0183] An acquisition unit, configured to acquire multiple words in the rewritten query problem;

[0184] A first calculation unit, configured to calculate the inverse document frequency of each word according to the number of multiple first reference text blocks;

[0185] A first determination unit, configured to determine the word frequency of each word in the corresponding first reference text block;

[0186] A second determination unit, configured to determine the length of each first reference text block and the average length of each first reference text block;

[0187] A second calculation unit, configured to calculate the first similarity between each first reference text block and the rewritten query problem according to each inverse document frequency, each word frequency, the length of each first reference text block, and the average length of each first reference text block.

[0188] In a possible implementation, the generation module 407 specifically includes:

[0189] A first sorting unit, configured to sort each first reference text block according to each first similarity to obtain a first sequence;

[0190] A second sorting unit, configured to sort each second reference text block according to each second similarity to obtain a second sequence;

[0191] A first acquisition unit, configured to acquire second reference text blocks that are the same as one or more first reference text blocks;

[0192] A first determination unit, configured to determine the first serial number of one or more first reference text blocks in the first sequence, and determine the second serial number of the corresponding second reference text block in the second sequence;

[0193] A fusion unit, configured to perform reverse sorting fusion processing according to the first serial number and the second serial number to obtain the first reverse sorting value of one or more first reference text blocks;

[0194] A first calculation unit, configured to calculate the second reverse sorting value of the remaining first reference text blocks, and calculate the third reverse sorting value of the remaining second reference text blocks;

[0195] A third sorting unit, configured to sort each first reverse sorting value, each second reverse sorting value, and each third reverse sorting value to obtain a reverse fusion sequence;

[0196] A second determination unit, configured to determine a first preset number of target reference text blocks from each first reference text block and each second reference text block according to the reciprocal fusion sequence;

[0197] A second acquisition unit, configured to acquire a first target similarity and / or a second target similarity corresponding to each target reference text block from each first similarity and each second similarity;

[0198] A second calculation unit, configured to calculate a hybrid similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity;

[0199] A fourth sorting unit, configured to perform a sorting process on each hybrid similarity to obtain a reciprocal hybrid similarity sequence corresponding to each target reference text;

[0200] A third determination unit, configured to determine a second preset number of target reference text blocks from each target reference text block according to the hybrid similarity sequence;

[0201] A fourth determination unit, configured to determine the second preset number of target reference text blocks as new context information.

[0202] In a possible implementation manner, the calculation formula for performing a reciprocal sorting and fusion process according to the first serial number and the second serial number to obtain a first reciprocal sorting value of one or more first reference text blocks includes:

[0203]

[0204] wherein, is the first reciprocal sorting value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; is the first serial number of the first reference text block d , R1 represents the first sequence; is the second serial number of the second reference text block corresponding to the first reference text block d, , R2 represents the second sequence.

[0205] In a possible implementation manner, the calculation formula for calculating a hybrid similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity includes:

[0206]

[0207] wherein, is the hybrid similarity corresponding to any target reference text block; ; is the first target similarity of the target reference text block ; The second target similarity of the target reference text block 。

[0208] In a possible implementation, the apparatus further includes:

[0209] A collection module, configured to collect multiple knowledge documents in a preset format;

[0210] A processing module, configured to preprocess each knowledge document to obtain multiple reference text blocks;

[0211] A conversion module, configured to convert each reference text block into a corresponding reference semantics;

[0212] A storage module, configured to store each reference text block and each reference semantics in a preset knowledge base.

[0213] In a possible implementation, the processing module specifically includes:

[0214] An analysis unit, configured to perform analysis processing on each knowledge document to extract corresponding multi-type text contents;

[0215] A chunking unit, configured to perform chunking processing on each type of text content according to a preset text length to obtain multiple reference text blocks.

[0216] For the description of the features in the corresponding embodiments of the problem query processing apparatus, reference may be made to the relevant descriptions in the corresponding embodiments of the problem query processing method, which will not be elaborated here one by one.

[0217] Figure 5 It is a schematic structural diagram of the electronic device provided by this application. As Figure 5 shown, the electronic device provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the electronic device further includes a communication component 503. Among them, the processor 501, the memory 502, and the communication component 503 are connected through a bus.

[0218] In a specific implementation process, at least one processor 501 executes the computer execution instructions stored in the memory 502, so that at least one processor 501 executes the above-mentioned problem query processing method embodiment.

[0219] For the specific implementation process of the processor 501, reference may be made to the above method embodiment, and its implementation principle and technical effects are similar, which will not be elaborated here in this embodiment.

[0220] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the application can be directly implemented by the execution of the hardware processor, or can be implemented by the combination of the hardware and software modules in the processor.

[0221] The memory may include a random access memory (RAM), and may also include a non-volatile memory (NVM), such as at least one disk memory.

[0222] The bus may be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.

[0223] The embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored, and the computer program is configured to execute the steps in any of the above embodiments of the problem query processing method when running.

[0224] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store computer programs.

[0225] The embodiments of the present application also provide a computer program product, the above computer program product includes a computer program, and when the computer program is executed by a processor, the steps in any of the above embodiments of the problem query processing method are implemented.

[0226] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium storing a computer program, where the computer program, when executed by a processor, implements the steps in any of the above-described embodiments of the problem query processing method.

[0227] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0228] The above has introduced in detail a problem query processing method and an electronic device provided by the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A problem query processing method, characterized in that, Including: Receiving a query question sent by a user terminal; Obtaining corresponding context information from multiple historical conversations according to the query question; Rewriting the query question according to the context information to obtain multiple rewritten query questions; For any rewritten query question, retrieving multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query question from a preset knowledge base, where the reference semantics correspond to second reference text blocks; Calculating a first similarity between each first reference text block and the rewritten query question; Calculating a second similarity between each reference semantics and the rewritten query question; Generating new context information according to the first similarities, the second similarities, and multiple reference text blocks, where the multiple reference text blocks include each first reference text block and each second reference text block; Inputting the query question and the new context information into a preset language model for query processing to generate a query result; Outputting the query result to the user terminal.

2. The problem query processing method according to claim 1, wherein The obtaining corresponding context information according to the query question and multiple historical conversations includes: Obtaining short-term conversations with a preset number of turns within a preset time according to the query question and the multiple historical conversations, and determining the short-term conversations with the preset number of turns as short-term memories; Extracting domain keywords of the query question; Retrieving one or more domain-related conversations corresponding to the domain keywords in the multiple historical conversations, and determining the one or more domain-related conversations as domain memories; Obtaining multiple remaining historical conversations other than the short-term memories within a preset time according to the query question and the multiple historical conversations, and determining the multiple remaining historical conversations as long-term memories; Performing a fusion process on the query question, the short-term memories, the domain memories, and the long-term memories to obtain a first prompt; Inputting the first prompt into a preset language model for processing to generate the context information of the query question.

3. The problem query processing method according to claim 1, characterized in that Wherein the reference semantics are semantic vectors; Correspondingly, for any rewritten query question, retrieving multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query question from a preset knowledge base includes: Performing keyword retrieval on the preset knowledge base according to the rewritten query question to obtain multiple first reference text blocks; Converting the rewritten query question into a corresponding question vector; Performing vector retrieval on the preset knowledge base according to the question vector to obtain multiple reference semantics.

4. The problem query processing method according to claim 1, wherein The rewriting the query question according to the context information to obtain multiple rewritten query questions includes: Inputting the context information, the query question, multiple pre-configured rewriting strategies, and a preset second prompt into the preset language model for processing, and performing the following steps: Supplementing the query question according to the context information to obtain a query question; Determining one or more rewriting strategies from the multiple rewriting strategies according to the query question and the second prompt; Obtaining the usage guides of the one or more rewriting strategies; Rewrite the query problem according to each usage guide to obtain multiple rewritten query problems.

5. The problem query processing method according to claim 4, wherein The configuration process of the multiple rewriting strategies includes: Determine each initial rewriting strategy; Perform functional configuration on each initial rewriting strategy to obtain each configured rewriting strategy; Perform usage guide configuration on each configured rewriting strategy to obtain multiple rewriting strategies.

6. The problem query processing method according to claim 4, wherein The multiple rewriting strategies include one or more of the following strategies: General query rewriting strategy, keyword rewriting strategy, language model pseudo-answer rewriting strategy, sub-question rewriting strategy, and core content extraction strategy.

7. The problem query processing method according to claim 1, wherein The calculation of the first similarity between each first reference text block and the rewritten query problem includes: Obtain multiple words in the rewritten query problem; Calculate the inverse document frequency of each word according to the number of the multiple first reference text blocks; Determine the word frequency of each word in the corresponding first reference text block; Determine the length of each first reference text block and the average length of each first reference text block; Calculate the first similarity between each first reference text block and the rewritten query problem according to each inverse document frequency, each word frequency, the length of each first reference text block, and the average length of each first reference text block.

8. The problem query processing method according to claim 1, wherein The generation of new context information according to the first similarities, the second similarities, and the multiple reference text blocks includes: Perform sorting processing on each first reference text block according to each first similarity to obtain a first sequence; Perform sorting processing on each second reference text block according to each second similarity to obtain a second sequence; Obtain second reference text blocks that are the same as one or more first reference text blocks; Determine the first serial number of the one or more first reference text blocks in the first sequence, and determine the second serial number of the corresponding second reference text block in the second sequence; Perform reverse sorting fusion processing according to the first serial number and the second serial number to obtain the first reverse sorting value of the one or more first reference text blocks; Calculate the second reverse sorting values of the remaining first reference text blocks, and calculate the third reverse sorting values of the remaining second reference text blocks; Perform sorting processing on each first reverse sorting value, each second reverse sorting value, and each third reverse sorting value to obtain a reverse fusion sequence; Determine a first preset number of target reference text blocks from the first reference text blocks and the second reference text blocks according to the reverse fusion sequence; Obtain the first target similarity and / or the second target similarity corresponding to each target reference text block from the first similarities and the second similarities; Calculate the mixed similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity; Perform sorting processing on each mixed similarity to obtain a reverse mixed similarity sequence corresponding to each target reference text; Determine a second preset number of target reference text blocks from the target reference text blocks according to the mixed similarity sequence; Determine the second preset number of target reference text blocks as the new context information.

9. The problem query processing method according to claim 8, wherein The calculation formula for performing reverse sorting fusion processing based on the first serial number and the second serial number to obtain the first reverse sorting value of the one or more first reference text blocks includes: In the formula, is the first reciprocal sorting value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; is the first serial number of the first reference text block d , R1 represents the first sequence; is the second serial number of the second reference text block corresponding to the first reference text block d, , R2 represents the second sequence.

10. The problem query processing method according to claim 8, wherein The calculation formula for calculating the mixed similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity includes: Wherein, is the hybrid similarity corresponding to any target reference text block; ; is the first target similarity of the target reference text block ; is the second target similarity of the target reference text block .

11. The problem query processing method according to claim 1, characterized in that Before retrieving multiple reference text blocks corresponding to the rewritten query problem from the preset knowledge base for any rewritten query problem, it further includes: Collecting multiple knowledge documents in a preset format; Preprocessing each knowledge document to obtain multiple reference text blocks; Converting each reference text block into a corresponding reference semantics; Storing each reference text block and each reference semantics into the preset knowledge base.

12. The problem query processing method according to claim 11, characterized in that The preprocessing of each knowledge document to obtain multiple reference text blocks includes: Performing parsing processing on each knowledge document to extract corresponding multi-type text contents; Performing chunking processing on each type of text content according to a preset text length to obtain multiple reference text blocks.

13. An electronic device, characterized in that, It includes: A memory for storing a computer program; A processor for implementing the steps of the problem query processing method according to any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, wherein the computer program, when executed by a processor, implements the steps of the problem query processing method according to any one of claims 1 to 12.

15. A computer program product, comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the steps of the problem query processing method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Information query expansion method, electronic equipment, storage medium and program product

    CN118535681A

  • Question answering method, device and computer program product

    CN118820420A

  • Retrieval enhancement generation method based on large language model and related products

    CN119025637A

  • Power document intelligent question and answer method and system based on large language model

    CN119577082A

  • Context-based big language model dialogue processing method and apparatus, and electronic device

    CN119831045A

Cited By

  • Question and answer query method and device based on large model

    CN120910222A

  • Interaction method and device, equipment and medium

    CN122332547A

  • Interaction methods, apparatuses, devices, and media

    CN122332547B