Question and answer method and device, related equipment and computer program product

Through the integration of two-stage fine-tuning training and structured knowledge base, the problem of insufficient performance of large models in specific domain question-and-answer applications is solved, and the effective utilization and performance improvement of large models for specific domain knowledge is achieved.

CN119227813AActive Publication Date: 2024-12-31ASIAINFO TECH CHINA INC

Patent Information

Application Number
CN202411719722.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2024-12-31
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

Existing large models have performance limitations in domain-specific Q&A applications. Some methods fail to make full use of original knowledge documents, resulting in the impact of the quality and relevance of search information, while others only use supervised fine-tuning and ignore search augmented generation (RAG). ) Injected knowledge leads to a split between model fine-tuning and prediction, and it is impossible to effectively utilize injected knowledge.

Method used

Using a two-stage fine-tuning training method, first use training data from a specific field to perform initial fine-tuning of the big model, and then the knowledge fragments retrieved in the structured knowledge base are further fine-tuned to the model as new training data, integrating user query and target knowledge. The fragments form prompts the input data and inputs to the pre-trained big model to generate the answer.

Benefits of technology

By deeply integrating large-scale fine-tuning technology and RAG technology, the model significantly improves performance in the application of Q&A in specific fields, solves the problem of separation between fine-tuning and prediction, and can effectively utilize structured knowledge fragments to improve the ability to deal with problems in specific fields. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119227813A_ABST
    Figure CN119227813A_ABST
Patent Text Reader

Abstract

The invention discloses a question and answer method and device, related equipment and a computer program product, and relates to the field of artificial intelligence. Target knowledge fragments related to user query are retrieved by utilizing a structured knowledge base containing knowledge fragments in a specific field, and then the user query and the target knowledge fragments are integrated to form prompt input data; prompt input data are input into a large model obtained through two stages of fine tuning training, in the first stage, fine tuning training is carried out through training data of a specific field, the instruction compliance of the model and the understanding ability of the model to the specific field are improved, in the second stage, RAG technology fine tuning training is fused, and the large model can utilize retrieved knowledge fragments, and the understanding ability of the model to the specific field is improved. And the capability of processing problems in a specific field is improved. According to the model training strategy, the model learns how to utilize the knowledge fragments, so that the knowledge fragments in the specific field can be effectively utilized in the prediction stage, and the performance of a large model in question and answer application in the specific field is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and more specifically, to a question-answering method, apparatus, related equipment, and computer program product. Background Art

[0002] Based on a huge neural network architecture, the large model has powerful language understanding and generation capabilities and performs well in many natural language processing tasks. However, when processing knowledge in a specific field, the large model has the problem of "hallucination", that is, it may generate content that is inconsistent with the facts. To solve this problem, the retrieval-augmented generation (RAG) technology came into being. It supplements the knowledge of the large model by retrieving external knowledge bases to improve its accuracy. In addition, the large model fine-tuning technology can also be used to adapt the pre-trained large model to downstream tasks.

[0003] However, existing large models still have some limitations in question-answering applications in specific fields. Some methods rely only on RAG technology and fail to make full use of the original knowledge documents, which affects the quality and relevance of the retrieved information; other methods only use large models for supervised fine-tuning, but ignore the knowledge injected by RAG, resulting in the large model not learning how to use the injected knowledge in the fine-tuning stage, but relying on the injected knowledge in the prediction stage. This inconsistency makes it impossible for the model to effectively use the retrieved injected knowledge when predicting, which leads to a split between model fine-tuning and model prediction. Neither of these two methods can fully improve the performance of large models in question-answering applications in specific fields. Summary of the invention

[0004] In view of the above problems, this application is proposed to provide a question-answering method, apparatus, related equipment and computer program product to improve the performance of large models in question-answering applications in specific fields. The specific solution is as follows: In a first aspect, a question-answering method is provided, comprising: Get user query; Retrieving target knowledge fragments related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field; Integrating the target knowledge fragment with the user query to form prompt input data; Inputting the prompt input data into a pre-trained large model to obtain an answer output by the large model that matches the user query; Among them, the pre-trained big model is obtained through two-stage fine-tuning training: in the first stage, the initial big model is fine-tuned using training data in a specific field to obtain a big model after one-stage training, and the training data includes user query samples and matching answer labels; in the second stage, on the basis of the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the big model after the one-stage training to obtain a big model after the two-stage training.

[0005] Preferably, the process of constructing the structured knowledge base includes: Parsing the text content in the original knowledge document of a specific field into a structured document tree, wherein the leaf nodes in the structured document tree represent knowledge fragments, and each node on the path from the root node to the parent node of each leaf node represents the structural information of the knowledge fragment corresponding to the leaf node in the original knowledge document; The knowledge fragments corresponding to each leaf node and their structural information are combined, and the combined text is converted into a vector, and the knowledge fragments corresponding to each leaf node and the converted vectors are correspondingly stored in the structured knowledge base.

[0006] Preferably, the process of constructing the structured knowledge base further includes: Converting the tables in the original knowledge document into target formats that can be processed by the large model; Use the pre-trained large model to summarize the table in the target format to obtain summary information; The summary information is converted into a vector, and the summary information is stored in the structured knowledge base as a knowledge fragment corresponding to the converted vector.

[0007] Preferably, the process of constructing the structured knowledge base further includes: The structural information corresponding to the knowledge fragments is correspondingly stored in the structured knowledge base.

[0008] Preferably, the structured knowledge base includes: a correspondence between knowledge fragments and vectors; Accordingly, the method of using a preset structured knowledge base to retrieve a target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, a target knowledge segment related to the user query vector is retrieved from the structured knowledge base.

[0009] Preferably, the structured knowledge base includes: a correspondence between knowledge fragments and vectors; Accordingly, the method of using a preset structured knowledge base to retrieve a target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, retrieving candidate knowledge fragments related to the user query vector from the structured knowledge base; Using the pre-trained relevance determination model, the relevance of each candidate knowledge fragment to the user query is determined respectively, and the top N candidate knowledge fragments with the highest relevance are selected as target knowledge fragments, wherein the relevance determination model is trained using knowledge fragment samples and user query samples labeled with relevance scores.

[0010] Preferably, the structured knowledge base includes: structural information of knowledge fragments in original knowledge documents; Then, after using the preset structured knowledge base to retrieve the target knowledge fragment related to the user query, the method further includes: For the retrieved target knowledge fragments related to the user query, the target knowledge fragments are reconstructed using the structural information of the target knowledge fragments in the original knowledge document to obtain the reconstructed target knowledge fragments.

[0011] Preferably, the structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; Then, the process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: If there are two leaf nodes corresponding to two target knowledge fragments that belong to the same parent node and are continuous in the original knowledge document, then remove the repeated characters in the two target knowledge fragments, and splice the two target knowledge fragments according to the original text order in the original knowledge document to obtain the reconstructed target knowledge fragment.

[0012] Preferably, the structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; Then, the process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: If there are at least two leaf nodes corresponding to the target knowledge fragments that share a common parent node, and the knowledge fragments corresponding to the leaf nodes under the parent node exceeding a preset proportion are included in the recalled target knowledge fragments, then all the knowledge fragments corresponding to the leaf nodes under the parent node will be recalled and merged into a reconstructed target knowledge fragment.

[0013] Preferably, the structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; The process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: For each target knowledge fragment among the recalled target knowledge fragments: Determine whether the number of knowledge fragments corresponding to all leaf nodes under the parent node to which the leaf node corresponding to the target knowledge fragment belongs contained in the recalled target knowledge fragments exceeds a preset ratio; if not, further determine whether the relevance of the target knowledge fragment to the user query is lower than a preset threshold; if so, delete the target knowledge fragment.

[0014] Preferably, the specific field is the communication field.

[0015] In a second aspect, a question-answering device is provided, comprising: A user query acquisition unit, used to acquire user queries; A target knowledge fragment retrieval unit, used to retrieve a target knowledge fragment related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field; a prompt input data generating unit, used for integrating the target knowledge fragment and the user query to form prompt input data; A question-answering unit, used for inputting the prompt input data into a pre-trained large model to obtain an answer output by the large model that matches the user query; Among them, the pre-trained big model is obtained through two-stage fine-tuning training: in the first stage, the initial big model is fine-tuned using training data in a specific field to obtain a big model after one-stage training, and the training data includes user query samples and matching answer labels; in the second stage, on the basis of the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the big model after the one-stage training to obtain a big model after the two-stage training.

[0016] In a third aspect, an electronic device is provided, comprising: a memory and a processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the question-answering method described in any one of the first aspects of the present application.

[0017] In a fourth aspect, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the various steps of the question-and-answer method described in any one of the first aspects of the present application are implemented.

[0018] In a fifth aspect, a computer program product is provided, which is tangibly stored in a non-volatile computer storage medium and includes machine executable instructions, which, when executed by a device, can implement the various steps of the question-and-answer method described in any one of the aforementioned first aspects of the present application.

[0019] By means of the above technical scheme, the present application uses a structured knowledge base containing knowledge fragments in a specific field to retrieve target knowledge fragments related to user queries, and then integrates the user queries and the target knowledge fragments to form prompt input data. Finally, the prompt input data is input into the large model obtained after two-stage fine-tuning training. The first stage of fine-tuning training of the large model uses training data in a specific field to improve the initial large model's ability to understand information in a specific field and the model's obedience to instructions. The second stage of fine-tuning training of the large model integrates RAG technology and structured knowledge base, so that the large model can effectively use the retrieved knowledge fragments and improve its ability to handle problems in specific fields. This method realizes the deep integration of large model fine-tuning technology and RAG technology, and enables the model to learn how to use the injected knowledge fragments in the model fine-tuning stage, so that the injected knowledge fragments can be effectively used in the prediction stage, solving the problem of separation between model fine-tuning and prediction in the prior art, and significantly improving the performance of large models in question-and-answer applications in specific fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings: Figure 1 A schematic diagram of an implementation system architecture of the question-answering method provided in an embodiment of the present application; Figure 2 A schematic diagram of a terminal structure provided in an embodiment of the present application; Figure 3 A schematic diagram of a server structure provided in an embodiment of the present application; Figure 4 A schematic diagram of a process flow of a question-and-answer method provided in an embodiment of the present application; Figure 5 A schematic diagram of a structured document tree is illustrated; Figure 6 An example of a question-answering system architecture diagram is shown; Figure 7 A schematic diagram of the structure of a question-and-answer device provided in an embodiment of the present application; Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] Before introducing this application, the English terms involved in this article are explained first: prompt: Instructions. When interacting with AI (such as an artificial intelligence model), you need to send instructions to AI. It can be a text description, such as "Please recommend me a pop song" when you interact with AI, or it can be a parameter description in a certain format. For example, if you want AI to draw in a certain format, you need to describe the relevant drawing parameters.

[0022] Large models: In the field of artificial intelligence, large models usually refer to large-scale pre-trained models. Such models are called "large" because they can be pre-trained on a large amount of data and can be transferred to a variety of downstream tasks. Their full English name is Large Pre-Trained Models or Large-Scale Pre-Training Models. Large models are characterized by their large scale and contain billions or even more parameters, which help them learn complex patterns in the data. The emerging capabilities of large models include but are not limited to: contextual learning, instruction following, code generation, step-by-step reasoning capabilities, etc. Large models can include large language models (LLMs) and multimodal large models. Large language models are mainly used to process text modal data. Multimodal large models further integrate multimodal capabilities on the basis of large language models and can process information in multiple modalities, such as images, text, audio, etc.

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

[0024] This application provides a question-answering method that can be applied to Figure 1 The system architecture shown in FIG. 1 may include a terminal 100 and a server 200. The server 200 may include one or more servers ( Figure 1 A server is included as an example for explanation).

[0025] The terminal 100 or the server 200 can be used alone to execute the question-answering method provided in the embodiment of the present application. In addition, the terminal 100 and the server 200 can also be used in collaboration to execute the question-answering method provided in the embodiment of the present application.

[0026] Next describe Figure 1 The product form of the mid-terminal 100; The terminal 100 in the embodiment of the present application can be a mobile phone, a tablet computer, a teaching screen, a wearable device, a vehicle-mounted device, a conference terminal, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc., and the embodiment of the present application does not impose any restrictions on this.

[0027] Figure 2 An optional hardware structure diagram of the terminal 100 is shown.

[0028] refer to Figure 2 As shown, the terminal 100 may include a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera 150 (optional), an audio circuit 160, a speaker 161, a microphone 162, an earphone jack 163 (optional), a processor 170, an external interface 180, a power supply 190 and other components. Those skilled in the art will appreciate that Figure 2 These are merely examples of terminals or multi-function devices and do not constitute limitations on the terminals or multi-function devices, which may include more or fewer components than those shown in the figures, or combinations of certain components, or different components.

[0029] The input unit 130 can be used to receive input digital or character information, and generate key signal input related to the user settings and function control of the portable multifunctional device. Specifically, the input unit 130 may include a touch screen 131 and / or other input devices 132. The touch screen 131 can collect the user's touch operations on or near it (such as the user's operation on or near the touch screen using any suitable object such as fingers, joints, stylus, etc.), and drive the corresponding connection device according to a pre-set program. The touch screen can detect the user's touch action on the touch screen, convert the touch action into a touch signal and send it to the processor 170, and can receive and execute the command sent by the processor 170; the touch signal at least includes the touch point coordinate information. The touch screen 131 can provide an input interface and an output interface between the terminal 100 and the user. In addition, the touch screen can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic wave. In addition to the touch screen 131, the input unit 130 can also include other input devices. Specifically, other input devices 132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.

[0030] Among them, other input devices 132 can receive input data and so on.

[0031] The display unit 140 may be used to display information input by the user or provided to the user, various menus of the terminal 100, interactive interfaces, file display, and / or playback of any multimedia file. In the embodiment of the present application, the display unit 140 may be used to display various interactive interfaces, processing results, etc. in the question-and-answer method.

[0032] The memory 120 can be used to store instructions and data. The memory 120 can mainly include an instruction storage area and a data storage area. The data storage area can store various data, such as multimedia files, texts, etc.; the instruction storage area can store software units such as operating systems, applications, instructions required for at least one function, or their subsets and extensions. It can also include a non-volatile random access memory; provide the processor 170 with hardware, software and data resources including management of computing and processing equipment, and support control software and applications. It is also used for the storage of multimedia files, and the storage of running programs and applications.

[0033] The processor 170 is the control center of the terminal 100. It uses various interfaces and lines to connect various parts of the entire terminal 100. By running or executing instructions stored in the memory 120 and calling data stored in the memory 120, it executes various functions of the terminal 100 and processes data, thereby controlling the terminal device as a whole. Optionally, the processor 170 may include one or more processing units; preferably, the processor 170 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application program, and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips. The processor 170 may also be used to generate corresponding operation control signals, send them to corresponding components of the computing and processing device, read and process data in the software, especially read and process data and programs in the memory 120, so that each functional module therein performs corresponding functions, thereby controlling the corresponding components to act according to the requirements of the instructions.

[0034] Among them, the memory 120 can be used to store software codes related to the question-answering method, the processor 170 can execute the steps of the question-answering method, and can also schedule other units (such as the above-mentioned input unit 130 and display unit 140) to implement corresponding functions.

[0035] The radio frequency unit 110 (optional) can be used for receiving and sending information or receiving and sending signals during a call, for example, after receiving the downlink information of the base station, it is sent to the processor 170 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the radio frequency unit 110 can also communicate with network devices and other devices through wireless communication. The wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.

[0036] In the embodiment of the present application, the RF unit 110 can send data to the server 200 and receive the processing result sent by the server 200. Exemplarily, the RF unit 110 sends the received user query to the server 200, and the server 200 obtains the answer matching the user query and returns the answer matching the user query to the terminal 100.

[0037] It should be understood that the radio frequency unit 110 is optional and can be replaced by other communication interfaces, such as a network port.

[0038] The terminal 100 also includes a power supply 190 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 170 through a power management system, so that the power management system can manage functions such as charging, discharging, and power consumption.

[0039] The terminal 100 further includes an external interface 180 , which may be a standard Micro USB interface or a multi-pin connector, and may be used to connect the terminal 100 to communicate with other devices, or to connect a charger to charge the terminal 100 .

[0040] Although not shown, the terminal 100 may also include a flashlight, a wireless fidelity (WiFi) module, a Bluetooth module, sensors with different functions, etc., which are not described in detail here. Some or all of the methods described below may be applied in the following embodiments. Figure 2 In the terminal 100 shown.

[0041] Next describe Figure 1 The product form of the server 200; Figure 3 A structural diagram of a server 200 is provided, such as Figure 3 As shown, the server 200 includes a bus 201, a processor 202, a communication interface 203, and a memory 204. The processor 202, the memory 204, and the communication interface 203 communicate with each other via the bus 201.

[0042] The bus 201 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0043] The processor 202 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0044] The memory 204 may include a volatile memory, such as a random access memory (RAM). The memory 204 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0045] The memory 204 may be used to store software codes related to the question-answering method, the processor 202 may execute the steps of the question-answering method, and may also schedule other units to implement corresponding functions.

[0046] It should be understood that the above-mentioned terminal 100 and server 200 can be centralized or distributed devices, and the processors in the above-mentioned terminal 100 and server 200 (such as processor 170 and processor 202) can be hardware circuits (such as application specific integrated circuit (ASIC), field-programmable gate array (FPGA), general-purpose processor, digital signal processor (DSP), microprocessor or microcontroller, etc.), or a combination of these hardware circuits. For example, the processor can be a hardware system with an instruction execution function, such as a CPU, DSP, etc., or a hardware system without an instruction execution function, such as an ASIC, FPGA, etc., or a combination of the above-mentioned hardware systems without an instruction execution function and hardware systems with an instruction execution function.

[0047] The present application embodiment provides a question-answering method, taking the method applied to a computer device as an example, wherein the computer device may be Figure 1 The terminal 100 or the system consisting of the terminal 100 and the server 200. Figure 4 , the question-answering method specifically includes the following steps: Step S100: Obtain user query.

[0048] Specifically, the system receives a query posed by a user.

[0049] Optionally, this step can consider the diversity of user input, including spelling errors, ambiguous expressions, etc., and perform necessary preprocessing, such as spell checking, synonym replacement, etc., and can also record the user's historical queries for personalized recommendations and context understanding.

[0050] User queries may be in various forms, such as voice input queries or text queries, etc. User queries in other modes may be uniformly converted into text modes for easier processing below.

[0051] Step S110: Retrieve target knowledge fragments related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field.

[0052] Specifically, the structured knowledge base contains knowledge fragments in a specific field, and the structured knowledge base is used to retrieve knowledge fragments related to user queries. Optionally, knowledge fragments can be obtained by parsing knowledge documents in a specific field. In addition, the structured knowledge base can be set to dynamically update, add or update new knowledge documents or knowledge fragments in a timely manner, and delete some outdated knowledge documents or knowledge fragments. Optionally, incremental learning technology can be considered. The design of the structured knowledge base can also consider supporting multimodal data, and can include version control and metadata management (such as source, author, creation time, etc.) to enhance the credibility and traceability of knowledge documents.

[0053] A specific field refers to a field where the question-answering method is applied or practiced within a specific industry, discipline or subject, which can be the communications field, finance field, education field or medical field, etc.

[0054] Step S120: Integrate the target knowledge fragment and the user query to form prompt input data.

[0055] Specifically, the user query is integrated with the knowledge fragments related to the user query retrieved using the structured knowledge base. Optionally, the process of forming the prompt input data can consider the organization and quantity of the knowledge fragments and the degree of relevance to the user query, and the integration process can try different input templates and strategies, such as thought chain prompting, few-shot prompting, etc., which can guide the model to generate more accurate and comprehensive answers.

[0056] Step S130: input the prompt input data into a pre-trained large model to obtain an answer output by the large model that matches the user query.

[0057] Among them, the pre-trained big model is obtained through two-stage fine-tuning training: in the first stage, the initial big model is fine-tuned using training data in a specific field to obtain a big model after one-stage training, and the training data includes user query samples and matching answer labels; in the second stage, on the basis of the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the big model after the one-stage training to obtain a big model after the two-stage training.

[0058] Specifically, the initial large model used for fine-tuning in the first stage can be a general large model, that is, a pre-trained large model. These general models are usually trained on massive text data and have certain language understanding and generation capabilities, such as the GPT series of large models. Use training data in a specific field to fine-tune the initial large model. The fine-tuning in the first stage can enable the initial large model to better understand domain-specific terms, concepts, language, knowledge or relationships, and can also enable the initial large model to improve instruction obedience. The training data in a specific field contains user query samples and matching answer labels. These data can be carefully collected and labeled to ensure quality and coverage. In addition, in order to minimize the difference between the answer predicted by the large model and the true answer, the large model can be debugged using methods such as the cross entropy loss function.

[0059] In the second stage, the knowledge fragments matching the user query are added to the training data of the first stage. The knowledge fragments can be added to the training data as context information or as additional input features, so that the large model can learn how to use the injected knowledge fragments after fine-tuning training in the second stage.

[0060] In addition, structured knowledge bases and user queries may be constantly changing, and large models can have the ability to continuously learn and update knowledge to adapt to new knowledge and queries.

[0061] The question-answering method provided in this embodiment performs two-stage fine-tuning training on the big model, thereby not only improving the big model's ability to understand specific fields and its obedience to instructions, but also enabling the big model to learn how to use knowledge fragments, and can achieve a deep integration of the big model fine-tuning technology and the RAG technology, and can provide more accurate and comprehensive answers to user queries.

[0062] In some embodiments of the present application, the construction process of the structured knowledge base in the above embodiments is introduced, and the process may include the following steps: Step S200: parse the text content in the original knowledge document of a specific field into a structured document tree, wherein the leaf nodes in the structured document tree represent knowledge fragments, and each node on the path from the root node to the parent node of each leaf node represents the structural information of the knowledge fragment corresponding to the leaf node in the original knowledge document.

[0063] Specifically, the original knowledge documents in a specific field can be, for example, technical documents, research papers, book chapters, etc. These original knowledge documents can also be in various formats, such as plain text, HTML, PDF, etc. Optionally, a suitable parser can be used to parse the original document into a structured document tree. The parser can be selected according to the format and complexity of the document. For example, for HTML documents, an HTML parser can be used; for PDF documents, a PDF parser and OCR technology can be used; for plain text documents, specific parsing rules can be designed according to the structural features of the original knowledge document (such as titles, paragraphs, lists, etc.).

[0064] The path from the root node to the parent node of each leaf node in the structured document tree constitutes the structural information of the leaf node. This path reflects the hierarchical structure of the knowledge fragment in the original document. For example, the structural information of a knowledge fragment may be "book / first chapter / first section / first paragraph".

[0065] Step S210: Combine the knowledge fragments and structural information corresponding to each leaf node, convert the combined text into a vector, and store the knowledge fragments corresponding to each leaf node and the converted vectors in the structured knowledge base accordingly.

[0066] Specifically, the knowledge fragments corresponding to each leaf node and the structural information corresponding to the knowledge fragments can be sequentially spliced ​​to obtain the combined text. A suitable text embedding model can be used to convert the combined text into a vector representation. Commonly used text embedding models include Word2Vec, GloVe, FastText, BERT, Sentence-BERT, etc. The choice of model may depend on the specific application scenario and performance requirements. The design of a structured knowledge base may consider the storage efficiency, retrieval efficiency, and subsequent application scenarios of the data. Various database technologies may be used, such as relational databases, NoSQL databases, graph databases, etc.

[0067] Through the above steps of building a structured knowledge base, the text content in the original knowledge document can be structured and stored efficiently, which improves the efficiency and accuracy of subsequent retrieval of knowledge fragments.

[0068] In some possible implementations, the structural information corresponding to the knowledge fragments may also be correspondingly stored in the structured knowledge base.

[0069] Next, Figure 5 A schematic diagram of a structured document tree is shown below.

[0070] Decompose the document into smaller, semantically related knowledge fragments, and use the title structure of the original knowledge document to establish a hierarchical relationship to facilitate the subsequent retrieval and utilization of knowledge fragments. You can use regular expressions, natural language processing tools, or specialized document parsing libraries to achieve the original knowledge document segmentation, and you can also use technologies such as XPath or CSS selectors to extract titles and their hierarchical relationships.

[0071] Each leaf node is a knowledge fragment, and the corresponding path (the path from the root node to the leaf node) constitutes the structural information of a knowledge fragment. The final document tree can have the document itself as the root node, the title and other information as the intermediate nodes, and the knowledge fragments as leaf nodes.

[0072] The above embodiment introduces the processing of text content in the original knowledge document when constructing a structured knowledge base. In some cases, the original knowledge document may also contain other forms of content besides text content, such as tables, images, etc. On this basis, this embodiment takes a table as an example to introduce how to process the table in the original knowledge document when constructing a structured knowledge base. Specifically, the following steps may be included: Step S300: convert the tables in the original knowledge document into target formats that can be processed by the large model.

[0073] Specifically, the target format may be LaTeX format or the like.

[0074] Step S310: Use the pre-trained large model to summarize the table in the target format to obtain summary information.

[0075] Specifically, the length of the generated summary can be controlled by the model, for example, limiting the number of words or sentences in the summary. The summary information can represent the content expressed by the table in the original knowledge document.

[0076] Step S320: convert the summary information into a vector, and store the summary information as a knowledge fragment in the structured knowledge base corresponding to the converted vector.

[0077] Specifically, in this step, an embedding model may be selected to convert the summary information into a vector, and the embedding model is consistent with the embedding model introduced above. In addition, an efficient indexing strategy may be established when storing in a structured knowledge base to quickly retrieve relevant content.

[0078] Through the above-mentioned steps of constructing the structured knowledge base, the table content in the original knowledge document is also processed into knowledge fragments and stored in the structured knowledge base. In the subsequent knowledge fragment retrieval process, the knowledge fragment represented by the table can be retrieved, thereby making the content represented by the knowledge fragment more comprehensive.

[0079] In addition, images in original knowledge documents can also be processed and stored in a similar manner.

[0080] The following embodiments introduce two specific implementation schemes of using the preset structured knowledge base to retrieve target knowledge fragments related to the user query mentioned above: The first solution specifically includes: Step S400: vectorize the user query to obtain a user query vector.

[0081] Specifically, a pre-trained embedding model can be used to vectorize user queries. The embedding model is consistent with the embedding model introduced above. In addition, a suitable vector dimension can also be selected.

[0082] Step S410: based on the vector relevance, retrieve the target knowledge fragment related to the user query vector from the structured knowledge base.

[0083] Specifically, the correlation between the user query vector and the vector stored in the structured knowledge base is calculated, and the knowledge fragment corresponding to the vector whose correlation exceeds a first threshold is used as the target knowledge fragment, wherein the correlation calculation method may include cosine similarity, dot product or Euclidean distance and other methods.

[0084] This solution uses vectorized representation to quickly compare the relevance between user queries and knowledge fragments, thereby achieving fast retrieval. Compared with traditional retrieval methods based on keyword matching, vector retrieval can better capture semantic information and improve retrieval efficiency.

[0085] The second option specifically includes: Step S500: vectorize the user query to obtain a user query vector.

[0086] Step S510: Retrieve candidate knowledge fragments related to the user query vector from the structured knowledge base based on the vector relevance.

[0087] Specifically, the correlation between the user query vector and the vector stored in the structured knowledge base is calculated, and the knowledge fragments corresponding to the vectors whose correlation exceeds the second threshold are taken as candidate knowledge fragments. The number of candidate knowledge fragments can be more than the final target knowledge fragments.

[0088] Step S520: Use the pre-trained relevance determination model to determine the relevance of each candidate knowledge fragment to the user query, and select the top N candidate knowledge fragments with the highest relevance as target knowledge fragments, wherein the relevance determination model is trained using knowledge fragment samples and user query samples labeled with relevance scores.

[0089] Specifically, the pre-trained relevance determination model can select various machine learning models as the relevance determination model, such as deep neural network, support vector machine, gradient boosting tree, etc. In addition, various features can be extracted to represent user queries and candidate knowledge fragments, such as word embedding, word frequency, TF-IDF, syntactic features, etc.

[0090] This solution adds a re-ranking step based on the relevance determination model on the basis of the first solution, which can put the knowledge fragments with higher relevance to the user query at the front, thereby improving the retrieval accuracy. This effectively solves the problem that the first solution may retrieve knowledge fragments with weak relevance by using vector similarity.

[0091] The following embodiment introduces another question-answering method, which, after the process of using the structured knowledge base preset in the structured knowledge base to retrieve the target knowledge fragment related to the user query in the question-answering method described above, further includes the following steps: For the retrieved target knowledge fragment related to the user query vector, the target knowledge fragment is reconstructed using the structural information of the target knowledge fragment in the original knowledge document to obtain a reconstructed target knowledge fragment.

[0092] On this basis, the reconstructed target knowledge fragments are integrated with user queries to form prompt input data, which are input into the pre-trained large model to obtain an answer output by the large model that matches the user query.

[0093] Specifically, the structural information can record the location and structural information of each knowledge fragment in the original knowledge document, such as paragraph number, chapter title, etc. Different reconstruction strategies can be adopted according to different structural information. Reconstruction refers to modifying and supplementing the knowledge fragments according to the retrieved knowledge fragments and their structural information in the original knowledge document, so as to make them more complete, easier to understand, and better meet the user's query needs. For example, the context information of the target knowledge fragment (e.g., the previous and next paragraphs, chapter titles) is added to the reconstructed knowledge fragment. Optionally, if the target knowledge fragment comes from a table, the information of the table can be added to the reconstructed knowledge fragment, such as title, row, column, original text, etc. Optionally, related text knowledge fragments and table knowledge fragments can be merged together.

[0094] The following embodiments introduce several possible ways to reconstruct the target knowledge fragment using the structural information in the original knowledge document, which are described as follows: 1. If there are two leaf nodes corresponding to two target knowledge fragments that belong to the same parent node and are continuous in the original knowledge document, then remove the repeated characters in the two target knowledge fragments, and splice the two target knowledge fragments according to the original text order in the original knowledge document to obtain the reconstructed target knowledge fragment.

[0095] Specifically, the repeated characters may be sentences or phrases repeated between adjacent paragraphs. Whether the knowledge fragments are continuous in the original knowledge document can be determined by comparing the positions, paragraphs or titles of the knowledge fragments in the original knowledge document.

[0096] The first reconstruction method mentioned above can effectively improve the coherence and completeness of knowledge fragments by removing duplicate content and splicing them in the order of the original text, while removing redundant information.

[0097] 2. If there are at least two leaf nodes corresponding to the target knowledge fragments that share a common parent node, and the knowledge fragments corresponding to the leaf nodes under the parent node exceeding a preset proportion are included in the recalled target knowledge fragments, then all the knowledge fragments corresponding to the leaf nodes under the parent node are recalled and merged into a reconstructed target knowledge fragment.

[0098] Specifically, the preset ratio can be dynamically adjusted according to different user queries and the structure of the original knowledge document. For example, for documents with a more complex structure and a larger amount of information, the preset ratio can be appropriately increased; for documents with a simpler structure and a smaller amount of information, the preset ratio can be appropriately reduced. The preset ratio can also be adjusted according to the specific content of the user query. For the recalled knowledge fragments, semantic analysis and other technologies can be used to identify the semantic relationship between the knowledge fragments and merge them using appropriate conjunctions or phrases.

[0099] The second reconstruction method mentioned above uses the structural information of the document to more comprehensively recall relevant knowledge fragments and improve the completeness of the knowledge fragments. By setting a preset ratio, the scope of recall can be flexibly controlled to avoid recalling too much irrelevant information, thereby more completely presenting the target knowledge fragments related to the user query.

[0100] 3. For each target knowledge fragment among the recalled target knowledge fragments: Determine whether the number of knowledge fragments corresponding to all leaf nodes under the parent node to which the leaf node corresponding to the target knowledge fragment belongs contained in the recalled target knowledge fragments exceeds a preset ratio; if not, further determine whether the relevance of the target knowledge fragment to the user query is lower than a preset threshold; if so, delete the target knowledge fragment.

[0101] Specifically, if the number of knowledge fragments corresponding to all leaf nodes under the parent node to which the leaf node corresponding to the target knowledge fragment A belongs included in the recalled target knowledge fragments does not exceed the preset proportion, it is further determined whether the relevance of the target knowledge fragment A to the user query is lower than the third threshold. If so, the target knowledge fragment A is deleted.

[0102] The third reconstruction method mentioned above can accurately screen out knowledge fragments that are irrelevant to user queries and remove irrelevant knowledge fragments, thereby improving the accuracy and simplicity of target knowledge fragment selection.

[0103] By combining the preset ratio and relevance threshold for double selection filtering, the granularity of selection can be effectively controlled.

[0104] Figure 6 This is a schematic diagram of the architecture of the question-and-answer system for this application.

[0105] like Figure 6 As shown, the architecture of the question-answering system of this application is divided into three modules: user-big model interaction module, structured knowledge base construction module and big model two-stage fine-tuning module.

[0106] User-big model interaction module: This module is the entry point for users to interact with the system. It is responsible for receiving user queries, understanding user intentions, and converting them into a format that the big model can understand. It plays the role of a bridge, connecting users with the structured knowledge base and the big model. The core function of this module is to efficiently and accurately convert user queries into structured retrieval requests, and ultimately integrate the knowledge fragments retrieved from the structured knowledge base with the user query and send them to the big model to generate the final answer.

[0107] First, the user-big model interaction module receives user queries. Considering the diversity of user input, the module can perform necessary preprocessing steps, such as vectorization and keyword extraction. In order to provide more personalized services, the module can also record the user's historical queries and use this information for personalized recommendations and context understanding.

[0108] Then, the user-big model interaction module needs to select an appropriate retrieval strategy to retrieve the target knowledge fragment from the structured knowledge base based on the preprocessed user query. The retrieval strategy may include the following possible methods: ① Based on the vector relevance, the target knowledge fragment that matches the user query is retrieved from the structured knowledge base. ② Based on the vector relevance, the candidate knowledge fragment that matches the user query is retrieved from the structured knowledge base, and the relevance determination model is used to determine the relevance of each candidate knowledge fragment to the user query, and the top N candidate knowledge fragments with the highest relevance are selected as the target knowledge fragment. After retrieving the target knowledge fragment, the target knowledge fragment that matches the user query can also be retrieved from the structured knowledge base based on the vector relevance, and the target knowledge fragment is reconstructed to obtain the reconstructed target knowledge fragment.

[0109] Finally, the user-big model interaction module needs to integrate the retrieved target knowledge fragments with the user query to form the final prompt input data. You can try different input templates and strategies to guide the big model to generate more accurate and comprehensive answers. Finally, the integrated prompt input data is sent to the big model, waiting for the model to generate the final answer and return it to the user.

[0110] Structured knowledge base building blocks: The structured knowledge base construction module is responsible for building a structured knowledge base to provide a high-quality knowledge source for the upstream user-large model interaction module.

[0111] The structured knowledge base construction module can parse the original knowledge document. The construction process can process the text content and table in the original knowledge document separately. The text content is parsed into a structured document tree according to the document structure features (such as title, paragraph, etc.). The leaf nodes of the structured document tree represent knowledge fragments, and the path from the root node to the leaf node represents the structural information of the knowledge fragment. The knowledge fragment and the corresponding structural information are merged and converted into a vector and stored in the structured knowledge base. For the table in the original knowledge document, first, the table is converted into a format that can be processed by the large model (such as LaTeX format), the table is summarized through the pre-trained model, the summary information is converted into a vector, and the summary information is used as a knowledge fragment, and the knowledge fragment and the vector are stored in the structured knowledge base.

[0112] Large model two-stage fine-tuning module: This module is responsible for training and fine-tuning the large model so that it can effectively use the injected knowledge for question answering. The core goal of the module is to integrate the information of the structured knowledge base into the large model so that it has stronger reasoning and question answering capabilities in a specific domain. The fine-tuning process usually adopts a two-stage strategy: the first stage uses the training data of a specific domain to fine-tune the initial large model to adapt it to the language and knowledge of the specific domain. The training data contains user query samples and matching answer labels; the second stage is based on the first stage, adding knowledge fragments retrieved from the structured knowledge base that match the user query samples as new training data, and further fine-tuning the model so that it can better understand and utilize structured knowledge. Finally, the fine-tuned model is used to receive user queries and retrieved knowledge fragments, and generate answers that match the user queries.

[0113] The question-and-answer device provided in an embodiment of the present application is described below. The question-and-answer device described below and the question-and-answer method described above can refer to each other.

[0114] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of a question-and-answer device disclosed in an embodiment of the present application.

[0115] like Figure 7 As shown, the device may include: A user query acquisition unit 11, used to acquire a user query; A target knowledge fragment retrieval unit 12 is used to retrieve a target knowledge fragment related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field; A prompt input data generating unit 13, used to integrate the target knowledge fragment and the user query to form prompt input data; A question-answering unit 14, configured to input the prompt input data into a pre-trained large model, and obtain an answer output by the large model that matches the user query; Among them, the pre-trained big model is obtained through two-stage fine-tuning training: in the first stage, the initial big model is fine-tuned using training data in a specific field to obtain a big model after one-stage training, and the training data includes user query samples and matching answer labels; in the second stage, on the basis of the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the big model after the one-stage training to obtain a big model after the two-stage training.

[0116] Optionally, the device of the present application may further include: A knowledge base text construction unit is used to parse the text content in the original knowledge document of a specific field into a structured document tree, wherein the leaf nodes in the structured document tree represent knowledge fragments, and each node on the path from the root node to the parent node of each leaf node represents the structural information of the knowledge fragment corresponding to the leaf node in the original knowledge document; the knowledge fragment corresponding to each leaf node and its structural information are combined, and the combined text is converted into a vector, and the knowledge fragment corresponding to each leaf node and the converted vector are correspondingly stored in the structured knowledge base.

[0117] Optionally, the device of the present application may further include: A knowledge base table construction unit, used to convert the tables in the original knowledge document into target formats that can be processed by the large model; Use the pre-trained large model to summarize the table in the target format to obtain summary information; The summary information is converted into a vector, and the summary information is stored in the structured knowledge base as a knowledge fragment corresponding to the converted vector.

[0118] Optionally, the device of the present application may further include: The knowledge base structure construction unit is used to store the structural information corresponding to the knowledge fragments in the structured knowledge base.

[0119] Optionally, the structured knowledge base includes: a correspondence between knowledge fragments and vectors; accordingly, the process of the target knowledge fragment retrieval unit using the preset structured knowledge base to retrieve the target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, a target knowledge segment related to the user query vector is retrieved from the structured knowledge base.

[0120] Optionally, the structured knowledge base includes: a correspondence between knowledge fragments and vectors; accordingly, the process of the target knowledge fragment retrieval unit using the preset structured knowledge base to retrieve the target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, retrieving candidate knowledge fragments related to the user query vector from the structured knowledge base; Using the pre-trained relevance determination model, the relevance of each candidate knowledge fragment to the user query is determined respectively, and the top N candidate knowledge fragments with the highest relevance are selected as target knowledge fragments, wherein the relevance determination model is trained using knowledge fragment samples and user query samples labeled with relevance scores.

[0121] Optionally, the structured knowledge base includes: structural information of knowledge fragments in original knowledge documents; then, the device of the present application may also include: The knowledge fragment reconstruction unit is used to reconstruct the target knowledge fragment related to the user query vector after the target knowledge fragment retrieval unit uses a preset structured knowledge base to retrieve the target knowledge fragment related to the user query. The target knowledge fragment is reconstructed by using the structural information of the target knowledge fragment in the original knowledge document to obtain the reconstructed target knowledge fragment.

[0122] Optionally, the structural information includes: path information from the leaf node to the root node corresponding to each knowledge fragment in the structured document tree after the text content in the original knowledge document is parsed. On this basis, the knowledge fragment reconstruction unit uses the structural information of the target knowledge fragment in the original knowledge document to reconstruct the target knowledge fragment, including: If there are two leaf nodes corresponding to two target knowledge fragments that belong to the same parent node and are continuous in the original knowledge document, then remove the repeated characters in the two target knowledge fragments, and splice the two target knowledge fragments according to the original text order in the original knowledge document to obtain the reconstructed target knowledge fragment.

[0123] Optionally, the structural information includes: path information from the leaf node to the root node corresponding to each knowledge fragment in the structured document tree after the text content in the original knowledge document is parsed. On this basis, the knowledge fragment reconstruction unit uses the structural information of the target knowledge fragment in the original knowledge document to reconstruct the target knowledge fragment, including: If there are at least two leaf nodes corresponding to the target knowledge fragments that share a common parent node, and the knowledge fragments corresponding to the leaf nodes under the parent node exceeding a preset proportion are included in the recalled target knowledge fragments, then all the knowledge fragments corresponding to the leaf nodes under the parent node will be recalled and merged into a reconstructed target knowledge fragment.

[0124] Optionally, the structural information includes: path information from the leaf node to the root node corresponding to each knowledge fragment in the structured document tree after the text content in the original knowledge document is parsed. On this basis, the knowledge fragment reconstruction unit uses the structural information of the target knowledge fragment in the original knowledge document to reconstruct the target knowledge fragment, including: For each target knowledge fragment among the recalled target knowledge fragments: Determine whether the number of knowledge fragments corresponding to all leaf nodes under the parent node to which the leaf node corresponding to the target knowledge fragment belongs contained in the recalled target knowledge fragments exceeds a preset ratio; if not, further determine whether the relevance of the target knowledge fragment to the user query is lower than a preset threshold; if so, delete the target knowledge fragment.

[0125] Optionally, the specific field is the communications field.

[0126] The present application also provides an electronic device in an embodiment. Figure 8 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, tablet computers, teaching large screens, wearable devices, etc. Figure 8 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0127] like Figure 8 As shown, the electronic device may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603 to implement the question-and-answer method of the aforementioned embodiment of the present application. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0128] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 8 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0129] An embodiment of the present application also provides a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements any one of the question-and-answer methods provided in the embodiments of the present application.

[0130] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any question-and-answer method provided in the embodiment of the present application.

[0131] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0132] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0133] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0134] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0135] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0136] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.

[0137] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A question-answering method, characterized in that: include: Get user query; Retrieving target knowledge fragments related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field; Integrating the target knowledge fragment with the user query to form prompt input data; Inputting the prompt input data into a pre-trained large model to obtain an answer output by the large model that matches the user query; The pre-trained large model is obtained through two-stage fine-tuning training: in the first stage, the initial large model is fine-tuned using training data in a specific field to obtain a large model after one stage of training, wherein the training data includes user query samples and matching answer labels; In the second stage, based on the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the large model trained in the first stage to obtain the large model trained in the second stage.

2. The method according to claim 1, characterized in that The construction process of the structured knowledge base includes: Parsing the text content in the original knowledge document of a specific field into a structured document tree, wherein the leaf nodes in the structured document tree represent knowledge fragments, and each node on the path from the root node to the parent node of each leaf node represents the structural information of the knowledge fragment corresponding to the leaf node in the original knowledge document; The knowledge fragments corresponding to each leaf node and their structural information are combined, and the combined text is converted into a vector, and the knowledge fragments corresponding to each leaf node and the converted vectors are correspondingly stored in the structured knowledge base.

3. The method according to claim 2, characterized in that The process of constructing the structured knowledge base also includes: Converting the tables in the original knowledge document into target formats that can be processed by the large model; Use the pre-trained large model to summarize the table in the target format to obtain summary information; The summary information is converted into a vector, and the summary information is stored in the structured knowledge base as a knowledge fragment corresponding to the converted vector.

4. The method according to claim 2, characterized in that: Also includes: The structural information corresponding to the knowledge fragments is correspondingly stored in the structured knowledge base.

5. The method according to claim 1, characterized in that The structured knowledge base includes: a correspondence between knowledge fragments and vectors; Accordingly, the method of using a preset structured knowledge base to retrieve a target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, a target knowledge segment related to the user query vector is retrieved from the structured knowledge base.

6. The method according to claim 1, characterized in that The structured knowledge base includes: a correspondence between knowledge fragments and vectors; Accordingly, the method of using a preset structured knowledge base to retrieve a target knowledge fragment related to the user query includes: Vectorizing the user query to obtain a user query vector; Based on the vector relevance, retrieving candidate knowledge fragments related to the user query vector from the structured knowledge base; Using the pre-trained relevance determination model, the relevance of each candidate knowledge fragment to the user query is determined respectively, and the top N candidate knowledge fragments with the highest relevance are selected as target knowledge fragments, wherein the relevance determination model is trained using knowledge fragment samples and user query samples labeled with relevance scores.

7. The method according to claim 1, 5 or 6, characterized in that: The structured knowledge base includes: structural information of knowledge fragments in original knowledge documents; Then, after using the preset structured knowledge base to retrieve the target knowledge fragment related to the user query, the method further includes: For the retrieved target knowledge fragments related to the user query, the target knowledge fragments are reconstructed using the structural information of the target knowledge fragments in the original knowledge document to obtain the reconstructed target knowledge fragments.

8. The method according to claim 7, characterized in that The structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; Then, the process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: If there are two leaf nodes corresponding to two target knowledge fragments that belong to the same parent node and are continuous in the original knowledge document, then remove the repeated characters in the two target knowledge fragments, and splice the two target knowledge fragments according to the original text order in the original knowledge document to obtain the reconstructed target knowledge fragment.

9. The method according to claim 7, characterized in that: The structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; Then, the process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: If there are at least two leaf nodes corresponding to the target knowledge fragments that share a common parent node, and the knowledge fragments corresponding to the leaf nodes under the parent node exceeding a preset proportion are included in the recalled target knowledge fragments, then all the knowledge fragments corresponding to the leaf nodes under the parent node will be recalled and merged into a reconstructed target knowledge fragment.

10. The method according to claim 7, characterized in that The structural information includes: path information from a leaf node to a root node corresponding to each knowledge fragment in a structured document tree parsed from the text content in the original knowledge document; The process of reconstructing the target knowledge fragment by using the structural information of the target knowledge fragment in the original knowledge document includes: For each target knowledge fragment among the recalled target knowledge fragments: Determine whether the number of knowledge fragments corresponding to all leaf nodes under the parent node to which the leaf node corresponding to the target knowledge fragment belongs contained in the recalled target knowledge fragments exceeds a preset ratio; if not, further determine whether the relevance of the target knowledge fragment to the user query is lower than a preset threshold; if so, delete the target knowledge fragment.

11. The method according to claim 1, characterized in that: The specific field is the communication field.

12. A question-answering device, characterized in that: include: A user query acquisition unit, used to acquire user queries; A target knowledge fragment retrieval unit, used to retrieve a target knowledge fragment related to the user query using a preset structured knowledge base, wherein the structured knowledge base contains knowledge fragments in a specific field; a prompt input data generating unit, used for integrating the target knowledge fragment and the user query to form prompt input data; A question-answering unit, used for inputting the prompt input data into a pre-trained large model to obtain an answer output by the large model that matches the user query; The pre-trained large model is obtained through two-stage fine-tuning training: in the first stage, the initial large model is fine-tuned using training data in a specific field to obtain a large model after one stage of training, wherein the training data includes user query samples and matching answer labels; In the second stage, based on the training data, knowledge fragments matching the user query samples retrieved using the structured knowledge base are added as new training data to fine-tune the large model trained in the first stage to obtain the large model trained in the second stage.

13. An electronic device, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the question-answering method as described in any one of claims 1 to 11.

14. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the question-answering method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, each step of the question-answering method as described in any one of claims 1 to 11 is implemented.

Citation Information

Patent Citations

  • Multi-field and multi-disciplinary science and technology policy resource retrieval method and device

    CN115344668A

  • Knowledge base question and answer method and device, electronic equipment and storage medium

    CN117290492A

  • Knowledge base question and answer method and device, equipment and medium

    CN117708300A

  • Academic conference question-answering system based on large language model

    CN118377867A

  • Knowledge question and answer model training method and device and knowledge question and answer method and device

    CN118504681A

Cited By

  • Text generation method and device, electronic equipment and computer readable storage medium

    CN119647406A

  • Scientific and technical literature table knowledge chain generation method based on large language model

    CN120930615A

  • Information processing method, electronic device and computer program product

    CN121542391A