Database retrieval method and device based on large language model, equipment and medium

By leveraging the query expansion and iterative retrieval verification mechanism of a large language model, extended query terms are generated and combined with a dual retrieval strategy of lexical and semantic terms. This solves the problem of low database retrieval efficiency in scenarios with significant semantic differences and achieves efficient database retrieval results.

CN121579710APending Publication Date: 2026-02-27SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202610098961.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-26
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In scenarios with significant semantic differences, existing technologies struggle to effectively reduce the computational overhead of database retrieval while simultaneously improving retrieval recall and accuracy. In particular, the direct use of large language models is costly, and recall-validation methods are inefficient when there are significant semantic or lexical differences.

Method used

By using a query expansion and iterative retrieval verification mechanism based on a large language model, expanded query terms are generated and combined with a dual retrieval strategy of lexical and semantic terms. The query representation and ranking strategy are dynamically updated, and the query process is optimized by using preset iteration termination conditions.

Benefits of technology

In scenarios with significant semantic differences, it significantly reduces retrieval computation overhead while improving retrieval recall and precision, achieving efficient database retrieval.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579710A_ABST
    Figure CN121579710A_ABST
Patent Text Reader

Abstract

The invention discloses a database retrieval method and device based on a large language model, equipment and a medium, and relates to the technical field of computers. Comprising the following steps: carrying out expansion reconstruction on an original query word by utilizing a large language model to generate a query word set containing the original query word and a plurality of expansion query words, screening a target query word from the query word set, and then carrying out retrieval from a target database table based on the target query word; reordering the retrieved candidate data entries by using a reordering strategy to determine target data entries, verifying the target data entries by using a large language model, and then storing the target data entries passing the verification into a verified result set; and updating the query word set and the reordering strategy by utilizing the verified result set, and re-screening the target query word until a preset iteration ending condition is met. Therefore, the retrieval calculation overhead can be reduced in a scene with significant semantic difference, and the retrieval recall rate and the retrieval accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a database retrieval method and device based on large language model, equipment and medium. BACKGROUND

[0002] The effectiveness of database query is highly dependent on the user's familiarity with the underlying data semantics and format. When the user query does not match the representation of the actual stored content in the database, a "semantic gap" occurs, which leads to low recall rate and poor accuracy of the retrieval results. Traditional methods such as keyword search and fuzzy matching are difficult to handle the diversity of natural language, often missing records with different vocabulary but equivalent semantics. In recent years, large language models have provided a new way to bridge the semantic gap with their deep semantic understanding capabilities.

[0003] However, directly using large language models for semantic scanning or verification of the entire database has a very high computational cost, making it difficult to apply to real-time retrieval scenarios in large-scale databases. To reduce the overhead, existing technologies mainly use two strategies: Cascade filtering: use a lightweight proxy model to pre-screen the entire database, and then pass the uncertain results to the main large language model for verification. This method reduces the number of large language model calls, but the proxy model's full database scanning itself has a huge overhead. Recall-verification: first use vector retrieval or keyword matching (such as BM25) to preliminarily recall the candidate set, and then use the large language model for verification. However, this method often has a very low initial recall rate when there is a significant semantic or lexical difference between the query word and the data value, resulting in low efficiency in the subsequent verification stage and still requiring scanning of a large number of irrelevant data.

[0004] As can be seen from the above, how to reduce the retrieval computation overhead and improve the retrieval recall rate and retrieval accuracy in scenarios with significant semantic differences is a problem that needs to be solved urgently. SUMMARY

[0005] Therefore, the purpose of the present application is to provide a database retrieval method and device based on large language model, which can reduce the retrieval computation overhead and improve the retrieval recall rate and retrieval accuracy in scenarios with significant semantic differences. The specific solutions are as follows: In a first aspect, the present application provides a database retrieval method based on large language model, comprising: obtaining an original query word and using a preset large language model to expand and reconstruct the original query word to generate a plurality of expanded query words, and then generating a current query word set based on the original query word and the plurality of expanded query words; selecting a target query word from the current query word set, and using a preset vocabulary retriever and a preset semantic retriever to retrieve from a target database table based on the target query word to obtain a plurality of candidate data entries; reordering the plurality of candidate data entries based on a current reordering strategy, so as to determine a preset number of target data entries from the plurality of candidate data entries according to a reordering result, and verifying the target data entries by using the preset large language model, and then storing the target data entries that pass the verification into a current verified result set; updating the current query word set and the current reordering strategy by using the current verified result set to obtain an updated current query word set and an updated current reordering strategy, and rejumping to the step of screening target query words from the current query word set until a preset iteration end condition is met.

[0006] Optionally, the expanding and reconstructing the original query word by using the preset large language model to generate a plurality of expanded query words comprises: determining a data column to be retrieved in the target database table to obtain a target column name corresponding to the data column to be retrieved, and generating a prompt template based on the original query word and the target column name; generating a plurality of expanded query words based on the prompt template by using the preset large language model; The prompt template contains the original query word, the target column name, and a plurality of example values in the data column to be retrieved.

[0007] Optionally, the screening target query words from the current query word set comprises: verifying the query words other than the original query word in the current query word set by using the preset large language model based on a preset secondary verification template, and taking the query words that pass the verification and the original query word as target query words.

[0008] Optionally, the reordering the plurality of candidate data entries based on a current reordering strategy comprises: obtaining a lexical feature score and a semantic feature score corresponding to the plurality of candidate data entries, and performing normalization processing on the lexical feature score and the semantic feature score; weighting and fusing the normalized lexical feature score and the semantic feature score based on a preset weight to obtain a comprehensive score corresponding to the plurality of candidate data entries, and reordering the plurality of candidate data entries based on the comprehensive score.

[0009] Optionally, before the verifying the target data entries by using the preset large language model, the method further comprises: If the number of entries in the current verified result set reaches a first preset threshold, obtaining a comprehensive score of all entries in the verified result set, and calculating the difference between adjacent comprehensive scores. a difference between a minimum value of all comprehensive scores in the verified result set and a maximum value of the differences as a qualified threshold, and screening the target data entries based on the qualified threshold.

[0010] Optionally, the preset iteration end condition includes a first preset iteration end condition and a second preset iteration end condition. The first preset iteration end condition is that the number of entries in the verified result set reaches a second preset threshold; and the second preset threshold is greater than the first preset threshold. The second preset iteration end condition is that the comprehensive score of all target data entries in the current iteration is lower than the qualified threshold, and the number of entries in the verified result set is greater than 0.

[0011] Optionally, after the target data entries are verified by using the preset large language model, the method further includes: If the number of target data entries that pass the verification in the current iteration is zero, the preset number is increased when the next round of iteration is performed.

[0012] In a second aspect, the present application provides a database retrieval device based on a large language model, which includes: A query word expansion module is configured to obtain an original query word, expand and reconstruct the original query word by using a preset large language model to generate a plurality of expanded query words, and then generate a current query word set based on the original query word and the plurality of expanded query words. A data retrieval module is configured to screen target query words from the current query word set, and retrieve from a target database table based on the target query words by using a preset vocabulary retriever and a preset semantic retriever to obtain a plurality of candidate data entries. A data verification module is configured to reorder the plurality of candidate data entries based on a current reordering strategy, so as to determine a preset number of target data entries from the plurality of candidate data entries according to a reordering result, and verify the target data entries by using the preset large language model, and then store the target data entries that pass the verification into a current verified result set. An iteration control module is configured to update the current query word set and the current reordering strategy by using the current verified result set to obtain an updated current query word set and an updated current reordering strategy, and jump back to the step of screening target query words from the current query word set until a preset iteration end condition is met.

[0013] In a third aspect, the present application provides an electronic device, which includes: A memory is configured to save a computer program. A processor is configured to execute the computer program to implement the foregoing database retrieval method based on a large language model.

[0014] In a fourth aspect, the present application provides a computer readable storage medium for storing a computer program, wherein the computer program is executed by a processor to implement the foregoing database retrieval method based on a large language model.

[0015] The present application provides a database retrieval method based on a large language model, obtains an original query word, and uses a preset large language model to expand and reconstruct the original query word to generate a plurality of expanded query words, and then generates a current query word set based on the original query word and the plurality of expanded query words; a target query word is selected from the current query word set, and based on the target query word, a preset vocabulary retriever and a preset semantic retriever are used to retrieve from a target database table to obtain a plurality of candidate data entries; the plurality of candidate data entries are reordered based on a current reordering strategy, so as to determine a preset number of target data entries from the plurality of candidate data entries according to the reordering result, and the target data entries are verified using the preset large language model, and then the target data entries that pass the verification are stored in a current verified result set; the current verified result set is used to update the current query word set and the current reordering strategy to obtain an updated current query word set and an updated current reordering strategy, and the step of selecting a target query word from the current query word set is re-executed until a preset iteration end condition is met.

[0016] As can be seen from the above, by introducing the query expansion and iterative retrieval verification mechanism based on a large language model, the semantic gap between user queries and database content is effectively bridged, and semantically relevant expanded query words can be dynamically generated and selected, and a vocabulary and semantic dual retrieval strategy is combined to continuously optimize query representation and sorting strategy in an iterative manner, thereby significantly reducing the calling overhead of the large language model while ensuring high recall rate and accuracy. Thus, in the case of significant semantic difference, the retrieval calculation overhead is reduced, and the retrieval recall rate and accuracy are improved. BRIEF DESCRIPTION OF DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor based on the provided drawings.

[0018] Figure 1 A flowchart of a database retrieval method based on a large language model is disclosed. Figure 2 A database retrieval device based on a large language model is disclosed. Figure 3 An electronic device structure is disclosed. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0020] The effectiveness of database query is highly dependent on the user's familiarity with the underlying data semantics and format. When the user query does not match the representation of the actual stored content in the database, a "semantic gap" is created, which can result in low recall and poor accuracy of the search results. Traditional methods such as keyword search and fuzzy matching are difficult to handle the diversity of natural language, often missing records with different vocabulary but semantically equivalent. In recent years, large language models have provided a new way to bridge the semantic gap with their deep semantic understanding capabilities. However, the computational cost of directly using large language models for semantic scanning or verification of the entire database is extremely high, making it difficult to apply to real-time retrieval scenarios in large-scale databases. To reduce the overhead, existing technologies mainly adopt two strategies: Cascade filtering: use a lightweight proxy model to pre-screen the entire database, and then pass the uncertain results to the main large language model for verification. This method reduces the number of calls to the large language model, but the proxy model's full database scanning itself has a huge overhead. Recall-verification: first, use vector retrieval or keyword matching (such as BM25) to preliminarily recall the candidate set, and then verify it by the large language model. However, this method often has a very low initial recall rate when there is a significant semantic or lexical difference between the query word and the data value, resulting in low efficiency in the subsequent verification stage and still requiring scanning of a large amount of irrelevant data. Therefore, the present application provides a database retrieval scheme based on a large language model, which can reduce the retrieval computation overhead and improve the retrieval recall rate and retrieval accuracy in scenarios with significant semantic differences.

[0021] Referring to Figure 1 The embodiments of the present application disclose a database retrieval method based on a large language model, which comprises: Step S11, obtaining an original query word, and using a preset large language model to expand and reconstruct the original query word to generate a plurality of expanded query words, and then generating a current query word set based on the original query word and the plurality of expanded query words.

[0022] In this embodiment, the original query word input by the user is received, and a preset large language model (such as LLaMA, GPT, etc.) is called to intelligently expand the original query word to bridge the semantic gap. Specifically, the expansion and reconstruction of the original query word using the preset large language model to generate a plurality of expanded query words can include: determining the data column to be retrieved in the target database table to obtain the target column name corresponding to the data column to be retrieved, and generating a prompt template based on the original query word and the target column name; using the preset large language model to generate a plurality of expanded query words based on the prompt template; wherein the prompt template contains the original query word, the target column name and a plurality of example values in the data column to be retrieved. That is, the large language model is explicitly guided to understand the user's deep intention through the customized prompt template. The prompt template requires the model to consider concept synonyms, hierarchical relationships and context semantic differences, while providing example values of the target table, so that the model can infer the data format and naming conventions of the specific database column. For example, in a specific implementation, the target database table is a species information table, and the column to be retrieved is the "scientific name" column. The user's original query word is "Barn Owl" (a common name of a type of owl). The system first randomly samples a plurality of example values from the "scientific name" column, such as "Tyto alba", "Strix nebulosa", etc. Then, a structured prompt template containing the original query word "Barn Owl", the target column name "scientific name", and the above example values is constructed and submitted to the large language model. Based on its knowledge of biological taxonomy, the large language model can generate a plurality of expanded query words such as "Tyto alba" (the scientific name of the Barn Owl), "Grass Owl", "Barn Owl", etc. The original query word and these expanded words together constitute the initial current query word set. This embodiment aims to generate query variants that better match the target table entries by using a large language model, thereby improving the accuracy of information retrieval.

[0023] It is worth mentioning that the embodiments of the present application can use zero-shot prompting for query reconstruction, which can achieve the best balance between efficiency and effectiveness in the query reconstruction framework. Further, too many expanded query words cannot effectively improve the coverage, but will greatly increase the time cost. Therefore, the number of expanded query words generated by the large language model can be limited in advance to avoid unlimited generation.

[0024] Step S12, screening a target query word from the current query word set, and using a preset vocabulary retriever and a preset semantic retriever to retrieve from the target database table based on the target query word to obtain a plurality of candidate data entries.

[0025] In this embodiment, to prevent the introduction of noise by the "hallucination" of the large language model, a secondary check needs to be performed on the expanded query words. Specifically, the filtering of the target query words from the current query word set can include: using the preset large language model to check the query words in the current query word set other than the original query word based on a preset secondary check template, and taking the query words that pass the check and the original query word as the target query words. That is, by accurately selecting a high-confidence query word subset, the search process is more targeted and effective, thereby improving the overall robustness of the system. For example, in a specific implementation, a simple check prompt (such as "Please judge whether 'Tyto alba' is 'Barn Owl' or a kind of it? Please directly answer 'Yes' or 'No'.") is used to require the large language model to verify the expanded words such as "Tyto alba" and "Grass Owl". Assuming that "Grass Owl" is judged as "No", it is filtered. Finally, "Barn Owl" and "Tyto alba" are determined as the target query words.

[0026] Further, the system concurrently enables a preset word retrieval device (such as based on the BM25 algorithm) and a preset semantic retrieval device (such as based on vector similarity calculation of a pre-trained model). For example, in a specific implementation, the word retrieval device performs exact matching and relevance scoring on the target query words such as "Tyto alba" in the corresponding columns of the target database table; the semantic retrieval device converts the text of each data entry into a semantic vector and calculates the similarity score with the semantic vector of the query words such as "Barn Owl". The two retrieval devices respectively return a list of candidate data entries with scores.

[0027] Step S13, reorder the plurality of candidate data entries based on the current reordering strategy, so as to determine a preset number of target data entries from the plurality of candidate data entries according to the reordering result, and check the target data entries using the preset large language model, and then store the target data entries that pass the check into the current verified result set.

[0028] In this embodiment, both vocabulary-based retrieval and semantic-based retrieval are used to recall and query similar candidate entries, and the candidate entries recalled by the two retrievers are integrated through re-ranking, and whether they meet the query conditions is verified by a large language model. Specifically, the re-ranking strategy based on the current re-ranking strategy can include: obtaining the vocabulary feature score and the semantic feature score corresponding to the plurality of candidate data entries, and normalizing the vocabulary feature score and the semantic feature score; based on the preset weight, the normalized vocabulary feature score and the semantic feature score are weighted and fused to obtain the comprehensive score corresponding to the plurality of candidate data entries, and the plurality of candidate data entries are re-ranked based on the comprehensive score. That is, after eliminating the dimensional difference through normalization, the two scores are fused by weighted summation to obtain the final comprehensive score of each entry and are sorted accordingly. This hierarchical fusion mechanism not only guarantees the accuracy of traditional vocabulary matching, but also integrates the generalization ability of semantic understanding. For example, in a specific implementation, the vocabulary retriever may return [entry A (Tyto alba), score 0.95], and the semantic retriever returns [entry A, score 0.88], [entry B (Strix nebulosa), score 0.75]. After normalization and weighted fusion (such as vocabulary weight 0.6, semantic weight 0.4), the final ranking is obtained: entry A is greater than entry B. The system selects the top b (such as b=5) entries as the target data entries to be verified in this round. It can be understood that when there is a lack of labeled data, the system defaults to giving equal weight to vocabulary and semantic features. This hierarchical fusion mechanism not only guarantees the accuracy of traditional vocabulary matching, but also integrates the generalization ability of semantic understanding, and finally forms a ranking result that takes into account accuracy and coverage.

[0029] Further, by calling a large language model, a simple verification prompt (such as "Judge 'Tyto alba' and 'Barn owl' are the same or a kind? Directly answer 'yes' or 'no.'") is used to perform batch parallel verification on the target data entries. The entries that answer "yes" (such as Tyto alba) are stored in the current verified result set. It is worth mentioning that if there is no verification passed target data entry in the current iteration process, the preset number of values is increased in the next iteration to avoid being trapped in an invalid cycle due to a too narrow single-round retrieval range, and the hit probability is improved by expanding the retrieval range in the next round.

[0030] Step S14, updating the current query word set and the current re-ranking strategy using the current verified result set to obtain an updated current query word set and an updated current re-ranking strategy, and rejumping to the step of screening target query words from the current query word set until a preset iteration end condition is met.

[0031] In this embodiment, the entries that pass the current round of verification are added to the next round of the current query set as new query words with high credibility. This allows the subsequent iterations to directly use the standard terms existing in the database for retrieval, further bridging the semantic gap. At the same time, the contribution of the vocabulary and semantic scores in the historical multi-round retrieval to the final verification result can be dynamically adjusted to achieve strategy optimization. The updated query set and strategy are used to start a new round of retrieval, reordering and verification. This iterative process continues, constantly discovering and incorporating new relevant entries into the verified result set.

[0032] It should be noted that the termination of iteration is controlled by a preset iteration end condition. The preset iteration end condition includes a first preset iteration end condition and a second preset iteration end condition. The first preset iteration end condition is to stop when the size of the verified result set reaches a preset upper limit B (such as B=100). The second preset iteration end condition is an optimization mode with an early stop mechanism. Specifically, before the target data entry is verified by the preset large language model, it further includes: if the number of entries in the current verified result set reaches a first preset threshold (such as B0=10), the comprehensive scores of all entries in the verified result set are obtained, and the difference between adjacent comprehensive scores is calculated; the difference between the minimum value of all comprehensive scores in the verified result set and the maximum value of the difference is taken as a qualified threshold, and the target data entry is filtered based on the qualified threshold. That is, after accumulating a small amount of verification results, a "qualified line" is dynamically calculated, and only entries with scores higher than this line are verified in the subsequent iteration, and a large number of low-score entries are skipped to save costs. Further, if the comprehensive scores of all target data entries in the current iteration are lower than the qualified threshold, and the number of entries in the verified result set is greater than 0, the early stop mechanism is triggered. Thus, the iteration can be terminated early when enough relevant results have been found and the quality of subsequent entries is very low, greatly saving computing resources.

[0033] As can be seen from the above, the embodiment of the present application effectively bridges the semantic gap between user queries and database content by constructing a closed-loop framework of "large language model query expansion-mixed retrieval and intelligent reordering-result verification and strategy iteration update". The world knowledge generated by the large language model is used to generate and match the extended query with the data format, and the vocabulary and semantic dual retrieval strategy is combined to continuously enrich the query representation and optimize the sorting weight through iteration, and a dynamic early stop mechanism is introduced, thereby greatly improving the recall rate and accuracy of database retrieval with controllable computing cost in the scene with significant semantic difference.

[0034] Referring to Figure 2 The embodiment of the present application discloses a database retrieval device based on a large language model, which comprises: The query word expansion module 11 is configured to obtain an original query word, expand and reconstruct the original query word by using a preset large language model to generate a plurality of expanded query words, and generate a current query word set based on the original query word and the plurality of expanded query words. The data retrieval module 12 is configured to filter a target query word from the current query word set, and retrieve a plurality of candidate data entries from a target database table based on the target query word by using a preset vocabulary retriever and a preset semantic retriever. The data verification module 13 is configured to reorder the plurality of candidate data entries based on a current reordering strategy, determine a preset number of target data entries from the plurality of candidate data entries according to a reordering result, verify the target data entries by using the preset large language model, and store target data entries that pass the verification into a current verified result set. The iteration control module 14 is configured to update the current query word set and the current reordering strategy by using the current verified result set to obtain an updated current query word set and an updated current reordering strategy, and jump back to the step of filtering a target query word from the current query word set until a preset iteration end condition is met.

[0035] In some embodiments, the query word expansion module 11 can specifically include: The prompt template generation unit is configured to determine a data column to be retrieved in the target database table to obtain a target column name corresponding to the data column to be retrieved, and generate a prompt template based on the original query word and the target column name. The prompt template includes the original query word, the target column name, and a plurality of example values in the data column to be retrieved. The expanded query word generation unit is configured to generate a plurality of expanded query words based on the prompt template by using the preset large language model.

[0036] In some embodiments, the data retrieval module 12 can specifically include: The target query word filtering unit is configured to verify query words other than the original query word in the current query word set by using the preset large language model based on a preset secondary verification template, and use the query words that pass the verification and the original query word as target query words.

[0037] In some embodiments, the data verification module 13 can specifically include: The entry scoring unit is configured to obtain a vocabulary feature score and a semantic feature score corresponding to the plurality of candidate data entries, and perform normalization processing on the vocabulary feature score and the semantic feature score. An item reordering unit is configured to weight and fuse the normalized word feature scores and the semantic feature scores based on preset weights to obtain comprehensive scores corresponding to the candidate data items, and reorder the candidate data items based on the comprehensive scores.

[0038] In some embodiments, the database retrieval apparatus based on the large language model further comprises: A difference calculation unit is configured to, if the number of items in the current verified result set reaches a first preset threshold, obtain comprehensive scores of all items in the verified result set, and calculate differences between adjacent comprehensive scores. An item screening unit is configured to take a difference between a minimum value of all comprehensive scores in the verified result set and a maximum value of the differences as a qualified threshold, and screen the target data items based on the qualified threshold. A preset number updating unit is configured to, if the number of target data items that pass the verification in the current iteration is zero, increase the preset number when performing the next iteration. Correspondingly, the iteration control module 14 specifically can include: A first iteration control unit is configured to, if a first preset iteration end condition is met, stop iteration; the first preset iteration end condition is that the number of items in the verified result set reaches a second preset threshold; the second preset threshold is greater than the first preset threshold. A second iteration control unit is configured to, if a second preset iteration end condition is met, stop iteration; the second preset iteration end condition is that the comprehensive scores of all target data items in the current iteration are all lower than the qualified threshold, and the number of items in the verified result set is greater than 0.

[0039] Further, the present application also discloses an electronic device, Figure 3 is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the contents in the figure cannot be considered as any limitation on the use range of the present application. The electronic device 20 specifically can include at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26. The memory 22 is configured to store a computer program, the computer program is loaded and executed by the processor 21 to realize the related steps in the database retrieval method based on the large language model disclosed in any of the preceding embodiments. In addition, the electronic device 20 in the present embodiment can be an electronic computer.

[0040] In this embodiment, the power supply 23 is configured to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 is configured to create a data transmission channel between the electronic device 20 and external devices, and the communication protocol followed by the communication interface 24 can be any communication protocol applicable to the technical solution of the present application, which will not be specifically limited herein; the input and output interface 25 is configured to obtain external input data or output data to the outside, and the specific interface type can be selected according to the specific application needs, which will not be specifically limited herein.

[0041] In addition, the memory 22 as a carrier for storing resources can be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage mode can be temporary storage or permanent storage.

[0042] The operating system 221 is configured to manage and control each hardware device on the electronic device 20 and the computer program 222, and can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program capable of completing the database retrieval method based on the large language model executed by the electronic device 20 disclosed in any of the preceding embodiments, the computer program 222 can further include a computer program capable of completing other specific work.

[0043] Further, the present application also discloses a computer readable storage medium for storing a computer program; wherein the computer program is executed by a processor to implement the database retrieval method based on the large language model disclosed above. For the specific steps of the method, please refer to the corresponding content disclosed in the preceding embodiments, which will not be described here.

[0044] Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. The same or similar parts of each embodiment can be referred to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method part.

[0045] The skilled person can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of both. In order to clearly show the interchangeability of hardware and software, the components and steps of each example have been described in the above description. Whether the functions are realized by hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to realize the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0046] The steps of a method or algorithm described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module can reside in RAM, flash memory, ROM, electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. The

[0047] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and do not imply or require any such actual relationship or order. Moreover, the terms "include", "contain", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements does not include only those elements recited, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the phrase "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0048] The above provides a detailed description of the technical solutions of the present application. The principles and implementation modes of the present application are described by applying specific examples. The above description of the embodiments is only to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range will be changed; in summary, the content of the specification should not be understood as a limitation of the present application.

Claims

1. A database retrieval method based on a large language model, characterized in that, The method comprises the following steps: acquiring an original query word, and performing extension reconstruction on the original query word by using a preset large language model to generate a plurality of extended query words, and then generating a current query word set based on the original query word and the plurality of extended query words; screening a target query word from the current query word set, and performing retrieval from a target database table based on the target query word by using a preset vocabulary retriever and a preset semantic retriever to obtain a plurality of candidate data entries; reordering the plurality of candidate data entries based on a current reordering strategy, so as to determine a preset number of target data entries from the plurality of candidate data entries according to a reordering result, and performing verification on the target data entries by using the preset large language model, and then storing the target data entries that pass the verification into a current verified result set; updating the current query word set and the current reordering strategy by using the current verified result set to obtain an updated current query word set and an updated current reordering strategy, and rejumping to the step of screening a target query word from the current query word set until a preset iteration end condition is met. 2.The database retrieval method based on a large language model according to claim 1, wherein, The method comprises the following steps: determining a data column to be retrieved in the target database table to obtain a target column name corresponding to the data column to be retrieved, and generating a prompt template based on the original query word and the target column name; generating a plurality of extended query words based on the prompt template by using the preset large language model; The prompt template contains the original query word, the target column name and a plurality of example values in the data column to be retrieved. 3.The database retrieval method based on a large language model according to claim 1, wherein, The method comprises the following steps: verifying the query words in the current query word set except the original query word by using the preset large language model based on a preset secondary verification template, and taking the query words that pass the verification and the original query word as target query words. 4.The database retrieval method based on a large language model according to claim 1, wherein, The method comprises the following steps: acquiring vocabulary feature scores and semantic feature scores corresponding to the plurality of candidate data entries, and performing normalization processing on the vocabulary feature scores and the semantic feature scores; performing weighted fusion on the normalized vocabulary feature scores and the semantic feature scores based on a preset weight to obtain comprehensive scores corresponding to the plurality of candidate data entries, and reordering the plurality of candidate data entries based on the comprehensive scores. 5.The database retrieval method based on a large language model according to claim 4, characterized in that, Before the verification on the target data entries by using the preset large language model, the method further comprises the following steps: if the number of entries in the current verified result set reaches a first preset threshold, acquiring comprehensive scores of all entries in the verified result set, and calculating difference values between adjacent comprehensive scores; taking the difference value between the minimum value in the comprehensive scores of all entries in the verified result set and the maximum value in the difference values as a qualified threshold, and screening the target data entries based on the qualified threshold. 6.The database retrieval method based on a large language model according to claim 5, wherein, The preset iteration end condition comprises a first preset iteration end condition and a second preset iteration end condition. The first preset iteration end condition is that the number of entries in the verified result set reaches a second preset threshold, and the second preset threshold is greater than the first preset threshold. The second preset iteration end condition is that the comprehensive score of all target data entries in the current iteration is lower than the qualified threshold, and the number of entries in the verified result set is greater than 0. 7.The database retrieval method based on a large language model according to claim 1, wherein, After the target data entries are verified by the preset large language model, the method further comprises: If the number of target data entries that pass the verification in the current iteration is zero, the preset number is increased when the next iteration is performed. 8.A database search apparatus based on a large language model, characterized by comprising: Comprise: The query word expansion module is configured to obtain an original query word, expand and reconstruct the original query word by using a preset large language model to generate a plurality of expanded query words, and then generate a current query word set based on the original query word and the plurality of expanded query words; The data retrieval module is configured to filter target query words from the current query word set, and retrieve a plurality of candidate data entries from a target database table based on the target query words by using a preset vocabulary retriever and a preset semantic retriever; The data verification module is configured to reorder the plurality of candidate data entries based on a current reordering strategy, determine a preset number of target data entries from the plurality of candidate data entries according to a reordering result, verify the target data entries by using the preset large language model, and store target data entries that pass the verification in a current verified result set; The iteration control module is configured to update the current query word set and the current reordering strategy by using the current verified result set to obtain an updated current query word set and an updated current reordering strategy, and jump back to the step of filtering target query words from the current query word set until a preset iteration end condition is met.

9. An electronic device, comprising: Comprise: The memory is configured to save a computer program; The processor is configured to execute the computer program to implement the database retrieval method based on the large language model according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer program is configured to be executed by the processor to implement the database retrieval method based on the large language model according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Iterative retrieval method and device for analyzing question and answer reasoning process and medium

    CN116662524A

  • Keyword expansion and multi-information fusion data element search method based on large model

    CN117453725A

  • Retrieval enhancement generation method and device based on reciprocal ranking fusion and medium

    CN119513141A

  • Searching method and device, electronic equipment and readable storage medium

    CN119513282A

  • Query method, system and equipment based on iterative retrieval generation verification and medium

    CN119988599A