A semantic similarity vector sparse coding indexing and retrieval method
By combining the deep learning semantic similarity model and the inverted index, and using the semantic similarity vector sparse coding index method, the accuracy and efficiency problems of the search engine in the semantic retrieval and recall stages are solved, and efficient semantic retrieval and index construction are achieved. .
Patent Information
- Application Number
- CN202210228816.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2042-03-08
AI Technical Summary
Existing search engines have problems with low recall and throughput in semantic retrieval, and the recall phase of mainstream reordering retrieval methods is not accurate enough, making it difficult to efficiently build and retrieve semantic indexes under massive data.
The deep learning semantic similarity model is combined with the inverted index, and the dense semantic vector is converted into a string through the semantic similarity vector and then sparse coding indexing method, and is stored in the index library for inverted sorting indexing, and the BM25 algorithm is used for correlation Sorting to improve the accuracy of semantic retrieval.
It effectively improves the accuracy of semantic retrieval, reduces the time and computing resource occupancy, achieves millisecond-level response, solves the problem that traditional methods cannot retrieve document results with similar semantics but different keywords, and saves time and calculations. resource.
Smart Images

Figure CN114860868B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of information retrieval, and relates to an information retrieval method combining a deep learning semantic similarity model and an inverted index, and specifically relates to a semantic similarity vector sparse coding indexing and retrieval method. Background Art
[0002] Information retrieval (IR) refers to the process and technology of organizing and storing information in a certain way and finding relevant information according to the needs of information users. Search engines are important tools for information retrieval. Traditional information retrieval methods mainly use keyword matching (conditional retrieval) technology. Users use one or more keywords to express their query intentions and submit the keywords as retrieval conditions to the search engine. Character matching is performed based on keywords and information resource indexing databases according to certain search strategies to find the required information. The document index for keyword retrieval is generally constructed based on the bag-of-words model to build an inverted structure. Each document is only regarded as a collection of a series of words. The retrieval query of the inverted table is a Boolean query task of a word item.
[0003] Since the advent of the information age, the explosive growth of information has made information retrieval technology particularly important. How to understand the meaning of the retrieved content from a semantic level, for example: "fat" people and "fat" servers, "computers" and "computers", "operating systems" and "Linux, IOS", etc., and accurately and quickly retrieve the content that users really want from massive information has become a key research topic.
[0004] The core of semantic indexing and search is user-based search, understanding user search behavior and motivation, and obtaining the most suitable information for user needs based on user context and intent analysis on the basis of original keyword search. Semantic indexing and relevance search research involves word segmentation, inverted indexing, query semantic analysis, word-sentence-paragraph-document-level semantic understanding, sorting rules, semantic similarity matching, and search engines. Many scholars have carried out a lot of theoretical research and technical exploration based on semantics and machine learning, deep learning, natural language understanding, and search algorithms based on traditional search technology.
[0005] (1) In terms of index text parsing, when search engines are used for rich text content, there are problems with low recall and throughput. Hao-peng Chan et al. designed a cloud search engine system based on Solr. They segment words based on rich text content and semantics, calculate the weight of each keyword, establish a text index, use the BM25 algorithm to calculate the similarity between keywords and text, and perform searches based on the similarity calculation.
[0006] (2) In terms of semantic understanding and representation of indexed documents, Salton et al. first proposed the vector space model (VSM), which maps text into vectors based on word frequency statistics. Landauer et al. proposed the LSI model based on the VSM model, which maps text from the vector space of terms to the semantic vector space through singular value decomposition (SVD), so that the vector has certain semantic information.
[0007] (3) Based on deep learning methods to realize text semantic vectorization, Devlin et al. proposed a new language expression BERT model (Bidirectional Encoder Representations from Transformers, BERT). All layers of this model focus on the contextual information of the entire context. Using a pre-trained model, an output layer is added, and fine-tuned to obtain good results on 11 tasks in the NLP field. Recently, Nils Reimers et al. proposed a Sentence-BERT model (SBERT), which improves the pre-trained BERT network and uses conjoined and triplet network structures to derive semantically meaningful sentences and compare cosine similarity. This improves speed while maintaining accuracy, and speeds up the query and sorting of massive similar texts.
[0008] (4) In terms of semantic dense vector search and sorting, the nearest neighbor search is the latest method to solve the problem of high-dimensional vector space. Facebook's Faiss package and Spotify's Annoy package are currently advanced methods of high-dimensional dense vector search and matching technology. However, Faiss is only a basic vector retrieval algorithm library that can run on a single machine and does not support distributed index construction. In the scenario of massive data, when the vector data set reaches tens of billions or more, building an index on a single machine will result in a single machine processing data volume, a long time to build the index, and the index built may reach more than 100 GB or even TB level, which will exceed the memory resource limit of the physical node of a single machine.
[0009] In general, although the above research has achieved certain results, it is still in the exploratory stage. The application practice of text semantic search is in its infancy. How to achieve efficient index construction and retrieval based on semantics and deep learning is still the focus and difficulty of research.
[0010] In order to solve the problems that existing search engines cannot realize semantic retrieval and the recall stage of the current mainstream re-ranking retrieval method is not accurate enough, the present invention designs a semantic retrieval method of dense vector and sparse coding based on the most commonly used inverted index method and deep learning semantic similarity model in modern search engines, so as to realize efficient index construction and retrieval based on semantics and deep learning. Summary of the invention
[0011] In view of the shortcomings of the prior art, the present invention provides a semantic similarity vector sparse coding indexing and retrieval method, which is based on the combination of a deep learning semantic similarity model and an inverted index, retains the representation characteristics of the semantic model vector, and effectively eliminates errors in the recall stage. It is used to solve the problems that commonly used search engines cannot realize semantic retrieval and the current mainstream re-ranking retrieval method is not accurate enough in the recall stage, thereby improving the accuracy of semantic retrieval.
[0012] In order to solve the above technical problems, the technical solution adopted by the present invention includes two parts, namely:
[0013] In the first part, the present invention provides a semantic similarity vector sparse coding indexing method, comprising the following steps:
[0014] Step S11, text semantic vectorization: using the deep learning semantic similarity model to generate a dense semantic vector that stores the semantic information of the text sentence from the input text data;
[0015] Step S12, re-sparse encoding of dense semantic vector: re-sparse encoding of the dense semantic vector generated in step S1 from vector form into a character string that preserves semantic information;
[0016] Step S13, inverted index: store the character string generated in step S2 into different fields in the index library for inverted indexing, and establish an inverted index for all documents.
[0017] Furthermore, the deep learning semantic similarity model adopted is a method that combines the SBERT model with the LSI model; when the input text length is less than 512, the SBERT model is used to convert the text into a semantic vector; when the text length is greater than 512, the long text is first divided into multiple short texts with a length not greater than 512 and the SBERT model is used to generate multiple semantic vectors, and then the average vector of multiple vectors except the first semantic vector is taken together with the first semantic vector as the SBERT semantic vector of this text. When the input text length is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text.
[0018] Further, in step S12, the dense semantic vector is converted into a string according to the following encoding format: each encoded vector string is represented by the dimension of the vector stored in the first bit, the second bit uses P or N to represent the positive or negative of the vector, positive is positive, and negative is negative, and the following bits are vector values with n decimal places retained according to the selected precision n, where the integer and decimal parts are connected with A.
[0019] Furthermore, when the SBERT model is combined with the LSI model, in step S13, the strings of the two model semantic vectors after sparse encoding are stored in different fields in the index library for inverted indexing: three new Field fields are created in the index library, the length of the text is stored in one field, and the remaining two fields store the SBERT vector string after sparse encoding of the dense semantic vector in step S2 in one field, and the LSI vector string in another field. The SBERT and LSI encoded strings are used as terms to establish dictionaries respectively, and inverted indexes are established for all documents based on the two dictionaries.
[0020] In the second part, the present invention provides an information retrieval method, which first determines whether the text to be retrieved is a document or a keyword. In the first case, when the type of the text to be retrieved is a document, the method includes the following methods:
[0021] S21, semantic vectorization of the text to be retrieved, detecting the length of the input retrieval content, and selecting different deep learning semantic similarity models according to the text length to generate a dense semantic vector that preserves the semantic information of the text sentence;
[0022] S22, sparsely encode the dense semantic vector of the text to be retrieved, and sparsely encode the dense semantic vector generated based on the deep learning semantic similarity model in step S21 from the vector form to a character string that retains the semantic information;
[0023] S23, sorting the encoded text similarity, using the search engine's inverted index, searching the encoded vector string according to the "or" relationship of the string, and completing the relevance sorting through the BM25 algorithm; the second case, when the type of the text to be retrieved is a keyword, includes the following methods:
[0024] S24, keyword search, perform keyword search on the text to be searched in the search engine and obtain the top-Y of the search results;
[0025] S25, re-search the Top-Y results. For each of the Top-Y results obtained in step S24, search the string and recall the Top-M results according to the method in the encoded text similarity sorting in step S23 when the type of the text to be searched is a document. The Top-Y results of the keyword search can recall Y*M results.
[0026] S26, deduplicate and re-sort the search results. First, remove the duplicate results from the Y*M results obtained in step S25. Then, since each result is obtained through two searches, the two scores are score1 and score2 respectively. Re-sort the de-duplicate results according to score1*score2, and finally take the Top-Y of the sorted results as the final recall results.
[0027] Furthermore, in step S21, when the text length is less than 512, the SBERT model is used to convert the text into a semantic vector. When the text length is greater than 512, the long text is divided into multiple short texts with a length not greater than 512 and the SBERT model is used to generate multiple semantic vectors. Then, the average vector of multiple vectors except the first short text semantic vector is taken and combined with the first short text semantic vector as the SBERT semantic vector of the text to be retrieved; when the input text length is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text.
[0028] Furthermore, in step S22, the encoding format is the same as the encoding format described above.
[0029] Furthermore, in step S23, when the length of the text to be retrieved does not exceed 512, the semantic vector string of the text to be retrieved based on the SBERT model semantic vector encoding is input into the search engine as the search content and the Top-N similar results are recalled; when the length of the text to be retrieved is greater than 512, the semantic vector string of the text to be retrieved based on the SBERT model semantic vector encoding is first input into the search engine as the search content and the Top-N similar results are recalled, and then the semantic vector string of the text to be retrieved based on the LSI model semantic vector encoding is input into the search engine as the search content and the Top-N similar results are recalled, and finally the results obtained by the two recall methods are re-sorted according to the weighted score method and the Top-N ranking results are taken as the final recall results.
[0030] Furthermore, in step S25, for each of the Top-Y results obtained in step S24, first determine the relationship between the Field storing the text length in the result and 512, and then, based on the determination result, retrieve the semantic character string stored in the LSI field or SBERT field of the result and recall the Top-M results according to the method of sorting the encoded text similarity in step S23.
[0031] Compared with the prior art, the present invention has the following advantages:
[0032] (1) The semantic vector retrieval method provided by the present invention is based on the combination of a deep learning semantic similarity model and an inverted index. The input text is first generated into a semantic vector using a deep learning semantic similarity model. The generated dense semantic vector is then sparsely encoded from a vector form into a string that preserves the semantic information and stored in a search engine as a field. Finally, the string containing the semantic information is retrieved using the basic search function of the search engine, and the Top-N semantically similar texts are recalled. The present invention can better retain the representation characteristics of the pre-trained semantic model vector, effectively eliminate errors in the recall stage, and improve the accuracy of semantic retrieval. Compared with brute force cosine similarity calculation, it can take advantage of the sparse text search engine, greatly reduce the time and computing resource usage, and achieve millisecond-level response to the recall of results.
[0033] (2) The present invention solves the problem that traditional TF-IDF and BM25 algorithms cannot retrieve documents with similar semantics but different keywords, and the problem that retrieval based on LDA and LSI algorithms requires the determination of the number of topic clusters and has a low accuracy rate, while also significantly saving time and computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0035] Figure 1 The present invention provides a flowchart for constructing an inverted index.
[0036] Figure 2 Schematic diagram of dense vector sparse encoding rules in Example 1.
[0037] Figure 3 This is an example diagram of sparse encoding of text vectors in Example 1.
[0038] Figure 4 This is the index storage structure diagram in Example 1.
[0039] Figure 5 It is the information retrieval flow chart of the present invention. DETAILED DESCRIPTION
[0040] The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
[0041] The traditional retrieval methods commonly used in search engines (such as TF-IDF, BM25, LDA, LSI) have low MRR, accuracy and other indicators. At the same time, for each search content, the Bert semantic vectors of all data in the library are traversed and the cosine similarity is calculated and sorted. Although the method has a higher accuracy, this work will consume a lot of time and computing resources when the amount of data is large, and it is difficult to use in industrial practice. Based on the most commonly used inverted index method and deep learning semantic similarity model in modern search engines, the present invention designs a semantic retrieval method of dense vector and sparse coding, which can retain the semantic features of the SBERT model, and has fast response time and low resource occupancy. It includes two parts, the first part is to construct an inverted index of text semantic vectors, and the second part is the retrieval of semantic vector indexes, which are introduced below.
[0042] Example 1
[0043] A semantic similarity vector sparse coding indexing method, the flow chart is as follows Figure 1 As shown, the following steps are included:
[0044] Step S11, text semantic vectorization: using the deep learning semantic similarity model to generate a dense semantic vector that preserves the semantic information of the text sentence for the input text data.
[0045] It should be noted that different deep learning semantic similarity models can be selected in the semantic vector generation stage. The deep learning semantic similarity model adopted in this embodiment is a method that combines the SBERT model and the LSI model.
[0046] According to the length of the input text, choose to use the SBERT model or LSI model to generate a semantic vector. When the input text length is less than 512, the SBERT model is used to convert the text into a semantic vector. However, the maximum token length supported by the SBERT model is 512. When the text length is greater than 512, it exceeds the maximum length that BERT can handle. Therefore, first divide the long text into multiple short texts with a length not greater than 512 and use the SBERT model to generate multiple semantic vectors. Then, take the average vector of multiple vectors except the first semantic vector and use it together with the first semantic vector as the SBERT semantic vector of this text. The specific operation of the algorithm for dividing long text into multiple short texts is as follows:
[0047] Table 1
[0048]
[0049]
[0050] Since the LSI model has a better effect on long texts, when the input text length is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text. That is to say, when the text length is greater than 512, two model vectors are generated. The vectors generated by the two models are both in digital form, which preserves the semantic information of the sentence.
[0051] Step S12, sparsely encoding the dense semantic vector: that is, sparsely encoding the dense semantic vector generated in step S1 from a vector form into a character string that preserves the semantic information.
[0052] The semantic vector generated by the SBERT model or LSI model in the previous step is converted into a string according to the selected precision and in a specific encoding format, retaining the vector's dimension, position, numerical size and other information. Specific encoding format: Each encoded vector string is represented by the first digit storing the dimension of the vector, the second digit uses P or N to represent the positive or negative of the vector (positive is positive, negative is negative), and the following digits are the vector values with n decimal places retained according to the selected precision n, where the integer and decimal parts are connected with A (and). For example, the four-dimensional vector [0.1265, -0.523, 1.23, -1.248] can be encoded into a string [1P0A13, 2N0A52, 3P1A23, 4N1A25]. The specific encoding rules are as follows: Figure 2 For example, the process of generating and encoding the semantic vector for the sentence “The sea embraces hundreds of rivers, and taking them will lead you far.” is as follows Figure 3 shown.
[0053] Step S13, inverted index: store the character string generated in step S2 into different fields in the index library for inverted indexing, and establish an inverted index for all documents.
[0054] The sparsely encoded strings of the semantic vectors of the two models are stored in different fields in the index library for inverted indexing. Three new Field fields are created in the index library. The length of the text is stored in one field. The remaining two fields store the SBERT vector string after sparse encoding of the dense semantic vector in step S2 in one field, and the LSI vector string in another field. The strings encoded by SBERT and LSI are used as terms to establish dictionaries respectively, and an inverted index is established for all documents based on the two dictionaries. The storage structure is as follows: Figure 4 shown.
[0055] Example 2
[0056] This embodiment provides an information retrieval method, specifically a semantic similarity vector sparse coding retrieval method, the process is as follows: Figure 5 As shown, the scheme is as follows:
[0057] The text to be retrieved can be divided into two types: documents and keywords. Therefore, we first determine whether the text to be retrieved is a document or a keyword, and then handle the two situations separately.
[0058] In the first case, the type of text to be retrieved is a document:
[0059] S21. Semantic vectorization of the text to be retrieved is performed. The length of the input search content is detected, and different deep learning semantic similarity models are selected according to the length of the text to generate a dense semantic vector that preserves the semantic information of the text sentence.
[0060] The following still uses the two deep learning semantic similarity models used in the first embodiment as an example. When the text length is less than 512, the SBERT model is used to convert the text into a semantic vector. When the text length is greater than 512, the long text is divided into multiple short texts of length not greater than 512 and the SBERT model is used to generate multiple semantic vectors. The long text segmentation method is the same as above (the same as that described in the first embodiment), and then the average vector of multiple vectors except the first short text semantic vector is taken and used together with the first short text semantic vector as the SBERT semantic vector of the text to be retrieved. When the input text length is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text.
[0061] S22, sparsely encode the dense semantic vector of the text to be retrieved, and sparsely encode the dense semantic vector generated based on the deep learning semantic similarity model in step S21 from vector form to a character string that retains the semantic information.
[0062] Specifically, the dense semantic vector generated based on the SBERT model and the LSI model is sparsely encoded from the vector form according to the selected precision and in a specific encoding format into a character string that retains the semantic vector dimension, position, numerical size and other information. The encoding format is the same as the encoding format in the sparse encoding of the dense semantic vector in the second step S12 of the first part of constructing the inverted index recorded in Example 1, and will not be repeated here.
[0063] S23, sorting of encoded text similarity, retrieval is to use the basic search function in the search engine to retrieve the string containing semantic information. The current mainstream information retrieval systems based on inverted indexes include Sphinx, Lucene and its extensions ElasticSearch, Solr, etc. With the help of the search engine's inverted index, the encoded vector string is retrieved according to the "or" relationship of the string, and the relevance sorting is completed through the BM25 algorithm.
[0064] The BM25 algorithm formula is as follows:
[0065]
[0066] Among them, q i Represents a morpheme after query parsing, IDF(q i ) indicates q i Inverse document frequency value, f(q i ,D) is q i The frequency of occurrence in document D, |D| is the length of document D, avgdl is the average length of all documents, and k1 and b are adjustment factors.
[0067] When the length of the text to be retrieved does not exceed 512, the semantic vector string encoded by the semantic vector of the SBERT model is input into the search engine as the search content and the Top-N similar results are recalled. When the length of the text to be retrieved is greater than 512, the semantic vector string encoded by the semantic vector of the SBERT model is first input into the search engine as the search content and the Top-N similar results are recalled. Then the semantic vector string encoded by the semantic vector of the LSI model is input into the search engine as the search content and the Top-N similar results are recalled. Finally, the results obtained by the two recalls are re-sorted according to the weighted score method and the Top-N ranking results are taken as the final recall results.
[0068] In the second case, the type of text to be searched is a keyword:
[0069] S24, keyword search, perform keyword search on the text to be searched in the search engine and obtain the top-Y search results.
[0070] S25, Top-Y results are searched again. For each of the Top-Y results obtained in step S24, first determine the relationship between the field storing the text length and 512, and then, based on the determination result, search the semantic string stored in the LSI field or SBERT field of the result according to the method in the encoding text similarity sorting in step S23 and recall the Top-M results. Since each result can recall M results, the Top-Y results of the keyword search can recall Y*M results.
[0071] S26, deduplicate and re-sort the search results. First, remove the duplicate results from the Y*M results obtained in the above step S25. Then, since each result is obtained through two searches, the two scores are score1 and score2 respectively, the de-duplicated results are re-sorted according to score1*score2. Finally, the Top-Y of the sorted results are taken as the final recall results.
[0072] The present invention is experimentally compared with TF-IDF, BM25 retrieval algorithm, latent semantic LDA and LSI method, pre-training model + ANN search engine method on multiple public data sets. Among them, the short text data sets used in the experiment include Quora question answer data set, LCQMC semantic matching data set, OPPO Xiaobu Assistant algorithm data set, and the long text data set used is the Chinese news data set THUCNews, which tests the semantic similarity text retrieval effect under two different data sets of Chinese and long text respectively. The short text data experiment uses MRR (Mean reciprocal rank) as the retrieval evaluation index, and the long text data experiment uses the accuracy of the recall result TOP10, that is, P@10, as the retrieval evaluation standard.
[0073]
[0074] Among them, Q is the number of retrievals, rank i is the ranking of the i-th correct retrieval result in the recall result
[0075] The recall results of the present invention in the short text data set are shown in Table 2. The MRR values are higher than the traditional BM25 algorithm, Bert semantic vector ANN similarity calculation method, and SBert semantic vector ANN similarity calculation method. The TOP10 recall results in the long text data set are shown in Table 3. The P@10 accuracy is higher than the traditional TF-IDF, BM25 algorithm, and classic topic models such as LDA and LSI, and slightly lower than the Bert semantic vector similarity calculation method.
[0076] The experimental retrieval results under two different data sets show that: this method can better retain the representation characteristics of the pre-trained semantic model vector and effectively eliminate the error in the recall stage; compared with the brute force cosine similarity calculation, it can take advantage of the sparse text search engine, greatly reduce the time and computing resource utilization, and achieve millisecond-level response for the recall of results. This method not only solves the problem that traditional TF-IDF, BM25 algorithms cannot retrieve documents with similar semantics but different keywords, and the problem that retrieval based on LDA and LSI algorithms requires the determination of the number of topic clusters and has low accuracy, but also greatly saves time and computing resources.
[0077] Table 2
[0078] BM25 Bert+ANN SBert+ANN The present invention Quora 0.338 0.386 0.392 0.408 LCQMC 0.556 0.686 0.707 0.709 OPPO 0.3 0.502 0.539 0.545
[0079] Table 3
[0080] TF-IDF BM25 LDA LSI Bert+ANN The present invention physical education 0.775 0.88 0.96 0.965 0.973 0.938 Home 0.675 0.669 0.915 0.914 0.919 0.898 entertainment 0.682 0.885 0.818 0.93 0.978 0.944 Real Estate 0.791 0.777 0.854 0.893 0.921 0.86 educate 0.726 0.77 0.842 0.870 0.944 0.902 Fashion 0.706 0.91 0.805 0.917 0.968 0.94 Current Affairs 0.805 0.766 0.765 0.901 0.928 0.932 game 0.609 0.888 0.812 0.941 0.982 0.94 science and technology 0.508 0.848 0.798 0.922 0.952 0.94 Finance 0.798 0.828 0.866 0.923 0.927 0.919 average 0.707 0.822 0.844 0.917 0.948 0.921
[0081] In summary, the present invention can retain the semantic vector features of the pre-trained SBERT model. Compared with the current mainstream semantic retrieval method of keyword retrieval to recall partial data and then re-sort them using semantic vectors, it eliminates the errors in the recall stage and improves the accuracy. At the same time, it has a fast response time and low resource occupancy, which can meet the computational requirements of semantic information retrieval in applications.
[0082] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Any changes, modifications, additions or substitutions made by ordinary technicians in this technical field within the essential scope of the present invention should fall within the protection scope of the present invention.
Claims
1. A semantic similarity vector sparse coding indexing method, characterized in that: The following steps are involved: Step S11, text semantic vectorization: using the deep learning semantic similarity model to generate a dense semantic vector that stores the semantic information of the text sentence from the input text data; The deep learning semantic similarity model used is a method that combines the SBERT model with the LSI model. When the input text length is less than 512, the SBERT model is used to convert the text into a semantic vector. When the text length is greater than 512, the long text is first divided into multiple short texts with a length not greater than 512 and the SBERT model is used to generate multiple semantic vectors. Then, the average vector of multiple vectors except the first semantic vector is taken together with the first semantic vector as the SBERT semantic vector of this text. When the input text length is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text. Step S12, re-sparse encoding of dense semantic vector: re-sparse encoding of the dense semantic vector generated in step S1 from vector form into a character string that preserves semantic information; Step S13, inverted index: store the character string generated in step S2 into different fields in the index library for inverted indexing, and establish an inverted index for all documents.
2. A semantic similarity vector sparse coding indexing method according to claim 1, characterized in that: In step S12, the dense semantic vector is converted into a character string according to the following encoding format: each encoded vector character string is represented by the dimension of the vector stored in the first bit, the second bit uses P or N to represent the positive or negative of the vector, positive is positive, and negative is negative, and the following bits are the vector values with n decimal places retained according to the selected precision n, where the integer and decimal parts are connected with A.
3. A semantic similarity vector sparse coding indexing method according to claim 1, characterized in that: When the SBERT model is combined with the LSI model, in step S13, the sparsely encoded strings of the semantic vectors of the two models are respectively stored in different fields in the index library for inverted indexing: three new Field fields are created in the index library, the length of the text is stored in one field, and the SBERT vector string sparsely encoded by the dense semantic vector in step S2 is stored in one field in the other two fields, and the LSI vector string is stored in another field. The SBERT and LSI encoded strings are used as terms to establish dictionaries respectively, and an inverted index is established for all documents based on the two dictionaries.
4. A semantic similarity vector sparse coding retrieval method, characterized in that: First, determine whether the text to be searched is a document or a keyword. In the first case, when the type of the text to be searched is a document, the following methods are included: S21, semantic vectorization of the text to be retrieved, detecting the length of the input retrieval content, and selecting different deep learning semantic similarity models according to the text length to generate a dense semantic vector that preserves the semantic information of the text sentence; In step S21, when the length of the text is less than 512, the SBERT model is used to convert the text into a semantic vector. When the length of the text is greater than 512, the long text is divided into multiple short texts of length not greater than 512 and the SBERT model is used to generate multiple semantic vectors. Then, the average vector of multiple vectors except the first short text semantic vector is taken and used together with the first short text semantic vector as the SBERT semantic vector of the text to be retrieved. When the length of the input text is greater than 512, the LSI model is used to generate a semantic vector based on the LSI model for the input text. S22, sparsely encode the dense semantic vector of the text to be retrieved, and sparsely encode the dense semantic vector generated based on the deep learning semantic similarity model in step S21 from the vector form to a character string that retains the semantic information; S23, sorting the encoded text similarity, using the search engine's inverted index, searching the encoded vector strings according to the "or" relationship of the strings, and completing the relevance sorting through the BM25 algorithm; The second case, when the type of text to be searched is a keyword, includes the following methods: S24, keyword search, perform keyword search on the text to be searched in the search engine and obtain the top-Y of the search results; S25, re-search the Top-Y results. For each of the Top-Y results obtained in step S24, search the string and recall the Top-M results according to the method in the encoded text similarity sorting in step S23 when the type of the text to be searched is a document. The Top-Y results of the keyword search can recall Y*M results. S26, deduplicate and re-sort the search results. First, remove the duplicate results from the Y*M results obtained in step S25. Then, since each result is obtained through two searches, the two scores are score1 and score2 respectively. Re-sort the de-duplicate results according to score1*score2, and finally take the Top-Y of the sorted results as the final recall results.
5. A semantic similarity vector sparse coding retrieval method according to claim 4, characterized in that: In step S22, the encoding format is the same as the encoding format described in claim 3.
6. A semantic similarity vector sparse coding retrieval method according to claim 4, characterized in that: In step S23, when the length of the text to be retrieved does not exceed 512, the semantic vector string of the text to be retrieved based on the SBERT model semantic vector encoding is input into the search engine as the search content and the Top-N similar results are recalled; when the length of the text to be retrieved is greater than 512, the semantic vector string of the text to be retrieved based on the SBERT model semantic vector encoding is first input into the search engine as the search content and the Top-N similar results are recalled, and then the semantic vector string of the text to be retrieved based on the LSI model semantic vector encoding is input into the search engine as the search content and the Top-N similar results are recalled, and finally the results obtained by the two recall methods are re-sorted according to the weighted score method and the Top-N ranking results are taken as the final recall results.
7. A semantic similarity vector sparse coding retrieval method according to claim 6, characterized in that: In step S25, for each of the Top-Y results obtained in step S24, first determine the relationship between the Field storing the text length in the result and 512, and then, based on the determination result, retrieve the semantic character string stored in the LSI field or SBERT field of the result and recall the Top-M results according to the method of sorting the encoded text similarity in step S23.
