Question and answer method, device and equipment based on large language model and storage medium

Entity extraction and matching is performed through large language models, combined with knowledge graphs and triple vector libraries, the problem of poor generalization of traditional neural network training is solved, and an efficient and reliable question-and-answer system is realized.

CN120353884APending Publication Date: 2025-07-22GUANGDONG ESHORE TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410059921.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-15
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

In the prior art, triple extraction of knowledge graphs relies on traditional neural network training, with poor generalization, high update and maintenance costs, stiff answers in the Q&A system and low user satisfaction.

Method used

The large language model is used for entity extraction and matching, and cascade matching is combined with the knowledge graph, entity content library and triple vector library for cascade matching, and the preset large language model is used to generate answers.

Benefits of technology

It improves the accuracy and reliability of the Q&A system, reduces training costs and maintenance difficulties, and enhances the fluency and reliability of the answers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120353884A_ABST
    Figure CN120353884A_ABST
Patent Text Reader

Abstract

The invention provides a question answering method and device based on a large language model, equipment and a storage medium, the question answering method based on the large language model determines at least one candidate entity by obtaining a user question and performing entity extraction on the user question through a preset large language model, and is beneficial to improving accuracy; searching for the knowledge graph according to the candidate entities, matching with the candidate entities through the entity content library when a search result represents that a first target entity which is the same as the candidate entities does not exist, and matching with the candidate entities according to a user question and a triple vector library when a matching result represents that a second target entity corresponding to the candidate entities does not exist. The method comprises the steps of obtaining a user question, determining a target triple vector, obtaining a target answer according to the user question, the target triple vector and a preset large language model, and determining the target answer by using the preset large language model based on a matching mode of cascade connection of a knowledge graph, an entity content library and a triple vector library, thereby being beneficial to improving the reliability of the answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and particularly to a question-answering method, device, equipment, and storage medium based on a large language model. Background Art

[0002] Currently, most of the extraction technologies for the triples of the knowledge graph and the entities of the user's questions are based on traditional neural networks, such as UIE, etc., which require a large amount of data for training. At the same time, a separate model needs to be trained for each vertical domain, with poor generalization, and high costs for updating and maintaining the knowledge graph. At the same time, currently, the question-answering systems that implement automatic question answering generally rely on a knowledge graph or a question-answering library. The answers of both methods are fixed, so the answer results will appear very rigid, the answering effect is poor, and the user satisfaction is affected. Summary of the Invention

[0003] Embodiments of this application provide a question-answering method, device, equipment, and storage medium based on a large language model to solve at least one problem existing in the related technologies. The technical solutions are as follows:

[0004] In a first aspect, embodiments of this application provide a method for question-answering based on a large language model, including:

[0005] Obtain a user question, perform entity extraction on the user question through a preset large language model, and determine at least one candidate entity;

[0006] Search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the candidate entity with an entity content library;

[0007] When the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user question and a triple vector library, where the triple vector library includes a number of triple vectors, and the triple vectors are obtained by performing natural language processing on the triples in the knowledge graph;

[0008] Obtain a target answer according to the user question, the target triple vector, and the preset large language model.

[0009] In an implementation, the entity content library includes an entity library and an entity vector library. The matching of the candidate entity with the entity content library includes:

[0010] Compare the candidate entity with the entity aliases in the entity library to determine whether there is an entity alias identical to the candidate entity;

[0011] When there is no entity alias identical to the candidate entity, vectorize the candidate entity to obtain a candidate vector;

[0012] Calculate a first similarity based on the candidate vector and the entity vectors in the entity vector library. When the first similarity is less than the similarity threshold, obtain a matching result indicating that there is no second target entity corresponding to the candidate entity;

[0013] Among them, the entity library has at least one entity alias of the entities in the knowledge graph, and the entity vector library has entity vectors corresponding to the entities in the knowledge graph.

[0014] In one implementation, the method further includes:

[0015] When there is an entity alias identical to the candidate entity, determine a second target entity corresponding to the entity alias from the entity library;

[0016] Determine a target triple containing the second target entity from the knowledge graph according to the second target entity;

[0017] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and the preset large language model.

[0018] In one implementation, the method further includes:

[0019] When the first similarity is greater than or equal to the similarity threshold, determine the second target entity corresponding to the entity vector with the maximum first similarity;

[0020] Determine a target triple containing the second target entity from the knowledge graph according to the second target entity;

[0021] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and the preset large language model.

[0022] In one implementation, the determining the target triple vector according to the user question and the triple vector library includes:

[0023] Vectorize the user question to obtain a question vector;

[0024] Calculate a second similarity between the question vector and each triple vector;

[0025] Use the triple vector with the maximum second similarity as the target triple vector.

[0026] In one implementation, the preset large language model is obtained through the following steps:

[0027] Obtain business data;

[0028] Quantize the basic large language model through NormalFloat with a preset number of digits to obtain a quantized basic large language model;

[0029] Determine a first low-rank matrix and a second low-rank matrix with zero initialization, and fine-tune the quantized basic large language model according to the business data to obtain a preset large language model.

[0030] In one implementation, the determining the first low-rank matrix and the second low-rank matrix with zero initialization, and fine-tuning the quantized basic large language model according to the business data to obtain a preset large language model includes:

[0031] Determine the product of the first low-rank matrix and the second low-rank matrix;

[0032] Calculate the sum of the product and the quantized basic large language model;

[0033] Fine-tune the quantized basic large language model according to the Gaussian distribution formula, the sum, and the business data to obtain a preset large language model.

[0034] In a second aspect, an embodiment of the present application provides a question and answer device based on a large language model, including:

[0035] An acquisition module, configured to acquire a user question, perform entity extraction on the user question through a preset large language model, and determine at least one candidate entity;

[0036] A matching module, configured to search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the candidate entity with the entity content library;

[0037] A determination module, configured to when the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user question and a triple vector library, where the triple vector library includes a plurality of triple vectors, and the triple vector is obtained by performing natural language processing on the triples in the knowledge graph;

[0038] An answering module, configured to obtain a target answer according to the user question, the target triple vector, and the preset large language model.

[0039] In one implementation, the matching module is further configured to:

[0040] When there is an entity alias identical to the candidate entity, determine a second target entity corresponding to the entity alias from the entity library;

[0041] Determine a target triple containing the second target entity from the knowledge graph according to the second target entity;

[0042] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and the preset large language model.

[0043] In one implementation, the matching module is further configured to:

[0044] When the first similarity is greater than or equal to the similarity threshold, determine the second target entity corresponding to the entity vector with the maximum first similarity;

[0045] Determine a target triple containing the second target entity from the knowledge graph according to the second target entity;

[0046] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and the preset large language model.

[0047] In one implementation, the question-answering device based on the large language model further includes a fine-tuning module, and the fine-tuning module is configured to:

[0048] Obtain service data;

[0049] Perform quantization processing on the basic large language model through NormalFloat with a preset number of digits to obtain a quantized basic large language model;

[0050] Determine a first low-rank matrix and a second low-rank matrix with zero initialization, and fine-tune the quantized basic large language model according to the service data to obtain a preset large language model.

[0051] In a third aspect, an embodiment of the present application provides an electronic device, including: a processor and a memory, where instructions are stored in the memory, and the instructions are loaded and executed by the processor to implement the methods in any one of the above aspects.

[0052] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed, the methods in any one of the above aspects are implemented.

[0053] The beneficial effects in the above technical solutions at least include:

[0054] By obtaining the user's question, performing entity extraction on the user's question through a preset large language model to determine at least one candidate entity, which is beneficial to improving accuracy; searching the knowledge graph based on the candidate entity, when the search result indicates that there is no first target entity identical to the candidate entity, matching the entity content library with the candidate entity, when the matching result indicates that there is no second target entity corresponding to the candidate entity, determining the target triple vector according to the user's question and the triple vector library, and obtaining the target answer based on the user's question, the target triple vector, and the preset large language model. The cascaded matching method based on the knowledge graph, the entity content library, and the triple vector library and using the preset large language model to determine the target answer is beneficial to improving the reliability of the answer.

[0055] The above summary is only for the purpose of the specification and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the present application will be readily apparent by reference to the drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In the drawings, unless otherwise specified, the same reference numerals throughout the several views represent the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.

[0057] Figure 1 It is a schematic flowchart of the steps of a question-answering method based on a large language model according to an embodiment of the present application;

[0058] Figure 2 It is a storage schematic diagram after triple extraction according to an embodiment of the present application;

[0059] Figure 3 It is a structural block diagram of a question-answering device based on a large language model according to an embodiment of the present application;

[0060] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0061] In the following, only some exemplary embodiments are briefly described. As those skilled in the art can recognize, the described embodiments can be modified in various different ways without departing from the spirit or scope of the present application. Therefore, the drawings and the description are considered to be exemplary in nature and not restrictive.

[0062] Refer to Figure 1, showing a flowchart of a question - answering method based on a large - language model according to an embodiment of the present application. The question - answering method based on the large - language model may at least include steps S100 - S400:

[0063] S100. Obtain a user question, perform entity extraction on the user question through a preset large - language model, and determine at least one candidate entity.

[0064] S200. Search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the entity content library with the candidate entity.

[0065] S300. When the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user question and the triple vector library.

[0066] S400. Obtain a target answer according to the user question, the target triple vector, and the preset large - language model.

[0067] The question - answering method based on the large - language model in the embodiment of the present application can be executed by an electronic control unit, a controller, a processor, etc. of terminals such as a computer, a mobile phone, a tablet, a vehicle - mounted terminal, etc., or can also be executed by a cloud server.

[0068] The technical solution of the embodiment of the present application, by obtaining the user question, performing entity extraction on the user question through a preset large - language model to determine at least one candidate entity, is beneficial to improving the accuracy; searching the knowledge graph according to the candidate entity, when the search result indicates that there is no first target entity identical to the candidate entity, matching the entity content library with the candidate entity, when the matching result indicates that there is no second target entity corresponding to the candidate entity, determining the target triple vector according to the user question and the triple vector library, and obtaining the target answer according to the user question, the target triple vector, and the preset large - language model. The cascaded matching method based on the knowledge graph, the entity content library, and the triple vector library and using the preset large - language model to determine the target answer is beneficial to improving the reliability of the answer.

[0069] In one implementation manner, the user can input a user question, such as a question in a certain field / scenario. In the embodiment of the present application, the business scenario of a communication operator is taken as an example, which may involve content such as traffic, monthly rent, text messages, call duration, packages, etc.

[0070] In one implementation manner, input the user's question into the preset large - language model, and perform entity extraction on the user question through the preset large - language model to determine at least one candidate entity.

[0071] Optionally, the preset large - language model is obtained through the following steps S1 - S3:

[0072] S1. Obtain business data.

[0073] Optionally, taking the business scenario of a communication operator as an example, users can store business documents in the system, thereby obtaining business data related to the communication operator's business in the business documents; the business data can include triple data, named entity recognition data, question-and-answer data, and a small amount of pre-training data. Among them, the triple data is marked in the format of subject-predicate-object. These several data types can effectively improve the accuracy of the large language model in subsequent knowledge graph construction, entity library construction, and question-and-answer. The small amount of pre-training data is to prevent the model from losing its basic capabilities. As shown in Table 1, it is the input format of several data types in the business data. The pre-training data is randomly read from the public dataset in each training epoch, so it is not shown in the table.

[0074] Table 1 Fine-tuning data format

[0075]

[0076]

[0077] S2. Quantize the basic large language model through NormalFloat with a preset number of digits to obtain the quantized basic large language model.

[0078] Optionally, taking glm2 as the basic large language model, glm2 stacks 28 layers of transformer structures, and the input dimension of each layer of transformer is 4096. It should be noted that the large language model is a deep learning model that can understand and generate natural language. They are usually trained with a large amount of text data to learn the rules and structures of the language. The large language model can be applied to various natural language processing tasks, such as text classification, question-and-answer, dialogue, etc. And a key feature of it is that they can be pre-trained and fine-tuned. Pre-training means training the model on a large-scale general corpus to learn the general knowledge of the language, and fine-tuning means further training the model on a specific domain or task to meet specific needs. Therefore, in order to be applied to the business scenario of the communication operator, only the business data needs to be used for fine-tuning. Compared with the existing method of using traditional neural networks to extract triples, which requires a large amount of data for training and separate training models for each vertical domain, it is more convenient and has a low maintenance cost.

[0079] Optionally, fine-tune glm2 using the QLoRA method, which has a lower fine-tuning cost compared to LoRA. During fine-tuning, the base large language model is quantized using NormalFloat with a preset number of bits (including but not limited to 4 bits). For example, the glm2 parameters are quantized, and then the constants of the quantized parameters are quantized again to reduce the storage space during calculation, resulting in a quantized base large language model.

[0080] S3. Determine the first low-rank matrix and the second low-rank matrix with zero initialization, and fine-tune the quantized base large language model according to the business data to obtain a preset large language model.

[0081] Specifically, determine the product of the first low-rank matrix and the second low-rank matrix, calculate the sum of the product and the quantized base large language model, and fine-tune the quantized base large language model according to the Gaussian distribution formula, the sum, and the business data to obtain a preset large language model.

[0082] Optionally, determine the product AB of the first low-rank matrix A and the second low-rank matrix B with zero initialization, and calculate the sum of the product and the quantized base large language model W0: W0 + BA. According to the Gaussian distribution formula (1), the sum, and the business data x, fine-tune the quantized base large language model to obtain a preset large language model, where h is the output of the preset large language model obtained after fine-tuning. In the embodiments of the present application, by fine-tuning the low-rank matrices A and B using the backpropagation gradient of the quantized pre-trained model, the large language model can learn knowledge in the vertical domain, which can reduce the training cost.

[0083] h = (W0 + BA)x (1)

[0084] In one implementation, use the above fine-tuned large language model, i.e., the preset large language model, to process the triple business data to be extracted (such as entity extraction and named entity recognition), so as to determine the input triple and the category corresponding to its entity. In addition, the results extracted by the model are edited and confirmed by business personnel to improve the accuracy, and finally, the knowledge graph is constructed using the extracted content through neo4j. For example, the basic forms of triples mainly include head entity, relationship, tail entity, and concept, attribute, attribute value, etc. For example, (Enjoyment Card, monthly rent, 29 yuan) is a triple; named entity recognition refers to identifying entities with specific meanings in the text, mainly including person names, place names, organization names, proper nouns, etc. For example, in the sentence "AA is a kung fu star born in BB", the task of named entity recognition is to find that "AA" is a person name, "BB" is a place name, and "kung fu" is a proper noun.

[0085] In the embodiments of the present application, an entity content library and a triple vector library are provided. The entity content library includes an entity library and an entity vector library. Among them, the entities in the confirmed triples are stored in the entity library. In addition to the entities, the entity library also has at least one entity alias corresponding to the entity (such as synonyms and other words that have the same or similar meanings as the entity); using text2vec-large-chinese as the text vectorization model, the entities in the confirmed triples are converted into 1024-dimensional vectors and stored in the entity vector library. Therefore, the entity vector library includes several entity vectors, which are the entity vectors corresponding to the entities in the knowledge graph. In addition, each triple in the knowledge graph is subjected to natural language processing, including conversion into natural language and vectorization. For example, the triple (enjoyment card, monthly rent, 29 yuan) is converted into the natural language "The monthly rent of the enjoyment card is 29 yuan", and then the natural language "The monthly rent of the enjoyment card is 29 yuan" is vectorized and converted into an embedding, that is, a triple vector, and then stored in the triple vector library. Therefore, the triple vector library includes several triple vectors. Such a storage method is to better utilize the knowledge graph, such as Figure 2 The figure shows a storage schematic diagram after triple extraction.

[0086] In one implementation, in step S200, after determining the candidate entity, the knowledge graph is searched according to the candidate entity to determine the search result. If the search result indicates the existence of a first target entity that is the same as the candidate entity, at this time, all the triples in the knowledge graph that contain the first target entity can be determined, and then these triples are concatenated into natural language, and then the natural language and the user question are input into a preset large language model to obtain the target answer. When the search result indicates the non-existence of a first target entity that is the same as the candidate entity, the entity content library is matched with the candidate entity.

[0087] In one implementation, the matching of the entity content library with the candidate entity in step S200 includes steps S210 - S230:

[0088] S210. Compare the candidate entity with the entity aliases in the entity library to determine whether there is an entity alias that is the same as the candidate entity.

[0089] Optionally, when the search result indicates the non-existence of a first target entity that is the same as the candidate entity, first, the candidate entity is compared with the entity aliases in the entity library to determine whether there is an entity alias that is the same as the candidate entity.

[0090] S220. When there is no entity alias that is the same as the candidate entity, perform vectorization processing on the candidate entity to obtain a candidate vector.

[0091] In the embodiments of the present application, when there is no entity alias identical to the candidate entity, the candidate entity is vectorized through a text vectorization model to obtain a candidate vector.

[0092] S230. Calculate a first similarity based on the candidate vector and the entity vectors in the entity vector library. When the first similarity is less than the similarity threshold, obtain a matching result indicating that there is no second target entity corresponding to the candidate entity.

[0093] In the embodiments of the present application, calculate the first similarity between the candidate vector and each entity vector in the entity vector library. When the first similarity is less than the similarity threshold, obtain a matching result indicating that there is no second target entity corresponding to the candidate entity.

[0094] It can be understood that if the first similarity is greater than or equal to the similarity threshold, then determine the second target entity corresponding to the entity vector with the maximum first similarity, and then determine the target triple (which can be one or more) containing the second target entity from the knowledge graph. Finally, splice the target triple into natural language, and according to the natural language, the user question, and the preset large language model, obtain the target answer. For example, input the natural language and the user question into the preset large language model to obtain the target answer.

[0095] It can be understood that if there is an entity alias identical to the candidate entity, determine the second target entity corresponding to the entity alias from the entity library, determine the target triple (which can be one or more) containing the second target entity from the knowledge graph according to the second target entity, and splice the target triple into natural language. Then, according to the natural language, the user question, and the preset large language model, obtain the target answer. For example, input the natural language and the user question into the preset large language model to obtain the target answer.

[0096] In one implementation, in step S300, determining the target triple vector according to the user question and the triple vector library includes steps S310 - S330:

[0097] S310. Vectorize the user question to obtain a question vector.

[0098] Optionally, vectorize the user question through a text vectorization model to obtain the embedding of the user question, that is, the question vector.

[0099] S320. Calculate the second similarity between the question vector and each triple vector.

[0100] S330. Use the triple vector with the maximum second similarity as the target triple vector.

[0101] In the embodiments of the present application, the triple vector with the second largest similarity is used as the target triple vector.

[0102] In the embodiments of the present application, in step S400, after determining the target triple vector, the target triple vector is converted into the corresponding natural language, and then the user question and the natural language are input into a preset large language model, and the preset large language model organizes the language to answer the question, and finally the target answer is obtained.

[0103] Through the method of the embodiments of the present application, at least the following effects can be achieved:

[0104] 1) Cooperate with the front end, use the preset large language model to extract triples from business documents, and let business personnel edit and confirm them, improving the efficiency of knowledge graph construction; at the same time, the front-end page also supports one-key fine-tuning, and entity aliases can be added to the front-end page. The confirmed triples can be used as training data again to continuously iterate and optimize the generalization ability of the preset large language model in this business scenario;

[0105] 2) Compared with using traditional neural networks to extract triples, a large amount of data is required for training, and a separate model needs to be trained for each vertical domain. The embodiments of the present application use business data to fine-tune a basic large language model with general generalization ability, and can extract triples with high efficiency without a large amount of manual annotation, which can reduce the training cost, improve the generalization ability, and reduce the cost of entity extraction and knowledge graph update and maintenance;

[0106] 3) Use the knowledge graph and the preset large language model to build a question answering system, inject the knowledge graph into the preset large language model. Compared with traditional answering based on the knowledge graph or the question answering library and answering only based on the large language model, it not only ensures the accuracy and reliability of the answer, but also improves the fluency of the answer, which is beneficial to avoiding rigid answers;

[0107] 4) A cascaded matching method based on the knowledge graph, the entity content library (including the entity library and the entity vector library), and the triple vector library is proposed, and a preset large language model is used to determine the target answer, which is beneficial to improving the reliability of the answer, fully using the storage method to match with the question, and strengthening the reliability during answering.

[0108] 5) The business data for fine-tuning includes triple extraction data, named entity recognition data, and conventional data during pre-training, which can not only improve the ability of the large language model in the vertical domain, but also prevent the model from losing its basic ability;

[0109] Referring to Figure 3 , a structural block diagram of a question answering device based on a large language model according to an embodiment of the present application is shown. The device may include:

[0110] An acquisition module, configured to acquire a user question, perform entity extraction on the user question through a preset large language model, and determine at least one candidate entity;

[0111] A matching module, configured to search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the candidate entity with an entity content library;

[0112] A determination module, configured to, when the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user question and a triple vector library. The triple vector library includes a plurality of triple vectors, and the triple vectors are obtained by performing natural language processing on the triples in the knowledge graph;

[0113] An answering module, configured to obtain a target answer according to the user question, the target triple vector, and a preset large language model.

[0114] In one implementation, the matching module is further configured to:

[0115] When there is an entity alias identical to the candidate entity, determine a second target entity corresponding to the entity alias from an entity library;

[0116] Determine a target triple including the second target entity from the knowledge graph according to the second target entity;

[0117] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and a preset large language model.

[0118] In one implementation, the matching module is further configured to:

[0119] When the first similarity is greater than or equal to a similarity threshold, determine the second target entity corresponding to the entity vector with the largest first similarity;

[0120] Determine a target triple including the second target entity from the knowledge graph according to the second target entity;

[0121] Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user question, and a preset large language model.

[0122] In one implementation, the question and answer device based on a large language model further includes a fine-tuning module, and the fine-tuning module is configured to:

[0123] Acquire service data;

[0124] Perform quantization processing on a base large language model through a NormalFloat with a preset number of digits to obtain a quantized base large language model;

[0125] Determine the first low-rank matrix and the second low-rank matrix for zero initialization, and fine-tune the quantized large language model according to business data to obtain a preset large language model.

[0126] For the functions of each module in each device of the embodiments of the present application, reference may be made to the corresponding descriptions in the above methods, which will not be elaborated herein.

[0127] Refer to Figure 4 , which shows a structural block diagram of an electronic device according to an embodiment of the present application. The electronic device includes: a memory 310 and a processor 320. Instructions that can run on the processor 320 are stored in the memory 310. The processor 320 loads and executes the instructions to implement the question-answering method based on the large language model in the above embodiments. Among them, the number of the memory 310 and the processor 320 can be one or more.

[0128] In one implementation, the electronic device further includes a communication interface 330 for communicating with external devices and performing data interaction and transmission. If the memory 310, the processor 320, and the communication interface 330 are implemented independently, the memory 310, the processor 320, and the communication interface 330 can be interconnected through a bus and complete communication with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 4 only a thick line is shown in

[0129] but it does not mean that there is only one bus or one type of bus.

[0130] The embodiments of the present application provide a computer-readable storage medium that stores a computer program. When the computer program is executed by a processor, it implements the question-answering method based on the large language model provided in the above embodiments.

[0131] The embodiments of the present application also provide a chip that includes a processor for calling and running instructions stored in a memory from the memory, so that a communication device installed with the chip executes the method provided by the embodiments of the present application.

[0132] An embodiment of the present application further provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is configured to execute the code in the memory. When the code is executed, the processor is configured to execute the method provided by the embodiment of the application.

[0133] It should be understood that the above-mentioned processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor that supports the advanced RISC machines (ARM) architecture.

[0134] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may further include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus random access memory (DR RAM).

[0135] In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present application are 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.

[0136] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples.

[0137] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of these features. In the description of the present application, "a plurality of" means two or more unless otherwise specifically defined.

[0138] Any process or method description represented in a flowchart or otherwise described herein may be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a specific logical function or process. And the scope of the preferred embodiments of the present application includes additional implementations, where the functions may be performed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed.

[0139] The logic and / or steps represented in a flowchart or otherwise described herein, for example, may be considered as a sequenced list of executable instructions for implementing a logical function and may be specifically implemented in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device.

[0140] It should be understood that the various parts of the present application may be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods may be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the method in the above embodiments may be completed by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0141] In addition, each functional unit in various embodiments of the present application may be integrated into a processing module, or each unit may exist physically alone, or two or more units may be integrated into one module. The above integrated module may be implemented in the form of hardware or in the form of a software functional module. If the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic disk, an optical disc, or the like.

[0142] As described above, the above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of various changes or substitutions, and these should all be covered by the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims

1. A question-answering method based on large language models, characterized in that, Including: Obtain a user's question, perform entity extraction on the user's question through a preset large language model, and determine at least one candidate entity; Search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the candidate entity with the entity content library; When the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user's question and the triple vector library. The triple vector library includes a number of triple vectors, and the triple vectors are obtained by performing natural language processing on the triples in the knowledge graph; Obtain a target answer according to the user's question, the target triple vector, and the preset large language model.

2. The question-answering method based on a large language model according to claim 1, wherein: The entity content library includes an entity library and an entity vector library. The matching of the candidate entity with the entity content library includes: Compare the candidate entity with the entity aliases in the entity library to determine whether there is an entity alias identical to the candidate entity; When there is no entity alias identical to the candidate entity, perform vectorization processing on the candidate entity to obtain a candidate vector; Calculate a first similarity according to the candidate vector and the entity vectors in the entity vector library. When the first similarity is less than the similarity threshold, obtain a matching result indicating that there is no second target entity corresponding to the candidate entity; Wherein, the entity library has at least one entity alias of the entities in the knowledge graph, and the entity vector library has entity vectors corresponding to the entities in the knowledge graph.

3. The question-answering method based on a large language model according to claim 2, wherein: The method further includes: When there is an entity alias identical to the candidate entity, determine a second target entity corresponding to the entity alias from the entity library; Determine a target triple containing the second target entity from the knowledge graph according to the second target entity; Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user's question, and the preset large language model.

4. The question-answering method based on a large language model according to claim 2, wherein: The method further includes: When the first similarity is greater than or equal to the similarity threshold, determine the second target entity corresponding to the entity vector with the maximum first similarity; Determine a target triple containing the second target entity from the knowledge graph according to the second target entity; Concatenate the target triple into natural language, and obtain a target answer according to the natural language, the user's question, and the preset large language model.

5. The question-answering method based on a large language model according to any one of claims 1-4, characterized in that: The determining of the target triple vector according to the user's question and the triple vector library includes: Vectorize the user's question to obtain a question vector; Calculate a second similarity between the question vector and each triple vector; Take the triple vector with the maximum second similarity as the target triple vector.

6. The question-answering method based on a large language model according to any one of claims 1-4, characterized in that: The preset large language model is obtained through the following steps: Obtain business data; Perform quantization processing on the basic large language model through NormalFloat with a preset number of digits to obtain a quantized basic large language model; Determine the first low-rank matrix and the second low-rank matrix with zero initialization, and fine-tune the quantized basic large language model according to the service data to obtain a preset large language model.

7. The question-answering method based on a large language model according to claim 6, wherein: The determining the first low-rank matrix and the second low-rank matrix with zero initialization, and fine-tuning the quantized basic large language model according to the service data to obtain a preset large language model includes: Determine the product of the first low-rank matrix and the second low-rank matrix; Calculate the sum of the product and the quantized basic large language model; Fine-tune the quantized basic large language model according to the Gaussian distribution formula, the sum, and the service data to obtain a preset large language model.

8. A question and answer device based on a large language model, characterized in that, Includes: An acquisition module, configured to acquire a user question, perform entity extraction on the user question through a preset large language model, and determine at least one candidate entity; A matching module, configured to search the knowledge graph according to the candidate entity. When the search result indicates that there is no first target entity identical to the candidate entity, match the candidate entity with the entity content library; A determination module, configured to when the matching result indicates that there is no second target entity corresponding to the candidate entity, determine a target triple vector according to the user question and the triple vector library, where the triple vector library includes a plurality of triple vectors, and the triple vectors are obtained by performing natural language processing on the triples in the knowledge graph; An answering module, configured to obtain a target answer according to the user question, the target triple vector, and the preset large language model.

9. An electronic device, characterized in that, Includes: A processor and a memory, where instructions are stored in the memory, and the instructions are loaded and executed by the processor to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, in which a computer program is stored, and when the computer program is executed, the method according to any one of claims 1-7 is implemented.