Multi-round dialogue method and device based on historical memory module, medium and product

By adopting a hierarchical storage architecture based on historical memory modules, the necessary historical information in multi-turn dialogue systems can be accurately obtained, solving the problems of wasted computing resources and information loss in traditional methods, and achieving efficient and accurate multi-turn dialogue processing.

CN121807890APending Publication Date: 2026-04-07HANGZHOU ANT KUAI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-12
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

In traditional multi-turn dialogue systems, the complete splicing of the user's current question with the historical dialogue content leads to a waste of computing resources and an increase in response latency. Furthermore, the limitation of the model context window results in information loss or low processing efficiency.

Method used

A hierarchical storage architecture based on historical memory modules is adopted, including a main storage layer and a detailed storage layer. By accurately understanding the dependencies of the current problem, only the necessary historical information is obtained from the detailed storage layer, and the answer is generated by combining it with the language model, thus avoiding indiscriminate data processing and information loss.

Benefits of technology

It significantly reduces system computational load and response latency, ensures the accuracy and consistency of multi-turn dialogues, reduces redundant data transmission and processing, and improves processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807890A_ABST
    Figure CN121807890A_ABST
Patent Text Reader

Abstract

The invention provides a multi-round dialogue method and device based on a historical memory module, a medium and a product. The history memory module comprises a main body storage layer and a detail storage layer; the main body storage layer is used for storing question and answer pairs in each dialogue round; the detail storage layer is used for storing total question and answer information and corresponding metadata in each dialogue round; the method comprises the steps of receiving a to-be-answered question of a current dialogue round, and obtaining a question-answer pair of a historical dialogue round belonging to the same session with the current dialogue round from a historical memory module; if the question and answer pair based on the historical dialogue round determines that the question to be answered depends on the historical dialogue content, obtaining metadata of total question and answer information of the historical dialogue round from a detail storage layer, based on the to-be-answered question and the metadata, obtaining matched target question and answer information from the total question and answer information of the historical dialogue rounds stored in the detail storage layer; and generating an answer of the current dialogue round by using a language model according to the to-be-answered question and the target question and answer information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of multi-turn dialogue technology, and more particularly to a multi-turn dialogue method, electronic device, computer-readable storage medium, and computer program product based on a history memory module. Background Technology

[0002] In multi-turn dialogue systems, traditional methods typically concatenate the user's current question with all historical dialogue content and then input it into a general Large Language Model (LLM), hoping that the model can generate a response based on complete contextual understanding.

[0003] However, this method has the following shortcomings: First, in actual dialogues, user questions do not always rely on historical content. For example, when a user starts a completely new topic, the details of previous conversations are irrelevant. Traditional methods fail to distinguish between these, concatenating all information at once, resulting in the processing of a large amount of irrelevant information. This not only wastes computational resources but also causes the length of the concatenated context to increase dramatically with the number of dialogue rounds, leading to low model processing efficiency, increased response latency, and high computational costs. Second, the context window of a general large language model has a fixed length limit. Excessively long historical dialogue concatenation text easily exceeds this limit, causing the model to be unable to fully receive historical information, resulting in a "memory loss" phenomenon. If a brute-force truncation of historical dialogue is used to adapt to the window length, crucial details necessary for answering the current question may be lost, thus affecting the accuracy of the answer. Summary of the Invention

[0004] In view of the above, one or more embodiments of this specification provide the following technical solutions: According to a first aspect of one or more embodiments of this specification, a multi-turn dialogue method based on a historical memory module is proposed, wherein the historical memory module includes a main storage layer and a detail storage layer; the main storage layer is used to store question-answer pairs in each dialogue turn; the detail storage layer is used to store full question-answer information and corresponding metadata in each dialogue turn; the method includes: Receive the unanswered question for the current dialogue round, and retrieve the question-answer pair from the history memory module that belongs to the same session as the current dialogue round; If it is determined from the question-and-answer pairs of the historical dialogue rounds that the question to be answered depends on the content of the historical dialogue, the metadata of the full question-and-answer information of the historical dialogue rounds is obtained from the detail storage layer, and the matching target question-and-answer information is obtained from the full question-and-answer information of the historical dialogue rounds stored in the detail storage layer based on the metadata of the question to be answered and the full question-and-answer information of the historical dialogue rounds. The language model is used to generate the answer for the current dialogue round based on the question to be answered and the target question-and-answer information.

[0005] According to a second aspect of the embodiments of this specification, an electronic device is provided, comprising: processor; Memory used to store processor-executable instructions; Wherein, when the processor executes the executable instructions, it is used to implement the method described in the first aspect.

[0006] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps of the method described in the first aspect.

[0007] According to a fourth aspect of the embodiments of this specification, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method described in the first aspect.

[0008] As can be seen from the above embodiments, this specification obtains a simplified historical dialogue round question-and-answer pair from the main storage layer, and quickly completes the dependency determination of the question to be answered in the current dialogue round on the historical dialogue with lightweight data. This avoids the redundant data transmission and computational overhead caused by the unconditional full splicing of historical dialogues in traditional solutions, and significantly reduces the system's computational load and response latency. Secondly, after clearly determining that the question to be answered depends on the content of the historical dialogue, the metadata of the full question-and-answer information of the historical dialogue round is obtained from the detail storage layer. Based on the metadata, filtering and indexing are performed to accurately extract the target question-and-answer information that matches the question to be answered from the full question-and-answer information in the detail storage layer. Through the lightweight indexing function of the metadata, the indiscriminate retrieval and processing of the full question-and-answer information is avoided. This not only quickly locates key details, but also further reduces the amount of data transmission and computation, while ensuring that the core information required to generate the answer is complete and available. This effectively avoids the information loss problem caused by context truncation and ensures the accuracy and coherence of multi-turn dialogues.

[0009] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description

[0010] Figure 1 This is a schematic diagram of the architecture of a multi-turn dialogue service system provided in an exemplary embodiment.

[0011] Figure 2 This is a schematic diagram of a server module provided in an exemplary embodiment.

[0012] Figure 3This is a flowchart of a multi-turn dialogue method based on a history memory module, provided as an exemplary embodiment.

[0013] Figure 4 This is a schematic diagram of four processing paths provided in an exemplary embodiment.

[0014] Figure 5 This is a schematic diagram of the structure of a device provided in an exemplary embodiment. Detailed Implementation

[0015] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0016] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.

[0017] Figure 1 This is a schematic diagram of the architecture of a multi-turn dialogue service system provided in an exemplary embodiment. The multi-turn dialogue service system includes a server 10 and several terminals 20.

[0018] Server 10 can be a physical server containing a single host, or it can be a virtual server hosted on a host cluster. It can also be a containerized server cluster, such as a cluster of container instances managed by a container orchestration platform like Kubernetes, a hybrid server cluster combining physical servers and virtual servers / containers, or an edge server deployed on an edge node. During operation, server 10 can run a multi-turn dialogue service program, thus becoming a corresponding multi-turn dialogue service platform.

[0019] Terminal 20 includes, but is not limited to, PCs (Personal Computers), mobile phones, tablets, laptops, PDAs (Personal Digital Assistants), and wearable devices (such as smart glasses and smartwatches). During operation, the terminal can run a multi-turn dialogue service program, acting as a client for this service. The client-side program can be a native application installed on the terminal, or it can be a mini-program, quick app, or other similar format. Alternatively, when using web technologies such as HTML5, the functionality can be achieved through a browser-displayed page. This browser can be a standalone browser application or a browser module embedded within an application.

[0020] The network for interaction between terminal 20 and server 10 can be implemented using either wired or wireless networks, depending on the communication methods supported by the respective terminals. This manual does not impose any restrictions on this. For example, a PC can support both wired and wireless communication, so it can use either wired or wireless networks as needed. Mobile phones typically only support wireless communication, so they can use wireless networks for communication.

[0021] For example, server 10 can access resources such as knowledge base 30, language model 40, and target database 50 related to multi-turn dialogue scenarios to provide data and capability support for multi-turn dialogue processing. By accessing language model 40 to provide natural language processing capabilities, knowledge base 30 to provide professional external knowledge, and database 50 to provide structured data support, the system's response capabilities and scenario adaptability are enriched.

[0022] For example, please refer to Figure 2 The server 10 includes a history memory module 11. The history memory module 11 adopts a hierarchical storage architecture, which includes a main storage layer and a detail storage layer. The main storage layer is used to store question-answer pairs in each dialogue round. The detail storage layer is used to store full question-answer information and corresponding metadata in each dialogue round. This ensures the complete storage of context data and provides a foundation for efficient retrieval.

[0023] For example, server 10 includes a question understanding module 12. Question understanding module 12 can receive the question to be answered in the current dialogue round sent by terminal 20 and integrate related auxiliary information. The auxiliary information includes, but is not limited to, at least one of the following: relevant information in the historical dialogue rounds belonging to the same session as the current dialogue round in the historical memory module 11, relevant external knowledge in the knowledge base 30, and relevant data in the target database 50, so as to achieve a comprehensive understanding of the current question.

[0024] For example, server 10 includes a question classification and processing module 13. Based on the question to be answered in the current dialogue round and related auxiliary information, question classification and processing module 13 decides on the processing method for the question to be answered, executes the subsequent processing flow according to the corresponding processing method, and finally generates the answer for the current dialogue round, which is then returned to terminal 20 via the network. Furthermore, it can update the history memory module 11 based on the question-and-answer information in the current dialogue round.

[0025] In summary, the multi-turn dialogue service system provided in this specification can accurately understand user needs and efficiently output targeted responses. Through modular architecture design and hierarchical data management, it achieves contextual coherence and flexible response in multi-turn dialogue scenarios, and is suitable for various service scenarios that require continuous interaction, such as intelligent customer service, intelligent assistants, and professional consultations.

[0026] The following is an exemplary description of a multi-turn dialogue method based on a history memory module provided in this specification: Please see Figure 3 The flowchart illustrates a multi-turn dialogue method based on a history memory module. The history memory module includes a main storage layer and a detail storage layer; the main storage layer stores question-answer pairs in each dialogue turn; the detail storage layer stores all question-answer information and corresponding metadata in each dialogue turn.

[0027] The full set of Q&A information refers to the complete interactive data in each round of dialogue, including but not limited to the questions asked by the user, additional explanations, and detailed data contained in the system's answers, such as tables, formulas, and long text explanations. Metadata refers to the structured index information used to describe the full set of Q&A information, including but not limited to information type (such as order data, scenario description), keywords (such as order number XXX, refund), timestamps, and associated round numbers, used to quickly locate key content in the full set of information.

[0028] For example, the multi-turn dialogue method based on the history memory module can be executed by server 10 in the aforementioned multi-turn dialogue service system, and the method includes: In S300, the question to be answered in the current dialogue round is received, and the question-answer pair in the historical dialogue round that belongs to the same session as the current dialogue round is retrieved from the history memory module.

[0029] A dialogue round refers to a complete "user asks a question - system answers" interaction unit. For example, a user sends "How do I change my password?" (ask a question), and the system replies with the steps to change it (answer). This process constitutes a dialogue round.

[0030] A session refers to a collection of multiple dialogue rounds conducted by the same user within a continuous time period around the same topic or task. For example, if a user asks questions such as "Can I get a refund for my order?", "How long will the refund take?", and "How can I check the refund progress?" around the topic of "order refund", these consecutive dialogue rounds together constitute a session. These unanswered questions belong to the same session and are assigned the same session identifier.

[0031] For example, the question understanding module of server 10 receives the unanswered questions of the current dialogue round sent by the network terminal 20. The format may include text, speech-to-text, etc., and the same session is located based on the session identifier (such as user ID + session start timestamp). Subsequently, the question understanding module calls the main storage layer interface of the history memory module to obtain the question-answer pairs of all historical dialogue rounds in the session. Each question-answer pair contains core fields such as "user question text", "system answer text", and "round number", ensuring that the data is lightweight and easy to retrieve quickly.

[0032] The core objective of this step is to first obtain a "condensed context" of the historical dialogue. The question-and-answer pairs in the main storage layer only retain the core information of each round of interaction, with a data volume far smaller than the full dialogue content. This provides a basis for subsequent judgments on whether the questions to be answered in the current dialogue round depend on the historical dialogue content, while avoiding the efficiency loss caused by directly calling large amounts of data, thus enabling on-demand retrieval of historical dialogue information.

[0033] In S302, if the question to be answered depends on the content of the historical dialogue based on the question-answer pair of the historical dialogue rounds, the metadata of the full question-answer information of the historical dialogue rounds is obtained from the detail storage layer, and the matching target question-answer information is obtained from the full question-answer information of the historical dialogue rounds stored in the detail storage layer based on the metadata of the question to be answered and the full question-answer information of the historical dialogue rounds.

[0034] Among them, relying on historical dialogue content means that the understanding or answer to the current question needs to rely on historical dialogue, such as specific parameters, scenario descriptions, and contextual references mentioned by the user before. For example, if a user asks "What is the progress of the refund for that order?", the specific information about "that order" needs to be obtained from historical dialogue.

[0035] For example, the server can call the detailed storage layer interface to obtain full question-and-answer information metadata for all historical dialogue rounds within the same session. Based on the core requirements of the current question, such as extracting keywords like "order number" and "parameter A," it matches the metadata to filter out a candidate set of full question-and-answer information that may contain the target question-and-answer information. For this candidate set, a semantic similarity algorithm, such as BERT-based vector cosine similarity, is used to perform deep matching between the current question and the candidate set, ultimately determining the target question-and-answer information directly related to the question, such as extracting the specific description of "order number XXX" from the historical full information.

[0036] This step, through the processing logic of "first determining dependencies in historical dialogue content → then indexing with metadata → finally locating the target information," solves the problems of low efficiency and redundant information caused by traditional full-data concatenation. Metadata, as a lightweight index, can significantly shorten the retrieval time of full-data information; while retrieving detailed information only when determining dependent history avoids meaningless data processing and ensures that the key details required for the answer are not omitted.

[0037] In one possible implementation, the server populates a preset prompt template with question-and-answer pairs of the question to be answered and historical dialogue rounds, generating prompt words. The preset prompt template includes multiple processing options for the question to be answered. The prompt words are then input into a trained classification model, which selects and outputs a target processing option related to the question to be answered from the multiple processing options. If the target processing option indicates that the question to be answered depends on historical dialogue content, the server performs metadata retrieving full question-and-answer information from the detail storage layer for all historical dialogue rounds and subsequent steps. Other processing options are described later.

[0038] The classification model can be based on a language model: a general-purpose large language model with classification capabilities can be directly used, leveraging its powerful semantic understanding to parse the context and options in the prompt words and output the corresponding target processing option. This type of model requires no additional training and can be directly adapted to task requirements through prompt word engineering.

[0039] Alternatively, a lightweight classification model can be specifically trained, using dialogue samples labeled with processing options as training data. The model learns the semantic associations in the samples to achieve rapid classification. Compared to general-purpose large language models, its parameter scale is smaller (usually in the millions to tens of millions, far smaller than the hundreds of billions or trillions of parameters in large language models), and its inference speed is faster.

[0040] This implementation reduces the complexity of classification tasks by using structured prompts, allowing the model to make decisions only from preset options rather than generating open-ended results, thereby improving the stability and interpretability of the judgments. It also provides two model options: a general-purpose language model suitable for scenarios with high adaptability requirements and limited sample sizes, which can be reused without additional training; and a lightweight model suitable for scenarios sensitive to response speed and resource consumption, which optimizes task accuracy through specialized training and has lower inference costs. Both can accurately output target processing options based on the semantic association between historical question-answer pairs and the current question, providing a clear basis for subsequent processing methods.

[0041] In S304, the language model is used to generate the answer for the current dialogue turn based on the question to be answered and the target question-answer information.

[0042] For example, the server can integrate the question to be answered with the target question-and-answer information obtained in S302 into input text, and call a pre-built language model, such as an industry-specific large language model. The language model performs semantic fusion and natural language generation based on the input text, outputting an answer that meets the needs of the current question and is consistent with the historical context. This step, through the semantic understanding and generation capabilities of the language model, organically integrates the current question with precisely located historical details, ensuring that the answer accurately responds to the current needs while maintaining logical consistency with the historical dialogue.

[0043] In some embodiments, after generating the response for the current dialogue turn, the server updates the history memory module to provide continuous contextual support for subsequent dialogue turns.

[0044] Regarding updates to the main storage layer: Considering that the content of the main storage layer is the primary context referenced by the question understanding module in the server during subsequent dialogues, if it contains multiple lengthy responses, it will quickly exhaust the language model's context window, leading to ineffective utilization of historical information later in the dialogue, or causing high latency and high costs due to the need to process excessively long context. Therefore, the server uses the data length of a single output word from the language model as the unit of division, and counts the number of divisions for the responses in the current dialogue round.

[0045] This embodiment uses the data length of a single output token (the smallest encoding unit used by the model during input processing and output generation) as the unit for real-time counting. This design choice is closely related to the core working mechanism of the language model for the following reasons: The language model does not directly understand characters or words, but processes "tokens" that are broken down from text. A token may be a word, a subword, or even a punctuation mark. Every processing step of the model (whether understanding input or generating output), every consumption of computational resources, and even billing, is fundamentally based on the number of tokens. Therefore, using tokens as the unit for partitioning and counting is a more accurate measurement method. Furthermore, the context window limit of the language model, the time (latency) required to generate an answer, and the computational cost are all directly proportional to the number of tokens processed. The more tokens an answer contains, the more contextual resources it occupies in subsequent dialogues, and the more computational resources it consumes to process it. Therefore, using lexical length as the threshold for determining whether a summary is needed (i.e., the "preset lexical number") effectively controls the model's key resource and performance bottleneck metrics. After generating the answer for the current round, the server uses its most basic processing unit—the lexical—to accurately count the data length of the answer, and then compares the counted lexical number (i.e., the number of segments mentioned above) with the preset lexical number.

[0046] If the number of segments exceeds the preset number of lexical units, it indicates that the answer is too lengthy. If it is directly stored in the main storage layer, which serves as the main dialogue thread, it will consume valuable context resources in subsequent dialogues, leading to high latency and high costs. Therefore, the server can use a language model to summarize the answer of the current dialogue turn, obtaining a summary with a data length that meets the preset number of lexical units indication—that is, a concise version with the number of lexical units within the allowed range. Then, the question-answer pair consisting of the unanswered question of the current dialogue turn and the summary content is stored in the main storage layer.

[0047] If the number of segments is not greater than the preset number of tokens, it means that the answer itself is very concise and will not put too much pressure on the subsequent context. In this case, the server will store the question-answer pair consisting of the unanswered question and the answer of the current dialogue round into the main storage layer.

[0048] This mechanism ensures that each record stored in the main storage layer achieves a balance between information volume and resource consumption, providing a fundamental guarantee for the long-term and efficient operation of multi-turn dialogues.

[0049] Regarding updates to the detail storage layer: the server can store all question-and-answer information for the current dialogue turn in the detail storage layer. For example, the full question-and-answer information for the current dialogue turn includes at least: the question to be answered, the target question-and-answer information, the answer for the current dialogue turn, the prompts input to the classification model, and the target processing options output by the classification model. In other words, the detail storage layer completely saves all question-and-answer information for each round of dialogue, ensuring that no details are lost.

[0050] In some extended embodiments, in multi-turn dialogue scenarios, some questions to be answered may be directly related to specific details in historical dialogues. For example, a user might repeatedly ask, "How do I download the file I mentioned before?" or "How many records are in the data table I mentioned before?" To quickly respond to such questions that rely on historical content and reduce unnecessary process overhead, a vector similarity matching step can be prioritized after receiving the questions to be answered in the current dialogue turn, as follows: The server can obtain a first vector derived from the question to be answered, and a second vector derived from each question and answer piece in the full question and answer information of the historical dialogue rounds in the detail storage layer. The first vector is a dense vector obtained by semantically encoding the question to be answered, used to quantify the semantic features of the question. The second vector is a dense vector obtained by semantically encoding each question and answer piece (such as the user's detailed description, specific data in the system response, scene description, etc.) in the full question and answer information of each dialogue round in the detail storage layer, used to quantify the semantic features of each question and answer piece.

[0051] The server can perform batch vector transformation on each question-and-answer item in the full question-and-answer information of that round in the detail storage layer after the historical dialogue round ends, using a preset semantic encoding model, to generate corresponding second vectors. The full question-and-answer information can be broken down into information units, such as "Order Number XXX" or "Shipping Time 2025-10-20," and each independent question-and-answer item can be converted into a second vector. These second vectors can be stored in the detail storage layer as supplementary metadata. This preprocessing mechanism avoids the computational delay of real-time conversion, laying the foundation for subsequent rapid matching.

[0052] After obtaining the first vector and the second vectors corresponding to historical dialogue rounds within the same session as the current dialogue round, the server calculates the similarity between the first vector and each of the second vectors, and then compares these similarities with a preset similarity threshold. The preset similarity threshold can be flexibly adjusted based on the accuracy requirements of the actual application scenario. For example, to prioritize the accuracy of the matching results and avoid misclassifying semantically similar but fundamentally different historical information as the target question and answer, the preset similarity threshold can be set relatively high, such as 0.8 or higher. Through high-threshold filtering, only the second vectors that highly match the semantics of the current question are retained, ensuring that the subsequently generated answers accurately match the user's needs.

[0053] In one scenario, if a target second vector with a similarity greater than a preset similarity threshold exists, the server can directly retrieve the target question-and-answer information indicated by the target second vector from the detail storage layer. Then, it uses a language model to generate the answer for the current dialogue round based on the question to be answered and the target question-and-answer information. In this step, the target question-and-answer information associated with the target second vector is directly retrieved from the detail storage layer, eliminating the need to execute the complete process of "obtaining historical question-and-answer pairs → determining dependencies → retrieving metadata → locating target information." Instead, the current question and target question-and-answer information are directly input into the language model to generate the answer. This path is suitable for scenarios where the question is highly related to specific historical details (such as repeated queries or supplementary queries for the same information), significantly shortening the processing chain through the "short-circuit mechanism" of vector matching.

[0054] In another case, if there is no target second vector with a similarity greater than the preset similarity threshold, it means that the question to be answered either does not depend on historical content, or the historical information it depends on needs to be determined through more complex contextual association analysis (rather than single information item matching). It needs to enter the subsequent process (i.e. steps S300~S304) to determine the dependency relationship through historical question-answer pairs and further process it.

[0055] This similarity matching step essentially provides a fast track for problems that rely on historical details: by pre-generating a second vector to achieve semantic quantification indexing of historical information, combined with real-time vector matching, it quickly locates related information, avoiding the redundant steps of "first analyzing the overall history → then judging dependencies → finally locating details" in the traditional process. For frequently occurring problems such as "repeated queries" and "clear contextual references," it can further improve response speed while reducing the system's repeated processing of historical data, thereby further reducing computational resource consumption.

[0056] In some embodiments, please refer to Figure 4 The following section, in conjunction with at least one of the knowledge base and target database, further explains the multiple processing options and their corresponding processing paths provided in the embodiments of this specification: The question understanding module in the server receives the questions to be answered in the current dialogue round and obtains at least one of the following auxiliary information: (1) Historical information acquisition: retrieve question-answer pairs from the historical memory module that belong to the same conversation as the current conversation round. Please refer to the above description for details.

[0057] (2) Database data loading: Based on the question to be answered, select the matching target data table from multiple data tables stored in the target database and obtain the metadata of the target data table.

[0058] The target database refers to the database that stores the structured data required for multi-turn dialogues. The data is organized in data tables and contains multi-dimensional structured information such as user-related, process-related, and resource configuration information, such as user consumption records, order status, and product parameters. It is the core data source to support dialogues that require data corroboration.

[0059] The target data table refers to a structured data table that is directly related to the query intent of the question to be answered. For example, when a user asks about my total spending in the past 3 months, the target data table is the user's spending record table; when a user asks about the unshipped orders, the target data table is the order information table.

[0060] The metadata of the target data table is a data dictionary describing the structure and data attributes of the target data table, including but not limited to: table structure definition (such as field name, field type, primary key / foreign key, field length), actual meaning of fields (such as the payment_amount field corresponding to the amount of a single transaction), data type (such as integer, string, date), enumeration values ​​(such as the enumeration options of the order_status field being pending payment / paid / pending shipment / shipped / completed), pre-defined relationships (such as the order table being associated with the user information table through the user_id field), field index information, data update frequency, access permission rules, etc., which are used to guide the server to quickly understand the data structure, accurately locate query fields, and avoid indiscriminately traversing the entire data.

[0061] For example, the question understanding module can semantically match at least one of the entities and keywords in the question to be answered with at least part of the metadata (such as table name, table function description, and actual meaning of fields) of each data table in the target database to determine the target data table, and then obtain the complete metadata of the target data table through the database interface.

[0062] (3) External knowledge retrieval: Based on at least one of the entities and keywords in the question to be answered, external knowledge related to at least one of the entities and keywords is retrieved from the pre-set knowledge base. For example, external knowledge includes, but is not limited to, domain terms, thesaurus and empirical rules, such as mapping “recent” to “past 30 days”.

[0063] An entity refers to a specific object with a clear referential meaning in the current unanswered question, including but not limited to user identifiers, specific objects (such as orders, product A), time / space identifiers (such as tomorrow, Beijing), and domain-specific objects (such as annualized rate of return, refund applications), etc.

[0064] Keywords refer to core words that can represent the core needs of the current problem, such as total consumption, undelivered, the past 3 months, how to apply, etc., which are the core clues for connecting external knowledge.

[0065] External knowledge refers to a set of general or domain-specific knowledge that is independent of historical dialogues and structured data in the database. It is used to help the system understand problems, complete semantics, and unify expression. It is stored in a pre-built knowledge base in a structured form. Its core function is to eliminate semantic ambiguity in problems, supplement domain common sense, and standardize query conditions.

[0066] External knowledge complements historical information and database data: historical information provides contextual information for dialogue, database data provides structured factual support, and external knowledge provides semantic analysis and rule supplementation. The three work together to ensure that the system has a comprehensive understanding of the needs of complex multi-turn dialogues.

[0067] Those skilled in the art will understand that in practical application scenarios, at least one of the above three types of information can be selected to be obtained according to actual needs, without the need to force the acquisition of all three types. The specific scope of information acquisition can be flexibly adjusted in combination with scenario adaptability and functional requirements.

[0068] The question classification and processing module in the server can fill at least one of the following into a preset prompt template to generate prompt words: the unanswered questions of the current dialogue round, the question-answer pairs of the historical dialogue rounds, the metadata of the target data table, and external knowledge. Figure 4 This example illustrates the scenario where all four types of information are filled into a preset prompt template. The preset prompt template includes multiple processing options for the question to be answered. These multiple processing options include: (1) Dependence on historical dialogue content: The criterion is that the question to be answered is semantically strongly dependent on the output of a previous round of dialogue. For example, the question to be answered contains pronouns referring to historical results (such as charts, tables) (such as "the chart", "the third row of data"), or the question is about the cause, comparison or explanation of historical results.

[0069] (2) Dependence on the content of the target database: The criteria for judgment are that the intent of the question to be answered is clear, the information elements are basically complete, and the semantic dependence on the historical dialogue is low, and it is necessary to access the target database to obtain new data to respond.

[0070] (3) No need to rely on other data: The criterion is that the question to be answered is unrelated to the domain of the target database.

[0071] (4) Unclear intent: The criteria for judgment are that the question to be answered is highly ambiguous, key information is missing (such as the query subject or necessary screening conditions are missing), or the referential relationship cannot be uniquely determined in the current context.

[0072] Next, the question classification and processing module in the server can input the prompt words into the trained classification model, which will then select and output the target processing option relevant to the question to be answered from multiple processing options. For example, each processing option carries a unique identifier, and the classification model can directly output the unique identifier of the target processing option.

[0073] In the first case (processing path 1), if the target processing option indicates that the question to be answered depends on the content of the historical dialogue, then the above steps S302~S304 are executed, which will not be repeated here.

[0074] In the second scenario (processing path 2), if the target processing option indicates that the question to be answered depends on the content of the target database, then a natural language query question is generated based at least on the metadata of the target data table and the question to be answered. During the generation process, the metadata provides key constraints: the field range of the query is clearly defined based on the table structure, the meaning of the fields ensures that the query semantics matches the data attributes, and the reasonableness of the query conditions is standardized based on the enumeration values ​​and relationships.

[0075] Natural language query questions refer to converting a user's current unanswered question into a natural language expression that conforms to database query logic, is semantically clear, and unambiguous. Its core function is to build a bridge between "user's natural language needs" and "database structured queries," providing a clear and standardized input foundation for subsequent text-to-SQL conversion.

[0076] Optionally, the natural language query generation process can also refer to at least one of the following: recalled external knowledge, obtained question-answer pairs from historical dialogue rounds, etc. This embodiment does not impose any limitations on this. Regarding the application of external knowledge, for example, vague time keywords (such as recent) expressed by users can be converted into specific time ranges (such as the past 30 days) through synonym mapping, or the field association logic required for the query can be supplemented through domain terminology parsing, making the natural language query more accurate. Regarding the application of question-answer pairs from historical dialogue rounds, for example, user identifiers, preconditions, and other information related to the current question can be extracted from historical dialogues to avoid result bias caused by missing query conditions.

[0077] Next, the text-to-SQL tool is invoked. The generated natural language query question is input into the tool. The text-to-SQL tool first combines the metadata of the target data table to parse the query logic, such as determining the query table name, filtering conditions, aggregate functions, field relationships, etc., and then generates the corresponding SQL statement according to the SQL syntax specifications supported by the target database.

[0078] After generation, the server submits the SQL statement to the target database for execution through the database interface. If the SQL statement has a syntax error or the query conditions are invalid (such as a field not existing or a data type mismatch), the target database will return an error message. The server can trigger a retry mechanism (such as re-optimizing the natural language query and converting it again) or terminate the process and report to the user that the relevant data cannot be obtained.

[0079] If the server receives a valid query result from the target database, it inputs the question to be answered and the query result together into the language model. The language model performs semantic fusion based on the two to generate an answer that conforms to natural language expression habits and directly responds to the user's needs.

[0080] Meanwhile, to ensure the continuity and traceability of multi-round dialogues, the full question and answer information of the current dialogue round needs to be supplemented with the following: the generated natural language query questions, the converted SQL statements, and the query results returned by the database, so as to provide complete data support for dependency determination, question backtracking, or model optimization in subsequent dialogues.

[0081] In the third scenario (processing path 3), if the target processing option indicates that the question to be answered does not rely on other data—that is, the answer to the question does not require the use of historical dialogue information from the historical memory module, structured data from the target database, or external knowledge from the knowledge base—it can be fully responded to solely by the language model's own general common sense, basic logic, or pre-built basic response capabilities. Such questions typically include, but are not limited to: general common sense queries (such as explanations of natural phenomena, definitions of basic concepts), simple instruction responses (such as inquiries about operation instructions, function descriptions), and independent questions without contextual relevance (such as date and time queries, basic rule inquiries), for example, asking about basic weather-related knowledge, basic steps for using a function, or simple explanations of general concepts.

[0082] In this scenario, the server can directly input the question to be answered into the language model. Based on the common sense, basic logic, and pre-set response paradigms learned during its training, the language model performs semantic parsing and natural language generation on the question, thereby obtaining the answer for the current dialogue round.

[0083] Meanwhile, to ensure the continuity and traceability of multi-round dialogues, the history memory module needs to be updated in a similar manner after the answer is generated.

[0084] In the fourth scenario (processing path 4), if the intent of the target processing option indicative of the question to be answered is ambiguous, the server generates a counter-question response. This response includes the question to be clarified and at least one potential intent. The potential intent is generated based on at least one of the following: metadata from the target data table, external knowledge, and question-and-answer pairs from historical dialogue rounds. The semantic similarity between the potential intent and the question to be answered meets a preset similarity condition. In other words, the potential intent is not randomly generated, but rather selected based on multi-source information to identify candidate directions that are highly semantically relevant to the current question. This ensures that users can quickly pinpoint their needs and improves clarification efficiency. By guiding users to clarify their core needs through counter-questions, the system avoids irrelevant answers due to misjudgment of intent, ensuring the accuracy of subsequent responses from the source and reducing the cost of ineffective interactions.

[0085] For example, server 10 can extract at least one of a limited set of keywords and entities from the question as core clues for generating intent candidates. Based on at least one of the extracted keywords and entities, initial intent candidates are generated by combining at least one of the following information to ensure the relevance and coverage of the candidates: ① Based on the metadata of the target data table: Extract the meaning of fields related to the keywords, enumeration values, or table function descriptions from the metadata to generate candidate options. For example, if the question contains the keyword "query," combining the function descriptions of "order table," "consumption table," and "logistics table" in the metadata, candidate options such as "query order-related information," "query consumption-related information," and "query logistics-related information" are generated. ② Based on external knowledge: Expand the scope of candidate options through synonym mapping and domain terminology association. For example, if the question contains the keyword "calculation," combining common scenarios in fields such as "amount calculation," "duration calculation," and "revenue calculation" from external knowledge, corresponding intent candidates are generated. ③ Question-answer pairs based on historical dialogue rounds: If there is related historical information in the same conversation, such as "orders" or "logistics" mentioned before, candidate options related to the historical topic will be generated first. For example, if the user asked about the order status in the past dialogue, the current question "how to check the relevant records" will generate the candidate option "query order records" first, thus improving the relevance of the candidate options.

[0086] For the generated initial intent candidates, a semantic similarity algorithm is used to calculate the semantic similarity between each initial intent candidate and the question to be answered. Only candidates with a similarity higher than a preset threshold (e.g., 0.7 or above) are retained, while irrelevant or low-relevance content is filtered out. Simultaneously, candidates are sorted from highest to lowest similarity, placing those most likely to match the user's true intent at the top for easy selection. After completion, the response is fed back to terminal 20 via the network, awaiting further user input.

[0087] Meanwhile, to ensure the continuity and traceability of multi-round dialogues, the questions to be answered, the generated counter-questions, the list of intent candidates, and the basis for their generation (such as associated metadata fields and external knowledge entries) are stored together as the full question and answer information of the current dialogue round in the detailed storage layer of the history memory module, providing data support for rapid processing of subsequent user feedback.

[0088] In this embodiment, the user's potential and mixed implicit intents are decomposed into four explicit and mutually exclusive processing paths: "relying on historical content," "relying on database content," "not relying on other data," and "unclear intent." This addresses the pain points of multiple intent confusion and blurred boundaries in traditional intent understanding. By transforming the complex intent understanding problem into a clearly defined four-category task, the complexity of semantic parsing is reduced. The system can accurately anchor the user's true needs based on clear classification criteria (such as whether it relies on history, whether it needs data support, and whether the intent is determinate). In particular, by clearly distinguishing between "new query intents without contextual relevance" (corresponding to the "not relying on other data" path) and "follow-up questioning intents based on historical dialogue" (corresponding to the "relying on historical content" path) through path division, the system avoids the problems of "abuse of historical information" or "contextual omission" caused by confusion between the two types of intents in traditional solutions, significantly improving the accuracy and stability of intent capture. Moreover, the four mutually exclusive paths correspond to clear processing logic, so the system does not need to perform a full process traversal. Instead, it directly matches a better processing link based on the classification results. This "classification decision-path matching" mode avoids the waste of computing resources (such as not needing to call the database or knowledge base for simple problems) and ensures in-depth processing of complex needs. It achieves a better allocation of resources for efficient response to simple problems and accurate processing of complex problems, and improves the overall processing throughput and response speed of the multi-turn dialogue system.

[0089] The various technical features in the above embodiments can be combined arbitrarily, as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, the arbitrary combination of various technical features in the above embodiments is also within the scope of this specification.

[0090] Figure 5 This is a schematic structural diagram of a device provided in an exemplary embodiment. For example... Figure 5 As shown, device 500 mainly consists of a communication interface 502, a user interface 504, a processor 506, and a data storage 508. These components are interconnected and communicate with each other via a system bus, network, or other connection mechanism 510. The communication interface 502 enables device 500 to communicate with other devices, access networks, and transmission networks via analog or digital modulation. For example, the communication interface 502 may include a chipset and antenna for wireless communication with a radio access network or access point. Furthermore, the communication interface 502 can be a wired interface such as Ethernet, Token Ring, or a USB port, or a wireless interface such as Wi-Fi, Bluetooth, Global Positioning System (GPS), or a wide-area wireless interface (e.g., WiMAX or LTE). Of course, the communication interface 502 can also support other forms of physical layer interfaces and standard or proprietary communication protocols. The communication interface 502 may also include multiple physical communication interfaces, such as Wi-Fi interfaces, Bluetooth interfaces, and wide-area wireless interfaces.

[0091] User interface 504 includes receiving user input and providing output to the user. Therefore, user interface 504 may include input components such as a keypad, keyboard, touch-sensitive or presence-sensitive panel, computer mouse, trackball, joystick, microphone, still camera, and video camera, and output components such as a display screen (which may be combined with a touch-sensitive panel), CRT, LCD, LED, display using DLP technology, printer, and other similar devices known or developed in the future. User interface 504 may also generate auditory output via speakers, speaker jacks, audio output ports, audio output devices, headphones, and other similar devices known or developed in the future. In some embodiments, user interface 504 may include software, circuitry, or other forms of logic capable of transmitting and receiving data from external user input / output devices. Additionally or alternatively, device 500 may support remote access from other devices via communication interface 502 or another physical interface (not shown). User interface 504 may be configured to receive user input, the position and movement of which may be indicated by indicators or cursors described herein. User interface 504 may also be configured as a display device for rendering or displaying text fragments.

[0092] Processor 506 may contain one or more general-purpose processors and / or special-purpose processors.

[0093] Data storage 508 may include one or more volatile and / or non-volatile storage components and may be integrated wholly or partially with processor 506. Data storage 508 may include removable and non-removable components.

[0094] Processor 506 is capable of executing program instructions 518 (e.g., compiled or uncompiled program logic and / or machine code) stored in data storage 508 to perform the various functions described herein. Data storage 508 may contain a non-transitory computer-readable medium on which program instructions are stored, which, when executed by device 500, enable device 500 to perform any methods, processes, or functions disclosed in this specification and / or the accompanying drawings. Execution of program instructions 518 by processor 506 may result in processor 506 using data 512.

[0095] For example, program instructions 518 may include an operating system 522 (e.g., an operating system kernel, device drivers, and / or other modules) installed on device 500 and one or more applications 520 (e.g., a browser, social application, or game application). Similarly, data 512 may include operating system data 516 and application data 514. Operating system data 516 is primarily accessible to the operating system 522, while application data 514 is primarily accessible to one or more applications 520. Application data 514 may reside in a file system visible or hidden from the user of device 500.

[0096] Application 520 can communicate with operating system 522 through one or more application programming interfaces (APIs). These APIs help application 520 read and / or write application data 514, transmit or receive information via communication interface 502, receive or display information on user interface 504, etc.

[0097] In some terminology, application 520 may be simply referred to as "app". Furthermore, application 520 can be downloaded to device 500 through one or more online app stores or app markets. However, applications can also be installed on device 500 in other ways, such as through a web browser or a physical interface on device 500 (e.g., a USB port).

[0098] In some embodiments, a multi-turn dialogue device based on a history memory module can be applied to, for example... Figure 5 The device shown implements the technical solution of this specification. The history memory module includes a main storage layer and a detail storage layer; the main storage layer stores question-and-answer pairs from each dialogue round; the detail storage layer stores all question-and-answer information and corresponding metadata from each dialogue round; this multi-turn dialogue device based on the history memory module may include: The question understanding module is used to receive the questions to be answered in the current dialogue round and to retrieve the question-answer pairs from the history memory module that belong to the same conversation as the current dialogue round. The question classification and processing module is used to retrieve the metadata of the full question and answer information of the historical dialogue rounds from the detail storage layer if the question to be answered depends on the content of the historical dialogue based on the question and answer pair of the historical dialogue rounds. Based on the metadata of the question to be answered and the full question and answer information of the historical dialogue rounds stored in the detail storage layer, the matching target question and answer information is retrieved. The question classification and processing module is also used to generate the answer for the current dialogue round based on the question to be answered and the target question-answer information using a language model.

[0099] In one implementation, the history memory module is used to divide the answers of the current dialogue turn using the data length of a single output lexical unit of the language model as the division unit and count the number of divisions. If the number of divisions is greater than the preset number of lexical units, the language model is used to summarize the answers of the current dialogue turn to obtain summary content with a data length that meets the preset number of lexical units indication. The question-answer pair consisting of the unanswered question of the current dialogue turn and the summary content is stored in the main storage layer. If the number of divisions is not greater than the preset number of lexical units, the question-answer pair consisting of the unanswered question of the current dialogue turn and the answer of the current dialogue turn is stored in the main storage layer. The full question-answer information of the current dialogue turn is stored in the detail storage layer. The full question-answer information of the current dialogue turn includes at least: the unanswered question, the target question-answer information, and the answer of the current dialogue turn.

[0100] In one implementation, the question classification and processing module is further used to fill the question-answer pairs of the question to be answered and the historical dialogue rounds into a preset prompt template to generate prompt words; the preset prompt template includes multiple processing options for the question to be answered; the prompt words are input into a trained classification model so that the classification model selects and outputs the target processing option related to the question to be answered from the multiple processing options.

[0101] Specifically, the question-and-answer pairing based on historical dialogue rounds determines that the question to be answered depends on historical dialogue content, including: target processing options indicating that the question to be answered depends on historical dialogue content. The full question-and-answer information for the current dialogue round also includes: prompts and target processing options.

[0102] In one implementation, the question understanding module is further configured to select a matching target data table from multiple data tables stored in the target database based on the question to be answered, and obtain the metadata of the target data table; and / or, based on at least one of the entities and keywords in the question to be answered, retrieve external knowledge related to at least one of the entities and keywords from a pre-set knowledge base. The metadata and / or external knowledge of the target data table are then populated into a pre-set prompt template.

[0103] In one implementation, the question classification and processing module is further configured to generate a natural language query question based at least on the metadata of the target data table and the question to be answered if the target processing option indicates that the question to be answered depends on the content of the target database; call a text-to-SQL tool to convert the natural language query question into an SQL statement and submit the SQL statement to the target database for execution; if the query result returned by the target database is received, use a language model to generate the answer for the current dialogue round according to the question to be answered and the query result; wherein, the full question and answer information for the current dialogue round also includes: the natural language query question, the SQL statement and the query result.

[0104] In one implementation, the question classification and processing module is further configured to input the question to be answered into the language model to obtain the answer for the current dialogue round if the target processing option indicates that the question to be answered does not depend on other data; if the target processing option indicates that the intent of the question to be answered is unclear, generate a counter-question response, which includes a question to be clarified and at least one intent candidate. The intent candidate is generated based on the metadata of the target data table, external knowledge and / or question-answer pairs of historical dialogue rounds, and the semantic similarity between the intent candidate and the question to be answered satisfies a preset similarity condition.

[0105] In one implementation, the question classification and processing module is further configured to obtain a first vector derived from the question to be answered, and a second vector derived from each question and answer piece in the full question and answer information of the historical dialogue rounds in the detail storage layer; calculate the similarity between the first vector and each second vector; if there is a target second vector with a similarity greater than a preset similarity threshold, obtain the target question and answer information indicated by the target second vector from the detail storage layer, and execute the step of generating the answer for the current dialogue round; if there is no target second vector with a similarity greater than a preset similarity threshold, execute the step of obtaining the question and answer pairs of the historical dialogue rounds.

[0106] For ease of description, the above devices are described by dividing them into various modules or units based on their functions. Of course, when implementing one or more of these specifications, the functions of each module or unit can be implemented in the same or different software and / or hardware, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units, etc. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.

[0107] Based on the same concept as the methods described above, this specification also provides an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor performs the steps of the method as described in any of the above embodiments by executing the executable instructions.

[0108] Based on the same concept as the methods described above, this specification also provides a computer-readable storage medium having computer instructions stored thereon that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.

[0109] Based on the same concept as the methods described above, this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the methods as described in any of the above embodiments.

[0110] What those skilled in the art will understand is: In this specification, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, product, or apparatus that includes said elements is not excluded.

[0111] In this specification, “a,” “an,” and “the” do not specifically refer to the singular, but may also include the plural.

[0112] In this specification, ordinal numbers such as "first," "second," etc., do not necessarily indicate order; they are often used to distinguish between objects. For example, "first server" and "second server" usually refer to two servers. To differentiate between these two servers, they are described as "first server" and "second server." Of course, sometimes these two servers may be the same server.

[0113] In this specification, unless explicitly stated otherwise, "receiving and sending data" does not necessarily mean direct receiving and sending; it can also mean indirect receiving and sending. For example, A receiving data sent by B can be understood as A directly receiving the data sent by B, or it can be understood as A indirectly receiving the data sent by B through other entities such as C. Similarly, B sending data to A can be understood as B sending the data directly to A, or it can be understood as B indirectly sending the data to A through other entities such as C. Here, C can be one entity, or it can be two or more entities.

[0114] In this specification, unless explicitly stated otherwise, the relationships between structures can be direct or indirect. For example, when describing "A is connected to B," unless it is explicitly stated that A and B are directly connected, it should be understood that A can be directly connected to B or indirectly connected to B. Similarly, when describing "A is on top of B," unless it is explicitly stated that A is directly above B (AB is adjacent and A is above B), it should be understood that A can be directly above B or indirectly above B (AB is separated by other elements, and A is above B). And so on.

[0115] This specification uses specific terms to describe embodiments thereof. Terms such as "an embodiment," "one embodiment," and / or "some embodiments" refer to a particular feature, structure, or characteristic associated with at least one embodiment of this specification. Therefore, it should be emphasized and noted that references to "an embodiment," "one embodiment," or "an alternative embodiment" in different locations throughout this specification do not necessarily refer to the same embodiment. Furthermore, those skilled in the art can combine and integrate the different embodiments or examples described herein, as well as the features of those different embodiments or examples, without contradiction.

[0116] Although one or more embodiments of this specification provide method steps as described in the embodiments or flowcharts, it is understood that the order of steps listed in the embodiments or flowcharts is only one of many possible execution orders and does not represent the only execution order. Therefore, when the claims involve method steps, any changes or adjustments to the order of such steps, or the parallelism between steps, are also within the scope of protection of the claims.

Claims

1. A multi-turn dialogue method based on a historical memory module, wherein the historical memory module includes a main storage layer and a detail storage layer; the main storage layer is used to store question-answer pairs in each dialogue turn; The detailed storage layer is used to store all question-and-answer information and corresponding metadata for each dialogue round; the method includes: Receive the unanswered question for the current dialogue round, and retrieve the question-answer pair from the history memory module that belongs to the same session as the current dialogue round; If it is determined from the question-and-answer pairs of the historical dialogue rounds that the question to be answered depends on the content of the historical dialogue, the metadata of the full question-and-answer information of the historical dialogue rounds is obtained from the detail storage layer, and the matching target question-and-answer information is obtained from the full question-and-answer information of the historical dialogue rounds stored in the detail storage layer based on the metadata of the question to be answered and the full question-and-answer information of the historical dialogue rounds. The language model is used to generate the answer for the current dialogue round based on the question to be answered and the target question-and-answer information.

2. The method according to claim 1, further comprising: Using the data length of a single output word of the language model as the unit of division, the answers of the current dialogue round are divided and the number of divisions is counted. If the number of divisions is greater than the preset number of lexical units, the language model is used to summarize the answers of the current dialogue round to obtain summary content with a data length that meets the data length indicated by the preset number of lexical units. The question-answer pair consisting of the unanswered question of the current dialogue round and the summary content is stored in the main storage layer. If the number of divisions is not greater than the preset number of tokens, the question-answer pair consisting of the unanswered question and the answer of the current dialogue round will be stored in the main storage layer. as well as The full set of question-and-answer information for the current dialogue round is stored in the detailed storage layer. The full set of question-and-answer information for the current dialogue round includes at least the question to be answered, the target question-and-answer information, and the answer for the current dialogue round.

3. The method according to claim 1 or 2, further comprising: At least the question-and-answer pairs of the questions to be answered and the historical dialogue rounds are filled into the preset prompt template to generate prompt words; The preset prompt template includes multiple processing options for the question to be answered; The prompt words are input into a trained classification model, which then selects and outputs a target processing option related to the question to be answered from the plurality of processing options. Wherein, the step of determining that the question to be answered depends on the content of the historical dialogue based on the question-answer pair of the historical dialogue rounds includes: the target processing option instructs that the question to be answered depends on the content of the historical dialogue; The full question-and-answer information for the current dialogue round also includes: the prompt words and the target processing options.

4. The method according to claim 3, further comprising: Based on the question to be answered, a matching target data table is selected from multiple data tables stored in the target database, and the metadata of the target data table is obtained; And / or, based on at least one of the entities and keywords in the question to be answered, recall external knowledge related to at least one of the entities and keywords from a pre-set knowledge base; The metadata of the target data table and / or the external knowledge are populated into the preset prompt template.

5. The method according to claim 4, further comprising: If the target processing option indicates that the question to be answered depends on the content of the target database, a natural language query question is generated based at least on the metadata of the target data table and the question to be answered; The natural language query is converted into an SQL statement using a text-to-SQL tool, and then the SQL statement is submitted to the target database for execution. If the query results returned by the target database are received, the language model is used to generate the answer for the current dialogue round according to the question to be answered and the query results; The full question-and-answer information for the current dialogue round also includes: the natural language query question, the SQL statement, and the query results.

6. The method according to claim 4, further comprising: If the target processing option indicates that the question to be answered does not depend on other data, the question to be answered is input into the language model to obtain the answer for the current dialogue round; If the target processing option indicates that the intent of the question to be answered is unclear, a counter-question response is generated. The counter-question response includes a question to be clarified and at least one intent candidate. The intent candidate is generated based on the metadata of the target data table, the external knowledge and / or the question-answer pairs of the historical dialogue rounds. The semantic similarity between the intent candidate and the question to be answered meets a preset similarity condition.

7. The method according to claim 1, further comprising, before retrieving from the history memory module a question-answer pair belonging to the same session as the current dialogue turn, the following: Obtain a first vector derived from the question to be answered, and obtain a second vector derived from each question and answer in the full question and answer information of the historical dialogue rounds in the detail storage layer; Calculate the similarity between the first vector and each of the second vectors; If a target second vector with a similarity greater than a preset similarity threshold exists, the target question-and-answer information indicated by the target second vector is obtained from the detail storage layer, and the step of generating the answer for the current dialogue round is executed. If there is no target second vector with a similarity greater than the preset similarity threshold, proceed with the step of obtaining question-answer pairs from historical dialogue rounds.

8. An electronic device, characterized in that, include: processor; A memory for storing processor-executable instructions; wherein the processor implements the steps of the method as described in any one of claims 1-7 by executing the executable instructions.

9. A computer-readable storage medium, characterized in that, It stores computer instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-7.

10. A computer program product, characterized in that, Includes a computer program / instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-7.