Problem query processing method and electronic equipment

By obtaining the context information of the user query problem, rewriting and calculating the similarity to generate new context information, the query result deviation problem caused by fixed rewriting strategy is solved, and the query accuracy of the large language model is improved.

CN120256587BActive Publication Date: 2025-08-08INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510705517.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-08-08
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 CN120256587B_ABST
    Figure CN120256587B_ABST
Patent Text Reader

Abstract

The present application discloses a question query processing method and electronic device, which relate to the field of data processing technology, including: obtaining context information from historical conversations according to a query question; rewriting the query question according to the context information to obtain multiple rewritten query questions; retrieving each first reference text block and multiple reference semantics of any rewritten query question; calculating a first similarity between each first reference text block and the rewritten query question; calculating a second similarity between each reference semantic and the rewritten query question; generating new context information based on each first similarity, each second similarity, each first reference text block, and the second reference text block corresponding to each reference semantic; inputting the query question and the new context information into a preset language model to obtain a query result, and using the obtained context information and the new context information to assist in querying the query question, so that the query result better meets the user's real needs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a question query processing method and electronic equipment. Background Art

[0002] A large language model is an AI system based on deep learning technology. It acquires general language understanding and generation capabilities through pre-training on massive amounts of text data, making it suitable for user query queries. However, large language models often suffer from noise, semantic ambiguity, and implicit requirements. Direct user queries can result in insufficient semantic alignment between the query and the target document. Therefore, it is often necessary to reword the query to initially improve the accuracy of the large language model.

[0003] In the related art, current user query rewriting methods typically use a fixed rewriting strategy to generate a single rewritten query, then input this single rewritten query into a large language model for query processing to obtain query results. However, the rewriting method of using a fixed rewriting strategy to generate a single rewritten query, and the processing method of inputting the single rewritten query into a large language model for query processing, can easily lead to query results that deviate from the user's actual needs. Summary of the Invention

[0004] The present application provides a question query processing method and electronic device to at least solve the problem in the related art of using a fixed rewriting strategy to generate a single rewritten query question, and a processing method of inputting a single re-query question into a large language model for query, which easily causes the query results to deviate from the user's actual needs.

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

[0006] Receive query questions sent by the user;

[0007] Obtain corresponding context information from multiple historical conversations based on the query question;

[0008] Rewrite the query question according to the context information to obtain multiple rewritten query questions;

[0009] For any rewritten query question, retrieving a plurality of first reference text blocks and a plurality of reference semantics corresponding to the rewritten query question from a preset knowledge base, wherein the reference semantics correspond to the second reference text block;

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

[0011] Calculate the second similarity between each reference semantic and the rewritten query question;

[0012] generating new context information according to each first similarity, each second similarity, and a plurality of reference text blocks, wherein the plurality of reference text blocks include each first reference text block and each second reference text block;

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

[0014] Output the query results to the user end.

[0015] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned question query processing methods when executing the computer program.

[0016] The present 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-mentioned question query processing methods are implemented.

[0017] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned question query processing methods when executed by a processor.

[0018] The question query processing method and electronic device provided in the embodiments of the present application receive a query question sent by a user terminal; obtain corresponding context information from historical conversations based on the query question; rewrite the query question based on 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 a first similarity between each first reference text block and the rewritten query question; calculate a second similarity between each reference semantic and the rewritten query question; generate new context information based on each first similarity, each second similarity and 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, so as to assist the language model in querying the query question by obtaining the context information and the new context information, so that the query result is more in line with the user's real needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0020] Figure 1 A schematic diagram of an application scenario of the problem query processing method provided in an embodiment of the present application;

[0021] Figure 2 Schematic diagram of the process of the problem query processing method provided in the embodiment of the application Figure 1 ;

[0022] Figure 3 Schematic diagram of the process of the problem query processing method provided in the embodiment of the application Figure 2 ;

[0023] Figure 4 A schematic diagram of the structure of a question query processing device provided in an embodiment of the present application;

[0024] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

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

[0027] The large language model is a natural language processing technology based on deep learning. Through training on massive amounts of text data, it has the ability to understand and generate human language. It is widely used in various tasks such as text generation, translation, and question-answering, and can be used for user question queries. However, large language models usually have noise, semantic ambiguity, and implicit requirements. When directly performing user queries, the semantic match between the query question and the target document paragraph will be insufficient. Therefore, it is usually necessary to rewrite the query question to initially improve the accuracy of the large language model. In the related art, the current rewriting of user query questions usually uses a corresponding fixed rewriting strategy to generate a single rewritten query question, and then inputs the single re-query question into the large language model for query processing to obtain the query result. However, in the related art, the rewriting method of using a fixed rewriting strategy to generate a single rewritten query question, and the processing method of inputting a single re-query question into the large language model for query, can easily cause the query results to deviate from the user's actual needs.

[0028] In order to solve the above technical problems, the embodiments of the present application propose the following technical concept: the inventor considers the query questions sent by the user, obtains the context information based on the query questions, and rewrites the query questions according to the context information to obtain each rewritten query question, obtains the corresponding first reference text blocks and each reference semantic according to any rewritten query question, wherein the reference semantic corresponds to the second reference text block, calculates the first similarity of the rewritten query question according to each first reference text block, calculates the second similarity of the rewritten query question according to each reference semantic block, uses each first similarity, each second similarity, each first reference text block and each first reference text block to generate new context information, inputs the query question and the new context information into the preset language model for query processing to generate query results, and obtains the context information and the new context information to assist in querying the query question, so that the query results are more in line with the user's real needs.

[0029] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0030] In conjunction 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 here. Figure 1 , Figure 1 Schematic diagram of an application scenario of the problem query processing method.

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

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

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

[0034] User terminal 101 sends a query question to electronic device 102 via a wireless network. Electronic device 102 obtains corresponding context information from multiple historical conversations based on the query question; rewrites the query question based on the context information to obtain multiple rewritten query questions; for any rewritten query question, retrieves 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; calculates a first similarity between each first reference text block and the rewritten query question; calculates a second similarity between each reference semantic and the rewritten query question; generates new context information based on each first similarity, each second similarity, each first reference text block, and each second reference text block; inputs the query question and the new context information into a preset language model for query processing to generate a query result; and outputs the query result to user terminal 101.

[0035] Figure 2 Schematic diagram of the process of the problem query processing method provided in the embodiment of the application Figure 1 ,like Figure 2 As shown, the embodiment of the present application provides a method for processing question queries, which is described in detail as follows:

[0036] S201: receiving a query question sent by a user terminal.

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

[0038] The query question is Query; the role information is doctor, scientist or other roles.

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

[0040] Specifically, step S202 includes:

[0041] S2021: Obtain a preset number of short-term conversations within a preset time based on the query question and multiple historical conversations, and determine the preset number of short-term conversations as short-term memory.

[0042] Specifically, based on the query question and multiple historical conversations, a sliding window mechanism is used to obtain short conversations with a preset number of rounds within a preset time.

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

[0044] The preset number of rounds may be 1, 2, or 3, or any other number of rounds.

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

[0046] S2023: Retrieve one or more corresponding domain-related conversations from multiple historical conversations based on the domain keyword, and determine the one or more domain-related conversations as domain memories.

[0047] Specifically, through the BM25 algorithm, one or more corresponding domain-related conversations are retrieved from multiple historical conversations based on domain keywords, and one or more domain-related conversations are determined as domain memories.

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

[0049] S2024: Acquire multiple remaining historical conversations excluding short-term memory within a preset time period based on the query question and the multiple historical conversations, and determine the multiple remaining historical conversations as long-term memory.

[0050] S2025: Fusing 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 of the query question.

[0052] In this embodiment, the preset language model may 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 terminal and the preset language model, and classifying and storing the multiple historical conversations according to different topics.

[0054] Specifically, multiple historical conversations between a user on the user terminal and a preset language model are collected, and the multiple historical conversations are classified and stored according to user, time and topic.

[0055] For example, in May 2025, Zhang San had five topic conversations with the language model. The first topic conversation lasted three rounds, and the second topic conversation lasted ten rounds.

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

[0057] Specifically, step S203 includes:

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

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

[0060] S20311: Determine each initial rewriting strategy.

[0061] In this embodiment, the initial rewriting strategies include 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: Functionally configure each initial rewriting strategy to obtain each configured rewriting strategy.

[0063] Specifically, step S20312 is as follows:

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

[0065] Specifically, the function of determining the initial general query rewriting strategy is to eliminate noise and refine content; the function of determining the initial keyword rewriting strategy is to eliminate noise and retain key information; the function of determining the initial language model pseudo-answer rewriting strategy is to generate pseudo-answers to expand the query to more information; the function of determining the initial sub-question rewriting strategy is to rewrite the original question containing multi-level information into sub-questions; the function of determining the core content extraction strategy is to extract the core content of 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, on the basis of step S203121, the corresponding initial rewriting strategies are functionally configured according to each function to obtain the following configured rewriting strategies: 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 a corresponding rewritten instance.

[0070] For example, the general query rewriting strategy uses the following guidelines: Original query: "I want to know how to effectively improve sleep quality without medication, especially if there are any natural remedies for people with long-term insomnia?" Rewritten to: "Natural remedies for long-term insomnia."

[0071] The guide to using the keyword rewriting strategy is: Original query: "Can you recommend a part-time job with flexible hours and the ability to improve communication skills?" After rewriting: "Part-time job recommendations with flexible hours and the ability to improve communication skills."

[0072] The language model pseudo-answer rewriting strategy allows for more information to be added to the query. A guideline for use is: Original query: "What are the advantages of physical computing?" Rewritten: "Advantages of physical computing: parallel computing, encryption security, and solving complex problems."

[0073] The following is a guide to using the subquestion rewriting strategy: 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 following is a guide to using the core content extraction strategy: Original query: "I need to know the park's ticket prices, opening hours, waiting times for popular shows, and itinerary plans." Rewritten: "Park ticket prices, opening hours, popular shows, and itineraries."

[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 can be: The language model receives a user question that requires an answer by searching the enterprise knowledge base for relevant content. There are currently five 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 based on its characteristics.

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

[0081] S2035: Rewrite the query questions according to the usage guidelines to obtain multiple rewritten query questions.

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

[0083] In this embodiment, the reference semantics is a semantic vector; accordingly, step S204 specifically includes:

[0084] S2041: Based on the rewritten query question, perform a keyword search on a preset knowledge base to obtain a plurality of first reference text blocks.

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

[0086] S2043: Based on the question vector, perform vector retrieval on a preset knowledge base to obtain multiple reference semantics.

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

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

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

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

[0091] Specifically, step b includes:

[0092] Step b1: parse each knowledge document to extract corresponding multiple types of text content.

[0093] Specifically, each knowledge document is parsed to extract text content of corresponding text types, table types, and image types.

[0094] Step b2: Divide each type of text content into blocks according to a preset text length to obtain a plurality of 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 corresponding reference semantics.

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

[0098] Among them, Eembedding refers to the technology of converting text into high-dimensional vectors using a large-scale language model. The generally used one is bge-large-zh-v1.5.

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

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

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

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

[0103] Specifically, step S205 includes:

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

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

[0106] In this embodiment, the inverse document frequency of each word is calculated based on the number of reference text blocks, and the calculation formula includes:

[0107]

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

[0109] S2053: Determine the 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 a first similarity between each first reference text block and the rewritten query question based on 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 calculation formula for calculating the first similarity between each first reference text block and the rewritten query question based on 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 includes:

[0113]

[0114] Where, is the first similarity between the first reference text block and the rewritten query question; is the rewritten query question; d is any first reference text block; n is the number of words; For any word q i The inverse document frequency of f(q i ,d) is any word q i word frequency 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 question.

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

[0117]

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

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

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

[0121] S209: Output the query result to the user end.

[0122] In summary, the question query processing method provided in this embodiment receives a query question sent by a user terminal; obtains corresponding context information from multiple historical conversations based on the query question; rewrites the query question based on the context information to obtain multiple rewritten query questions; for any rewritten query question, retrieves multiple first reference text blocks and multiple reference semantics corresponding to the rewritten query question from a preset knowledge base, wherein the reference semantics corresponds to a second reference text block; calculates a first similarity between each first reference text block and the rewritten query question; calculates a second similarity between each reference semantic and the rewritten query question; generates new context information based on each first similarity, each second similarity and multiple reference text blocks; inputs the query question 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 the context information, it is used to assist the language model in querying the query question, so that the query result is more in line with the user's real needs.

[0123] In addition, the question query processing method provided in this embodiment inputs context information, query questions, multiple preset rewriting strategies, and a preset second prompt word into a preset language algorithm for processing, and performs the following steps: supplementing the query question according to the context information to obtain a query question; determining one or more rewriting strategies from multiple rewriting strategies according to the query question and the second prompt word; obtaining a usage guide for one or more rewriting strategies; rewriting the query question according to each usage guide to obtain multiple rewritten query questions, and rewriting the query question through one or more rewriting strategies to obtain multiple rewritten query questions, so that the reference text blocks retrieved subsequently have diversity and relevance to ensure 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 extensions, and have good openness, thereby ensuring the overall performance improvement of the problem query processing system.

[0125] Figure 3 Schematic diagram of the process of information collection and processing provided in the embodiment of the present application Figure 2 In the embodiment of the present application, Figure 2 Based on the embodiment provided, wherein the multiple reference text blocks include each first reference text block and each second reference text block, 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. Figure 3 As shown, the method includes:

[0126] S301: Sort the first reference text blocks according to the first similarities to obtain a first sequence.

[0127] S302: Sort the second reference text blocks according to the second similarities to obtain a second sequence.

[0128] S303: Acquire a second reference text block that is identical to one or more first reference text blocks.

[0129] In this embodiment, each first reference text block and each second reference text block may partially overlap.

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

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

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

[0133]

[0134] Where, is the first inverse ranking value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; 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 inverse ranking value of each remaining first reference text block, and calculate the third inverse ranking value of each remaining second reference text block.

[0136] S307: Sorting the first reciprocal sorting values, the second reciprocal sorting values, and the third reciprocal sorting values to obtain a reciprocal 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 reciprocal fusion sequence.

[0138] S309: 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.

[0139] S310: Calculating a mixed 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 mixed similarity corresponding to each first target reference text block according to each first target similarity and each second target similarity includes:

[0141]

[0142] Where, is the mixed similarity corresponding to any target reference text block; ; The first target similarity of the target reference text block ; The second target similarity of the target reference text block .

[0143] S311: Sorting the mixed similarities to obtain a reciprocal mixed 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 mixed similarity sequence.

[0145] In this embodiment, the second preset number is less than or equal to the first preset number.

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

[0147] In summary, the question query processing method provided by this embodiment obtains a first sequence by sorting each first reference text block according to each first similarity; obtains a second sequence by sorting each second reference text block according to each second similarity; obtains a second reference text block that is identical to one or more first reference text blocks; determines the first sequence number of one or more first reference text blocks in the first sequence, and determines the second sequence number of the corresponding second reference text block in the second sequence; performs a reciprocal sorting fusion process based on the first sequence number and the second sequence number to obtain a first reciprocal sort value of one or more first reference text blocks; calculates the second reciprocal sort value of the remaining first reference text blocks, and calculates the third reciprocal sort value of the remaining second reference text blocks; and sorts each first reciprocal sort value, each second reciprocal sort value, and each third reciprocal sort value. , to obtain a reciprocal fusion sequence; 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; 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; calculate the mixed similarity corresponding to each target reference text block according to each first target similarity and / or each second target similarity; sort each mixed similarity to obtain a reciprocal mixed similarity sequence corresponding to each target reference text; determine a second preset number of target reference text blocks from each target reference text block according to the mixed similarity sequence; determine the second preset number of target reference text blocks as new context information, and by determining the new context information, use it to assist the subsequent language model in querying the query question, so that the query result is more in line with the user's real needs.

[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the 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 This is a schematic diagram of the structure of the question query processing device provided in the embodiment of the present application. Figure 4 As shown, an embodiment of the present application also provides a question query processing device, including: a receiving module 401, an acquisition module 402, a rewriting module 403, a retrieval module 404, a first calculation module 405, a second calculation module 406, a generation module 407, an input module 408 and an output module 409.

[0150] Receiving module 401, for receiving a query sent by a user terminal;

[0151] An acquisition module 402 is configured to acquire corresponding context information from multiple historical conversations according to a query question;

[0152] A rewriting module 403 is configured to rewrite the query question according to the context information to obtain a plurality of rewritten query questions;

[0153] A retrieval module 404 is configured to retrieve, for any rewritten query, a plurality of first reference text blocks and a plurality of reference semantics corresponding to the rewritten query from a preset knowledge base, wherein the reference semantics correspond to the second reference text block;

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

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

[0156] A generating module 407 is configured to generate new context information based on the first similarities, the second similarities, and a plurality of reference text blocks, wherein the plurality of reference text blocks include the first reference text blocks and the second reference text blocks;

[0157] Input module 408, for inputting the query question and new context information into a preset language model for query processing to generate query results;

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

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

[0160] A first acquisition unit is configured to acquire a preset number of short-term conversations within a preset time period based on a query question and multiple historical conversations, and determine the preset number of short-term conversations as short-term memory;

[0161] Extraction unit, used to extract domain keywords of query questions;

[0162] A retrieval unit, configured to retrieve one or more corresponding domain-related conversations from a plurality of historical conversations according to a domain keyword, and determine the one or more domain-related conversations as domain memories;

[0163] A second acquisition unit is configured to acquire a plurality of remaining historical conversations within a preset time period, excluding short-term memory, based on the query question and the plurality of historical conversations, and determine the plurality of remaining historical conversations as long-term memory;

[0164] A fusion unit, configured to fuse 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 context information of the query question.

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

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

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

[0169] The second retrieval unit is used to perform vector retrieval on a preset knowledge base according to the question vector to obtain multiple reference semantics.

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

[0171] The input unit is used to input the context information, the query question, the preset multiple rewriting strategies, and the preset second prompt word into the preset language algorithm for processing, and perform the following steps:

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

[0173] a determining 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 a usage guide for one or more rewriting strategies;

[0175] The rewriting unit is used to rewrite the query questions 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, used for determining each initial rewriting strategy;

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

[0179] The second configuration module is used to configure the usage guide for each configured rewriting strategy to obtain multiple rewriting strategies.

[0180] In one possible implementation, the multiple 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 from the rewritten query question;

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

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

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

[0187] The second calculation unit is configured to calculate a 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.

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

[0189] A first sorting unit, configured to sort the first reference text blocks according to the first similarities to obtain a first sequence;

[0190] a second sorting unit, configured to sort the second reference text blocks according to the second similarities to obtain a second sequence;

[0191] A first acquiring unit, configured to acquire a second reference text block that is identical to one or more first reference text blocks;

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

[0193] a fusion unit, configured to perform a reciprocal sorting fusion process according to the first sequence number and the second sequence number to obtain a first reciprocal sorting value of one or more first reference text blocks;

[0194] A first calculation unit is configured to calculate a second reciprocal ranking value of each remaining first reference text block, and calculate a third reciprocal ranking value of each remaining second reference text block;

[0195] a third sorting unit, configured to sort the first reciprocal sorting values, the second reciprocal sorting values, and the third reciprocal sorting values to obtain a reciprocal fusion sequence;

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

[0197] A second acquiring unit is 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 is configured to calculate a mixed 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 sort the mixed similarities to obtain a reciprocal mixed similarity sequence corresponding to each target reference text;

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

[0201] The fourth determining unit is configured to determine a second preset number of target reference text blocks as new context information.

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

[0203]

[0204] Where, is the first inverse ranking value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; 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, a 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:

[0206]

[0207] Where, is the mixed similarity corresponding to any target reference text block; ; 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, used to collect multiple knowledge documents in a preset format;

[0210] A processing module, configured to pre-process each knowledge document to obtain a plurality of reference text blocks;

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

[0212] The storage module is used to store each reference text block and each reference semantics into a preset knowledge base.

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

[0214] A parsing unit, used to parse each knowledge document to extract corresponding multiple types of text content;

[0215] The block division unit is used to divide each type of text content into blocks according to a preset text length to obtain a plurality of reference text blocks.

[0216] For the description of the features in the embodiment corresponding to the question query processing device, please refer to the relevant description of the embodiment corresponding to the question query processing method, and will not be repeated here.

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

[0218] During the specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502 , so that the at least one processor 501 executes the above-mentioned embodiment of the question query processing method.

[0219] The specific implementation process of the processor 501 can be found in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here in this embodiment.

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

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

[0222] A bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Buses can be categorized as address buses, data buses, and control buses. For ease of illustration, the buses in the drawings of this application are not limited to just one bus or just one type of bus.

[0223] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned question query processing method embodiments when run.

[0224] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0225] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above-mentioned question query processing method embodiments are implemented.

[0226] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the steps in any of the above-mentioned question query processing method embodiments.

[0227] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0228] The above is a detailed introduction to a question query processing method and electronic device provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A method for processing a question query, characterized in that: include: Receive query questions sent by the user; Acquiring corresponding context information from multiple historical conversations according to the query question; rewriting the query question according to the context information to obtain a plurality of rewritten query questions; For any rewritten query question, retrieving a plurality of first reference text blocks and a plurality of reference semantics corresponding to the rewritten query question from a preset knowledge base, wherein the reference semantics correspond to the second reference text block; Calculating a first similarity between each first reference text block and the rewritten query question; Calculating a second similarity between each reference semantic and the rewritten query question; generating new context information according to the first similarities, the second similarities, and a plurality of reference text blocks, wherein the plurality of reference text blocks include the first reference text blocks and the second reference text blocks; 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; The step of rewriting the query question according to the context information to obtain a plurality of rewritten query questions includes: inputting the context information, the query question, a plurality of pre-configured rewriting strategies, and a preset second prompt word 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 plurality of rewriting strategies according to the query question and the second prompt word; Obtaining usage guidelines for the one or more rewriting strategies; and rewriting the query questions according to the usage guidelines to obtain a plurality of rewritten query questions.

2. The problem query processing method according to claim 1, characterized in that: The obtaining corresponding context information according to the query question and the multiple historical conversations includes: Obtaining a preset number of short conversations within a preset time period based on the query question and the multiple historical conversations, and determining the preset number of short conversations as short-term memory; Extracting domain keywords for the query question; Retrieving one or more corresponding domain-related conversations from the plurality of historical conversations according to the domain keyword, and determining the one or more domain-related conversations as domain memories; Acquire multiple remaining historical conversations within a preset time period excluding the short-term memory according to the query question and the multiple historical conversations, and determine the multiple remaining historical conversations as long-term memory; fusing the query question, the short-term memory, the domain memory, and the long-term memory to obtain a first prompt word; The first prompt word is input into a preset language model for processing to generate context information of the query question.

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

4. The problem query processing method according to claim 1, characterized in that: The configuration process of the multiple rewriting strategies includes: Determine each initial rewriting strategy; Performing functional configuration on each of the initial rewriting strategies to obtain each configured rewriting strategy; The configured rewriting strategies are configured using the guide to obtain a plurality of rewriting strategies.

5. The problem query processing method according to claim 1, characterized in that: 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.

6. The problem query processing method according to claim 1, characterized in that: The calculating of the first similarity between each first reference text block and the rewritten query question includes: Obtaining multiple words in the rewritten query question; Calculating the inverse document frequency of each word according to the number of the plurality of first reference text blocks; determining the frequency of each word in the corresponding first reference text block; determining the length of each first reference text block and the average length of each first reference text block; A first similarity between each first reference text block and the rewritten query question is calculated based on 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.

7. The problem query processing method according to claim 1, characterized in that: Generating new context information according to the first similarities, the second similarities, and the plurality of reference text blocks includes: Sorting the first reference text blocks according to the first similarities to obtain a first sequence; Sorting the second reference text blocks according to the second similarities to obtain a second sequence; obtaining a second reference text block that is identical to one or more first reference text blocks; Determining first sequence numbers of the one or more first reference text blocks in the first sequence, and determining second sequence numbers of corresponding second reference text blocks in the second sequence; Performing a reciprocal sorting fusion process according to the first serial number and the second serial number to obtain a first reciprocal sorting value of the one or more first reference text blocks; Calculating the second reciprocal ranking value of each remaining first reference text block, and calculating the third reciprocal ranking value of each remaining second reference text block; Sorting each first reciprocal sort value, each second reciprocal sort value, and each third reciprocal sort value to obtain a reciprocal fusion sequence; Determining a first preset number of target reference text blocks from the first reference text blocks and the second reference text blocks according to the reciprocal fusion sequence; Obtaining a first target similarity and / or a second target similarity corresponding to each target reference text block from the first similarities and the second similarities; Calculating the mixed similarities corresponding to the target reference text blocks according to the first target similarities and / or the second target similarities; Sorting each mixed similarity to obtain a reciprocal mixed similarity sequence corresponding to each target reference text; determining a second preset number of target reference text blocks from the target reference text blocks according to the mixed similarity sequence; The second preset number of target reference text blocks are determined as new context information.

8. The problem query processing method according to claim 7, characterized in that: The calculation formula for performing the reciprocal sorting fusion processing according to the first serial number and the second serial number to obtain the first reciprocal sorting value of the one or more first reference text blocks includes: Where, is the first inverse ranking value of the first reference text block; D is a set of one or more first reference text blocks; K is a constant; 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.

9. The problem query processing method according to claim 7, characterized in that: The calculation formula for calculating the mixed similarity corresponding to each target reference text block based on each first target similarity and / or each second target similarity includes: Where, is the mixed similarity corresponding to any target reference text block; ; The first target similarity of the target reference text block ; The second target similarity of the target reference text block .

10. The problem query processing method according to claim 1, characterized in that: Before retrieving a plurality of reference text blocks corresponding to any rewritten query question from a preset knowledge base, the method further includes: Collect multiple knowledge documents in pre-set formats; Preprocessing each knowledge document to obtain multiple reference text blocks; Convert each reference text block into corresponding reference semantics; The reference text blocks and the reference semantics are stored in the preset knowledge base.

11. The problem query processing method according to claim 10, characterized in that: The preprocessing of each knowledge document to obtain multiple reference text blocks includes: Parse each knowledge document to extract corresponding multiple types of text content; Each type of text content is divided into blocks according to a preset text length to obtain a plurality of reference text blocks.

12. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is configured to implement the steps of the question query processing method according to any one of claims 1 to 11 when executing the computer program.

13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the question query processing method according to any one of claims 1 to 11 are implemented.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the question query processing method according to any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

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

    CN118535681A

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

    CN119831045A