Large language model retrieval augmentation method and apparatus, electronic device, and storage medium
By constructing domain knowledge graphs and deep learning model auxiliary components, the problems of resource cost and latency in the application of large language models in vertical domains are solved, and the efficiency and accuracy of handling professional problems are improved.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- PING AN TECH (SHENZHEN) CO LTD
- Filing Date
- 2025-11-28
- Publication Date
- 2026-07-16
AI Technical Summary
When traditional techniques combine large language models with vector knowledge bases for application in vertical domains, they increase the cost of technical resources and the delay in answer generation.
By acquiring domain text data from the target vertical domain, a domain knowledge graph is constructed. A large model auxiliary component is built using a deep learning model. The large model auxiliary component is then trained using domain text data. The trained large model auxiliary component is integrated into the target large language model. Domain fine-tuning information is obtained from the domain knowledge graph to fine-tune the large language model, resulting in a retrieval-enhanced large language model.
It improves the efficiency of large language models in handling professional problems in vertical fields and the accuracy of outputting professional search results, while reducing hardware resource requirements.
Smart Images

Figure CN2025138601_16072026_PF_FP_ABST
Abstract
Description
Large language model retrieval enhancement methods, devices, electronic devices and storage media
[0001] This application claims priority to Chinese Patent Application No. 202510034045.9, filed on January 7, 2025, entitled “Method, Apparatus, Electronic Device and Storage Medium for Enhancing Large Language Model Retrieval”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device and storage medium for enhancing large language model retrieval. Background Technology
[0003] In certain vertical application areas, such as medical and legal scenarios, the application of large language models (e.g., ChatGPT, Gemini, Wenxin Yiyan, Tongyi Qianwen, etc.) is increasing, used to provide assisted consultation and other tasks. However, the inventors have found that when dealing with specialized vertical domain problems, the application of large language models in these domains may result in inaccurate answers due to a lack of in-depth knowledge of the specific domain; when no relevant domain knowledge is available, the large model may fabricate answers, combining unrelated knowledge to provide a response. To address these issues, traditional techniques attempt to combine large language models with vector knowledge bases, using methods such as vector retrieval to query specific professional knowledge in real time while the model is generating answers. While this can improve the accuracy of the model in specific domains and make the generated answers more professional, it also presents some problems. Running large models combined with external knowledge bases requires higher hardware resources; real-time vector retrieval has high computational resource requirements, which may increase the delay in answer generation and affect user experience; the highly specialized and complex terminology in vertical domains increases the technical difficulty and cost of building and maintaining vector knowledge bases. Summary of the Invention
[0004] The main technical problem addressed by the implementation method of this application is that when traditional techniques combine large language models with vector knowledge bases and apply them to vertical domains, the cost of various technical resources is increased, as well as the delay in answer generation.
[0005] To address the aforementioned technical problems, the first technical solution adopted in this application is: providing a method for enhancing large language model retrieval, comprising: acquiring domain text data of a target vertical domain; constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data; constructing a large model auxiliary component using a deep learning model, and training the large model auxiliary component using the domain text data to obtain a trained large model auxiliary component; integrating the trained large model auxiliary component into a target large language model; acquiring domain fine-tuning information from the domain knowledge graph, and fine-tuning the target large language model using the domain fine-tuning information to obtain a retrieval-enhanced large language model.
[0006] To address the aforementioned technical problems, the second technical solution adopted in this application is: providing a large language model retrieval enhancement device, comprising: a domain knowledge graph module, used to acquire domain text data of a target vertical domain and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data; a model auxiliary component module, used to construct a large model auxiliary component using a deep learning model and train the large model auxiliary component using the domain text data to obtain a trained large model auxiliary component; a model component integration module, used to integrate the trained large model auxiliary component into a target large language model; and a large language model fine-tuning module, used to acquire domain fine-tuning information from the domain knowledge graph and fine-tune the target large language model using the domain fine-tuning information to obtain a retrieval-enhanced large language model.
[0007] To address the aforementioned technical problems, the third technical solution adopted in this application is: providing an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform: acquiring domain text data of a target vertical domain; constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data; constructing a large model auxiliary component using a deep learning model, and training the large model auxiliary component using the domain text data to obtain a trained large model auxiliary component; integrating the trained large model auxiliary component into a target large language model; acquiring domain fine-tuning information from the domain knowledge graph, and fine-tuning the target large language model using the domain fine-tuning information to obtain a retrieval-enhanced large language model.
[0008] To address the aforementioned technical problems, the fourth technical solution adopted in this application is: providing a non-volatile computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device performs the following: acquiring domain text data of a target vertical domain; constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data; constructing a large model auxiliary component using a deep learning model, and training the large model auxiliary component using the domain text data to obtain a trained large model auxiliary component; integrating the trained large model auxiliary component into a target large language model; acquiring domain fine-tuning information from the domain knowledge graph, and fine-tuning the target large language model using the domain fine-tuning information to obtain a retrieval-enhanced large language model.
[0009] Unlike related technologies, this application acquires domain text data of the target vertical domain, constructs a domain knowledge graph corresponding to the target vertical domain based on the domain text data, uses a deep learning model to construct a large model auxiliary component, and trains the large model auxiliary component using domain text data to obtain a trained large model auxiliary component; integrates the trained large model auxiliary component into the target large language model; obtains domain fine-tuning information from the domain knowledge graph, and uses the domain fine-tuning information to fine-tune the target large language model to obtain a retrieval-enhanced large language model, thereby improving the efficiency of the large language model in handling professional problems in the vertical domain and the accuracy of outputting professional retrieval results. Attached Figure Description
[0010] One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements having the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0011] Figure 1 is a schematic diagram of the operating environment of the large language model retrieval enhancement method provided in the embodiments of this application.
[0012] Figure 2 is a schematic diagram of the execution flow of the large language model retrieval enhancement method provided in the embodiments of this application.
[0013] Figure 3 is a schematic diagram of the execution flow of obtaining the large model auxiliary component provided in the embodiment of this application.
[0014] Figure 4 is a schematic diagram of the execution flow for obtaining large language model-enhanced retrieval results provided in an embodiment of this application.
[0015] Figure 5 is a schematic diagram of the system structure of the large language model retrieval enhancement device provided in the embodiments of this application.
[0016] Figure 6 is a schematic diagram of the hardware structure of an electronic device for implementing the large language model retrieval enhancement method provided in an embodiment of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0018] It should be noted that, unless otherwise specified, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device schematic diagram or the order in the flowchart.
[0019] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0020] To facilitate understanding of this embodiment, a detailed description of the large language model retrieval enhancement method disclosed in this application embodiment will be provided first. Please refer to Figure 1, which is a schematic diagram of the operating environment of the large language model retrieval enhancement method provided in this application embodiment. As shown in Figure 1, the execution subject of the large language model retrieval enhancement method provided in this application embodiment is generally an electronic device with certain computing power, such as a computer device. In some possible implementations, the large language model retrieval enhancement method can be implemented by the processor calling computer-readable instructions stored in the memory. The computer device in Figure 1 can be a server. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. It is understood that the number of computer devices in Figure 1 is merely illustrative and can be expanded in any number according to actual needs.
[0021] Please refer to Figure 2. Figure 2 is a schematic diagram of the execution flow of the large language model retrieval enhancement method provided in the embodiment of this application. As shown in Figure 2, it includes the following steps:
[0022] S1. Obtain domain text data of the target vertical domain, and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data.
[0023] As a preferred implementation, the steps for constructing a domain knowledge graph described above may include: First, preprocessing the domain text data, such as text cleaning, word segmentation, stop word removal, and word embedding on the acquired medical text data. Then, extracting corresponding sub-domain entities and their entity attributes from the preprocessed domain text data; for example, extracting the disease entity and its corresponding disease entity attributes from medical text data about a certain disease. Additionally, extracting entity relationships between sub-domain entities using a pre-defined natural language processing tool; for example, extracting entity relationships between the aforementioned multiple disease entities. Finally, constructing a domain knowledge graph corresponding to the target vertical domain using the sub-domain entities, entity attributes, and entity relationships. Furthermore, acquiring professional knowledge base data for the target vertical domain and adding it to the domain knowledge graph; for example, acquiring third-party professional knowledge database data about a certain disease and adding it to the aforementioned medical domain knowledge graph to increase its professionalism.
[0024] S2. Use a deep learning model to build a large model auxiliary component, and train the large model auxiliary component using domain text data to obtain the trained large model auxiliary component.
[0025] As an optional implementation, please continue to refer to Figure 3. Figure 3 is a schematic diagram of the execution flow of obtaining the large model auxiliary component provided by the embodiment of this application. As shown in Figure 3, it may include steps S21 to S25.
[0026] S21. Construct an initial deep learning model using a pre-defined neural network.
[0027] S22. Preprocess the domain text data and extract domain text feature data from the domain text data.
[0028] S23. Train the entity extraction and intent recognition functions of the initial deep learning model using domain text feature data.
[0029] S24. Use a preset loss function to fine-tune the parameters of the initial deep learning model, and optimize the entity extraction and intent recognition functions.
[0030] In a preferred embodiment, the entity extraction function in step S24 above is based on a bidirectional long short-term memory network. The process of entity extraction through the bidirectional long short-term memory network may include the following steps S241 to S244:
[0031] S241. Convert the domain text feature data into a domain text feature sequence.
[0032] Bidirectional Long Short-Term Memory (BiLSTM) is a deep learning neural network structure, a variant of Long Short-Term Memory (LSTM). BiLSTM is very effective when processing sequence data because it can capture the relationships between sequences, thus better understanding contextual information.
[0033] S242. Generate the forward propagation hidden state and the backward propagation hidden state of the domain text feature sequence.
[0034] BiLSTM comprises two independent LSTM networks, processing the sequence forward and backward respectively. The forward LSTM processes the input sequence in chronological order, while the backward LSTM processes it in reverse chronological order. At each time step, the forward and backward LSTMs compute the hidden state, and the final hidden state is the connection between the two. The forward and backward propagation processes capture past and future contextual information, respectively, thereby improving the ability to understand and model the sequence.
[0035] S243. Combine the forward propagation hidden state and the backward propagation hidden state to obtain the domain text hidden state.
[0036] S244. Identify domain entity boundaries based on the hidden state of the domain text, and divide the domain text feature data by the domain entity boundaries to obtain the extracted domain entities.
[0037] As another preferred implementation, the process of extracting domain entities can be optimized, that is, after the above step S244, the following steps S2441 to S2443 can be included.
[0038] S2441. Obtain the hidden state sequence and the corresponding label sequence at each time step generated by the bidirectional long short-term memory network during the process of obtaining domain entities.
[0039] S2442. Calculate the first probability of the label sequence using a preset conditional random field probability graph model. The formula for calculating the first probability is as follows:
[0040] Where i represents the position index of the label in the sequence, and n represents the number of label elements in the sequence. This indicates that label y is at position i. i The score, Indicates label y i-1 Transfer to label y iThe transition score, where X represents the domain text feature sequence, Y... X Let Y represent all possible label sequences given a sequence X, and let P(Y|H) represent the first probability.
[0041] S2443. Optimize the process of extracting entities using the bidirectional long short-term memory network based on the first probability of the calculated label sequence.
[0042] As another preferred embodiment, the intent recognition function in step S24 above is constructed based on convolutional neural networks and recurrent neural networks. The process of intent recognition through a conditional random field probabilistic graphical model may include the following steps S245 to S248:
[0043] S245. Convert the received intent data to be analyzed into the corresponding intent sequence to be analyzed.
[0044] S246. Input the sequence of intent to be analyzed into a preset convolutional neural network. The convolutional neural network performs a convolution operation on the sequence of intent to be analyzed to obtain the feature map of intent to be analyzed. The processing formula for the convolution operation is: c i =f(W c ·X i:i+h-1 +b c )
[0045] Among them, W c ∈R represents the convolution kernel weights, b c Let f represent the bias term, h represent the kernel size, i represent the position number of the element in the sequence to be analyzed, and c represent the activation function. i This represents the result of the convolution operation on the i-th sequence element;
[0046] S247. Input the intent feature map to be analyzed into the recurrent neural network. The recurrent neural network processes the feature sequence in the intent feature map sequentially according to time steps. The operation of the recurrent neural network at each time step is represented as: h t =σ(W hh h t-1 +W xh c t +b h )
[0047] Among them, h t-1 c represents the hidden state at the previous time step. t W represents the input at the current time step. hh W indicates a hidden state. xh Let b represent the input weight matrix. h Let h represent the bias term, σ represent the activation function, and h represent the activation term. t This indicates the processing result at the current time step.
[0048] S248. Obtain the first hidden state at the last time step in the recurrent neural network. Process the first hidden state through a preset fully connected layer and a preset normalized exponential function to obtain the intent recognition result. The formula for calculating the intent recognition result is as follows: y = softmax(W hy h n +b y )
[0049] Among them, W hy Let b represent the weight matrix of the fully connected layer. y represents the bias term, softmax represents the normalized exponential function, and y represents the intent recognition result.
[0050] As a preferred implementation, before the bidirectional long short-term memory network processing in the above steps, the domain text feature data can also be processed using the BERT model or other pre-trained models to better capture rich contextual relationships, reduce feature engineering, and improve the accuracy and robustness of the deep learning model.
[0051] S25. Set the trained deep learning model as a large model auxiliary component.
[0052] Once the deep learning model has been trained, it can be updated based on newly acquired domain knowledge data. The updated deep learning model is then used to update the large model auxiliary component, enabling timely updates to the search capabilities of the large language model.
[0053] S3. Integrate the trained large model auxiliary components into the target large language model.
[0054] While traditional large language models have excellent technical capabilities in various aspects, in vertical domains, when combined with knowledge graphs for search, deep learning models can be used to assist in entity extraction and intent recognition, thereby enhancing the domain expertise of large language models in the knowledge search process and the professionalism of their answers to domain-specific questions.
[0055] S4. Obtain domain fine-tuning information from the domain knowledge graph, and use the domain fine-tuning information to fine-tune the target large language model to obtain a retrieval-enhanced large language model.
[0056] As an optional implementation, please continue to refer to Figure 4. Figure 4 is a schematic diagram of the execution flow for obtaining the large language model enhanced retrieval results provided by the embodiment of this application. As shown in Figure 4, it may include steps S51 to S54.
[0057] S51. Receive the question text data input by the target user, process the question text data through the large model auxiliary component, and obtain entity keywords and question intent data.
[0058] S52. Query the domain knowledge graph based on entity keywords to obtain the corresponding entity data of the question domain.
[0059] S53. Based on the entity data and intent data of the question domain, retrieve the domain knowledge graph to obtain the retrieved entity data and the corresponding retrieved entity relationship data.
[0060] S54. Generate model retrieval result data based on the retrieved entity data and the retrieved entity relationship data, and send the model retrieval result data to the target user.
[0061] The large language model retrieval enhancement method provided in this application involves: acquiring domain text data of a target vertical domain; constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data; constructing a large model auxiliary component using a deep learning model and training the large model auxiliary component using domain text data to obtain a trained large model auxiliary component; integrating the trained large model auxiliary component into the target large language model; obtaining domain fine-tuning information from the domain knowledge graph and using the domain fine-tuning information to fine-tune the target large language model to obtain a retrieval-enhanced large language model, thereby improving the efficiency of the large language model in handling professional problems in vertical domains and the accuracy of outputting professional retrieval results.
[0062] Please refer to Figure 5. Figure 5 is a schematic diagram of the system structure of the large language model retrieval enhancement device provided in the embodiment of this application. As shown in Figure 5, the large language model retrieval enhancement device 50 includes: a domain knowledge graph module 51, a model auxiliary component module 52, a model component integration module 53, and a large language model fine-tuning module 54.
[0063] The domain knowledge graph module 51 is used to acquire domain text data of the target vertical domain and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data.
[0064] The model auxiliary component module 52 is used to construct a large model auxiliary component using a deep learning model, and to train the large model auxiliary component using the domain text data to obtain the trained large model auxiliary component.
[0065] The model component integration module 53 is used to integrate the trained large model auxiliary components into the target large language model;
[0066] The large language model fine-tuning module 54 is used to obtain domain fine-tuning information from the domain knowledge graph, and use the domain fine-tuning information to fine-tune the target large language model to obtain a retrieval-enhanced large language model.
[0067] As an optional implementation, the domain knowledge graph module 51 is specifically used to perform text preprocessing on the domain text data; extract corresponding sub-domain entities and entity attributes of the sub-domain entities from the preprocessed domain text data; extract entity relationships between the sub-domain entities using a preset natural language processing tool; construct a domain knowledge graph corresponding to the target vertical domain using the sub-domain entities, the entity attributes, and the entity relationships; obtain professional knowledge base data of the target vertical domain, and add the professional knowledge base data to the domain knowledge graph.
[0068] As an optional implementation, the model auxiliary component module 52 is specifically used to construct an initial deep learning model using a preset neural network; preprocess the domain text data and extract domain text feature data from the domain text data; train the entity extraction function and intent recognition function of the initial deep learning model using the domain text feature data; fine-tune the parameters of the initial deep learning model using a preset loss function, and optimize the entity extraction function and the intent recognition function; and set the trained deep learning model as the large model auxiliary component.
[0069] As an optional implementation, the model-aided component module 52 is further specifically used to convert the domain text feature data into a domain text feature sequence; generate the forward propagation hidden state and the backward propagation hidden state of the domain text feature sequence; concatenate the forward propagation hidden state and the backward propagation hidden state to obtain the domain text hidden state; identify the domain entity boundary according to the domain text hidden state, and divide the domain text feature data through the domain entity boundary to obtain the extracted domain entity.
[0070] As an optional implementation, the model-aiding component module 52 is further specifically used to obtain the hidden state sequence and the corresponding label sequence at each time step generated by the bidirectional long short-term memory network in the process of obtaining the domain entity; and to calculate the first probability of the label sequence through a preset conditional random field probabilistic graphical model. The formula for calculating the first probability is as follows:
[0071] Where i represents the position index of the label in the sequence, and n represents the number of label elements in the sequence. This indicates that label y is at position i. i The score, Indicates label y i-1 Transfer to label y i The transfer score, where X represents the domain text feature sequence, Y XLet P(Y|H) represent all possible label sequences given a sequence X, and let P(Y|H) represent the first probability. The process of extracting entities using the bidirectional long short-term memory network is optimized based on the first probability of the calculated label sequence.
[0072] As an optional implementation, the model-assistive component module 52 is further specifically used to convert the received intent data to be analyzed into a corresponding intent sequence to be analyzed; input the intent sequence to be analyzed into a preset convolutional neural network, and perform a convolution operation on the intent sequence to be analyzed through the convolutional neural network to obtain the intent feature map to be analyzed. The processing formula for the convolution operation is: c i =f(W c ·X i:i+h-1 +b c )
[0073] Among them, W c ∈R represents the convolution kernel weights, b c Let f represent the bias term, h represent the kernel size, i represent the position number of the element in the sequence to be analyzed, and c represent the activation function. i This represents the result of the convolution operation on the i-th sequence element; the input of the intent feature map to be analyzed is fed into the recurrent neural network, which processes the feature sequence in the intent feature map sequentially according to time steps. The operation of the recurrent neural network at each time step is represented as: h t =σ(W hh h t-1 +W xh c t +b h )
[0074] Among them, h t-1 c represents the hidden state at the previous time step. t W represents the input at the current time step. hh W indicates a hidden state. xh Let b represent the input weight matrix. h Let h represent the bias term, σ represent the activation function, and h represent the activation term. t This represents the processing result at the current time step; the first hidden state of the last time step in the recurrent neural network is obtained, and the first hidden state is processed through a preset fully connected layer and a preset normalized exponential function to obtain the intent recognition result. The calculation formula for the intent recognition result is as follows: y = softmax(W hy h n +b y )
[0075] Among them, W hy Let b represent the weight matrix of the fully connected layer. yrepresents the bias term, softmax represents the normalized exponential function, and y represents the intent recognition result.
[0076] As an optional implementation, the large language model retrieval enhancement device 50 further includes a model retrieval enhancement module. This module receives question text data input by a target user, processes the question text data through the large model auxiliary component to obtain entity keywords and question intent data; queries the domain knowledge graph based on the entity keywords to obtain corresponding question domain entity data; retrieves the domain knowledge graph based on the question domain entity data and the question intent data to obtain retrieval entity data and corresponding retrieval entity relationship data; generates model retrieval result data based on the retrieval entity data and the retrieval entity relationship data; and sends the model retrieval result data to the target user.
[0077] It should be noted that the above-described large language model retrieval enhancement device can execute the large language model retrieval enhancement method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the embodiments of the large language model retrieval enhancement device can be found in the large language model retrieval enhancement method provided in the embodiments of this application.
[0078] Please refer to Figure 6. Figure 6 is a schematic diagram of the hardware structure of the electronic device 600 for executing the large language model retrieval enhancement method provided in the embodiment of this application. As shown in Figure 6, the electronic device 600 includes:
[0079] One or more processors 610 and memory 620, with one processor 610 as an example in Figure 6.
[0080] The processor 610 and the memory 620 can be connected via a bus or other means; Figure 6 shows an example of a connection via a bus.
[0081] The memory 620, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the large language model retrieval enhancement method in the embodiments of this application. The processor 610 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions, and modules stored in the memory 620, thereby implementing the large language model retrieval enhancement method in the above-described method embodiments.
[0082] Memory 620 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created by the use of the large language model retrieval enhancement device. Furthermore, memory 620 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 620 may optionally include memory remotely located relative to processor 610, and this remote memory may be connected to the large language model retrieval enhancement device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0083] The one or more modules are stored in the memory 620. When executed by the one or more processors 610, they execute the large language model retrieval enhancement method in any of the above method embodiments. For example, they execute the method steps S1 to S4 in FIG2, the method steps S21 to S25 in FIG3, and the method steps S51 to S54 in FIG4 to realize the functions of modules 51-51 in FIG5.
[0084] The above-described product can perform the methods provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for performing the methods. Technical details not described in detail in this embodiment can be found in the methods provided in the embodiments of this application.
[0085] This application provides a computer-readable storage medium, which may be non-volatile or volatile. The computer-readable storage medium stores computer-executable instructions, which are executed by one or more processors, such as processor 610 in FIG. 6. These one or more processors can execute the large language model retrieval enhancement method in any of the above method embodiments. For example, they can execute method steps S1 to S4 in FIG. 2, method steps S21 to S25 in FIG. 3, and method steps S51 to S54 in FIG. 4, thereby implementing the functions of modules 51-51 in FIG. 5.
[0086] This application provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions, which, when executed by the electronic device, enable the electronic device to execute the large language model retrieval enhancement method in any of the above method embodiments. For example, it executes the method steps S1 to S4 in FIG2, the method steps S21 to S25 in FIG3, and the method steps S51 to S54 in FIG4, thereby implementing the functions of modules 51-51 in FIG5.
[0087] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0088] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0089] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
A method for enhancing retrieval using a large language model, wherein, include: Acquire domain text data of a target vertical domain, and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data; A large model auxiliary component is constructed using a deep learning model, and the large model auxiliary component is trained using the domain text data to obtain the trained large model auxiliary component. Integrate the trained large model auxiliary components into the target large language model; Domain fine-tuning information is obtained from the domain knowledge graph, and the target large language model is fine-tuned using the domain fine-tuning information to obtain a retrieval-enhanced large language model. According to claim 1, the large language model retrieval enhancement method, wherein, The step of constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data includes: Perform text preprocessing on the domain text data; Extract the corresponding sub-domain entities and the entity attributes of the sub-domain entities from the preprocessed domain text data; The entity relationships between entities in the subdivided domain are extracted using a preset natural language processing tool; Construct a domain knowledge graph corresponding to the target vertical domain using the subdivided domain entities, the entity attributes, and the entity relationships; Obtain the professional knowledge base data of the target vertical domain, and add the professional knowledge base data to the domain knowledge graph. According to claim 1, the large language model retrieval enhancement method, wherein, The steps of constructing a large model auxiliary component using a deep learning model and training the large model auxiliary component using the domain text data include: Build an initial deep learning model using a pre-defined neural network; Preprocess the domain text data and extract domain text feature data from the domain text data; The entity extraction and intent recognition functions of the initial deep learning model are trained using the domain text feature data. The parameters of the initial deep learning model are tuned using a preset loss function, and the entity extraction function and the intent recognition function are optimized. The trained deep learning model is set as the auxiliary component of the large model. According to claim 3, the large language model retrieval enhancement method, wherein, The entity extraction function is built on a bidirectional long short-term memory network, and the steps for entity extraction through the bidirectional long short-term memory network include: Convert the domain text feature data into a domain text feature sequence; Generate the forward propagation hidden state and the backward propagation hidden state of the domain text feature sequence; By concatenating the forward propagation hidden state and the backward propagation hidden state, the domain text hidden state is obtained; Based on the hidden state of the domain text, the boundaries of domain entities are identified, and the domain text feature data is divided by the boundaries of the domain entities to obtain the extracted domain entities. According to claim 4, the large language model retrieval enhancement method, wherein, After the steps of identifying domain entity boundaries based on the hidden state of the domain text, dividing the domain text feature data through the domain entity boundaries, and obtaining the extracted domain entities, the method further includes: Obtain the hidden state sequence and the corresponding label sequence at each time step generated by the bidirectional long short-term memory network during the process of obtaining the domain entity; The first probability of the label sequence is calculated using a preset conditional random field probabilistic graphical model. The formula for calculating the first probability is as follows: Where i represents the position index of the label in the sequence, and n represents the number of label elements in the sequence. This indicates that label y is at position i. i The score, Indicates label y i-1 Transfer to label y i The transfer score, where X represents the domain text feature sequence, Y X Let P(Y|H) represent all possible label sequences given sequence X, and let P(Y|H) represent the first probability. The process of extracting entities from the bidirectional long short-term memory network is optimized based on the first probability of the calculated label sequence. According to the large language model retrieval enhancement method according to claim 5, wherein, The intent recognition function is built upon convolutional neural networks and recurrent neural networks. The steps for intent recognition using the conditional random field probabilistic graphical model include: The received intent data to be analyzed is converted into the corresponding intent sequence to be analyzed; The input sequence of intent to be analyzed is fed into a preset convolutional neural network. The convolutional neural network performs a convolution operation on the sequence of intent to be analyzed to obtain a feature map of intent to be analyzed. The processing formula for the convolution operation is as follows: c i =f(W c ·X i:i+h-1 +b c ) Among them, W c ∈R represents the convolution kernel weights, b c Let f represent the bias term, h represent the kernel size, i represent the position number of the element in the sequence to be analyzed, and c represent the activation function. i This represents the result of the convolution operation on the i-th sequence element; The intent feature map to be analyzed is input into the recurrent neural network. The recurrent neural network processes the feature sequence in the intent feature map sequentially according to time steps. The operation of the recurrent neural network at each time step is represented as follows: h t =σ(W hh h t-1 +W xh c t +b h ) Among them, h t-1 c represents the hidden state at the previous time step. t W represents the input at the current time step. hh W indicates a hidden state. xh Let b represent the input weight matrix. h Let h represent the bias term, σ represent the activation function, and h represent the activation term. t This indicates the processing result at the current time step; The first hidden state at the last time step in the recurrent neural network is obtained. This first hidden state is then processed through a preset fully connected layer and a preset normalized exponential function to obtain the intent recognition result. The calculation formula for the intent recognition result is as follows: y =softmax(W hy h n +b y ) Among them, W hy Let b represent the weight matrix of the fully connected layer. y represents the bias term, softmax represents the normalized exponential function, and y represents the intent recognition result. According to claim 1, the large language model retrieval enhancement method, wherein, After the step of fine-tuning the target large language model using the domain fine-tuning information to obtain the retrieval-enhanced large language model, the method further includes: Receive question text data input by the target user, process the question text data through the large model auxiliary component, and obtain entity keywords and question intent data; The domain knowledge graph is queried based on the entity keywords to obtain the corresponding question domain entity data; Based on the question domain entity data and the question intent data, the domain knowledge graph is retrieved to obtain the retrieved entity data and the corresponding retrieved entity relationship data. Model retrieval result data is generated based on the retrieved entity data and the retrieved entity relationship data, and the model retrieval result data is sent to the target user. A large language model retrieval enhancement device, wherein, include: The domain knowledge graph module is used to acquire domain text data of a target vertical domain and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data. The model auxiliary component module is used to construct a large model auxiliary component using a deep learning model, and to train the large model auxiliary component using the domain text data to obtain the trained large model auxiliary component. The model component integration module is used to integrate the trained large model auxiliary components into the target large language model; The large language model fine-tuning module is used to obtain domain fine-tuning information from the domain knowledge graph, and use the domain fine-tuning information to fine-tune the target large language model to obtain a retrieval-enhanced large language model. An electronic device, wherein, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform: Acquire domain text data of a target vertical domain, and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data; A large model auxiliary component is constructed using a deep learning model, and the large model auxiliary component is trained using the domain text data to obtain the trained large model auxiliary component. Integrate the trained large model auxiliary components into the target large language model; Domain fine-tuning information is obtained from the domain knowledge graph, and the target large language model is fine-tuned using the domain fine-tuning information to obtain a retrieval-enhanced large language model. The electronic device according to claim 9, wherein, The step of constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data includes: Perform text preprocessing on the domain text data; Extract the corresponding sub-domain entities and the entity attributes of the sub-domain entities from the preprocessed domain text data; The entity relationships between entities in the subdivided domain are extracted using a preset natural language processing tool; Construct a domain knowledge graph corresponding to the target vertical domain using the subdivided domain entities, the entity attributes, and the entity relationships; Obtain the professional knowledge base data of the target vertical domain, and add the professional knowledge base data to the domain knowledge graph. The electronic device according to claim 9, wherein, The steps of constructing a large model auxiliary component using a deep learning model and training the large model auxiliary component using the domain text data include: Build an initial deep learning model using a pre-defined neural network; Preprocess the domain text data and extract domain text feature data from the domain text data; The entity extraction and intent recognition functions of the initial deep learning model are trained using the domain text feature data. The parameters of the initial deep learning model are tuned using a preset loss function, and the entity extraction function and the intent recognition function are optimized. The trained deep learning model is set as the auxiliary component of the large model. The electronic device according to claim 11, wherein, The entity extraction function is built on a bidirectional long short-term memory network, and the steps for entity extraction through the bidirectional long short-term memory network include: Convert the domain text feature data into a domain text feature sequence; Generate the forward propagation hidden state and the backward propagation hidden state of the domain text feature sequence; By concatenating the forward propagation hidden state and the backward propagation hidden state, the domain text hidden state is obtained; Based on the hidden state of the domain text, the boundaries of domain entities are identified, and the domain text feature data is divided by the boundaries of the domain entities to obtain the extracted domain entities. The electronic device according to claim 12, wherein, After the steps of identifying domain entity boundaries based on the hidden state of the domain text, dividing the domain text feature data through the domain entity boundaries, and obtaining the extracted domain entities, the method further includes: Obtain the hidden state sequence and the corresponding label sequence at each time step generated by the bidirectional long short-term memory network during the process of obtaining the domain entity; The first probability of the label sequence is calculated using a preset conditional random field probabilistic graphical model. The formula for calculating the first probability is as follows: Where i represents the position index of the label in the sequence, and n represents the number of label elements in the sequence. This indicates that label y is at position i. i The score, Indicates label y i-1 Transfer to label y i The transfer score, where X represents the domain text feature sequence, Y X Let P(Y|H) represent all possible label sequences given sequence X, and let P(Y|H) represent the first probability. The process of extracting entities from the bidirectional long short-term memory network is optimized based on the first probability of the calculated label sequence. The electronic device according to claim 13, wherein, The intent recognition function is built upon convolutional neural networks and recurrent neural networks. The steps for intent recognition using the conditional random field probabilistic graphical model include: The received intent data to be analyzed is converted into the corresponding intent sequence to be analyzed; The input sequence of intent to be analyzed is fed into a preset convolutional neural network. The convolutional neural network performs a convolution operation on the sequence of intent to be analyzed to obtain a feature map of intent to be analyzed. The processing formula for the convolution operation is as follows: c i =f(W c ·X i:i+h-1 +b c ) Among them, W c ∈R represents the convolution kernel weights, b c Let f represent the bias term, h represent the kernel size, i represent the position number of the element in the sequence to be analyzed, and c represent the activation function. i This represents the result of the convolution operation on the i-th sequence element; The intent feature map to be analyzed is input into the recurrent neural network. The recurrent neural network processes the feature sequence in the intent feature map sequentially according to time steps. The operation of the recurrent neural network at each time step is represented as follows: h t =σ(W hh h t-1 +W xh c t +b h ) Among them, h t-1 c represents the hidden state at the previous time step. t W represents the input at the current time step. hh W indicates a hidden state. xh Let b represent the input weight matrix. h Let h represent the bias term, σ represent the activation function, and h represent the activation term. t This indicates the processing result at the current time step; The first hidden state at the last time step in the recurrent neural network is obtained. This first hidden state is then processed through a preset fully connected layer and a preset normalized exponential function to obtain the intent recognition result. The calculation formula for the intent recognition result is as follows: y =softmax(W hy h n +b y ) Among them, W hy Let b represent the weight matrix of the fully connected layer. y represents the bias term, softmax represents the normalized exponential function, and y represents the intent recognition result. The electronic device according to claim 9, wherein, After the step of fine-tuning the target large language model using the domain fine-tuning information to obtain the retrieval-enhanced large language model, the method further includes: Receive question text data input by the target user, process the question text data through the large model auxiliary component, and obtain entity keywords and question intent data; The domain knowledge graph is queried based on the entity keywords to obtain the corresponding question domain entity data; Based on the question domain entity data and the question intent data, the domain knowledge graph is retrieved to obtain the retrieved entity data and the corresponding retrieved entity relationship data. Model retrieval result data is generated based on the retrieved entity data and the retrieved entity relationship data, and the model retrieval result data is sent to the target user. A non-volatile computer-readable storage medium, wherein, The non-volatile computer-readable storage medium stores computer-executable instructions that, when executed by an electronic device, cause the electronic device to perform the following: Acquire domain text data of a target vertical domain, and construct a domain knowledge graph corresponding to the target vertical domain based on the domain text data; A large model auxiliary component is constructed using a deep learning model, and the large model auxiliary component is trained using the domain text data to obtain the trained large model auxiliary component. Integrate the trained large model auxiliary components into the target large language model; Domain fine-tuning information is obtained from the domain knowledge graph, and the target large language model is fine-tuned using the domain fine-tuning information to obtain a retrieval-enhanced large language model. The non-volatile computer-readable storage medium according to claim 16, wherein, The step of constructing a domain knowledge graph corresponding to the target vertical domain based on the domain text data includes: Perform text preprocessing on the domain text data; Extract the corresponding sub-domain entities and the entity attributes of the sub-domain entities from the preprocessed domain text data; The entity relationships between entities in the subdivided domain are extracted using a preset natural language processing tool; Construct a domain knowledge graph corresponding to the target vertical domain using the subdivided domain entities, the entity attributes, and the entity relationships; Obtain the professional knowledge base data of the target vertical domain, and add the professional knowledge base data to the domain knowledge graph. The non-volatile computer-readable storage medium according to claim 16, wherein, The steps of constructing a large model auxiliary component using a deep learning model and training the large model auxiliary component using the domain text data include: Build an initial deep learning model using a pre-defined neural network; Preprocess the domain text data and extract domain text feature data from the domain text data; The entity extraction and intent recognition functions of the initial deep learning model are trained using the domain text feature data. The parameters of the initial deep learning model are tuned using a preset loss function, and the entity extraction function and the intent recognition function are optimized. The trained deep learning model is set as the auxiliary component of the large model. The non-volatile computer-readable storage medium according to claim 18, wherein, The entity extraction function is built on a bidirectional long short-term memory network, and the steps for entity extraction through the bidirectional long short-term memory network include: Convert the domain text feature data into a domain text feature sequence; Generate the forward propagation hidden state and the backward propagation hidden state of the domain text feature sequence; By concatenating the forward propagation hidden state and the backward propagation hidden state, the domain text hidden state is obtained; Based on the hidden state of the domain text, the boundaries of domain entities are identified, and the domain text feature data is divided by the boundaries of the domain entities to obtain the extracted domain entities. The non-volatile computer-readable storage medium according to claim 19, wherein, After the steps of identifying domain entity boundaries based on the hidden state of the domain text, dividing the domain text feature data through the domain entity boundaries, and obtaining the extracted domain entities, the method further includes: Obtain the hidden state sequence and the corresponding label sequence at each time step generated by the bidirectional long short-term memory network during the process of obtaining the domain entity; The first probability of the label sequence is calculated using a preset conditional random field probabilistic graphical model. The formula for calculating the first probability is as follows: Where i represents the position index of the label in the sequence, and n represents the number of label elements in the sequence. This indicates that label y is at position i. i The score, Indicates label y i-1 Transfer to label y i The transfer score, where X represents the domain text feature sequence, Y X Let P(Y|H) represent all possible label sequences given sequence X, and let P(Y|H) represent the first probability. The process of extracting entities from the bidirectional long short-term memory network is optimized based on the first probability of the calculated label sequence.