Vector library cleaning method, storage medium and electronic device based on large language model
By cleaning the vector library of the large language model and using clustering and effectiveness evaluation processing, the 'illusion' problem when the large language model generates text is solved, the memory usage of the Prompt guidance library is reduced, and the accuracy of the generated content is improved. and efficiency.
Patent Information
- Application Number
- CN202410964208.9
- 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 the input information when generating text, which is called "illusion". This may cause losses especially in vertical fields with high accuracy requirements. There are low problems in the existing Prompt guidance library. Quality prompt information causes invalid memory usage.
A vector library cleaning method based on a large language model is used to generate the effective value of each record through clustering and validity evaluation processing, remove records with effective values less than the threshold, reduce low-quality prompt information, and optimize the memory usage of the Prompt boot library.
By counting the number of recalls and user Q&A behavior, we can accurately evaluate the effectiveness of each record, remove low-quality records, reduce the memory usage of the Prompt boot library, and improve the accuracy and efficiency of generated content.
Smart Images

Figure CN118503398B
Abstract
Description
Background Art
[0002] 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.
[0003] In some general scenarios with low requirements for answer accuracy (such as story writing scenarios), the "hallucination" problem of large language models has little impact. However, in some vertical field scenarios with high accuracy requirements (such as medical, financial, civil aviation, etc.), the "hallucination" problem of large language models can cause great losses. Therefore, in order to overcome the "hallucination" problem of large language models, Prompt Engineering is usually used. Prompt is used to create concise and guiding instructions or questions and application prompts (Prompt), ensuring that the model can accurately understand the user's intentions and generate high-quality content that meets expectations.
[0004] In the prior art, when generating a prompt guide library in a prompt project, multiple prompt information with high similarity is usually collected. However, in actual use, since multiple prompt information with high similarity realize roughly the same function, and different prompt information have different hallucination suppression capabilities for large language models, a certain amount of low-quality prompt information exists in multiple prompt information with high similarity, and the memory of the prompt guide library is invalidly occupied. Summary of the invention
[0005] In view of the above technical problems, the technical solution adopted by the present invention is:
[0006] According to one aspect of the present invention, a vector library cleaning method based on a large language model is provided, the method comprising the following steps:
[0007] Obtain a vector database to be cleaned, which includes multiple records, and similar records exist in the multiple records; each record includes a question-answer pair and a question ID, and the question ID is a vector encoding corresponding to the question part of the question-answer pair, and the answer part of the question-answer pair is used as reference information for the large language model to answer questions similar to the question part;
[0008] Cluster multiple records by question ID to generate multiple record groups;
[0009] According to the recall times of each record by the large language model in the historical data and the corresponding user question-answering behavior, each record in the record group is evaluated for effectiveness and a valid value corresponding to each record is generated;
[0010] Clear the records whose effective values are less than the first threshold value in the record group;
[0011] The effectiveness assessment process includes:
[0012] According to the recall times of each record by the large language model, the first sub-valid value corresponding to each record is generated; A n i is the first valid sub-value corresponding to the i-th record in the n-th record group;
[0013] Obtain interactive question-answer pair information from the historical question-answer information generated by the large language model; each interactive question-answer pair information includes the question information corresponding to two adjacent question-answer dialogues, the respectively recalled records, and the group ID of the record group to which the recalled records belong;
[0014] If the similarity between two question information in the interactive question-answer pair is greater than the second threshold, and the group IDs of the record groups to which the records corresponding to the two questions belong are the same, then the number of invalid recalls corresponding to each record first recalled in the interactive question-answer pair is cumulatively increased by 1;
[0015] The total number of invalid recalls corresponding to each record is used as the second sub-valid value corresponding to each record; B n i is the second sub-valid value corresponding to the i-th record in the n-th record group;
[0016] Generate a valid value corresponding to each record according to the first sub-valid value and the second sub-valid value corresponding to each record; C n i is the valid value corresponding to the i-th record in the n-th record group, C n i The following conditions must be met:
[0017] ,
[0018] Among them, k is greater than 1.
[0019] Furthermore, after obtaining the interactive question-answer pair information from the historical question-answer information generated by the large language model, the effectiveness evaluation process further includes:
[0020] If the similarity between two question information in the interactive question and answer pair information is less than the second threshold, the number of invalid recalls corresponding to each record of the first recall in the interactive question and answer pair is kept unchanged.
[0021] Furthermore, after obtaining the interactive question-answer pair information from the historical question-answer information generated by the large language model, the effectiveness evaluation process further includes:
[0022] If the similarity between two question information in the interactive question and answer pair is greater than the second threshold, and the group IDs of the record groups to which the records corresponding to the two questions belong are different, the number of invalid recalls corresponding to each record first recalled in the interactive question and answer pair remains unchanged.
[0023] Furthermore, the method also includes:
[0024] Generate a corresponding question ID based on the vector encoding corresponding to the question information input by the user; the question ID and the question ID use the same vector encoding technology;
[0025] According to the similarity between the question ID and the question ID in the vector database to be cleaned, at least one record is selected for recall;
[0026] After the recalled records are concatenated with the question information entered by the user, new question information is generated and input into the large language model.
[0027] Furthermore, the vector database to be cleaned includes a milvus database.
[0028] Furthermore, the second threshold is greater than or equal to 0.8.
[0029] Furthermore, multiple records are clustered based on the question ID, and the clustering methods used include K-Means clustering, DBSCAN clustering, or OPTICS clustering.
[0030] Furthermore, the similarity between two question information in the interactive question-answer pair information is calculated by the SimCSE model.
[0031] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned vector library cleaning method based on a large language model is implemented.
[0032] According to a third aspect of the present invention, an electronic device is provided, 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 vector library cleaning method based on a large language model when executing the computer program.
[0033] The present invention has at least the following beneficial effects:
[0034] In the present invention, by statistics of historical data, it is possible to clearly know the number of times each prompt information (i.e., record) in the Prompt guide library (i.e., the vector database to be cleaned) is recalled in the corresponding historical period, i.e., the first sub-valid value corresponding to each record. The first sub-valid value can directly reflect the usage frequency of the corresponding prompt information, and can represent the effectiveness of the corresponding prompt information from one aspect.
[0035] In addition, if the last answer of the large language model does not solve the user's problem, the user will ask the same question to the large language model again, and the corresponding last recall is invalid. Therefore, through the user's next question-and-answer behavior after each question-and-answer session, it is inferred whether the last answer of the large language model accurately solved the user's problem, that is, the second sub-effective value corresponding to each record can be obtained. The second sub-effective value can indicate the level of guidance ability of the recalled prompt information (record) to the large language model.
[0036] The present invention can more accurately indicate the effectiveness of each record in the actual use of the large language model through the effective value by combining the first sub-effective value with the second sub-effective value. Thus, the records (i.e., low-quality prompt information) in the record group with effective values less than the first threshold can be cleared, thereby reducing the invalid occupation of the prompt guide library memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] 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.
[0038] Figure 1 A flowchart of a vector library cleaning method based on a large language model provided in an embodiment of the present invention.
[0039] Figure 2 A schematic diagram of data in the milvus database provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0040] 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.
[0041] As a possible embodiment of the present invention, Figure 1 As shown, a vector library cleaning method based on a large language model is provided, and the method includes the following steps:
[0042] S100: Obtain a vector database to be cleaned, the vector database to be cleaned includes multiple records, and similar records exist in the multiple records. Each record includes a question-answer pair and a question ID, the question ID is the vector encoding corresponding to the question part of the question-answer pair, and the answer part of the question-answer pair is used as reference information when the large language model answers questions similar to the question part.
[0043] Preferably, the vector database to be cleaned may be a milvus database. Figure 2 As shown, the column corresponding to query is the text corresponding to the question part of the question and answer pair; the column corresponding to answer is the text corresponding to the answer part of the question and answer pair; and the column corresponding to query-embedding is the question ID column.
[0044] Milvus is an open source database system designed for vector data, especially suitable for processing high-dimensional vector data (also called Embedding) generated by deep learning and other machine learning models. These vectors are usually used to represent the characteristics of images, text, sound or other unstructured data, making similarity search possible.
[0045] The vector database to be cleaned in this step can be the Prompt guide library corresponding to the civil aviation field, in which the multiple records stored are some knowledge related to the civil aviation field. These knowledge are all processed into the form of question and answer pairs. Specifically, it can be: Question and Answer Pair 1--Q (question part): How to check whether you need to take a shuttle bus for the flight. A (answer part): You can check whether you need to take a shuttle bus for the flight on the airline 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 you up. The shuttle bus is a means of transportation connecting the terminal in the airport and the remote aircraft. If the plane stays at a remote position, it is necessary to use a shuttle bus to transport passengers to the plane. The above-mentioned question and answer information includes data directly accumulated by the user, as well as information extracted from certain long and short documents. In this embodiment, it is also necessary to use the vector generation capability of the milvus database to generate a corresponding vector, that is, the question ID, from the text of the question part of the question and answer pair.
[0046] Among them, the vector database to be cleaned includes multiple similar records, such as question and answer pair 2--Q: How to check whether the flight needs to take a shuttle bus. A: You can check whether the flight needs to take a shuttle bus on the xxxxapp. 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 terminal in the airport and the remote aircraft. If the aircraft stays at the remote aircraft position, it is necessary to use the shuttle bus to transport passengers to the plane.
[0047] For example, answer 3--Q: Why do you need to take a shuttle bus? A: You can check whether you need to take a shuttle bus for your flight 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.
[0048] In the above example, question-answer pairs 1-3 are similar records.
[0049] The splicing between the prompt information and the user input is performed as follows:
[0050] S110: Generate a corresponding question ID according to the vector encoding corresponding to the question information input by the user. The question ID and the question ID use the same vector encoding technology.
[0051] S120: Filter at least one record for recall based on the similarity between the question ID and the question ID in the vector database to be cleaned.
[0052] S130: After the recalled records are combined with the question information input by the user, new question information is generated and input into the large language model.
[0053] Specifically, the recalled records are the above question-answer pairs 1-3, and the question information input by the user is: What kind of flights are more likely to take a shuttle bus.
[0054] Then the new question information generated in S130 is: Answer the question according to the reference answer provided below: Question and answer pair 1: Q: How to check whether the flight requires a shuttle bus. A: You can check whether the flight requires a shuttle bus on the airline 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 you up. The shuttle bus is a means of transportation connecting the terminal in the airport and the remote aircraft. If the aircraft stays at a remote aircraft position, it is necessary to use a shuttle bus to transport passengers to the plane.
[0055] Question 2: Q: How can I 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.
[0056] Question 3: Q: Why do you need to take a shuttle bus? A: You can check whether you need to take a shuttle bus for your flight 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.
[0057] Question: What kind of flights are more likely to have a shuttle bus?
[0058] S200: Clustering multiple records based on question IDs to generate multiple record groups.
[0059] Specifically, multiple records are clustered by question ID, and the clustering methods used include K-Means clustering, DBSCAN clustering, or OPTICS clustering. Among them, K of K-Means clustering can be determined according to the number of categories defined when collecting records, and the other clustering methods are based on density or distance, which can be adjusted according to actual use.
[0060] S300: Based on the number of recalls of each record by the large language model in the historical data and the corresponding user question-answering behavior, each record in the record group is subjected to validity evaluation and processing, and a valid value corresponding to each record is generated.
[0061] In this embodiment, in order to enable the large language model to understand the user's question more clearly and accurately and give a targeted answer, the corresponding record will be matched and recalled in advance according to the question input by the user or the question generated by multiple rounds of dialogue in the early stage to generate a prompt text. The historical data can be data of a preset historical period, which can be a period of one week or one month.
[0062] The effectiveness assessment process includes:
[0063] S301: Generate the first sub-valid value corresponding to each record according to the number of times the large language model recalls each record. n i It is the first valid sub-value corresponding to the i-th record in the n-th record group.
[0064] By counting the historical data, we can clearly know the number of times each prompt information (i.e., record) in the prompt guide library (i.e., the vector database to be cleaned) has been recalled in the corresponding historical period, i.e., the first sub-valid value corresponding to each record. The first sub-valid value can directly reflect the usage frequency of the corresponding prompt information, which can indicate the effectiveness of the corresponding prompt information from one aspect.
[0065] S302: Obtain interactive question-answer pair information from the historical question-answer information generated by the large language model. Each interactive question-answer pair information includes question information corresponding to two adjacent question-answer dialogues, respectively recalled records, and the group ID of the record group to which the recalled records belong.
[0066] The interactive question-answer pair information described in this step is a complete process from the user asking a question to the large language model giving an answer. This process usually includes obtaining the user's question information, recalling the prompt text (that is, the record in the vector database to be cleaned) based on the user's question information, and then splicing the recalled prompt information with the user's question information into a new question information input into the large language model, and finally the large language model gives the corresponding inference answer. In this process, a corresponding interactive question-answer pair information can be obtained.
[0067] S303: If the similarity between two question information in the interactive question and answer pair is greater than the second threshold, and the group ID of the record group to which the records corresponding to the two questions are recalled is the same, then the number of invalid recalls corresponding to each record first recalled in the interactive question and answer pair is cumulatively increased by 1.
[0068] Specifically, the similarity between two question information in the interactive question-answer pair information is calculated by the SimCSE model. The second threshold is greater than or equal to 0.8.
[0069] The SimCSE model is a pre-trained model for semantic similarity calculation, and its full name is Similarity Enhanced Contrastive Learning for Sentence Embedding. The main purpose is to learn high-quality sentence representations from unlabeled texts through self-supervised learning, thereby improving the accuracy of semantic similarity calculation between sentences. It is especially effective in short text similarity judgment tasks. Therefore, in this step, the model obtained after further training with corresponding field data (such as Minghang field data forecast) can be used to calculate the similarity of two question information in the interactive question and answer pair information.
[0070] Specifically, the pre-trained RoBERTa model can be fine-tuned based on the SimCSE framework and using specific domain corpora (such as civil aviation corpora), aiming to improve the performance of the model on specific tasks in the civil aviation field, such as customer service dialogue understanding, flight information extraction, and passenger demand analysis.
[0071] S304: If the similarity between the two question information in the interactive question and answer pair information is less than the second threshold, the number of invalid recalls corresponding to each record of the first recall in the interactive question and answer pair is kept unchanged.
[0072] S305: If the similarity between the two question information in the interactive question and answer pair is greater than the second threshold, and the group IDs of the record groups to which the records corresponding to the two questions are recalled are different, then the number of invalid recalls corresponding to each record first recalled in the interactive question and answer pair is kept unchanged.
[0073] Usually, if the last answer of the large language model does not solve the user's problem, the user will ask the same question to the large language model again, and the corresponding last recall is invalid. Therefore, through the user's next question-and-answer behavior after each question-and-answer session, it is inferred whether the last answer of the large language model accurately solved the user's problem, that is, the second sub-effective value corresponding to each record can be obtained. The second sub-effective value can indicate the level of guidance ability of the recalled prompt information (record) to the large language model.
[0074] S306: The total number of invalid recalls corresponding to each record is used as the second sub-valid value corresponding to each record. n i It is the second sub-valid value corresponding to the i-th record in the n-th record group.
[0075] S307: Generate a valid value corresponding to each record according to the first sub-valid value and the second sub-valid value corresponding to each record. n i is the valid value corresponding to the i-th record in the n-th record group, C n i The following conditions must be met:
[0076] ,
[0077] Among them, k is greater than 1. For example, k=1.3.
[0078] In the effective value calculation formula of this embodiment, a weight k greater than 1 is assigned to the second sub-effective value. Since, when using a large language model in a vertical field, more attention is paid to the accuracy of the generated results, the influence of the second sub-effective value in the calculation will be further increased during the calculation, so the second sub-effective value will be further amplified by k, so that the final effective value can more accurately represent the effectiveness of each record in the actual use of the large language model.
[0079] In addition, in order to more accurately determine the validity of each record, k=1+Q corresponding to multiple records recalled at one time; Q is the similarity between the text of the answer part in each recalled record and the answer text generated by the large language model.
[0080] S400: Clearing records in the record group whose effective values are less than a first threshold.
[0081] The first threshold value can be determined according to the effective value score corresponding to each record in the actual use scenario. The present invention can more accurately indicate the effectiveness of each record in the actual use of the large language model through the effective value by combining the first sub-effective value with the second sub-effective value. Thus, the records (i.e., low-quality prompt information) in the record group with effective values less than the first threshold value can be cleared, thereby reducing the invalid occupation of the Prompt guide library memory.
[0082] 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.
[0083] 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.
[0084] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0085] 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".
[0086] 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.
[0087] 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).
[0088] 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.
[0089] 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).
[0090] 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.
[0091] 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.
[0092] 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.
[0093] 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.
[0094] 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.
[0095] 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.
[0096] 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.
[0097] 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.
[0098] 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).
[0099] 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.
[0100] 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.
[0101] 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 vector library cleaning method based on a large language model, characterized in that: The method comprises the following steps: Obtain a vector database to be cleaned, the vector database to be cleaned includes multiple records, and similar records exist in the multiple records; each record includes a question-answer pair and a question ID, the question ID is a vector code corresponding to the question part in the question-answer pair, and the answer part in the question-answer pair is used as reference information when the large language model answers questions similar to the question part; Cluster multiple records by question ID to generate multiple record groups; According to the recall times of each record by the large language model in the historical data and the corresponding user question-answering behavior, each record in the record group is evaluated for effectiveness and a valid value corresponding to each record is generated; Clear the records whose effective values are less than the first threshold value in the record group; The effectiveness evaluation process includes: According to the recall times of each record by the large language model, the first sub-valid value corresponding to each record is generated; A n i is the first valid sub-value corresponding to the i-th record in the n-th record group; Obtain interactive question-answer pair information from the historical question-answer information generated by the large language model; each interactive question-answer pair information includes the question information corresponding to two adjacent question-answer dialogues, the respectively recalled records, and the group ID of the record group to which the recalled records belong; If the similarity between two question information in the interactive question-answer pair is greater than the second threshold, and the group IDs of the record groups to which the records corresponding to the two questions belong are the same, then the number of invalid recalls corresponding to each record first recalled in the interactive question-answer pair is cumulatively increased by 1; The total number of invalid recalls corresponding to each record is used as the second sub-valid value corresponding to each record; B n i is the second sub-valid value corresponding to the i-th record in the n-th record group; Generate a valid value corresponding to each record according to the first sub-valid value and the second sub-valid value corresponding to each record; C n i is the valid value corresponding to the i-th record in the n-th record group, C n i The following conditions must be met: , Wherein, k is greater than 1; After obtaining interactive question-answer pair information from historical question-answer information generated from the large language model, the effectiveness evaluation process further includes: If the similarity between two question information in the interactive question-answer pair information is less than the second threshold, the number of invalid recalls corresponding to each record of the first recall in the interactive question-answer pair is kept unchanged; After obtaining interactive question-answer pair information from historical question-answer information generated from the large language model, the effectiveness evaluation process further includes: If the similarity between two question information in the interactive question-answer pair information is greater than the second threshold, and the group IDs of the record groups to which the records corresponding to the two questions belong are different, then the number of invalid recalls corresponding to each record first recalled in the interactive question-answer pair remains unchanged; The method further comprises: Generate a corresponding question ID according to the vector encoding corresponding to the question information input by the user; the question ID and the question ID use the same vector encoding technology; According to the similarity between the question ID and the question ID in the vector database to be cleaned, at least one record is selected for recall; After the recalled records are concatenated with the question information entered by the user, new question information is generated and input into the large language model.
2. The method according to claim 1, characterized in that The vector database to be cleaned includes the milvus database.
3. The method according to claim 1, characterized in that The second threshold is greater than or equal to 0.
8.
4. The method according to claim 1, characterized in that: Cluster multiple records by question ID using K-Means clustering, DBSCAN clustering, or OPTICS clustering.
5. The method according to claim 1, characterized in that The similarity between two question information in the interactive question-answer pair information is calculated using the SimCSE model.
6. A non-transitory computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, a vector library cleaning method based on a large language model is implemented 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, the vector library cleaning method based on a large language model is implemented as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Ship static data supplementing method and device, electronic equipment and readable storage medium
CN113836118A
Data mining method and device based on large language model, equipment and medium
CN117667979A
Knowledge updating method and device of language model, equipment and storage medium
CN117828055A
KR20210063011A
