A large model output generation method, medium and device based on external knowledge
Through matching with external knowledge base and confidence judgment, the problem of inaccurate output of large language models in vertical fields is solved, and the accuracy and applicability of the output are improved.
Patent Information
- Application Number
- CN202410962991.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Large language models may be inaccurate, self-contradictory, or inconsistent with input information when generating text, especially in vertical fields with high accuracy requirements, affecting users' accurate acquisition of professional domain knowledge.
Using a large model output generation method based on external knowledge, by matching the initial input with multiple categories of external knowledge bases in the target field, using the target similarity calculation model to generate sentence vectors, sorting and splicing question and answer reference information, and deciding to load the input based on confidence to generate output in a specialized or general-purpose large language model.
It improves the output accuracy of large language models in vertical fields with high accuracy requirements, overcomes the "illusion" problem, and ensures the accurate acquisition of professional domain knowledge.
Smart Images

Figure CN118503433B
Abstract
Description
Background Art
[0002] Large Language Models (LLMs) have shown extensive application potential in many fields due to their powerful language understanding and generation capabilities. The "hallucination" problem of large language models refers to the phenomenon that these models may be inaccurate, self-contradictory, or inconsistent with the input information when generating text. Although large language models (LLMs) have demonstrated excellent capabilities in many natural language processing tasks, such as language understanding, text generation, question-answering systems, etc., they sometimes generate content that seems reasonable but is actually wrong or irrelevant. This phenomenon is called "hallucination". The reasons for hallucinations include: the model training data may not be sufficient to cover all knowledge areas or there are biases; the model may over-generalize the patterns learned from the training data, resulting in incorrect application in new situations; the model cannot obtain the latest information in real time, so it may generate outdated or wrong content; the pursuit of the best probability of predicting the next word may sacrifice global logical consistency or factual accuracy, etc.
[0003] Currently, large language models are used in some professional application scenarios to provide more accurate and diverse business services. In order to meet the ability to answer professional and non-professional questions, existing application scenarios usually integrate both general large language models and special large language models. In some general scenarios with low answer accuracy requirements (such as story writing scenarios), the "hallucination" problem of large language models has little impact. However, in some vertical field scenarios with higher accuracy requirements (such as medical, financial, civil aviation, etc.), users usually need the model to output more accurate and correct domain expertise to solve the corresponding problems. In the existing technology, due to the "hallucination" problem of large language models, it will affect the user's accurate acquisition of professional knowledge, making it unable to be better applied to vertical fields with higher accuracy requirements. Summary of the invention
[0004] In view of the above technical problems, the technical solution adopted by the present invention is:
[0005] According to one aspect of the present invention, a method for generating a large model output based on external knowledge is provided, the method comprising the following steps:
[0006] Use the initial input to match with multiple categories of external knowledge bases in the target domain to recall the question and answer reference records corresponding to the multiple categories of external knowledge bases; the question and answer reference records include: question and answer reference information and confidence; the external knowledge base includes a long text knowledge base, a short text knowledge base, a structured data knowledge base and an intent knowledge base;
[0007] Use the target similarity calculation model to generate the similarity between the initial input and the sentence vector corresponding to each question and answer reference information; the target similarity calculation model is a RoBERTa model trained based on the SimCSE framework using the corpus corresponding to the target domain;
[0008] Sort and concatenate multiple question-answer reference information in descending order of similarity to generate initial reference information;
[0009] After splicing the initial input and the initial reference information, a first target input is generated;
[0010] If any of the confidences corresponding to multiple question-and-answer reference information is greater than the confidence threshold of the corresponding category, the first target input is loaded into the dedicated large language model corresponding to the target domain to generate the corresponding output; the dedicated large language model is obtained by training the general large language model using the corpus corresponding to the target domain.
[0011] According to a second aspect of the present invention, there is provided a non-transitory computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-mentioned method for generating a large model output based on external knowledge.
[0012] According to a third aspect of the present invention, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for generating a large model output based on external knowledge when executing the computer program.
[0013] The present invention has at least the following beneficial effects:
[0014] First, the initial input is used to match various types of knowledge bases in the corresponding target field. Since the information in the corresponding knowledge base is all processed standardized information, the question and answer reference information in the various question and answer reference records recalled is the standard information with a higher relevance to the information that the user wants to ask for in the initial input. At the same time, the present invention is also provided with a long text knowledge base, a short text knowledge base, a structured data knowledge base and an intention knowledge base, so that various forms of prior knowledge in the target field can be sorted and stored in the corresponding knowledge base, thereby further ensuring the completeness of the knowledge. In addition, the multiple recalled question and answer reference information will be sorted in order according to the similarity between the multiple recalled question and answer reference information and the initial input, and then spliced with the initial input to form a prompt information text in the Prompt project with a higher relevance and high quality. The prompt information is used to clarify the task requirements, constraints or expected answer formats, so as to guide large language models (LLMs) to generate high-quality text outputs that meet specific requirements and expectations, thereby further overcoming the probability of "hallucination" in large language models.
[0015] In addition, the general large language model is usually more prone to "hallucination" problems than the special large language model when answering questions in the corresponding field. Therefore, in the present invention, when generating the recall results corresponding to each type of knowledge, the corresponding confidence is also generated, which indicates the degree of match between the initial input and the recall result. Then, according to the relationship between the confidence of each type of result and the corresponding threshold, it is determined whether to load the first target input into the special large language model or the general large language model. Since the recall results are all professional and accurate prior knowledge in some corresponding fields, the higher the corresponding confidence, the closer the answer that the initial input wants to obtain is to professional and accurate information. That is, it is necessary to overcome the model "hallucination" problem more effectively. Therefore, in the present invention, if there is any confidence greater than the confidence threshold of the corresponding category, the first target input is loaded into the special large language model, and then the special large language model can be used to generate a more accurate output with a higher understanding ability of the target field, so as to further overcome the "hallucination" problem of the large language model and improve its applicability in vertical fields with higher accuracy requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1A flowchart of a method for generating a large model output based on external knowledge provided by an embodiment of the present invention;
[0018] Figure 2 A flowchart of a method for generating a large model output based on fusion information is provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0020] As a possible implementation mode of the present invention, Figure 1 As shown, a method for generating a large model output based on external knowledge is provided, and the method comprises the following steps:
[0021] S100: Use the initial input to match with multiple categories of external knowledge bases in the target field to recall the question and answer reference records corresponding to the multiple categories of external knowledge bases. The question and answer reference record includes: question and answer reference information and confidence. The external knowledge base includes a long text knowledge base, a short text knowledge base, a structured data knowledge base and an intention knowledge base. Specifically, the target field in this embodiment can be the civil aviation field. The long text knowledge base can be an existing long document text in the civil aviation field.
[0022] The short text knowledge base can be the question-answer knowledge in the field of civil aviation. The structured data knowledge base can be the existing knowledge graph in the field of civil aviation.
[0023] Specifically, the initial input (i.e., query) can be matched with the professional prior knowledge in the civil aviation field in the long text knowledge base, short text knowledge base, structured data knowledge base, and intent knowledge base respectively in the following way:
[0024] When the external knowledge base is a short text knowledge base.
[0025] Use the initial input to match against multiple categories of external knowledge bases, including:
[0026] S110: Obtain the first similarity between the sentence vector corresponding to the initial input and the sentence vector corresponding to each question-answer pair in the short text knowledge base by sentence vector retrieval. The sentence vector is obtained by a RoBERTa model trained with the corresponding corpus of the target domain based on the SimCSE framework.
[0027] S111: taking each question-answer pair corresponding to a first similarity greater than a first similarity threshold and the corresponding first similarity as recalled question-answer reference information and the corresponding confidence level, respectively.
[0028] The model trained on civil aviation corpus using the RoBERTa model based on the SimCSE framework can be used to generate sentence vectors for text and compare their similarities. SimCSE is an unsupervised sentence representation learning method that mainly constructs positive and negative sample pairs of sentences and uses the output of BERT-like models to learn better sentence representations through comparative learning.
[0029] In the above manner, the initial input of the comparison calculation can be matched with the question-answer pairs in the short text knowledge base to select one or more recall results. When filtering the recall results, the top few in the familiarity ranking can be selected, or the similarity threshold can be used for filtering.
[0030] When the external knowledge base is a long text knowledge base.
[0031] Use the initial input to match against multiple categories of external knowledge bases, including:
[0032] S120: Based on the BM25 algorithm, keyword matching is performed between the initial input and each text in the long text knowledge base to generate a second similarity corresponding to each text in the long text knowledge base.
[0033] S121: taking each text corresponding to a second similarity greater than a second similarity threshold and the corresponding second similarity as recalled question and answer reference information and the corresponding confidence level, respectively.
[0034] In this embodiment, the initial input is matched with the long document through ES (Elasticsearch). Elasticsearch is an open source search engine that is built on the Lucene library and provides a distributed, RESTful-style full-text search engine. In Elasticsearch, "matching" is a core concept in the query process, which involves how to find documents that match the user's query conditions from the index.
[0035] This step is specifically about keyword matching based on the BM25 algorithm, which is a relevance scoring method widely used in the field of information retrieval and text mining, and is used to evaluate the matching degree between keywords in the query and the document. The BM25 algorithm is an improvement on the classic TF-IDF model. It not only considers term frequency (TF) and inverse document frequency (IDF), but also introduces factors such as document length normalization and query frequency, so as to more accurately reflect the importance of keywords in the document and improve the matching accuracy.
[0036] When the external knowledge base is a structured data knowledge base.
[0037] Use the initial input to match against multiple categories of external knowledge bases, including:
[0038] S130: Based on KB-QA, extract key entities from the initial input, determine the corresponding relationship between the key entities and entities in the structured data knowledge base, and generate target entity information.
[0039] S131: Use the target entity information as the recalled question and answer reference information.
[0040] S132: extracting the similarity between the key entity and the target entity information from the initial input as the corresponding confidence level.
[0041] Since the structured data in this embodiment is a knowledge graph in the corresponding field, the KB-QA (knowledge base question answering) method can be used to perform entity recognition matching and entity similarity calculation to determine the recall result.
[0042] In this embodiment, the matching of the structured knowledge base in S130-S132 may specifically be:
[0043] Entity Recognition: Named Entity Recognition (NER) technology is used to identify entities with specific meanings from user questions (i.e. initial input), such as names, places, times, etc. This can be achieved through pre-trained models such as BERT, which can understand the context and accurately annotate entity types and boundaries.
[0044] Entity Linking: Mapping the identified entities to entities in the knowledge base. This step involves finding the entries in the knowledge base that best match the entity mentioned in the question, usually by calculating the similarity between the entities.
[0045] Entity similarity calculation: By comparing the entity representation in the question with the description of the entity in the knowledge base, the similarity between them is calculated. Common methods include: Similarity calculation based on pre-trained models: such as SimBERT, BGE, GTE, etc. These models can represent entities as high-dimensional vectors, and then evaluate the similarity between entities by calculating the cosine similarity or other similarity metrics between vectors. Methods based on semantic distance: Iterative alignment strategy, calculating semantic distance through the generative model of the joint vector, such as the distance defined by the energy function. Rule-based and pattern matching: In some cases, pre-defined rules or patterns can also be used to directly match entities.
[0046] When the external knowledge base is an intention knowledge base.
[0047] Using the initial input to match with multiple categories of external knowledge bases respectively, including: using the intention recognition data processing system with patent number: ZL202110934400.X to perform matching calculations. The question and answer reference information in this embodiment can be the intention recognition result generated by the intention classification model; the confidence in this embodiment is the confidence generated by the intention classification model.
[0048] After the matching operation in S100, if the question entered by the user is a question that requires accurate answers to professional domain knowledge, there will usually be at least one recall result with a high confidence level. At this point, the recall result can be used to generate a corresponding prompt (i.e., the content in the subsequent S200-S500 steps) so that the professional large language model can better understand the question and accurately output the answer.
[0049] If no question-and-answer reference information is matched after the matching operation of S100 (that is, the recall result is an empty set), it indicates that the question input by the user is most likely not a question that requires accurate answers to professional domain knowledge. At this time, the initial input can be directly loaded into the general large language model according to the method of S101 below to generate the corresponding output.
[0050] S101: If the question-answer reference information is not matched, the initial input is loaded into the general large language model to generate the corresponding output.
[0051] S200: Generate similarities between the initial input and the sentence vectors corresponding to each question and answer reference information using a target similarity calculation model. The target similarity calculation model is a RoBERTa model trained using corpus corresponding to the target domain based on the SimCSE framework.
[0052] S300: sorting and concatenating multiple question-answer reference information in descending order of similarity to generate initial reference information.
[0053] Step S200 is used to recalculate the similarity between each recall result and the initial input, thereby laying the foundation for the subsequent splicing and sorting. S300 sorts all the recall results and generates the prompt of the initial input. The more effective references in the prompt are placed in a more forward position, which can facilitate the large language model to better refer to and generate a more accurate answer.
[0054] S400: After splicing the initial input and the initial reference information, a first target input is generated.
[0055] The first target input generated is the input with a prompt, for example, the question information (that is, the initial input) entered by the user is: What kind of flight is more likely to take a shuttle bus. The corresponding multiple references are sorted by similarity as follows:
[0056] Reference 1: Q: How to check whether a flight requires a shuttle bus? A: You can check whether a flight requires a shuttle bus on the airline app. After opening the app, if there is a shuttle bus logo in the lower right corner of the ticket page, it means that there will be a shuttle bus to pick you up. The shuttle bus is a means of transportation that connects the airport terminal and the remote aircraft. If the aircraft is parked at a remote aircraft position, the shuttle bus will be needed to transport passengers to the aircraft.
[0057] Reference 2: Q: How to check whether a flight requires a shuttle bus. A: You can check whether a flight requires a shuttle bus on the xxxx app. After opening the app, if there is a shuttle bus logo in the lower right corner of the ticket page, it means that there will be a shuttle bus to pick you up. The shuttle bus is a means of transportation that connects the airport terminal and the remote aircraft. If the aircraft is parked at a remote aircraft position, the shuttle bus will be needed to transport passengers to the aircraft.
[0058] Reference 3: Flights that arrive before 22:00 but take off after 10:00 the next morning generally use shuttle buses. This is because these flights will occupy the jet bridge for a long time, which may affect the on-time arrival of flights during the morning rush hour of the next day.
[0059] The first target input generated based on the above information is as follows:
[0060] Answer the questions according to the reference answers provided below: Reference 1: Q: How to check whether a flight requires a shuttle bus. A: You can check whether a flight requires a shuttle bus on the flight xxx app. After opening the APP, if there is a shuttle bus logo in the lower right corner of the ticket page, it means that there will be a shuttle bus to pick up. The shuttle bus is a means of transportation connecting the airport terminal and the remote aircraft. If the aircraft stays at a remote aircraft position, the shuttle bus will be needed to transport passengers to the aircraft. Reference 2: Q: How to check whether a flight requires a shuttle bus. A: You can check whether a flight requires a shuttle bus on the xxxx app. After opening the APP, if there is a shuttle bus logo in the lower right corner of the ticket page, it means that there will be a shuttle bus to pick up. The shuttle bus is a means of transportation connecting the airport terminal and the remote aircraft. If the aircraft stays at a remote aircraft position, the shuttle bus will be needed to transport passengers to the aircraft. Reference 3: Flights that arrive before 22:00 but take off after 10:00 am the next day generally use shuttle buses. Because these flights will occupy the jet bridge for a long time, it may affect the on-time arrival of flights during the next morning rush hour. Question: What kind of flights are more likely to take the shuttle bus?
[0061] S500: If any confidence level among the confidence levels corresponding to the plurality of question-answer reference information is greater than the confidence level threshold of the corresponding category, the first target input is loaded into the dedicated large language model corresponding to the target domain to generate a corresponding output. The dedicated large language model is obtained by training the general large language model using the corpus corresponding to the target domain.
[0062] S600: If each of the confidences corresponding to the plurality of question-answer reference information is less than or equal to the confidence threshold of the corresponding category, the first target input is loaded into the general large language model to generate a corresponding output.
[0063] In this embodiment, the confidence thresholds include confidence thresholds corresponding to the long text knowledge base, the short text knowledge base, the structured data knowledge base and the intent knowledge base, respectively. The thresholds can be determined based on what setting values are used in the actual use process to make the results output by the large language model more accurate.
[0064] In this embodiment, the relationship between the confidence level of each type of result and the corresponding threshold value is used to determine whether the first target input should be loaded into a dedicated large language model or a general large language model. Since the recall results are all professional and accurate prior knowledge in some corresponding fields, the higher the corresponding confidence level, the closer the answer the initial input wants to obtain is to professional and accurate information. That is, it is necessary to overcome the "hallucination" problem of the model more effectively. Therefore, in the present invention, if there is any confidence level greater than the confidence threshold of the corresponding category, the first target input will be loaded into a dedicated large language model, and then the dedicated large language model can be used to generate a more accurate output with a higher understanding of the target field, so as to further overcome the "hallucination" problem of the large language model and improve its applicability in vertical fields with higher accuracy requirements.
[0065] As another possible embodiment of the present invention, Figure 2 As shown, a method for generating a large model output based on fusion information is also provided, and the method comprises the following steps:
[0066] W100: Use the initial input to match multiple categories of external knowledge bases in the target domain to recall the question and answer reference records corresponding to multiple categories of external knowledge bases. The question and answer reference records include: question and answer reference information and confidence. The external knowledge base includes long text knowledge base, short text knowledge base, structured data knowledge base and intent knowledge base.
[0067] Specifically, the target field in this embodiment is also the civil aviation field. The specific implementation method of W100 is the same as the implementation method of S100 described above. In addition, when establishing an external knowledge base, it is possible to determine in advance whether to set an itinerary query mark for the corresponding question and answer reference record based on the collected relevant reference information and whether it is necessary to refer to the user's itinerary information to more accurately and appropriately output the standard. The itinerary query mark indicates the content of the answer part in the question and answer reference information in the corresponding question and answer reference record, which is related to the value corresponding to at least one field in the user's itinerary information. Usually, an itinerary query mark is added to some question and answer reference information that involves the need to use user itinerary information to further determine the output content. As in the following reference:
[0068] The question in the Q&A reference information is: Is there any compensation for flight delays or cancellations?
[0069] The answer in the Q&A reference information is as follows: (1) If a flight is delayed or cancelled at the departure airport due to the airline's own reasons such as maintenance, flight scheduling, crew, etc., the airline will provide passengers with services such as meals or accommodation.
[0070] (2) If a flight is delayed or cancelled at the departure airport due to weather, emergencies, air traffic control, security checks or passengers, the carrier shall assist the passengers in arranging meals and accommodation at the passengers’ own expense.
[0071] (3) If a domestic flight is delayed or cancelled at a stopover point, the carrier shall provide meals or accommodation services to the stopover passengers regardless of the reason.
[0072] It can be seen from the above question and answer reference information example that when answering the corresponding question, if more accurate user itinerary information can be provided, the large language model can combine the itinerary information to output an answer that is more relevant to the user's itinerary, rather than just outputting the judgment rules provided in the answer part of the question and answer reference information.
[0073] W200: If any question-and-answer reference record also includes a travel query tag, the travel information of the user corresponding to the initial input is obtained.
[0074] Specifically, the itinerary information includes multiple fields, such as flight number, departure place, destination, take-off time, arrival time, cabin type, seat number, boarding gate, meals, baggage and other information.
[0075] W300: Generate the similarity between the initial input and the sentence vector corresponding to each question and answer reference information using the target similarity calculation model. The target similarity calculation model is a RoBERTa model trained based on the SimCSE framework using the corpus corresponding to the target domain.
[0076] W400: Sort and concatenate multiple question-answer reference information in descending order of similarity to generate initial reference information.
[0077] The specific implementation of W300 and W400 in this embodiment is the same as the implementation of S200 and S300 described above, and will not be repeated here.
[0078] W500: Concatenate the trip information with the initial reference information to generate secondary reference information.
[0079] When the itinerary information is spliced with the initial reference information, there is no restriction on the splicing position of the reference information, and it can usually be directly spliced at the head or tail of the initial reference information or behind the question and answer reference information with the itinerary query mark.
[0080] However, in order to make the itinerary information more effective, the more important fields in the information will be placed at the front of the itinerary information. For example, the content expressed by the flight number, seat number, departure place, destination, departure time and other fields is more important than the content expressed by the baggage and meals fields. Therefore, they will be placed at the front.
[0081] Specifically, the arrangement order of the fields in the itinerary information can be determined as follows:
[0082] First:
[0083] W501: Generate the field priority of each field according to the importance of each field to the itinerary in the civil aviation field. The importance can be determined by the technicians in this field.
[0084] W502: Sort each field in descending order of field priority to generate a second-trip field sequence.
[0085] W503: According to the second itinerary field sequence, obtain the itinerary information of the user corresponding to the initial input.
[0086] Second:
[0087] W510: Generate the field priority corresponding to each type of question and answer reference information based on the relevance of each field to the answer part of each type of question and answer reference information.
[0088] W511: Sort each field in descending order of field priority to generate a first trip field sequence corresponding to each type of question and answer reference information.
[0089] W512: According to the first itinerary field sequence corresponding to each type of question and answer reference information, obtain the itinerary information of the user corresponding to the initial input of the corresponding type.
[0090] In this method, a first itinerary field sequence with different field orderings is designed according to the type of question, thereby providing more targeted itinerary information for each type of question in a more detailed and accurate manner.
[0091] W600: After concatenating the initial input and the secondary reference information, a second target input is generated.
[0092] W600 forms a new input by combining the Prompt information formed by the secondary reference information with the initial input (ie, qes).
[0093] Specifically, an example of the generated second target input is as follows:
[0094] I am a citizen of a certain country. For me, China is a certain country. The itinerary information of my most recent flight is as follows: {info} Reference answer: {wenwen_res} Please answer the following questions based on the reference answer and my itinerary information: {qes}, please write based on your itinerary information in your answer, do not write based on the reference answer.
[0095] Among them, {info} is the trip information, {wenwen_res} is the initial reference information, and {qes} is the initial input.
[0096] W700: Load the second target input into the dedicated large language model corresponding to the target domain to generate a corresponding output. The dedicated large language model is obtained by training the general large language model using the corpus corresponding to the target domain.
[0097] Usually, if the recalled record contains itinerary query information, it indicates that the user needs a more accurate answer. Therefore, in this embodiment, whether the recall result carries a itinerary query mark is used to directly determine whether the first target input is loaded into a dedicated large language model or a general large language model. Because the itinerary query mark is used to indicate that the content of the recall result is related to the user's itinerary information. Therefore, according to the itinerary query mark, it can be determined that the answer that the initial input wants to obtain is also closer to professional and accurate information. That is, it is necessary to overcome the model "hallucination" problem more effectively. In addition, a dedicated large language model can be used to generate more accurate outputs with a higher understanding of the target field, so as to further overcome the "hallucination" problem of the large language model and improve its applicability in vertical fields with higher accuracy requirements.
[0098] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0099] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by combining software with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0100] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0101] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0102] The electronic device according to this embodiment of the present invention is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0103] The electronic device is presented in the form of a general-purpose computing device. The components of the electronic device may include, but are not limited to: the at least one processor mentioned above, the at least one storage device mentioned above, and a bus connecting different system components (including storage devices and processors).
[0104] The storage stores program codes, which can be executed by the processor, so that the processor executes the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification.
[0105] The memory may include readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory, and may further include read only memory (ROM).
[0106] The storage may also include a program / utility having a set (at least one) of program modules, such program modules including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0107] The bus may represent one or more of several types of bus structures including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
[0108] The electronic device may also communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may communicate with one or more devices that enable a user to interact with the electronic device, and / or may communicate with any device that enables the electronic device to communicate with one or more other computing devices (e.g., routers, modems, etc.). This communication may be performed through an input / output (I / O) interface. In addition, the electronic device may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter. The network adapter communicates with other modules of the electronic device through a bus. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0109] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0110] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0111] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, a system, device or component of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0112] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0113] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0114] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0115] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0116] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0117] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for generating large model output based on external knowledge, characterized in that: The method comprises the following steps: Using the initial input to match with multiple categories of external knowledge bases in the target domain, respectively, to recall the question-answer reference records corresponding to the multiple categories of external knowledge bases; The question and answer reference record includes: question and answer reference information and confidence; the external knowledge base includes a long text knowledge base, a short text knowledge base, a structured data knowledge base and an intention knowledge base; Use the target similarity calculation model to generate the similarity between the initial input and the sentence vector corresponding to each question and answer reference information; the target similarity calculation model is a RoBERTa model trained based on the SimCSE framework using the corpus corresponding to the target field; Sort and concatenate multiple question-answer reference information in descending order of similarity to generate initial reference information; After splicing the initial input and the initial reference information, a first target input is generated; If any confidence level among the confidence levels corresponding to the plurality of question-answer reference information is greater than the confidence level threshold of the corresponding category, the first target input is loaded into the dedicated large language model corresponding to the target domain to generate a corresponding output; the dedicated large language model is obtained by training a general large language model using the corpus corresponding to the target domain; After generating the first target input, the method further includes: If each of the confidences corresponding to the plurality of question-answer reference information is less than or equal to the confidence threshold of the corresponding category, then the first target input is loaded into the universal large language model to generate a corresponding output; After using the initial input to match with external knowledge bases of multiple categories respectively, the method further includes: If no question-answer reference information is matched, the initial input is loaded into a universal large language model to generate a corresponding output; The question and answer reference record further includes: a trip query mark; the trip query mark indicates the content of the answer part in the question and answer reference information in the corresponding question and answer reference record, and is related to the value corresponding to at least one field in the user's trip information; After recalling the question-answer reference records corresponding to the external knowledge bases of multiple categories, the method further includes: If any question-and-answer reference record includes a trip query tag, the trip information of the user corresponding to the initial input is obtained; Use the target similarity calculation model to generate the similarity between the initial input and the sentence vector corresponding to each question and answer reference information; the target similarity calculation model is a RoBERTa model trained based on the SimCSE framework using the corpus corresponding to the target field; Sort and concatenate multiple question-answer reference information in descending order of similarity to generate initial reference information; splicing the trip information with the initial reference information to generate secondary reference information; After concatenating the initial input and the secondary reference information, a second target input is generated; The second target input is loaded into a dedicated large language model corresponding to the target domain to generate a corresponding output; the dedicated large language model is obtained by training a general large language model using the corpus corresponding to the target domain.
2. The method according to claim 1, characterized in that When the external knowledge base is a short text knowledge base; Use the initial input to match against multiple categories of external knowledge bases, including: By using sentence vector retrieval, the first similarity between the sentence vector corresponding to the initial input and the sentence vector corresponding to each question-answer pair in the short text knowledge base is obtained; the sentence vector is obtained by the RoBERTa model trained with the corresponding corpus of the target domain based on the SimCSE framework; Each question-answer pair corresponding to a first similarity greater than a first similarity threshold and the corresponding first similarity are used as recalled question-answer reference information and the corresponding confidence level, respectively.
3. The method according to claim 1, characterized in that When the external knowledge base is a long text knowledge base; Use the initial input to match against multiple categories of external knowledge bases, including: Based on the BM25 algorithm, the initial input is matched with each text in the long text knowledge base for keywords, and the second similarity corresponding to each text in the long text knowledge base is generated; Each text corresponding to a second similarity greater than a second similarity threshold and the corresponding second similarity are used as recalled question and answer reference information and the corresponding confidence level, respectively.
4. The method according to claim 1, characterized in that When the external knowledge base is a structured data knowledge base; Use the initial input to match against multiple categories of external knowledge bases, including: Based on KB-QA, key entities are extracted from the initial input, and the corresponding relationship between the key entities and entities in the structured data knowledge base is determined to generate target entity information; Using the target entity information as the recalled question and answer reference information; The similarity between the key entity and the target entity information extracted from the initial input is used as the corresponding confidence.
5. The method according to claim 1, characterized in that: The target areas include civil aviation.
6. A non-transitory computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements a large model output generation method based on external knowledge as described in any one of claims 1 to 5.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it implements a large model output generation method based on external knowledge as described in any one of claims 1 to 5.
