Question and answer method and device and electronic equipment

By combining a pre-defined language model with tool calls, this question-answering method solves the problems of limited semantic representation and insufficient response in existing question-answering systems, enabling efficient and accurate responses to complex queries and providing high-quality question-answering services.

CN121743440APending Publication Date: 2026-03-27CHINA MOBILE GROUP DESIGN INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-29
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing question-answering methods suffer from limited semantic representation, making it difficult to accurately match complex user queries. The retrieval process lacks recall and accuracy, multi-dimensional semantic enhancement, and a high-concurrency streaming response design in the system architecture. User feedback does not form an effective closed loop, making it difficult to provide efficient and accurate question-answering services.

Method used

By identifying user query needs through a pre-set language model, and combining real-time query data obtained by tool calls with retrieval query data from a pre-set database, query answers are generated. Multi-dimensional semantic analysis and deep re-ranking strategies are employed to achieve adaptability to complex queries and efficient response to dynamic scenarios.

Benefits of technology

It significantly improves the question-and-answer system's ability to adapt to complex queries, its response efficiency in dynamic scenarios, and the accuracy of answers, providing users with higher-quality question-and-answer services that better meet their needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121743440A_ABST
    Figure CN121743440A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a question and answer method and device and electronic equipment, and relates to the technical field of artificial intelligence, and one specific implementation mode of the method comprises the steps that on the basis of a preset language model, a query requirement corresponding to a query question input by a user is recognized; under the condition that the tool calling demand exists in the query demand, real-time query data associated with the query problem is determined based on a query tool corresponding to the tool calling demand; based on the real-time query data and the retrieval query data, a query answer corresponding to the query question is determined, the query answer is pushed to the user, and the retrieval query data is query data obtained through retrieval from a preset database and associated with the query question. According to the method, the adaptation capability to complex query, the response efficiency of dynamic scenes and the accuracy of answers in the question and answer process are improved, and high-quality question and answer services better meeting the requirements are provided for users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence technology, specifically to a question-answering method, apparatus, and electronic device. Background Technology

[0002] With the continuous development of technologies such as artificial intelligence, natural language processing, and knowledge management, intelligent question answering methods have been widely used in various industry scenarios due to their efficient information interaction capabilities, becoming an important technical means to solve users' information query needs.

[0003] Currently, question answering methods in related technologies mainly fall into three core technical categories: First, generative question answering methods based on large models rely on large-scale pre-trained language models to understand complex questions and generate answers; second, question answering methods based on knowledge graphs construct structured knowledge bases in the dimensions of entities, relations, and attributes, and combine entity disambiguation and semantic parsing to adapt to the professional question answering needs of specific fields such as water conservancy, electric power, and law; and third, retrieval-enhanced generation (RAG) methods, which vectorize large-scale documents and integrate semantic retrieval and generation models to improve the question answering capabilities for open domains and unstructured knowledge.

[0004] However, the aforementioned generative, knowledge graph-based, and retrieval-enhanced generative question answering methods have obvious limitations: on the one hand, the semantic representation is singular, mostly using single vectors or structured graphs as a single representation method, resulting in insufficient recall and accuracy during the retrieval process; on the other hand, the understanding of users' complex query intent is not deep enough, making it difficult to accurately match core needs, ultimately resulting in a low degree of matching between the answer and the user's expectations, and failing to fully meet the needs of efficient and accurate question answering. Summary of the Invention

[0005] This application provides a question-answering method, apparatus, and electronic device to address the problems in related technologies, such as limited semantic representation, insufficient response to complex dynamic tasks, and poor timeliness and accuracy of answers.

[0006] In a first aspect, embodiments of this application provide a question-and-answer method, which includes: identifying the query requirement corresponding to a user-input query question based on a preset language model; if the query requirement includes a tool call requirement, determining real-time query data associated with the query question based on the query tool corresponding to the tool call requirement; determining the query answer corresponding to the query question based on the real-time query data and the retrieved query data, and pushing the query answer to the user; wherein the retrieved query data is query data associated with the query question retrieved from a preset database.

[0007] In some embodiments, determining the query answer corresponding to a query question based on real-time query data and retrieval query data includes: determining retrieval query data associated with the query question in a preset database; fusing the retrieval query data and real-time query data to obtain fused query data; integrating the fused query data and the query question according to a prompt word template to obtain answer generation prompt words; and generating the query answer based on the answer generation prompt words.

[0008] In some embodiments, identifying the query requirements corresponding to the user-input query question based on a preset language model includes: standardizing the query question based on the preset language model to obtain a standardized query question; and performing semantic analysis on the standardized query question to determine the query requirements corresponding to the query question.

[0009] In some embodiments, determining the retrieval query data associated with the query question in a preset database includes: determining the query question vector corresponding to the query question; performing similarity analysis on the query question vector with a first text block vector and a first question vector in the preset database to obtain the text block similarity between the query question vector and the first text block vector and the question similarity between the query question vector and the first question vector; determining candidate query data based on the text block similarity, question similarity, and the frequency of occurrence of the first text block; and performing deep re-sorting on the candidate query data to determine the retrieval query data in the candidate query data.

[0010] In some embodiments, before determining the query answer corresponding to the query question based on real-time query data and retrieval query data, the method includes: parsing the file to be processed based on the file parser corresponding to the file to be processed to obtain the text to be processed, wherein the file parser is determined based on the file extension of the file to be processed; dividing the text to be processed based on the text structure of the text to be processed to obtain at least one text block; performing language enhancement on a first text block in the at least one text block based on a preset language model to obtain a first text question corresponding to the first text block, wherein the first text block is any text block in the at least one text block; performing vectorization processing on the first text block and the first text question to obtain a first text vector of the first text block and a first question vector of the first text question; generating first structured data based on the first text vector, the first question vector, and the first metadata corresponding to the first text block, and storing the first structured data in a preset database.

[0011] In some embodiments, after dividing the text to be processed based on the text structure of the text to be processed to obtain at least one text block, the method includes: performing context merging processing on mergeable text blocks that satisfy merging constraints in the at least one text block based on the text size of the at least one text block, to obtain at least one text block after merging processing.

[0012] In some embodiments, the method further includes: upon receiving a query question input by a user, determining answer generation data for generating the query answer in sequence according to the generation stage of the query answer, wherein the answer generation data includes the generation status and generation result of generating the query answer; and pushing the answer generation data to the user.

[0013] In some embodiments, after pushing the query answer to the user, the method includes: obtaining user feedback data on the query answer; adjusting the user's query question and query answer based on the feedback data to obtain fine-tuned training samples; adjusting the model parameters of a preset language model based on the fine-tuned training samples to obtain an adjusted target language model, so as to use the target language model to identify the updated query question input by the user.

[0014] Secondly, embodiments of this application provide a question-and-answer device, the device comprising: The recognition unit is used to identify the query requirements corresponding to the user's input query question based on a preset language model. The first determining unit is used to determine the real-time query data associated with the query question based on the query tool corresponding to the tool call requirement when there is a tool call requirement in the query request. The second determining unit is used to determine the query answer corresponding to the query question based on real-time query data and retrieval query data, and push the query answer to the user. The retrieval query data is query data related to the query question retrieved from a preset database.

[0015] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory for storing a computer program capable of running on the processor, wherein, when the processor runs the computer program, it performs the method described in any embodiment of the first aspect.

[0016] This application provides a question-answering method that, based on a preset language model, identifies the query requirement corresponding to the user's input query question. If the query requirement includes a tool invocation requirement, it determines the real-time query data associated with the query question based on the corresponding query tool. Based on the real-time query data and the retrieved query data, it determines the query answer corresponding to the query question and pushes the answer to the user. The retrieved query data is query data associated with the query question retrieved from a preset database. This method improves the adaptability to complex queries, the response efficiency to dynamic scenarios, and the accuracy of answers during the question-answering process, providing users with a higher-quality question-answering service that better meets their needs.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0018] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are merely embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort, and this application can be applied to other similar scenarios based on the provided drawings.

[0019] Figure 1 A flowchart illustrating a question-and-answer method provided in an embodiment of this application; Figure 2 A flowchart illustrating the second question-and-answer method provided in this application embodiment; Figure 3 This application provides a specific schematic diagram illustrating the determination of search query data in an embodiment. Figure 4 A schematic diagram illustrating a specific method for constructing a preset database, as provided in an embodiment of this application; Figure 5 A schematic diagram of a specific question-and-answer system provided in this application embodiment; Figure 6 A schematic diagram illustrating a specific question-and-answer method provided in an embodiment of this application; Figure 7 A schematic diagram of the structure of a question-and-answer device 700 provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0020] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. The described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0021] It should be noted that the terms "system," "device," "unit," and / or "module" used in this application are methods of distinguishing different components, elements, parts, sections, or assemblies at different levels. However, if other terms can achieve the same purpose, they can be replaced by other expressions.

[0022] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.

[0023] With the development of technologies in artificial intelligence, natural language processing and knowledge management, intelligent question answering methods have been widely used in various industries. Currently, the mainstream technical routes have formed three core directions: generative question answering methods based on large models, question answering methods based on knowledge graphs, and retrieval-enhanced generation (RAG) methods. These three routes are adapted to different needs such as complex question generation, domain-specific professional question answering, and open-domain unstructured knowledge question answering.

[0024] Currently, related technologies focus on building customized question-and-answer systems for specific fields. For example, knowledge graphs are built for the water conservancy field to achieve entity disambiguation and iterative question-and-answer; multimodal data is integrated to build knowledge graphs for the power engineering field to optimize knowledge base query efficiency; and industry-wide model fine-tuning combined with regulatory knowledge bases is used to improve the accuracy of compliance questions and answers in the securities compliance field. Other related technologies focus on optimizing general technologies, such as supporting multi-turn dialogues and user feedback adjustments based on multi-model collaboration, optimizing the document retrieval process for clause-based documents through RAG technology, improving the quality of knowledge graph question-and-answer by combining iterative retrieval reasoning and introspection mechanisms, or achieving industry-specific knowledge question-and-answer through dual knowledge base design combined with historical dialogues.

[0025] However, related technologies generally have significant limitations: their semantic representation is limited, relying mainly on single vectors or structured graphs, lacking multi-dimensional semantic enhancement, resulting in insufficient retrieval matching and coverage; their understanding of user query intent is insufficient, mostly relying on keyword matching or shallow recognition, making it difficult to adapt to complex and conversational query needs; their retrieval and re-ranking strategies are simple, lacking multi-path hybrid recall and deep ranking mechanisms, resulting in weak accurate positioning capabilities in complex scenarios; their system architecture lacks high-concurrency streaming response design, leading to poor real-time interactive experience; user feedback does not form an effective closed loop, lacking a complete process of structured collection, optimization, and model fine-tuning, resulting in insufficient self-evolution capabilities; and they lack automated evaluation and performance analysis frameworks, making system optimization lack quantitative basis and hindering a comprehensive improvement in question-answering quality.

[0026] To address the problems in related technologies, this application proposes a question-answering method that accurately identifies user query needs and determines whether a tool needs to be invoked through a pre-set language model. When a tool invocation is required, the real-time query data obtained by the tool is collaboratively integrated with the retrieval query data from a pre-set database to generate a query answer. This significantly improves the question-answering system's adaptability to complex queries, its response efficiency in dynamic scenarios, and the accuracy of the answers, providing users with a higher quality question-answering service that better meets their needs.

[0027] The question-and-answer method provided in this application will be described in detail below with reference to the accompanying drawings.

[0028] Figure 1 A flowchart of a question-and-answer method provided in an embodiment of this application is shown. Figure 1 As shown, the question-and-answer method includes steps 101-103.

[0029] Step 101: Based on the preset language model, identify the query requirements corresponding to the user's input query question.

[0030] In this application, the system can perform semantic parsing and intent classification on the user-input query (natural language query) through a preset language model, transforming colloquial, ambiguous, and even cross-domain queries into standardized query requirements that the system can recognize, providing a basis for decision-making on whether to call tools and how to retrieve data.

[0031] The essence of this application is to solve the problem of converting what the user says into what the system should do, and to avoid subsequent processing deviations due to semantic ambiguity and unclear intent (for example, when a user asks for the current power grid load data of a certain place, it is necessary to identify the core requirement of needing real-time data and calling the tool, rather than simply searching the historical knowledge base).

[0032] A pre-trained language model refers to a natural language processing model that has been trained (or fine-tuned for a specific domain) beforehand. It possesses semantic understanding and intent classification capabilities and can be a general-purpose large model or a vertically-domain fine-tuned model. Its role is to serve as the core engine for intent recognition, handling the semantic parsing and demand judgment of user queries.

[0033] The query is a natural language request entered by the user through the interactive interface. It can take the form of conversational questions (such as today's power grid maintenance progress), professional questions (such as 10kV line fault diagnosis standards), fuzzy queries (such as recent compliance requirements), etc., and is the raw input for the system to process.

[0034] The query requirement is the core objective and processing requirements of the user query extracted after parsing by a pre-defined language model.

[0035] Step 102: If the query request includes a tool call requirement, determine the real-time query data associated with the query question based on the query tool corresponding to the tool call requirement.

[0036] In the embodiments of this application, when it is determined that there is a need for tool invocation in the user's needs, the system matches the corresponding query tool, and interacts with external data sources or external systems through the tool to obtain real-time, dynamic or operational data that cannot be obtained from the preset database, thereby making up for the limitations of the static knowledge base.

[0037] The essence of this application is to solve the problem that static knowledge bases cannot cover dynamic needs, so that the system can not only answer historical knowledge, but also respond to dynamic tasks such as real-time data queries and specific operation executions (such as when users need real-time power grid load, they need to call the real-time power grid monitoring tool to obtain data, rather than retrieving historical load records).

[0038] Tool call requirements are a subclass of query requirements, referring to user needs that must be met through external tools (rather than relying solely on a pre-defined database). Their core characteristics are the need for real-time data, dynamic calculations, external system interaction, or specific operations (such as data statistics, file generation, real-time interface queries, etc.).

[0039] Query tools refer to external functional modules or interfaces that interface with the system of this application, used to obtain real-time data or perform specific operations. According to their functions, they can be divided into real-time data query tools (such as power grid load monitoring interfaces, weather data interfaces, industry policy update interfaces, etc., used to obtain real-time dynamic data), operation tools (such as report generation tools, data statistical analysis tools, file export tools, etc., used to perform specific business operations), and dedicated system interface tools (such as interface tools that interface with enterprise internal ERP and monitoring systems, used to obtain dynamic data in a specific field), etc.

[0040] Real-time query data refers to dynamic data / operation results obtained from external data sources / systems through query tools and directly related to the query question. It has the characteristics of timeliness, dynamism, and specific relevance (such as the power grid load of a certain region at a certain time on a certain day of a certain month of a certain year being 8500MW, or the initial draft of a maintenance report generated in a certain month of a certain year).

[0041] Step 103: Based on real-time query data and retrieval query data, determine the query answer corresponding to the query question and push the query answer to the user. The retrieval query data is the query data related to the query question retrieved from the preset database.

[0042] In the embodiments of this application, the application can collaboratively integrate the acquired dynamic real-time data with the static historical knowledge data retrieved from the preset database (i.e., the retrieval query data), and then combine it with the user's original query to generate a logically coherent, data-accurate, and demand-appropriate final answer (i.e. the query answer) through a preset language model, while simultaneously completing the answer push.

[0043] The essence of this application is to solve the problem that a single data source cannot satisfy complex queries: real-time data ensures the timeliness of the answer, and retrieval query data ensures the professionalism and completeness of the answer. The answer generated after the two are combined not only conforms to the real-time scenario, but also has the support of historical knowledge (for example, if a user asks "whether the current power grid load in a certain area exceeds the safety standard", it is necessary to combine real-time load data and safety standard data in a preset database to generate an accurate answer).

[0044] The retrieved query data refers to static / historical knowledge data related to the query question, which is retrieved from a preset database. The source is structured / unstructured knowledge (such as document text blocks, knowledge graph entities, historical cases, etc.) stored in the preset database, and has the characteristics of stability, professionalism, and traceability (such as the emergency handling process when the power grid safety load limit in a certain region is 10000MW and the power grid load exceeds the standard).

[0045] The pre-built database is a structured knowledge base constructed in advance in this application, storing processed domain knowledge, including: data sources: multi-format documents (PDF, DOCX, XLSX, etc.), industry standards, historical cases, knowledge graphs, etc.; data format: text blocks after text segmentation and vectorization, semantic vectors, metadata (such as source documents, chapter positions, etc.); core function: to provide static knowledge support and is the source of data for retrieval and query.

[0046] The query answer is the final response result generated by integrating real-time query data and retrieval query data to meet the user's query needs. It must be accurate (based on real data), complete (covering core needs), logical (clear and organized), and traceable (key data can be traced back to its source).

[0047] After obtaining the query answer, the generated query answer can be fed back to the user through the system interaction interface (such as web page, APP, API interface), which can support streaming push (real-time display of the answer generation process) or one-time push (feedback after the complete answer is generated), to improve the user experience.

[0048] In summary, the question-answering method proposed in this application identifies the query requirements corresponding to the user's input query based on a pre-defined language model; when the query requirements include tool invocation requirements, it determines the real-time query data associated with the query question based on the query tool corresponding to the tool invocation requirement; based on the real-time query data and the retrieved query data, it determines the query answer corresponding to the query question and pushes the query answer to the user. The retrieved query data is the query data associated with the query question retrieved from a pre-defined database. This method improves the adaptability to complex queries, the response efficiency to dynamic scenarios, and the accuracy of answers during the question-answering process, providing users with a higher-quality question-answering service that better meets their needs.

[0049] based on Figure 1 The embodiment shown, Figure 2 A flowchart of the second question-and-answer method is further shown. Figure 2 based on Figure 1 The illustrated embodiment further defines step 103. Figure 2In the illustrated embodiment, step 103 includes steps 203, 204, 205, 206, and 207. For example... Figure 2 As shown, the method includes the following steps: Step 201: Based on the preset language model, identify the query requirements corresponding to the user's input query question.

[0050] In this application embodiment, during the user interaction stage, the primary goal of this application is to deeply explore the user's true query intent, rather than being limited to superficial keyword matching. Therefore, a dual mechanism of query normalization and semantic analysis is designed: first, the original query question is normalized and transformed by a preset language model and prompt word template to generate a normalized query question; then, semantic analysis is carried out based on the normalized query question to finally clarify the corresponding query requirements and achieve accurate understanding and transcription of the user's query.

[0051] Specifically, upon receiving the original query input by the user (i.e., the query question described in this application), a pre-defined language model (such as a large language model LLM) specifically for question transcription will be invoked, and a prompt word template customized for user question transcription will be used to complete the standardization process of the original query.

[0052] The prompt word template incorporates rich domain knowledge and transcription rules, effectively handling colloquial, ambiguous, or non-standard user input. It accurately transcribes this input into one or more structured, technically rigorous query questions. The core design includes three key elements: first, synonym mapping, such as semantically unifying "high traffic" with "high load," and "high congestion" with "high load"; second, concept differentiation, strictly defining easily confused domain concepts such as 4G and 5G, and zero traffic with low traffic; and third, intent preservation, fully retaining key constraints in the user query, such as the number of cases and scenario limitations. For example, if a user inputs "Give me 3 high traffic cases," guided by the prompt word template and semantic analysis from a pre-defined language model, the query will be transcribed as "Please provide 3 network optimization cases under high load scenarios," ensuring precise alignment between the query semantics and the semantic representation in the knowledge base.

[0053] Through the standardization process described in this application, originally colloquial, vague, or non-standard queries can be transformed into technically rigorous and standardized query questions, significantly improving the accuracy of subsequent retrieval processes and providing a foundation for high-quality knowledge-based question answering.

[0054] In addition, this application also supports a multi-question transcription function, that is, a broad user-input query question can be broken down into multiple related specific technical questions. For example, when a user queries "5G network optimization", it will be transcribed into multiple sub-queries such as "5G network coverage optimization method", "5G network capacity optimization strategy", and "5G network quality optimization technology". Through this multi-dimensional expansion mechanism, the comprehensiveness and accuracy of the retrieval are further guaranteed, ensuring that no potential user needs are missed.

[0055] Step 202: If the query request includes a tool call requirement, determine the real-time query data associated with the query question based on the query tool corresponding to the tool call requirement.

[0056] In this application embodiment, the application focuses on scenarios where the query requirement includes the tool call requirement. The core is to match the corresponding query tool based on the requirement, and then obtain real-time query data related to the query question. Through the deep integration of retrieval augmented generation (RAG) and external tool call, the pain point of traditional RAG systems that rely solely on static knowledge bases cannot meet the real-time, operability and dynamic data query requirements is solved, and an intelligent question answering platform with intelligent decision-making, dynamic execution and seamless collaboration between knowledge and tools is built.

[0057] This application adopts a layered architecture of intent recognition, tool planning, tool execution, result fusion, and streaming feedback to ensure that each link can be independently expanded and optimized, and that the functions of each layer are clearly defined: The intent recognition layer relies on deep semantic understanding based on a pre-set language model (LLM) to automatically identify whether there is a need to call a tool in the query question; if a need to call a tool is determined, the tool planning layer dynamically selects suitable tools or toolchains based on the recognition results and completes automatic parameterization to obtain the query tool; the tool execution layer calls the query tool securely and efficiently through a unified interface to obtain real-time query data; the result fusion layer injects the real-time query data returned by the tool into the RAG process or collaborates with the knowledge retrieval results to generate the final query answer; and the streaming feedback layer realizes streaming output throughout the entire process, allowing users to keep track of the system's processing progress in real time.

[0058] Specifically, after identifying the query requirement in step 201, if a tool call requirement is determined through a preset language model, the tool planning and execution process is initiated. First, the system has a built-in unified tool registration and scheduling module that supports various tool types such as APIs, scripts, and microservices. All available tools must be registered in advance, and metadata such as tool name, function description, input and output parameters, calling method, and security policy must be entered. The relevant information is stored in a database or configuration file for unified management and dynamic expansion. Next, the system combines the tool call requirement, user context, and tool metadata to automatically select the most suitable query tool (tool or toolchain, and also supports multi-tool combination calling mode). For example, real-time data can be queried through the tool first, and then historical knowledge can be retrieved for supplementation.

[0059] Meanwhile, the system has the capability of automated parameter processing, which can automatically extract key parameters from query questions. If any parameters are missing, they can be completed using examples with internalized prompts, ensuring the accuracy and contextual relevance of tool calls. Finally, the system executes calls through a unified tool call interface, and all call processes are configured with timeout control, error retries, and permission verification mechanisms to comprehensively ensure the stability and security of the system.

[0060] Understandably, in the intent recognition stage of determining whether a tool call requirement exists, this application uses an LLM-driven intent recognition module to perform deep semantic analysis on user queries. This not only understands the user's knowledge needs but also accurately identifies implicit intents for tool calls, such as real-time data acquisition, system status queries, and external operation execution. This module performs multiple rounds of Prompt engineering on user input, combining domain knowledge and historical data to determine whether a tool call is needed. For example, for questions like "What is the current network congestion situation?" or "Please check user A's data plan usage," it can accurately identify the need to call network monitoring APIs or user data query tools. Furthermore, it supports custom rules and continuous learning, and can dynamically expand new tool call scenarios according to business needs.

[0061] Step 203: Determine the retrieval query data associated with the query question in the preset database.

[0062] In this embodiment, the application can efficiently and accurately filter search query data that is highly relevant to the query question from a preset database. Through a progressive process of vector transformation, multi-way retrieval, candidate filtering, and deep sorting, it ensures both the comprehensiveness of the retrieval and the accuracy of the results, providing high-quality knowledge support for subsequent answer generation.

[0063] First, the system transforms the query questions, after the normalization process in step 201, into query question vectors that can be recognized by a computer. This transformation uses a pre-trained model (such as Sentence-BERT, BGE, etc.) that generates text vectors consistent with those in the preset database. Through semantic encoding, the core semantics of the natural language query are mapped to the vector space, ensuring that the query vectors and the vectors stored in the database are in the same semantic dimension. This lays the foundation for subsequent similarity calculations and transforms "text matching" into "vector similarity matching," significantly improving retrieval efficiency under massive amounts of data.

[0064] Subsequently, the system initiates a multi-path hybrid retrieval process, using the `search_by_query` method to perform parallel searches between the query question vector and multiple vector indexes in a pre-defined database (such as the Milvus vector database). The retrieval dimensions encompass the first text block vector corresponding to the original text block (directly representing the core content of the text), and the first question vectors corresponding to multiple exploratory questions generated for that text block (such as question 1 vector, question 2 vector, and question 3 vector, representing the text semantics from different perspectives). Specifically, the system executes four retrieval operations simultaneously: the query vector is compared with the first text block vector and the three first question vectors, and each retrieval uses algorithms such as cosine similarity to obtain a matching score and return candidate documents. This multi-dimensional parallel retrieval strategy can recall relevant content from multiple semantic perspectives, including the text itself and text-derived questions, effectively overcoming the limitations of traditional single-path retrieval and improving the retrieval recall rate.

[0065] After the retrieval is complete, the system collects all candidate documents returned from multiple retrievals, performs merging, deduplication, and weighted filtering. First, all candidate documents are integrated and duplicate text blocks are removed to avoid redundant data consuming computational resources. Then, a weighted scoring mechanism is executed through a custom function, calculating the final score for each candidate document based on three core indicators: text block similarity between the query vector and the first text block vector, question similarity between the query vector and each first question vector (taking the maximum or average value), and the frequency of the first text block in historical search results (higher frequency indicates stronger generality or relevance). After sorting according to the weighted scores, the Top-N highest-scoring candidate documents are selected to form a high-quality candidate query data set.

[0066] Finally, the system performs deep re-ranking of candidate query data, offering two modes adapted to different scenarios: First, LLM-driven intelligent re-ranking, where the query question and candidate query data are input into a dedicated LLM, which guides the model to analyze the question type (e.g., seeking a definition, obtaining a solution), identify core concepts, and recognize user constraints (e.g., case quantity requirements) through complex prompt word templates. It ultimately returns the most relevant document index in structured JSON format, leveraging the deep semantic understanding and logical reasoning capabilities of the LLM to improve ranking accuracy. Second, localized dedicated model re-ranking, which directly calculates the deep semantic relevance score between the query and the document using a locally deployed dedicated re-ranking model (e.g., CrossEncoder). It supports parallel processing and optimization strategies such as hybrid scoring combining lexical overlap, ensuring both effectiveness and low latency. After ranking using either mode, the Top-K (K≤N) candidate documents with the highest relevance and optimal information content are selected as the final retrieval query data, providing core knowledge support for subsequent answer generation.

[0067] Furthermore, for ease of understanding, such as Figure 3 As shown, this application provides a specific schematic diagram for determining search query data. (Refer to...) Figure 3 First, starting with the transcribed query vector generated in step 201, this vector is the semantic encoding of the user's normalized query, ensuring it resides in the same semantic space as the database vector. Next, a multi-path parallel retrieval stage begins: the system simultaneously calls two types of vector indexes from the Milvus database—content vector index (corresponding to the first text block vector, directly representing the core content of the text) and question vector index (corresponding to the first question vector, representing the semantics of the text from the perspective of exploratory questions). Parallel retrieval is performed from multiple semantic dimensions of the text itself and text-derived questions, outputting multiple candidate sets and significantly improving the recall rate of relevant knowledge. Then, weighting and deduplication operations are performed: the candidate sets obtained from the multi-path retrieval are integrated, and duplicate text blocks are removed to avoid redundancy; a custom weighting algorithm is then used to score candidate documents based on three indicators: text block similarity, question similarity, and text block frequency, ultimately forming a high-quality candidate set to ensure the relevance and quality of the candidate data. Finally, the system enters the deep re-ranking stage: It offers two modes for precisely filtering the most relevant context. For deep semantic reasoning (such as complex intents or cross-domain queries), LLM intelligent re-ranking is used, guiding the large model through prompts to analyze the question type and identify core concepts before outputting the ranking results. For scenarios requiring both efficiency and high concurrency, local model re-ranking is used, rapidly calculating the relevance score between the query and the document using a dedicated re-ranking model. After this stage, the most relevant context that best matches the user's intent is obtained, which is the retrieval query data required for this application.

[0068] In this embodiment of the application, it is determined that database preprocessing and construction need to be completed before retrieving and querying data. This process is divided into two core stages: document parsing and intelligent segmentation, and semantic enhancement and vectorized data entry, which provides a standardized and multi-dimensional knowledge carrier for subsequent retrieval.

[0069] Among these, document parsing and intelligent chunking are the cornerstones of database construction. Their goal is to transform diverse raw documents into standardized text units suitable for vectorization, uniformly scheduled by the document preprocessing functions of the document_reader module. 1) Multi-format document parsing: The system traverses the source directory, identifies and classifies supported document formats (.docx, .xlsx, .pdf, .txt), and equips each format with a dedicated parser (such as ExcelParser to parse table structure, DocxParser to extract paragraphs and levels, and PlainPDFParser to preserve PDF paragraph structure), not only extracting text, but also preserving the document's inherent structure and semantic information (such as table titles and chapter levels).

[0070] 2) Intelligent Block Segmentation and Merging: Breaking through the limitations of traditional fixed-length segmentation, this method first divides text blocks based on the natural boundaries of the document (paragraphs, tables, chapters). Then, it dynamically adjusts the text blocks based on text size thresholds (e.g., minimum 500 characters, maximum 2000 characters). Shorter text blocks are merged with adjacent blocks to ensure semantic integrity, while longer text blocks are segmented at semantic boundaries (periods, paragraph ends). The final output is Markdown-formatted text blocks with metadata (source path, block number, character count), and a processing report is generated recording statistical information such as the number of files and the total number of text blocks, providing a basis for subsequent optimization.

[0071] For semantic enhancement and vectorized data storage, this stage utilizes multi-vector representation and parallelized data storage to construct a deep semantic description for each text block and efficiently store it in a vector database. 1) LLM-based Semantic Enhancement: For each text block, a pre-defined Language Model (LLM) and carefully designed prompt word templates are used to generate multiple (e.g., 3) exploratory questions to explore the text's connotations from different angles (e.g., principles, decisions, indicators). For example, for the text block on "5G site construction," LLM will generate questions such as "What are the methods for planning new construction to increase system capacity?" and "What dimensions need to be considered in macro site construction?" to supplement the knowledge unit with multi-dimensional semantics.

[0072] 2) Multi-vector vectorization processing: The SentenceTransformer model encapsulated by TextVectorizer is used to vectorize the original text block and the generated exploratory questions respectively, to obtain the first text vector (the semantics of the text block itself) and the first question vector (the semantics of multiple exploratory questions), thus realizing the multi-dimensional semantic representation of a single text block.

[0073] 3) Parallelized Data Insertion: A two-tiered parallel strategy is employed, using file-level and paragraph-level parallelism. Multiple documents are processed simultaneously using a thread pool (file-level parallelism), and all paragraphs within each document are processed in parallel (parallel-level parallelism). Structured records containing "first text vector, first question vector, and metadata (tags, source path, timestamp)" are inserted into the Milvus vector database in batches. Simultaneously, the system is equipped with sophisticated error handling and logging mechanisms to ensure data consistency and process robustness; failure to process a single paragraph does not affect the overall process.

[0074] Through the above process, each knowledge unit stored in the preset database has a text block and a multi-vector representation of multiple exploratory questions, providing a semantically rich and structurally standardized retrieval foundation for the multi-way hybrid retrieval in step 203, thereby ensuring the accuracy and comprehensiveness of the retrieved data.

[0075] Furthermore, for ease of understanding, such as Figure 4 As shown, this application provides a specific schematic diagram of constructing a preset database. (Refer to...) Figure 4First, starting with standardized text blocks, which are knowledge units with complete semantics and metadata after being processed in the "document parsing and intelligent segmentation" stage, the system proceeds to the LLM semantic enhancement stage: the system calls a preset language model (LLM) and, based on carefully designed prompt word templates, generates three exploratory questions for each standardized text block (e.g., for the text block "5G site construction," generating specific questions about capacity methods, construction dimensions, and digital indoor distribution). These questions explore the text's connotation from different angles, forming a multi-dimensional content set together with the original text, breaking through the limitations of "single text semantics" and laying the foundation for subsequent multi-vector retrieval. Then, text vectorization is performed: a unified sentence vector model (such as `SentenceTransformer`) is used to semantically encode both the "original text block" and the "three generated exploratory questions," generating two types of core vectors: content vectors (representing the core semantics of the original text) and question vectors (representing the semantics of the exploratory questions), achieving a multi-dimensional semantic representation of a single text block. Afterwards, the system organizes the "content vector, question vector and corresponding metadata (such as source path, tags, processing timestamp)" into structured records and enters the batch collection and insertion stage: through a two-level parallel strategy at the file level and paragraph level, the structured records are inserted into the Milvus vector database in batches and efficiently, and finally the construction of the preset database is completed, providing a semantically rich and structurally standardized knowledge carrier for the accurate acquisition of subsequent retrieval and query data.

[0076] Step 204: Merge the retrieved query data and the real-time query data to obtain merged query data.

[0077] In this application embodiment, the application can organically integrate retrieval query data (static knowledge from a preset database) and real-time query data (dynamic data from tool calls) through standardized processing and flexible fusion strategies to form logically coherent and informationally complete fused query data, providing a unified high-quality context for subsequent generation of accurate answers.

[0078] First, the system standardizes the real-time query data. Because the results returned by the tool are in various formats (such as JSON, text, and tables), direct merging would lead to semantic fragmentation or prevent LLM from recognizing them. Therefore, structured parsing is necessary to extract key information. For example, core data is extracted from tables, key fields are broken down from JSON, and core conclusions are extracted from text. Ultimately, all real-time data is uniformly transformed into a natural language context format that LLM can understand, ensuring semantic compatibility with the retrieved query data.

[0079] Subsequently, the system selects the appropriate fusion method based on the type of query requirement: For time-sensitive or operational needs (such as "current alarm status of a certain base station" or "querying user A's real-time data usage"), a "tool-first" mode is adopted. Real-time query data serves as the primary context, with retrieved query data used as supplementary information to provide background knowledge, explanations of principles, or historical references (such as the meaning of alarm codes or interpretations of data plan rules), ensuring that the answer is both relevant to the real-time situation and complete. For analytical needs requiring background knowledge (such as "analyzing the cause of abnormalities in user A's package" or "troubleshooting a device malfunction"), a "knowledge-first" approach is adopted. First, based on the retrieved data, relevant domain knowledge, historical cases, or parameter standards (such as package definitions or troubleshooting procedures) are extracted. These are then used as parameters or contextual inputs for tool calls, ensuring more targeted tool execution and avoiding analytical biases caused by a lack of background information.

[0080] Furthermore, the system supports the dynamic integration of multi-round interactions and toolchain combinations. For complex queries (such as "first query network congestion data for a certain area over the past 3 days, then analyze optimization solutions"), RAG retrieval and tool invocation can be executed alternately. That is, real-time congestion data is first obtained through tools, then relevant optimization knowledge is retrieved. If further detailed analysis is required, tools can be invoked again to query specific base station parameters, dynamically adjusting the integration order and data weights to achieve automated closed-loop management of complex business processes.

[0081] The entire fusion process is deeply integrated with the entire system workflow: from the moment a user submits a query, through intent recognition, tool planning, tool execution, and result standardization, to the final fusion with the retrieved query data to build a Prompt, the entire process is streamed to the user via the Server-Sent Events (SSE) protocol. At the same time, all data processing, tool calls, and fusion logic are recorded in detailed logs to facilitate subsequent traceability and optimization, ensuring the accuracy, compatibility, and traceability of the fused query data.

[0082] Step 205: Integrate the fused query data and query question according to the prompt word template to obtain the answer prompt words.

[0083] In the embodiments of this application, this application can organically integrate fusion query data (static retrieval knowledge and dynamic real-time data) with the user's original query question through standardized prompt word templates, forming logically clear and well-defined answer generation prompt words, providing accurate guidance for LLM to generate high-quality answers.

[0084] This prompt template is meticulously designed with multiple guiding principles: First, answers must be strictly based on contextual information from the integrated query data, and fabricated content is prohibited. Second, answers must be accurate, complete, and logically coherent, ensuring no core information is omitted and all information is logically consistent. Third, reliability and traceability are emphasized; key conclusions must be supported by corresponding evidence in the integrated query data, guaranteeing the credibility of the answers. During integration, the system automatically fills in fields such as the user's original query, the core content of the integrated query data, and generation requirements according to the template format, forming structured and semantically clear prompts to ensure that the LLM accurately understands the task objectives and constraints.

[0085] Step 206: Generate prompt words based on the answer to generate the query answer.

[0086] In the embodiments of this application, this application can output accurate, real-time and exploratory query answers to users through generative large language models (LLM) and streaming response mechanisms.

[0087] First, the system inputs the answer generation prompts generated in step 205 into the LLM model. Based on the contextual information in the fused query data, the model performs logical organization and language polishing to generate detailed and reliable answers. The entire generation process adopts a streaming mechanism, implemented through a multi-process service architecture defined in flask / rag_flask_service.py: after receiving a query request, the service creates an independent child process to execute the time-consuming generation task. The parent and child processes communicate through a message queue. During the generation process, the child process continuously encapsulates intermediate states (such as "generating the final reply...") and partial results into structured data packets and sends them to the queue. The main process reads these packets in real time and pushes them to the client via the Server-Sent Events (SSE) protocol. Users do not need to wait for the entire process to complete; they can gradually see the answer being generated, significantly optimizing the interactive experience.

[0088] Meanwhile, the system incorporates a sophisticated timeout control and resource management mechanism: by storing timeout timers for each task in a shared dictionary across multiple processes, if a child process fails to update data within the specified time, the main process will proactively terminate the process, release resources, and return a timeout error to the client, ensuring system robustness. Furthermore, while generating the main answer, the system will also use the user's query and the complete answer as context to generate multiple related follow-up questions and recommend them to the user, forming a guided dialogue loop and improving system usability and user engagement. The entire process supports full-process streaming output, allowing users to track the complete progress of system thinking, tool calls, data acquisition, and answer generation in real time, ensuring an efficient and transparent interactive experience.

[0089] Step 207: Push the query answer to the user.

[0090] In the embodiments of this application, the application can push query answers in real time and achieve continuous self-optimization of the system through a closed-loop process driven by user feedback, which not only ensures the user experience of the current interaction, but also lays the foundation for long-term performance improvement.

[0091] First, the system pushes the query answer generated in step 206 to the user via a streaming push mechanism. Based on the multi-process streaming service architecture defined in flask / rag_flask_service.py, and employing the Server-Sent Events (SSE) protocol, the system provides real-time feedback to the user on the complete answer generation process. From intermediate states such as "Searching" and "Tool invocation" to the gradually generated answer fragments, users can obtain key information without waiting for the entire process to complete, significantly improving the real-time nature and transparency of the interaction.

[0092] After the answer is pushed out, the system initiates a closed-loop optimization process: Users can submit multi-dimensional feedback data through the front-end interface via the feedback API. Feedback types include likes (GOOD, indicating satisfaction), dislikes (BAD, requiring tags such as "incorrect answer," "inaccurate," "unanswered," etc., and a detailed description), and cancellations (CANCEL, retracting previous feedback). The system will accurately classify and structure the feedback data. Simultaneously, the system fully records all information for each dialogue, including the user's original query, the system-generated answer, feedback type, tags, description, and timestamp, accumulating rich data for model optimization.

[0093] Subsequently, the system enters the training corpus selection and optimization phase: through an intelligent selection mechanism, high-quality dialogue samples are automatically identified. This includes both positive samples from user likes and optimized samples from dislikes that have been manually edited (e.g., correcting errors and improving content logic), formatting them into standard training corpora for user questions, system responses, and context. When fine-tuning the preset language model based on this corpus, the system assigns higher weights to high-quality samples to ensure that the optimization direction aligns with real user needs.

[0094] After fine-tuning, the performance statistics and analysis module compares the model performance before and after the fine-tuning from multiple dimensions, including success rate, average response time, user satisfaction, and feedback quality. If performance is significantly improved, the system automatically deploys the new model; if performance degrades, a version rollback is triggered to ensure system stability. In addition, the system supports real-time statistical analysis and automated monitoring and alerts, regularly compiling key metrics such as total requests, success rate, and feedback distribution. When metrics are abnormal, alerts are pushed out promptly to help the development team quickly locate bottlenecks and optimize performance.

[0095] This application achieves a complete closed loop of answer push, feedback collection, corpus optimization, model fine-tuning, and performance verification. The system realizes continuous evolution through use, feedback, and iteration, allowing the model's capabilities to continuously improve with user interaction and optimize the accuracy of question answering and user experience in the long term.

[0096] In summary, the question-answering method proposed in this application not only completes the entire information processing loop from receiving queries to outputting answers, but also takes into account both answer quality and user experience, laying the foundation for subsequent optimization. The process first retrieves and reorders relevant document fragments, then integrates high-quality fused query data with the user's original query according to a standardized template to create prompts. LLM is used to generate evidence-based answers, and a multi-process architecture and SSE protocol enable streaming output, allowing users to know the processing progress in real time and view the answers step by step without waiting. When generating the main answer, related follow-up exploration questions are also generated simultaneously, and the final answer push triggers user feedback collection, providing initial data support for subsequent model fine-tuning. This ensures the accuracy and traceability of the answers while significantly improving the user experience.

[0097] based on Figures 1 to 2 The illustrated embodiments, such as Figure 5 As shown, this application provides a schematic diagram of a specific question-and-answer system.

[0098] Reference Figure 5 This system, through the collaboration of six major functional modules, constructs a complete intelligent question-answering closed loop, encompassing document processing, intelligent retrieval, real-time interaction, and continuous optimization. First, the automated document processing and vectorization module enables intelligent parsing, segmentation, semantic enhancement, and multi-vector input of documents in various formats, laying a semantically rich knowledge foundation for retrieval. Second, the intelligent execution module, which integrates RAG and tool invocation, can dynamically identify user intent and invoke tools, seamlessly integrating real-time data with knowledge retrieval and improving the responsiveness to complex dynamic tasks. Third, the multi-stage hybrid information retrieval and relevance re-ranking method ensures that retrieval results highly match user intent through query normalization, multi-path parallel recall, and dual-mode deep re-ranking. Simultaneously, the high-concurrency streaming response and multi-process service architecture adopts asynchronous multi-process task execution, message queue communication, and SSE streaming response to achieve real-time interaction and efficient resource utilization. Furthermore, the closed-loop automated evaluation and performance analysis framework provides quantitative evidence for system optimization through automated evaluation, semantic similarity quantification, and structured reports. Finally, the intelligent evolution and large-scale model fine-tuning optimization system based on user feedback collects multi-dimensional user feedback, filters high-quality dialogue samples, and fine-tunes the large-scale model, forming a continuous self-optimization closed loop. Through the organic combination of these functions, this system significantly improves the accuracy, real-time performance, usability, and continuous evolution capability of intelligent question answering, providing efficient and accurate knowledge question answering services for various fields.

[0099] Specifically, the complete end-to-end processing flow of the above system can be described as follows: Figure 6 As shown, Figure 6 This diagram illustrates a specific question-answering method provided in this application. The process begins with the input of the original document and continues until the final answer and related question recommendations are presented to the user, forming a complete, closed-loop intelligent question-answering lifecycle. The entire process is meticulously designed into multiple interconnected and interdependent stages, each employing unique technical methods to ensure the quality and efficiency of the final output.

[0100] The first stage is the knowledge base construction phase. Starting with the input of original documents, the system performs intelligent segmentation and preprocessing on documents of various formats (DOCX, XLSX, PDF, TXT, etc.), breaking them down into semantically complete text blocks based on natural semantic boundaries and length thresholds. Then, LLM is called to perform semantic enhancement, generating three exploratory questions for each text block, realizing multi-dimensional semantic expansion of a single text block. Next, a unified sentence vector model is used to vectorize the content and questions of the original text blocks, respectively. Finally, the vectors and metadata are batch-inserted into the Milvus vector database to complete the construction of the vector knowledge base, laying a semantically rich knowledge foundation for subsequent retrieval.

[0101] After entering the user interaction phase, the user submits a query. The system first uses the query intent understanding and transcription module to standardize the colloquial query using LLM and domain prompt word templates, and identifies whether there is a need to call a tool. If it is determined that a tool needs to be called, the system enters the tool selection and invocation process. The system dynamically matches and adapts the tool (such as API, microservice) through the tool registry, automatically extracts parameters and executes the call, and then standardizes and parses the returned tool results, converting them into a format that can be understood by LLM and injecting them into the RAG process. If no tool call is needed, the system directly enters the multi-path hybrid retrieval stage, where the transcribed query vector is retrieved in parallel with the "content vector" and "question vector" in the vector database. After merging and deduplication, the most relevant retrieval query data is selected through deep re-sorting (LLM intelligent re-sorting or local model re-sorting). Then, the retrieval data and tool results (if any) are integrated, input into LLM to generate answers, and related question recommendations are generated. Finally, the system uses the Server-Sent Events protocol to achieve streaming answer output, allowing users to perceive the processing progress in real time.

[0102] The final stage of the process is the closed-loop optimization phase. The system fully records historical dialogues and user feedback (likes / dislikes, tag descriptions, etc.); high-quality dialogue samples are selected through the intelligent evolution module, and after manual editing and optimization, standard training corpus is generated; the large model is fine-tuned and trained based on this corpus, and after training, performance is verified through automated evaluation (indicators such as semantic similarity and user satisfaction); if the performance is improved, the new model is automatically deployed; otherwise, it is rolled back to the original version, thereby achieving continuous self-evolution of the system.

[0103] The above process, through a full-link design that includes multi-vector enhancement of the knowledge base, accurate recognition of user intent, deep integration of tools and RAG, streaming interactive experience, and user feedback-driven optimization, not only ensures the accuracy and real-time performance of question answering, but also endows the system with the ability to iterate over a long period of time, thus comprehensively improving the adaptability of intelligent question answering in professional scenarios and the user experience.

[0104] It is understandable that the specific implementation process of each stage in the above process can be referred to Figures 1 to 4 The embodiments shown will not be described in detail here.

[0105] To implement the above embodiments, this application also provides a question-and-answer device. Figure 7 This is a schematic diagram of the structure of a question-and-answer device 700 provided in an embodiment of this application. Figure 4 As shown, the device includes: The recognition unit 710 is used to recognize the query requirements corresponding to the user's input query question based on a preset language model; The first determining unit 720 is used to determine the real-time query data associated with the query question based on the query tool corresponding to the tool call requirement when there is a tool call requirement in the query request. The second determining unit 730 is used to determine the query answer corresponding to the query question based on real-time query data and retrieval query data, and push the query answer to the user. The retrieval query data is query data related to the query question retrieved from a preset database.

[0106] In some embodiments, the second determining unit 730 is configured to: determine retrieval query data associated with the query question in a preset database; merge the retrieval query data and real-time query data to obtain fused query data; integrate the fused query data and the query question according to the prompt word template to obtain answer generation prompt words; and generate a query answer based on the answer generation prompt words.

[0107] In some embodiments, the identification unit 710 is configured to: perform normalization processing on the query question based on a preset language model to obtain a normalized query question; and perform semantic analysis on the normalized query question to determine the query requirements corresponding to the query question.

[0108] In some embodiments, the second determining unit 730 is configured to: determine the query question vector corresponding to the query question; perform similarity analysis between the query question vector and the first text block vector and the first question vector in a preset database to obtain the text block similarity between the query question vector and the first text block vector and the question similarity between the query question vector and the first question vector; determine candidate query data based on the text block similarity, question similarity, and the frequency of occurrence of the first text block; and perform deep re-sorting processing on the candidate query data to determine the retrieval query data in the candidate query data.

[0109] In some embodiments, the second determining unit 730 is configured to: before determining the query answer corresponding to the query question based on real-time query data and retrieval query data, parse the file to be processed based on the file parser corresponding to the file to be processed to obtain the text to be processed, wherein the file parser is determined based on the file extension of the file to be processed; divide the text to be processed based on the text structure of the text to be processed to obtain at least one text block; perform language enhancement on the first text block in the at least one text block based on a preset language model to obtain the first text question corresponding to the first text block, wherein the first text block is any text block in the at least one text block; perform vectorization processing on the first text block and the first text question to obtain the first text vector of the first text block and the first question vector of the first text question; generate first structured data based on the first text vector, the first question vector and the first metadata corresponding to the first text block, and store the first structured data in a preset database.

[0110] In some embodiments, the second determining unit 730 is configured to: divide the text to be processed based on the text structure of the text to be processed to obtain at least one text block, and then, based on the text size of the at least one text block, perform context merging processing on the mergeable text blocks in the at least one text block that satisfy the merging constraints to obtain at least one text block after merging processing.

[0111] In some embodiments, the apparatus further includes a recommendation unit, configured to: upon receiving a query question input by a user, sequentially determine answer generation data for generating the query answer according to the generation stage of the query answer, the answer generation data including the generation status and generation result of generating the query answer; and push the answer generation data to the user.

[0112] In some embodiments, the apparatus further includes: an optimization unit, which, after the user pushes the query answer to the user, obtains the user's feedback data on the query answer; adjusts the user's query question and query answer based on the feedback data to obtain fine-tuned training samples; and adjusts the model parameters of a preset language model based on the fine-tuned training samples to obtain an adjusted target language model, so as to use the target language model to identify the updated query question input by the user.

[0113] The methods and apparatus provided in the embodiments of this application have been described above. To implement the functions of the methods provided in the embodiments of this application, the electronic device may include a hardware structure and software modules, and may implement the above functions in the form of a hardware structure, software modules, or a hardware structure plus software modules. One of the above functions may be executed in the form of a hardware structure, software modules, or a hardware structure plus software modules.

[0114] Figure 8 This is a block diagram illustrating an electronic device 800 for implementing the above-described question-answering method, according to an exemplary embodiment. For example, the electronic device 800 may be a mobile phone, computer, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.

[0115] Reference Figure 8 The electronic device 800 may include a communication interface 801, capable of interacting with other devices; a processor 802, connected to the communication interface 801 to enable interaction with other devices, used to execute the methods provided by one or more of the above-described technical solutions when running a computer program; and a memory 803, on which the computer program is stored. Specifically, the specific processing procedure of the processor 802 can refer to the question-and-answer method described in the above embodiments of this disclosure.

[0116] Of course, in practical applications, the various components in electronic device 800 are coupled together through bus system 804. It can be understood that bus system 804 is used to realize the connection and communication between these components. In addition to a data bus, bus system 804 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 8 The general labeled all buses as Bus System 804.

[0117] The memory 803 in this embodiment is used to store various types of data to support the operation of the electronic device 800. Examples of such data include any computer program used to operate on the electronic device 800.

[0118] The methods disclosed in the embodiments of this application can be applied to processor 802, or implemented by processor 802. Processor 802 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 802 or by instructions in the form of software. The processor 802 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 802 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in memory 803. Processor 802 reads the information in memory 803 and combines its hardware to complete the steps of the aforementioned method.

[0119] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0120] Embodiments of this disclosure also propose a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to execute the question-and-answer method described in the above embodiments of this disclosure.

[0121] Embodiments of this disclosure also provide a computer program product, including a computer program that is executed by a processor using the question-and-answer method described in the above embodiments of this disclosure.

[0122] Embodiments of this disclosure also propose a chip including one or more interface circuits and one or more processors; the interface circuits are used to receive signals from the memory of an electronic device and send signals to the processors, the signals including computer instructions stored in the memory, which, when executed by the processor, cause the electronic device to perform the question-and-answer method described in the above embodiments of this disclosure.

[0123] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0124] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0125] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0126] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (control method), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.

[0127] It should be understood that various parts of the embodiments of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0128] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.

[0129] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc.

[0130] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A question-and-answer method, characterized in that, The method includes: Based on a pre-defined language model, the system identifies the query requirements corresponding to the user's input query question. If the query request includes a tool call request, then based on the query tool corresponding to the tool call request, determine the real-time query data associated with the query question; Based on the real-time query data and the retrieved query data, the query answer corresponding to the query question is determined, and the query answer is pushed to the user. The retrieved query data is query data related to the query question retrieved from a preset database.

2. The method according to claim 1, characterized in that, The process of determining the query answer corresponding to the query question based on the real-time query data and the retrieved query data includes: Determine the retrieval query data in the preset database that is associated with the query question; The retrieved query data and the real-time query data are merged to obtain merged query data; The fused query data and the query question are integrated according to the prompt word template to obtain the answer prompt words; Based on the answer, prompt words are generated, and the query answer is generated.

3. The method according to claim 1, characterized in that, The query requirements, which are based on a preset language model and identify the query questions input by the user, include: Based on the preset language model, the query problem is standardized to obtain a standardized query problem; Semantic analysis is performed on the standardized query problem to determine the query requirements corresponding to the query problem.

4. The method according to claim 2, characterized in that, The step of determining the retrieval query data associated with the query question in the preset database includes: Determine the query question vector corresponding to the query question; The query question vector is compared with the first text block vector and the first question vector in the preset database to obtain the text block similarity between the query question vector and the first text block vector and the question similarity between the query question vector and the first question vector. Candidate query data are determined based on the text block similarity, the question similarity, and the frequency of occurrence of the first text block; The candidate query data is subjected to deep re-sorting to determine the retrieval query data in the candidate query data.

5. The method according to claim 1, characterized in that, Before determining the query answer corresponding to the query question based on the real-time query data and the retrieved query data, the method includes: Based on the file parser corresponding to the file to be processed, the file to be processed is parsed to obtain the text to be processed. The file parser is determined based on the file extension of the file to be processed. Based on the text structure of the text to be processed, the text to be processed is divided to obtain at least one text block; Based on the preset language model, language enhancement is performed on the first text block in the at least one text block to obtain the first text question corresponding to the first text block, wherein the first text block is any text block in the at least one text block; The first text block and the first text question are vectorized to obtain the first text vector of the first text block and the first question vector of the first text question. Based on the first text vector, the first question vector, and the first metadata corresponding to the first text block, first structured data is generated and stored in a preset database.

6. The method according to claim 5, characterized in that, After dividing the text to be processed based on its text structure to obtain at least one text block, the method includes: Based on the text size of the at least one text block, context merging processing is performed on mergeable text blocks that satisfy the merging constraints in the at least one text block to obtain at least one merged text block.

7. The method according to claim 1, characterized in that, The method further includes: Upon receiving the query question input by the user, the answer generation data for generating the query answer is determined sequentially according to the stages of query answer generation. The answer generation data includes the generation status and generation result of generating the query answer. The generated answer data is pushed to the user.

8. The method according to claim 1, characterized in that, After the query answer is pushed to the user, the method includes: Obtain the user's feedback data on the query answer; Based on the feedback data, the user's query questions and answers are adjusted to obtain a fine-tuned training sample; The model parameters of the preset language model are adjusted based on the fine-tuned training samples to obtain the adjusted target language model, which is then used to identify the update query question input by the user.

9. A question-and-answer device, characterized in that, The device includes: The recognition unit is used to identify the query requirements corresponding to the user's input query question based on a preset language model. The first determining unit is used to determine real-time query data associated with the query question based on the query tool corresponding to the tool call requirement when there is a tool call requirement in the query request. The second determining unit is used to determine the query answer corresponding to the query question based on the real-time query data and the retrieved query data, and push the query answer to the user. The retrieved query data is query data related to the query question retrieved from a preset database.

10. An electronic device, characterized in that, include: The processor and the memory used to store computer programs that can run on the processor. When the processor is used to run the computer program, it performs the method according to any one of claims 1 to 8.