Government and enterprise field knowledge base searching method, system and equipment and storage medium
By using word segmentation and keyword extraction processing in the knowledge base search of government and enterprise fields, and using semantic embedding models to generate dense semantic vectors for comparison, the problem of too large semantic vector dimensions and inaccurate search results in traditional methods is solved, and more efficient and accurate search results are achieved.
Patent Information
- Application Number
- CN202411531959.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-03-14
AI Technical Summary
The traditional knowledge base search method based on text semantics has problems in the government and enterprise fields that the semantic vector dimensions are too large and the search results are not accurate enough.
The input text is extracted using word segmentation and keywords, and the input text and keywords are embedded into dense semantic vectors through the semantic embedding model, and compared with the government and enterprise knowledge semantic vector library to filter out reference vectors that meet the preset filtering conditions, thereby extracting the corresponding government and enterprise knowledge text and keywords.
It improves the efficiency and accuracy of knowledge base search in government and enterprise fields, highlights the relevance of text on key information, and reduces the performance impact of storage and search.
Smart Images

Figure CN119621993A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of knowledge base search technology, and in particular to a knowledge base search method, system, device and storage medium in the government and enterprise fields. Background Art
[0002] The traditional steps of searching a knowledge base based on text semantics are usually:
[0003] S1: Input the text to be searched into the word segmenter;
[0004] S2: The word segmenter constructs a statistical dictionary containing word frequencies and parts of speech through the knowledge base text set in advance, generates an acyclic graph of all word segmentation situations based on the statistical dictionary, and uses a graph algorithm to find the word segmentation path with the highest probability to obtain the text segmentation result;
[0005] S3: Use sparse vectors to represent the text segmentation results;
[0006] S4: Represent the text in the knowledge base text set with sparse vectors and construct a text set vector matrix;
[0007] S5: Calculate semantic similarity based on the sparse vector corresponding to the text segmentation result and the sparse vector of the knowledge base text set to obtain a semantic similarity result;
[0008] S6: Determine the best search result based on the semantic similarity results.
[0009] The knowledge base in the government and enterprise field has the characteristics of large data scale and structured knowledge. The government and enterprise field includes the government affairs field and the enterprise field. The knowledge base in the government and enterprise field covers all aspects of government services and enterprise services, including policies and regulations, administrative approval, public services and other fields, and the data scale is huge. The traditional search method is applied to the search of the knowledge base in the government and enterprise field, and the main shortcomings are as follows:
[0010] First, due to the huge amount of data in the knowledge base in the government and enterprise fields, using sparse vectors based on bag-of-words to represent text semantics will cause the dimension of the semantic vector to be too large. For example, if the bag-of-words constructed from a text set contains 10,000 unique words, the text semantics will also be represented as a 10,000-dimensional sparse vector. The data volume is too large and there is a lot of redundant information, which greatly affects the storage and search performance.
[0011] Second, directly using the semantic vectors of text sentences to calculate similarity cannot highlight the similarity of key information in the sentences, which is extremely critical in text search in the government and enterprise fields. The same question or statement in the government and enterprise fields often has a variety of different grammatical expressions, but they all contain similar key words or phrases. The search results obtained using traditional search methods are not accurate enough. Summary of the invention
[0012] In order to improve the search efficiency of search engines for government and enterprise field texts and the accuracy of search results, the present application provides a government and enterprise field knowledge base search method, system, device and storage medium.
[0013] In order to achieve the above-mentioned purpose of the present invention, the present invention provides a knowledge base search method in the government and enterprise fields.
[0014] The present invention provides a method for searching a knowledge base in the government and enterprise fields, comprising:
[0015] Get the input text to be searched;
[0016] Perform word segmentation and keyword extraction on the input text to obtain the keywords of the input text;
[0017] Inputting the input text and the keywords of the input text into the semantic embedding model respectively, obtaining the input text dense semantic vector corresponding to the input text, and the input text keyword dense semantic vector corresponding to the keywords of the input text;
[0018] The dense semantic vector of the input text and the dense semantic vector of the input text keywords are respectively compared with the government and enterprise knowledge semantic vectors in the government and enterprise knowledge semantic vector library, and the government and enterprise knowledge semantic vectors that meet the preset screening conditions are selected as reference vectors;
[0019] The government and enterprise knowledge text and / or government and enterprise knowledge text keywords corresponding to the reference vector are extracted from the government and enterprise knowledge text library to obtain search results.
[0020] Optionally, the method for the semantic embedding model to obtain the dense semantic vector of the input text / the dense semantic vector of the input text keyword includes:
[0021] Inputting the input text / keywords of the input text into a word segmenter, and the word segmenter decomposes the input text / keywords of the input text into a list of subwords;
[0022] Obtain a natural text vocabulary, the natural text vocabulary including a subword list of a plurality of reference words and an ID corresponding to the subword list of the reference words;
[0023] Mapping the subword list of the received text content to the ID corresponding to the subword list according to the natural text vocabulary to obtain a subword ID list;
[0024] Input the subword ID list into the deep learning model and output the embedding vector of each subword in the received text content;
[0025] The embedding vectors of the subwords are merged into a sentence-level embedding vector through an average pooling method, and the sentence-level embedding vector is used as the input text dense semantic vector / input text keyword dense semantic vector.
[0026] Optionally, after the word segmenter decomposes the received text content into a subword list and before mapping the subword list of the received text content to an ID corresponding to the subword list according to the natural text word library, the method further includes:
[0027] Add a start tag at the beginning of the subword list and a end tag at the end of the subword list.
[0028] Optionally, the search results include a combination of government and enterprise knowledge text and government and enterprise knowledge text keywords;
[0029] Determine the number of combinations of government and enterprise knowledge texts and government and enterprise knowledge text keywords included in the search results, and when the number is greater than or equal to 2, perform the following steps:
[0030] Calculate the cosine similarity between the dense semantic vector of the input text and the semantic vector of the government and enterprise knowledge text to obtain the similarity between the input text and the government and enterprise knowledge text;
[0031] Calculate the cosine similarity between the dense semantic vector of the input text keyword and the semantic vector of the government and enterprise knowledge text keyword to obtain the similarity between the input text keyword and the government and enterprise knowledge text keyword;
[0032] Calculate the comprehensive similarity of each combination according to the similarity between the input text and the government and enterprise knowledge text and the similarity between the input text keyword and the government and enterprise knowledge text keyword in each combination;
[0033] Sort the combinations in the search results in descending order of comprehensive similarity;
[0034] Output the sorted search results.
[0035] Optionally, the comprehensive similarity calculation expression is:
[0036] sim(T i , P) = (1-α) × sim(T i , S p )+α×sim(K i , K P ),
[0037] Among them, T i is the input text, P is the government and enterprise knowledge, S p For government and enterprise knowledge texts, K i K is the input text keyword, p Keywords for government and enterprise knowledge texts, sim(T i , P) represents the comprehensive similarity between the input text and government and enterprise knowledge, sim(T i , S p) represents the similarity between the vector features of the input text and the vector features of the government and enterprise knowledge text, sim(K i , K p ) represents the similarity between the vector features of the input text keywords and the vector features of the government and enterprise knowledge keywords, and α represents the semantic weight of the government and enterprise knowledge keywords in the government and enterprise knowledge description text.
[0038] Optionally, the method further comprises:
[0039] Obtaining statistical information of the keywords of the input text in the current business system, wherein the statistical information represents the frequency of occurrence of each keyword of the input text in the government affairs corresponding to the input text;
[0040] The weight of the input text keywords is determined based on the statistical information.
[0041] Optionally, after performing word segmentation processing on the input text and before respectively inputting the input text and the keywords of the input text into the semantic embedding model, the method further includes:
[0042] Perform text cleaning and stop word filtering on the input text.
[0043] In order to solve the above problems, the present invention also provides a knowledge base search system in the government and enterprise fields, the system comprising:
[0044] An acquisition module is used to obtain the input text to be searched;
[0045] The extraction module is used to perform word segmentation and keyword extraction on the input text to obtain the keywords of the input text;
[0046] A vector embedding module, used to input the input text and the keywords of the input text into the semantic embedding model respectively, to obtain the input text dense semantic vector corresponding to the input text, and the input text keyword dense semantic vector corresponding to the keywords of the input text;
[0047] A screening module is used to compare the input text dense semantic vector and the input text keyword dense semantic vector with the government and enterprise knowledge semantic vectors in the government and enterprise knowledge semantic vector library, and screen out the government and enterprise knowledge semantic vectors that meet the preset screening conditions as reference vectors;
[0048] The output module is used to extract the government and enterprise knowledge text and / or government and enterprise knowledge text keywords corresponding to the reference vector from the government and enterprise knowledge text library to obtain search results.
[0049] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0050] at least one processor; and,
[0051] a memory communicatively connected to the at least one processor; wherein,
[0052] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned government and enterprise field knowledge base search method.
[0053] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned government and enterprise field knowledge base search method.
[0054] In summary, this application includes the following beneficial technical effects:
[0055] When parsing the input text, the characteristics of the keywords are considered in addition to the semantics of the input text itself; considering the semantic similarity between the input text keywords and key information of government and enterprise knowledge can highlight the relevance of the text in key information, thereby improving the accuracy of search results for similar texts in the government and enterprise fields.
[0056] The dense vector used in this application not only contains the semantics of text vocabulary, but also contains the semantic information of sentence grammar, vocabulary position order and context, which can better reflect the real semantic information of the text.
[0057] Since there are many words with similar content in the government and enterprise fields, adding start and end tags can facilitate the model's confirmation of text content and type, and improve the model's recognition of input text or input text keywords. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 A schematic diagram of a process flow of a government and enterprise knowledge base search method provided by an embodiment of the present invention;
[0059] Figure 2 A schematic diagram of a process for embedding an input text and keywords of the input text into a dense semantic vector of a fixed dimension provided by an embodiment of the present invention;
[0060] Figure 3 The processing flow of the method for searching a knowledge base in the political and business fields in one embodiment of the present invention when the search results are multiple;
[0061] Figure 4 A schematic diagram of a process flow of a government and enterprise knowledge base search method provided by another embodiment of the present invention;
[0062] Figure 5A schematic diagram of the structure of an electronic device for implementing the government and enterprise field knowledge base search method provided in one embodiment of the present invention.
[0063] Reference numerals: 10, processor; 11, memory; 12, communication bus; 13, communication interface.
[0064] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0065] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0066] In the description of the present invention, it is necessary to understand that the terms "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0067] In the description of the present invention, unless otherwise specified and limited, it should be noted that the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the internal connection between two components. It can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to the specific circumstances.
[0068] Reference Figure 1 As shown, it is a flowchart of a method for searching a knowledge base in the government and enterprise field provided by an embodiment of the present invention. "Government and enterprise" is an abbreviation of government affairs and enterprise, and the government and enterprise field specifically refers to the government affairs field and the enterprise field. In this embodiment, the method for searching a knowledge base in the government and enterprise field includes:
[0069] S1. Obtain input text to be searched.
[0070] The input text may be manually input by a staff member, may be imported by an external device, or may be uploaded through a cloud platform. This embodiment does not limit the method for obtaining the input text.
[0071] S2. Perform word segmentation and keyword extraction on the input text to obtain keywords of the input text.
[0072] When processing the word segmentation of the input text, you can use existing word segmentation tools such as nltk, pkuseg, jieba, lac, etc.; the full name of NLTK in English is Natural Language Toolkit, NLTK is a platform for building Python programs to process human language data; PKUSEG is a Chinese word segmentation tool based on deep learning, developed by the Natural Language Processing and Social Humanities Computing Laboratory of Tsinghua University; Jieba is a commonly used Chinese word segmentation tool, supporting three word segmentation modes: precise mode, full mode and search engine mode; the full name of LAC in English is Language Analysis Component, LAC is a natural language processing tool developed by Baidu, mainly used for Chinese word segmentation and part-of-speech tagging. According to the actual situation of the text type and the text library, TF-IDF or TextRank can be used in combination with the business keyword library to extract keywords from the input text; TF-IDF's English full name is Term Frequency / Inverse Document Frequency, which is a method for measuring the importance of keywords in the field of information retrieval. The weight of keywords is calculated by term frequency and inverse document frequency; TextRank is a graph-based keyword extraction method that constructs a neighboring relationship network between words and uses the PageRank algorithm to calculate the rank of each word.
[0073] In this embodiment, when the input text is segmented, the entries in the comprehensive text library are referenced. The comprehensive text library contains text data in the fields of government affairs, finance, education, law, economy, medical care, transportation, employment, etc. collected from other business systems or open source projects. The comprehensive text library includes a comprehensive word segmentation library, a general stop word library and a business stop word library; the word segmentation library is a tool library for Chinese word segmentation, which contains a series of dictionaries and algorithms that can help the Chinese in the text to be segmented. The general stop word library refers to a word library used to filter out common but meaningless words in natural language processing. These words appear very frequently in the text, but usually do not contain specific meanings, so they are regarded as noise. The stop words in the business stop word library are frequently used in the government and enterprise fields, contain a low amount of information, and are not suitable as keywords, for example: "handling", "report", "application", etc. By using a stop word library, the quality and efficiency of text processing can be improved.
[0074] S3. Input the input text and the keywords of the input text into the semantic embedding model respectively. The semantic embedding model embeds the input text and the keywords of the input text into dense semantic vectors respectively, thereby obtaining the input text dense semantic vector and the input text keyword dense semantic vector.
[0075] In this embodiment, the embedding model is used to embed vectors for the input text or the keywords of the input text; the embedding model is a method for converting discrete data (such as text, images, etc.) into continuous vector representations, and the embedding model can adopt a suitable Transformer-based deep learning semantic embedding model; the vector storage part can adopt a suitable vector database such as faisss, pgvector, etc. according to actual performance requirements. FAISS (Facebook AI Similarity Search) is an open source library developed by Facebook, mainly used for large-scale similarity retrieval problems. It is written in C++ and provides a Python interface, which can provide millisecond-level retrieval performance when performing similarity searches on billion-level data sets; pgvector is another vector database, and pgvector is designed to be used to process various types of data sources.
[0076] The input text is embedded into a dense semantic vector of fixed dimension through deep learning semantic embedding models such as BERT and T5. BERT stands for Bidirectional Encoder Representations from Transformers, which is a pre-trained language representation model. T5 stands for Text to Text Transfer Transformer, which is a general model in the field of pre-trained language models proposed by Google.
[0077] The dense vector embedded by the deep learning model is used to represent the text semantics. The dense vector is relative to the one-hot encoded sparse vector obtained by the traditional bag-of-word (BoW)-based sentence embedding method. The one-hot encoding dimension is equal to the vocabulary size, and most dimensions are zero after embedding. The vector embedded by the deep learning model usually has a fixed dimension, such as 768 dimensions, and most dimensions are non-zero values and contain semantic information. The dense vector with fixed dimensions obtained by model embedding greatly improves the storage and search efficiency of vectors compared to sparse vectors with tens of thousands of dimensions.
[0078] Reference Figure 2 The dense vector used in this application not only contains the semantics of text vocabulary, but also contains the semantic information of sentence grammar, vocabulary position order and context, which can better reflect the real semantic information of the text.
[0079] Specifically, the method for the semantic embedding model to obtain the dense semantic vector of the input text / the dense semantic vector of the input text keyword includes:
[0080] S31. Input the input text / keywords of the input text into a tokenizer, which decomposes the input text / keywords of the input text into a list of subwords;
[0081] S32. Obtain a natural text corpus, which includes a list of subwords of several reference words and the IDs corresponding to the list of subwords of the reference words;
[0082] When the received text content is "natural language processing", decompose the received content into a list of subwords ["自", "然", "语", "言", "处", "理"] according to the natural text corpus.
[0083] S33. Map the list of subwords of the received text content to the IDs corresponding to the list of subwords according to the natural text corpus to obtain a list of subword IDs;
[0084] S34. Input the list of subword IDs into a deep learning model to output the embedding vectors of each subword in the received text content;
[0085] S35. Combine the embedding vectors of the subwords into a sentence-level embedding vector through average pooling, and use the sentence-level embedding vector as the dense semantic vector of the input text / dense semantic vector of the keywords of the input text.
[0086] In the preferred embodiment of this embodiment,
[0087] After the tokenizer decomposes the received text content into a list of subwords and before mapping the list of subwords of the received text content to the IDs corresponding to the list of subwords according to the natural text corpus, it further includes:
[0088] Add a start marker at the start position of the list of subwords and an end marker at the end position of the list of subwords.
[0089] For example, in this embodiment, add a [CLS] marker at the start position of the text and a [SEP] marker at the end position of the text, for example: ["[CLS]", "自", "然", "语", "言", "处", "理", "[SEP]"]. Since there are many similar words in the government and enterprise fields, adding a start marker and an end marker can facilitate the model to confirm the text content and type, and improve the recognition effect of the model on the input text or the keywords of the input text.
[0090] S4. Compare the dense semantic vector of the input text and the dense semantic vector of the keywords of the input text with the government and enterprise knowledge semantic vectors in the government and enterprise knowledge semantic vector library respectively, and select the government and enterprise knowledge semantic vectors that meet the preset screening conditions as reference vectors.
[0091] Government and enterprise knowledge represents information such as words and phrases commonly used in government services and enterprise operation and management; the government and enterprise knowledge semantic vector library includes several reference vectors, including government and enterprise knowledge text semantic vectors and government and enterprise knowledge text keyword semantic vectors;
[0092] Specifically, the semantic vector of government-enterprise knowledge text includes the semantic vector of government affairs knowledge text and the semantic vector of enterprise knowledge text; the keyword semantic vector of government-enterprise knowledge text includes the keyword semantic vector of government affairs knowledge text and the keyword semantic vector of enterprise knowledge text.
[0093] S5. Extract the government and enterprise knowledge text and / or government and enterprise knowledge text keywords corresponding to the reference vector from the government and enterprise knowledge text library to obtain search results.
[0094] The government and enterprise knowledge text database includes a number of government and enterprise knowledge texts and a number of government and enterprise knowledge text keywords;
[0095] The government-enterprise knowledge texts include a number of government affairs knowledge texts and a number of enterprise knowledge texts, and the government-enterprise knowledge text keywords include government affairs knowledge text keywords and a number of enterprise knowledge text keywords;
[0096] The search results include government and enterprise knowledge texts and combinations of government and enterprise knowledge text keywords;
[0097] In actual use, the number of search results may be 0, 1, or more;
[0098] In a preferred implementation of this embodiment, the government and enterprise domain knowledge base search method further includes:
[0099] Reference Figure 3 , determine the number of combinations of government and enterprise knowledge texts and government and enterprise knowledge text keywords included in the search results, and when the number is greater than or equal to 2, perform the following steps:
[0100] S661, calculating the cosine similarity between the dense semantic vector of the input text and the semantic vector of the government and enterprise knowledge text, to obtain the similarity between the input text and the government and enterprise knowledge text;
[0101] S662, performing cosine similarity calculation on the dense semantic vector of the input text keyword and the semantic vector of the government and enterprise knowledge text keyword to obtain the similarity between the input text keyword and the government and enterprise knowledge text keyword;
[0102] S663, calculating the comprehensive similarity of the government and enterprise knowledge text and the combination of government and enterprise knowledge text keywords based on the similarity between the input text and the government and enterprise knowledge text keywords and the similarity between the input text keywords and the government and enterprise knowledge text keywords;
[0103] The comprehensive similarity calculation expression is:
[0104] sim(Ti , P) = (1-α) × sim(T i , S p )+α×sim(K i , K P ),
[0105] Among them, T i is the input text, P is the government and enterprise knowledge, which represents the words and phrases commonly used in government services and enterprise operation and management; S p For government and enterprise knowledge texts, K i K is the input text keyword, p Keywords for government and enterprise knowledge texts, sim(T i , P) represents the comprehensive similarity between the input text and government and enterprise knowledge, sim(T i , S p ) represents the similarity between the vector features of the input text and the vector features of the government and enterprise knowledge text, sim(K i , K p ) represents the similarity between the vector features of the input text keywords and the vector features of the government and enterprise knowledge keywords, and α represents the semantic weight of the government and enterprise knowledge keywords in the government and enterprise knowledge description text.
[0106] A professional vector database is used to store vectors, and indexes are established using the Euclidean distance and inner product of the vectors to facilitate vector data updates and at the same time improve the search speed for similar vectors.
[0107] In addition to the text sentence semantics, key information semantics is also used as the second similarity feature. The similarity of the two features is dynamically weighted to obtain the comprehensive similarity of the text. The key information semantic similarity highlights the relevance of the text in key information, thereby improving the accuracy of similar text search results in the government and enterprise fields.
[0108] Obtain statistical information of the keywords of the input text in the current business system, where the statistical information represents the frequency of occurrence of each keyword of the input text in the government affairs corresponding to the input text; determine the weight of the keywords of the input text based on the statistical information.
[0109] In the specific implementation process, the keyword weights can be manually marked, or the keyword weight values can be automatically updated based on statistical information in the actual business system.
[0110] The weight value can roughly reflect the importance of the keyword in the search business. For example, for the item "motor vehicle driver's license review and inspection", the extracted keywords are "motor vehicle driver's license" and "review and inspection". In actual business, the frequency of using "motor vehicle driver's license" or its synonym "driver's license" as a keyword for search is much higher than "review and inspection". Therefore, "review and inspection" is usually not used as a keyword in semantic similarity calculation. The weight of the term "motor vehicle driver's license" is set according to the frequency of handling "motor vehicle driver's license review and inspection" in the driver's license handling matters in the business system, and can be updated in real time in the system at a certain period. For example, the recent "motor vehicle driver's license review and inspection" accounted for 20% of the driver's license handling business, and the weight can be directly updated to 20%.
[0111] S64, sorting the search results from high to low according to the comprehensive similarity of the government and enterprise knowledge text and the combination of keywords in the government and enterprise knowledge text;
[0112] S65. Output the sorted search results.
[0113] Reference Figure 4 In another embodiment of the present application, after the input text is segmented, and before the input text and the keywords of the input text are respectively input into the semantic embedding model, the government and enterprise domain knowledge base search method further includes:
[0114] S30, performing text cleaning and stop word filtering on the input text.
[0115] By removing insignificant words and special characters, the volume of data can be reduced, the dimension can be reduced, and thus the computational complexity can be reduced, and the efficiency of text processing can be improved. At the same time, the cleaning process can also help remove noise, ensure that the data is accurate, reliable and consistent, provide a better foundation for subsequent text analysis or modeling tasks, and improve the processing efficiency and accuracy of text data.
[0116] Based on the same inventive concept, an embodiment of the present invention provides a knowledge base search system in the government and enterprise fields.
[0117] The government and enterprise knowledge base search system of the present invention can be loaded in an electronic device. According to the implemented functions, the government and enterprise knowledge base search system includes an acquisition module, an extraction module, a vector embedding module, a screening module and an output module.
[0118] The acquisition module can acquire the input text to be searched, the government and enterprise knowledge text library, and the government and enterprise knowledge semantic vector library;
[0119] The extraction module can perform word segmentation on the input text and extract keywords from the input text to obtain the keywords of the input text;
[0120] The vector embedding module can input the input text and the keywords of the input text into the semantic embedding model respectively, and the semantic embedding model embeds the input text and the keywords of the input text into dense semantic vectors respectively, thereby obtaining the dense semantic vector of the input text and the dense semantic vector of the input text keywords;
[0121] The screening module can compare the dense semantic vector of the input text and the dense semantic vector of the input text keywords with the reference vectors in the government and enterprise knowledge semantic vector library, and screen out the reference vectors that meet the preset screening conditions;
[0122] The output module can filter out government and enterprise knowledge texts and / or government and enterprise knowledge text keywords corresponding to reference vectors that meet preset filtering conditions from the government and enterprise knowledge text library to obtain search results.
[0123] The module described in the present invention may also be referred to as a unit, which refers to a series of computer program segments that can be executed by a processor of an electronic device and can complete fixed functions, and is stored in a memory of the electronic device.
[0124] The various variations and specific examples of the government and enterprise field knowledge base search method provided in the above embodiment are also applicable to the government and enterprise field knowledge base search system of this embodiment. Through the above detailed description of the government and enterprise field knowledge base search method, technical personnel in this field can clearly know the implementation method of the government and enterprise field knowledge base search system in this embodiment. For the sake of brevity of the specification, it will not be described in detail here.
[0125] The present application also discloses an electronic device, such as Figure 5 , which is a schematic diagram of the structure of an electronic device for searching a knowledge base in the government and enterprise field according to an embodiment of the present invention. The electronic device may include at least one processor 10, a memory 11 connected to the at least one processor for communication, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a program for searching a knowledge base in the government and enterprise field.
[0126] Among them, the processor 10 can be composed of an integrated circuit in some embodiments, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPU), microprocessors, digital processing chips, graphics processors and various control chips. The processor 10 is the control core (Control Unit) of the electronic device, which uses various interfaces and lines to connect the various components of the entire electronic device, and executes or executes the program or module stored in the memory 11 (for example, executing the government and enterprise field knowledge base search method, etc.), and calls the data stored in the memory 11 to execute various functions of the electronic device and process data.
[0127] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the knowledge base search method program in the government and enterprise fields, but also can be used to temporarily store data that has been output or is to be output.
[0128] The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0129] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0130] Figure 5 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 5 The structure shown does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0131] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to various components. Preferably, the power source may be logically connected to at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0132] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited by this structure.
[0133] Furthermore, if the module / unit integrated in the electronic device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile.
[0134] The present application embodiment provides a computer-readable storage medium, for example, including: any entity or device, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM) that can carry the computer program code. The computer-readable storage medium stores a computer program that can be loaded by a processor and execute the government and enterprise field knowledge base search method of the above embodiment.
[0135] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", "an implementation", "a preferred implementation" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0136] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A knowledge base search method in the government and enterprise field, characterized in that: Get the input text to be searched; Perform word segmentation and keyword extraction on the input text to obtain the keywords of the input text; Inputting the input text and the keywords of the input text into the semantic embedding model respectively, obtaining the input text dense semantic vector corresponding to the input text, and the input text keyword dense semantic vector corresponding to the keywords of the input text; The dense semantic vector of the input text and the dense semantic vector of the input text keywords are respectively compared with the government and enterprise knowledge semantic vectors in the government and enterprise knowledge semantic vector library, and the government and enterprise knowledge semantic vectors that meet the preset screening conditions are selected as reference vectors; The government and enterprise knowledge text and / or government and enterprise knowledge text keywords corresponding to the reference vector are extracted from the government and enterprise knowledge text library to obtain search results.
2. The government and enterprise domain knowledge base search method according to claim 1, characterized in that: The method for obtaining the dense semantic vector of input text / the dense semantic vector of input text keywords by the semantic embedding model includes: Inputting the input text / keywords of the input text into a word segmenter, and the word segmenter decomposes the input text / keywords of the input text into a list of subwords; Obtain a natural text vocabulary, the natural text vocabulary including a subword list of a plurality of reference words and an ID corresponding to the subword list of the reference words; Mapping the subword list of the received text content to the ID corresponding to the subword list according to the natural text vocabulary to obtain a subword ID list; Input the subword ID list into the deep learning model and output the embedding vector of each subword in the received text content; The embedding vectors of the subwords are merged into a sentence-level embedding vector through an average pooling method, and the sentence-level embedding vector is used as the input text dense semantic vector / input text keyword dense semantic vector.
3. The government and enterprise domain knowledge base search method as claimed in claim 2, characterized in that: After the word segmenter decomposes the received text content into a subword list, and before the subword list of the received text content is mapped to an ID corresponding to the subword list according to the natural text word library, the method further includes: Add a start tag at the beginning of the subword list and a end tag at the end of the subword list.
4. The method for searching a knowledge base in the government and enterprise field according to any one of claims 1 to 3, characterized in that: The search results include a combination of government and enterprise knowledge texts and government and enterprise knowledge text keywords; Determine the number of combinations of government and enterprise knowledge texts and government and enterprise knowledge text keywords included in the search results, and when the number is greater than or equal to 2, perform the following steps: Calculate the cosine similarity between the dense semantic vector of the input text and the semantic vector of the government and enterprise knowledge text to obtain the similarity between the input text and the government and enterprise knowledge text; Calculate the cosine similarity between the dense semantic vector of the input text keyword and the semantic vector of the government and enterprise knowledge text keyword to obtain the similarity between the input text keyword and the government and enterprise knowledge text keyword; Calculate the comprehensive similarity of each combination according to the similarity between the input text and the government and enterprise knowledge text and the similarity between the input text keyword and the government and enterprise knowledge text keyword in each combination; Sort the combinations in the search results in descending order of comprehensive similarity; Output the sorted search results.
5. The government and enterprise knowledge base search method according to claim 4, characterized in that: The comprehensive similarity calculation expression is: sim(T i ,P)=(1-α)×sim(T i ,S p )+α×sim(K i ,K P ), Among them, T i is the input text, P is the government and enterprise knowledge, S p For government and enterprise knowledge texts, K i K is the input text keyword, p Keywords for government and enterprise knowledge texts, sim(T i ,P) represents the comprehensive similarity between the input text and government and enterprise knowledge, sim(T i ,S p ) represents the similarity between the vector features of the input text and the vector features of the government and enterprise knowledge text, sim(K i ,K p ) represents the similarity between the vector features of the input text keywords and the vector features of the government and enterprise knowledge keywords, and α represents the semantic weight of the government and enterprise knowledge keywords in the government and enterprise knowledge description text.
6. The government and enterprise domain knowledge base search method according to claim 1, 2, 3 or 5, characterized in that: The method further comprises: Obtaining statistical information of the keywords of the input text in the current business system, wherein the statistical information represents the frequency of occurrence of each keyword of the input text in the government affairs corresponding to the input text; The weight of the input text keywords is determined based on the statistical information.
7. The method for searching government and enterprise domain knowledge base according to claim 1, 2, 3 or 5, characterized in that: After the word segmentation processing is performed on the input text, and before the input text and the keywords of the input text are respectively input into the semantic embedding model, the method further includes: Perform text cleaning and stop word filtering on the input text.
8. A government and enterprise knowledge base search system, used to implement the government and enterprise knowledge base search method according to any one of claims 1 to 7, characterized in that: include: An acquisition module is used to obtain the input text to be searched; The extraction module is used to perform word segmentation and keyword extraction on the input text to obtain the keywords of the input text; A vector embedding module, used to input the input text and the keywords of the input text into the semantic embedding model respectively, to obtain the input text dense semantic vector corresponding to the input text, and the input text keyword dense semantic vector corresponding to the keywords of the input text; A screening module is used to compare the input text dense semantic vector and the input text keyword dense semantic vector with the government and enterprise knowledge semantic vectors in the government and enterprise knowledge semantic vector library, and screen out the government and enterprise knowledge semantic vectors that meet the preset screening conditions as reference vectors; The output module is used to extract the government and enterprise knowledge text and / or government and enterprise knowledge text keywords corresponding to the reference vector from the government and enterprise knowledge text library to obtain search results.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor (10); and, a memory (11) communicatively connected to the at least one processor (10); Wherein, the memory (11) stores a computer program that can be executed by the at least one processor (10), and the computer program is executed by the at least one processor (10) so that the at least one processor (10) can execute the government and enterprise field knowledge base search method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer storage medium stores a computer program; when the computer program is executed by the processor, it implements the government and enterprise field knowledge base search method as described in any one of claims 1 to 7.