Index construction method, chip, electronic device and medium
By loading and unloading the model on demand in electronic devices, the problem of resource waste in the index construction branch is solved, the index construction efficiency and search accuracy are improved, and more efficient resource utilization is achieved.
Patent Information
- Application Number
- CN202510019493.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-07
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-01-07
AI Technical Summary
In the prior art, when electronic devices build multiple indexes to build branches, they are prone to waste of resources and inefficiency, because multiple branches load the same model as required, resulting in frequent model loading and unloading operations.
By loading and unloading models on demand in the index building block, keeping the model loading only when indexing is needed, avoiding unnecessary model loading and unloading operations, and setting up a queue between the module and the model to judge the build requirements, reducing unnecessary startup and shutdown operations.
It effectively reduces the waste of equipment resources, improves index construction efficiency and the accuracy of search results, and improves search results.
Smart Images

Figure CN119513045B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of electronic devices, and particularly relates to an index construction method, a chip, an electronic device, and a medium. Background Art
[0002] A large number of files can be stored in an electronic device. To facilitate quickly searching for a desired target file among a large number of files, searching can be performed in combination with the index information of the files. Thus, it is necessary to construct an index for the files.
[0003] There can be multiple ways to construct an index. For different index construction methods, there can be multiple index construction branches correspondingly in an electronic device. When an index construction branch runs, a model can be loaded to use the model function to perform corresponding processing operations.
[0004] The same processing operations can be included in different index construction branches. Thus, the same model can be loaded as needed by multiple index construction branches. However, this technical implementation easily leads to waste of resources. Summary of the Invention
[0005] This application provides an index construction method, a chip, an electronic device, and a medium, which helps to save device resources.
[0006] In a first aspect, an embodiment of this application provides an index construction method, which is applied to an electronic device. The electronic device includes a first module and a second module. The first module is used to generate first information of a first file, and the first file is any file for which an index needs to be constructed. The index construction method includes: if at least one of a first type index and a second type index of the first file needs to be constructed and the first model is not loaded, then load the first model; by running the second module, perform at least one of a first operation and a second operation. The first operation includes: if the first type index of the first file needs to be constructed, then generate the first type index of the first file according to the first information of the first file and the first model. The second operation includes: if the second type index of the first file needs to be constructed, then generate the second type index of the first file according to the first file and the first model. If there is no file for which the first type index needs to be constructed, no file for which the second type index needs to be constructed, and the first model has been loaded, then unload the first model.
[0007] In an embodiment of this application, the electronic device loads / unloads the first model as needed in combination with the construction requirements of various types of indexes, so that when any type of index needs to be constructed, the model is always loaded, and the model is unloaded only when no index of any type needs to be constructed. In this way, overly frequent loading / unloading of the model can be avoided, unnecessary model loading / unloading operations can be reduced, and thus unnecessary waste of device resources can be reduced.
[0008] Optionally, the index building method further includes: if at least one of the first type index and the second type index of the first file to be built and the second module is not started, then start the second module; if there is no file to be built with the first type index, no file to be built with the second type index, and the second module has been started, then close the second module.
[0009] By starting / stopping the second module on demand, unnecessary module start / stop operations can be reduced, thereby reducing unnecessary waste of device resources.
[0010] Optionally, the index building method further includes: if the first type index of the first file to be built and the first module is not started, then start the first module; if there is no file to be built with the first type index and the first module has been started, then close the first module.
[0011] By starting / stopping the first module on demand, unnecessary module start / stop operations can be reduced, thereby reducing unnecessary waste of device resources.
[0012] Optionally, the second module includes a first queue and a second queue; the first queue is used to temporarily store the first information of the first file; the second queue is used to temporarily store the first file or the second information of the first file, and the second information is used to generate the second type index of the first file; the non-existence of a file to be built with the first type index includes: the first queue is empty; the non-existence of a file to be built with the second type index includes: the second queue is empty.
[0013] By according to the queue situation, it can be accurately judged whether there is a file to be built with the corresponding index, which helps to accurately execute the on-demand opening / closing of the module and the on-demand loading / unloading of the model.
[0014] Optionally, generating the first information of the first file includes: generating the first information of the first file according to the second model; the index building method further includes: if the first information of the first file is to be generated and the second model is not loaded, then load the second model; if there is no file to be generated with the first information and the second model has been loaded, then unload the second model.
[0015] The electronic device can load / unload the second model on demand in combination with the generation requirement of the first information, which can avoid overly frequent loading / unloading of the model, reduce unnecessary model loading / unloading operations, and thus reduce unnecessary waste of device resources.
[0016] Optionally, generating the first information of the first file includes: generating the first information of the first file according to the second model; the processing priority of the first operation is lower than that of the second operation.
[0017] Compared with the search results obtained when searching based on the second type of index of partial documents, the search results obtained when searching based on the second type of index of all documents can be more accurate, which helps to improve the search effect.
[0018] Optionally, the index construction method further includes: obtaining search information; according to the search information and various types of indexes already constructed by the electronic device, obtaining the search results corresponding to each type of index in various types of indexes to obtain multiple search results; generating the search results of the search information according to the multiple search results.
[0019] Regardless of whether various types of indexes of all files have been constructed, before all types of indexes of all files are completed, the electronic device always uses the search strategy of full-path search to implement file search, which can make full use of the constructed index information of each index, thereby helping to improve the search effect.
[0020] Optionally, generating the search results of the search information according to the multiple search results includes: performing weighted fusion processing according to the first result of the target file in one or more target search results to obtain the second result of the target file; where the target file is any file in the multiple search results; where the multiple search results include one or more target search results, the electronic device has constructed the index of the type corresponding to the target search result of the target file, and the sum of the weights corresponding to the one or more target search results is one; generating the search results of the search information according to the second result of the target file.
[0021] By performing targeted full-path search result fusion processing on each file according to the current index construction situation of each file when fusing full-path search results, the fusion effect can be improved.
[0022] In a second aspect, an embodiment of the present application provides an index construction device, which is applied to an electronic device. The electronic device includes a first module and a second module; the first module is used to generate the first information of the first file, and the first file is any file for which an index needs to be constructed; the index construction device includes: a first processing module, which is used to load the first model if at least one of the first type index and the second type index of the first file to be constructed is to be constructed and the first model has not been loaded; a second processing module, which is used to perform at least one of a first operation and a second operation by running the second module; the first operation includes: if the first type index of the first file is to be constructed, generating the first type index of the first file according to the first information and the first model; the second operation includes: if the second type index of the first file is to be constructed, generating the second type index of the first file according to the first file and the first model; a third processing module, which is used to unload the first model if there is no file for which the first type index and the second type index are to be constructed and the first model has been loaded.
[0023] In a third aspect, an embodiment of the present application provides a chip, including: a processor configured to execute computer program instructions stored in a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute the method according to any one of the first aspect.
[0024] In a fourth aspect, an embodiment of the present application provides an electronic device, which includes one or more memories for storing computer program instructions, and one or more processors, wherein when the computer program instructions are executed by the one or more processors, the electronic device is triggered to execute the method according to any one of the first aspect.
[0025] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the computer is caused to execute the method according to any one of the first aspect.
[0026] In a sixth aspect, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program runs on a computer, the computer is caused to execute the method according to any one of the first aspect.
[0027] The technical effects of the foregoing aspects can be referred to each other and will not be elaborated herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required to be used in the embodiments will be briefly introduced below.
[0029] Figure 1 A schematic structural diagram of building an index for an electronic device provided in an embodiment of the present application;
[0030] Figure 2 Another schematic structural diagram of building an index for an electronic device provided in an embodiment of the present application;
[0031] Figure 3 A schematic flowchart of the process of building a summary index for an electronic device provided in an embodiment of the present application;
[0032] Figure 4 A timing diagram of the process of building a summary index for an electronic device provided in an embodiment of the present application;
[0033] Figure 5 A schematic diagram of the process of processing a summary service provided in an embodiment of the present application;
[0034] Figure 6 A schematic flowchart of the process of building a shard index for an electronic device provided in an embodiment of the present application;
[0035] Figure 7 A timing diagram of the process of constructing a sharded index for an electronic device provided by an embodiment of the present application;
[0036] Figure 8 A schematic diagram of the processing process of an AI document search service provided by an embodiment of the present application;
[0037] Figure 9 A flowchart of the process of an electronic device performing document search provided by an embodiment of the present application;
[0038] Figure 10 A timing diagram of the file search process of an electronic device provided by an embodiment of the present application;
[0039] Figure 11 A schematic diagram of the processing process of another AI document search service provided by an embodiment of the present application;
[0040] Figure 12 A schematic diagram of a search result display page provided by an embodiment of the present application;
[0041] Figure 13 A schematic diagram of another search result display page provided by an embodiment of the present application;
[0042] Figure 14 A flowchart of an index construction method provided by an embodiment of the present application;
[0043] Figure 15 A schematic diagram of the structure of an electronic device provided by an embodiment of the present application;
[0044] Figure 16 A schematic diagram of the software architecture of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0045] For a better understanding of the technical solutions of the present application, the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0046] It should be clear that the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts belong to the scope of protection of the present application.
[0047] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms of "a", "the" and "said" used in the embodiments of the present application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0048] It should be understood that the term "at least one" as used herein refers to one or more, and "a plurality" refers to two or more. The term "and / or" as used herein is merely a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. Herein, A and B can be singular or plural. Additionally, the character " / " herein generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, and c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple.
[0049] It should be understood that although terms such as first and second may be used to describe the set thresholds in the embodiments of the present application, these set thresholds should not be limited to these terms. These terms are only used to distinguish the set thresholds from each other. For example, without departing from the scope of the embodiments of the present application, the first set threshold can also be referred to as the second set threshold, and similarly, the second set threshold can also be referred to as the first set threshold.
[0050] A large number of files, such as documents, videos, pictures, etc., can be stored in an electronic device. To facilitate quickly searching for a desired target file among a large number of files, searching can be combined with the index information of the files. Thus, it is necessary to build an index for the files.
[0051] Feasibly, the device for performing file search and the device for storing files can be the same device or different devices.
[0052] Feasibly, there can be various types of indexes. For example, it can include BM25 index, vector index, etc.
[0053] Among them, BM25 (Best Match 25) is an improved algorithm based on term frequency (TF) and inverse document frequency (IDF), which can improve the quality of search results and is a ranking function widely used in information retrieval.
[0054] The construction speed of the BM25 index is usually very fast and does not involve model inference. Different from the construction of the BM25 index that does not need to rely on model functions, the construction of the vector index can rely on a vectorization model, and by using the vectorization function provided by the vectorization model, the vector index of the file can be constructed.
[0055] In one example, the vectorization model can encode a piece of text into a string of numbers as the vectorization result of the text.
[0056] Exemplarily, the electronic device can process a document, such as generating a summary, fragmenting (or slicing, for example, every 200 words as a fragment), segmenting, chaptering, extracting high-frequency keywords, etc. from the document, and then use the vectorization model to perform vectorization processing on the processing results of the document (such as the summary of the document, the fragmented content of the document, etc.), and obtain a vector index according to the vectorization result. Among them, the vectorization result can be stored as a vector index, or the vectorization result can be processed to obtain a vector index.
[0057] In other examples, the electronic device may not process the document and directly perform full-text vectorization on the document.
[0058] In this way, the vector index can be further divided into a summary index, a fragment index, a full-text index, etc. By constructing the vector index, the electronic device can intelligently search for the target document required by the user through semantic search, so as to support the semantic search needs of the user.
[0059] For different index construction methods, there can be multiple index construction branches corresponding in the electronic device. When the index construction branch runs, it can load the model to use the model function to construct the index. Feasibly, the index construction branch can be a process in the electronic device for constructing the index.
[0060] The same processing operations can be included in different index construction branches, so multiple index construction branches can load the same model for processing as needed. For example, to construct the summary index and fragment index of a document, there can be a summary index construction branch and a fragment index construction branch in the electronic device. Both of these branches include vectorization processing. When these two branches run, they can both load the same vectorization model to generate the summary index and the fragment index respectively.
[0061] Feasibly, the above-mentioned same model can be a model in the electronic device (such as a side model in the user terminal device), or a model in other devices.
[0062] Feasibly, the operation of the index construction branch loading the model can specifically be to load the model into the memory of the electronic device. After that, the index construction branch can also unload the model from the memory to stop loading the model (or end the loading of the model) to release the model resources.
[0063] In addition to loading the same model described above, the index construction branch can also load other models for index generation. For example, the abstract index construction branch can load an abstract generation model to use the model function to generate an abstract. Feasibly, the abstract generation model can be a large language model. A large language model is a large artificial intelligence model. By using the large language model to generate an abstract, the quality of the abstract can be improved.
[0064] In one example, referring to Figure 1 , the electronic device may include an abstract index construction branch and a shard index construction branch. Among them, the abstract index construction branch may include an abstract generation module 101 and an abstract index construction module 102, and the shard index construction branch may include a document sharding module 103 and a shard index construction module 104.
[0065] As Figure 1 shown, when there is a document for which an abstract index needs to be constructed, the abstract generation module 101 can load the abstract generation model 105 to use the abstract generation model 105 to generate an abstract of the document. After that, the abstract index construction module 102 can load the vectorization model 106 to use the vectorization model 106 to perform vectorization processing on the abstract of the document to construct an abstract index of the document. When there is no document for which an abstract index needs to be constructed, the abstract index construction module 102 can unload the abstract generation model 105 and the vectorization model 106.
[0066] Feasibly, after the electronic device generates an abstract of a document, in addition to being able to generate an abstract index of the document based on the abstract, it can also display the abstract for the user to view the specific content of the abstract.
[0067] As Figure 1 shown, when there is a document for which a shard index needs to be constructed, the document sharding module 103 can, after parsing the document, shard the document to obtain multiple shard contents of the document (or a set of shard contents). After that, the shard index construction module 104 can load the vectorization model 106 to use the vectorization model 106 to perform vectorization processing on the shard contents of the document to construct a shard index of the document. When there is no document for which a shard index needs to be constructed, the shard index construction module 104 can unload the vectorization model 106.
[0068] Feasibly, in addition to Figure 1 the abstract index construction branch and the shard index construction branch shown, the electronic device may also include other index construction branches that need to use the vectorization model 106. The implementation logic of this other index construction branch can be similar to that of Figure 1 the two branches shown, which will not be elaborated here.
[0069] Since multiple index construction branches can load / unload the same model (such as the vectorization model 106 above) as needed, it is easy to have the situation where the model is repeatedly loaded / unloaded, resulting in waste of device resources.
[0070] In addition, there can be a significant difference in the processing speeds of different index construction branches, which can easily lead to resource preemption and other situations. For example, the summary index construction branch uses a summary generation model to generate summaries, which takes a relatively long time, while the sharding time of the sharding index construction branch is relatively short, resulting in a significant difference in the processing speeds of the two branches. When the summary index construction branch uses the vectorization model, it will affect the use of the vectorization model by the sharding index construction branch, thereby blocking the sharding index construction branch and affecting the index construction efficiency of the sharding index construction branch.
[0071] To address the problem of device resource waste caused by multiple index construction branches repeatedly loading / unloading the same model, an embodiment of the present application provides a model reuse method. This model reuse method can place the parts that use the same model function in multiple index construction branches (such as Figure 1 the summary index construction module 102 and the sharding index construction module 104 shown) in one index construction branch, and this one index construction branch loads / unloads the model as needed based on the processing results of other parts (such as Figure 1 the summary generation module 101 and the document sharding module 103 shown) of these multiple index construction branches on the file.
[0072] Taking the construction of a summary index and a sharding index as an example, an electronic device may include a summary generation module, a file sharding module, and an index construction module. A summary vectorization queue and a sharding vectorization queue are built in the index construction module. Among them, the summary generation module can be used to use a summary generation model to generate a summary of the file; the summary vectorization queue can be used to temporarily store the summary to be vectorized; the file sharding module can be used to perform sharding processing on the file to generate multiple sharding contents of the file; the sharding vectorization queue can be used to temporarily store the sharding contents to be vectorized; the index construction module can be used to use a vectorization model to perform vectorization processing on the summary in the summary vectorization queue and the sharding contents in the sharding vectorization queue respectively to construct a summary index and a sharding index correspondingly.
[0073] Exemplarily, the above file can be a document, a picture containing characters, a video containing characters, etc.
[0074] Feasibly, the summary generation module can load the summary generation model when there is a file for which a summary index needs to be constructed, and unload the model to stop loading the summary generation model when there is no such file.
[0075] Feasibly, when there are files for which a summary index needs to be built and / or files for which a shard index needs to be built, the index construction module can load the vectorization model, and when there are no files for which a summary index needs to be built and no files for which a shard index needs to be built, unload the model so as to no longer load the vectorization model.
[0076] Feasibly, the operation of loading the model can include loading the model into the memory of the electronic device, and the operation of unloading the model can include unloading the model from the memory so as to no longer load the model.
[0077] Different from Figure 1 In the illustrated example, both the summary index construction module 102 and the shard index construction module 104 can load / unload the vectorization model 106 as needed for building the summary index and the shard index respectively. In the embodiments of the present application, only the index construction module loads / unloads the vectorization model as needed, so that when building either the summary index or the shard index, the model is always loaded, and the model is unloaded only when neither the summary index nor the shard index needs to be built, enabling the summary vectorization process and the shard content vectorization process to share the functions of the model. This can avoid overly frequent loading / unloading of the model, reduce unnecessary model loading / unloading operations, and thus reduce unnecessary waste of device resources.
[0078] See Figure 2 , in an embodiment of the present application, the electronic device may include a summary generation module 201 and an index construction module 202. The index construction module 202 includes a document sharding module 203 and has two task queues, namely a summary vectorization queue 204 and a shard vectorization queue 205. Among them, the summary vectorization queue 204 can be used to temporarily store the summaries to be vectorized, and the shard vectorization queue 205 can be used to temporarily store the shard content to be vectorized.
[0079] In other embodiments, the document sharding module 203 may also be located outside the index construction module 202.
[0080] Feasibly, the summary generation module 201 can be used to generate a summary of a document using a summary generation model 208 (such as a large language model), and then store the generated summary in a summary task database 206 for use by the index construction module 202. Among them, the summary task database 206 can be used to store the summaries to be vectorized. In addition, the summary generation module 201 can also send the generated summary to the display module of the electronic device for display.
[0081] In one embodiment, when there is a document for which an abstract needs to be generated but the abstract generation model 208 is not loaded, the abstract generation module 201 may load the abstract generation model 208 to generate the abstract of the document using the functions of the abstract generation model 208; and when there is no document for which an abstract needs to be generated but the abstract generation model 208 is loaded, the abstract generation model 208 may be unloaded to release the model resources.
[0082] In one embodiment, when there is a document for which an abstract needs to be generated but the abstract generation module 201 is not started, the electronic device may start the abstract generation module 201; and when there is no document for which an abstract needs to be generated but the abstract generation module 201 is started, the electronic device may close the abstract generation module 201.
[0083] Feasibly, the index construction module 202 can be used to deposit the abstracts in the abstract task database 206 into the abstract vectorization queue 204 to wait for vectorization processing.
[0084] Exemplarily, the index construction module 202 may deposit each abstract in the abstract task database 206 into the tail of the abstract vectorization queue 204 in the order of the abstract generation time. Feasibly, after depositing any abstract in the abstract task database 206 into the abstract vectorization queue 204, the abstract may no longer be stored in the abstract task database 206.
[0085] Feasibly, the document sharding module 203 can be used to perform sharding processing on the document for which a sharded index needs to be constructed to generate the sharded content of the document, and deposit the generated sharded content into the sharding task database 207 for use by the index construction module 202. Among them, the sharding task database 207 can be used to store the sharded content to be vectorized.
[0086] Feasibly, the index construction module 202 can be used to deposit the sharded content in the sharding task database 207 into the sharding vectorization queue 205 to wait for vectorization processing.
[0087] Exemplarily, the index construction module 202 may deposit each group of sharded content in the sharding task database 207 into the tail of the sharding vectorization queue 205 in the order of the storage time of the sharded content. Feasibly, after depositing any group of sharded content in the sharding task database 207 into the sharding vectorization queue 205, the sharding task database 207 may no longer store the group of sharded content.
[0088] Feasibly, the index construction module 202 can be used to perform vectorization processing on the abstracts in the abstract vectorization queue 204 using the vectorization model 209 to generate the abstract index of the document, and perform vectorization processing on the sharded content in the sharding vectorization queue 205 to generate the sharded index of the document.
[0089] In one embodiment, when there are documents for which a summary index and / or a shard index need to be built, but the vectorization model 209 is not loaded, the index construction module 202 may load the vectorization model 209 to generate a summary index and / or a shard index for the documents using the functions of the vectorization model 209; and when there are no documents for which a summary index needs to be built and no documents for which a shard index needs to be built, but the vectorization model 209 is already loaded, the vectorization model 209 may be unloaded to release model resources.
[0090] In one embodiment, an electronic device may start the index construction module 202 when there are documents for which a summary index and / or a shard index need to be built, but the index construction module 202 is not started; and may shut down the index construction module 202 when there are no documents for which a summary index needs to be built and no documents for which a shard index needs to be built, but the index construction module 202 is already started.
[0091] Feasibly, since the time taken for the summary generation module 201 to generate a summary is usually relatively long, if the summary vectorization queue 204 is not empty and / or the summary generation module 201 is working, it may indicate that there are documents for which a summary index needs to be built; if the summary vectorization queue 204 is empty and the summary generation module 201 is not working, it may indicate that there are no documents for which a summary index needs to be built.
[0092] Feasibly, since the time taken for the document sharding module 203 to perform sharding is usually relatively short, if the shard vectorization queue 205 is not empty, it may indicate that there are documents for which a shard index needs to be built; if the shard vectorization queue 205 is empty, it may indicate that there are no documents for which a shard index needs to be built.
[0093] Different from Figure 1 In the example shown, both the summary index construction module 102 and the shard index construction module 104 can load / unload the vectorization model 106 as needed to be used for building the summary index and the shard index respectively, while Figure 2 In the embodiment shown, only the index construction module 202 loads / unloads the vectorization model 209 as needed, so that when building either a summary index or a shard index, the model is always loaded, and the model is unloaded only when neither the summary index nor the shard index needs to be built, enabling the summary vectorization process and the shard content vectorization process to share the functions of the model. This can avoid overly frequent loading / unloading of the model, reduce unnecessary model loading / unloading operations, and thus reduce unnecessary waste of device resources.
[0094] Such as Figure 2As shown, the two vectorized queues can be placed in the index construction module instead of the abstract generation module. In this way, the abstract generation module can be started / stopped as needed and loaded / unloaded as needed in combination with the existence of the document for which the abstract is to be generated, so as to reduce unnecessary waste of device resources and not affect the existing functions of the abstract generation module (such as generating the abstract of the document for display).
[0095] Since the time-consuming of abstract generation is usually higher than that of document sharding, Figure 2 In the embodiment shown, the index construction module 202 can preferentially process the sharding vectorized queue 205 when both the abstract vectorized queue 204 and the sharding vectorized queue 205 are not empty. This helps to complete the sharding index construction of all documents as early as possible. In this way, when the user issues a search request, the electronic device can search based on the sharding index of all documents and obtain the sharding index search result.
[0096] Compared with the sharding index search result obtained when searching based on the sharding index of partial documents, the sharding index search result obtained when searching based on the sharding index of all documents can be more accurate, which helps to improve the search effect.
[0097] Feasibly, in addition to Figure 2 the abstract vectorized queue and the sharding vectorized queue shown, the electronic device may also include a vectorized queue for other types of indexes that need to use the vectorized model. The implementation logic of the vectorized queue for other types of indexes is similar to that of Figure 2 the two vectorized queues shown and will not be elaborated here.
[0098] In an embodiment of the present application, referring to Figure 3 , the index construction process of the electronic device may include the following steps 301 to 309. Figure 3 The embodiment shown reflects that during the process of constructing the abstract index, the electronic device loads / unloads the abstract generation model and the vectorized model as needed, and starts / stops the abstract generation module and the index construction module as needed.
[0099] Among them, the electronic device includes an abstract generation module and an index construction module, and the index construction module includes an abstract vectorized queue and a sharding vectorized queue. Exemplarily, the electronic device may be the Figure 2 electronic device shown.
[0100] Step 301, initiate an abstract generation task.
[0101] Exemplarily, when there is a new document, the electronic device can initiate an abstract generation task for the new document to generate the abstract of the new document. The generated abstract can be used for display and for constructing the abstract index.
[0102] Step 302, start the abstract generation module.
[0103] By starting the abstract generation module when initiating an abstract generation task, on-demand startup of the abstract generation module can be achieved.
[0104] In one example, after the electronic device initiates an abstract generation task, it can perform the operation of starting the abstract generation module.
[0105] In another example, after the electronic device initiates an abstract generation task, it can determine whether the abstract generation module has been started. If not, start the abstract generation module; if it has been started, no operation is required to maintain the startup of the abstract generation module.
[0106] For example, when a new document is stored in the electronic device, the abstract generation module may not have completed generating an abstract for the previously stored document. When the electronic device initiates an abstract generation task based on the storage of the new document and the abstract generation module has been started, the electronic device can perform no operation to maintain the startup of the abstract generation module.
[0107] Step 303, determine whether the abstract generation model has been loaded. If so, execute Step 304; otherwise, load the abstract generation model and execute Step 304.
[0108] Feasibly, the abstract generation module can use the abstract generation model to generate an abstract of the document. Then, when the abstract generation module has been started, the abstract generation model can be loaded to achieve on-demand loading of the abstract generation model.
[0109] Step 304, determine whether the index construction module has been started. If so, execute Step 305; otherwise, start the index construction module, load the vectorization model, and execute Step 306.
[0110] Feasibly, the index construction module can perform vectorization processing on the abstract generated by the abstract generation module to generate an abstract index of the document. Then, the electronic device can start the index construction module and load the vectorization model when the abstract generation module has been started to achieve on-demand startup of the index construction module and on-demand loading of the vectorization model.
[0111] Step 305, determine whether the vectorization model has been loaded. If so, execute Step 306; otherwise, load the vectorization model and execute Step 306.
[0112] Feasibly, the index construction module can use the vectorization model to construct an abstract index of the document. Then, the electronic device can load the vectorization model when the index construction module has been started to achieve on-demand loading of the vectorization model.
[0113] Step 306: Fetch the abstract from the abstract task database into the abstract vectorization queue and construct an abstract index.
[0114] Feasibly, the abstract generated by the abstract generation module can be stored in the abstract task database. Then, the index construction module can add the abstracts in the abstract task database to the abstract vectorization queue and perform vectorization processing on each abstract in the abstract vectorization queue to construct the abstract index of the corresponding document until the abstract vectorization queue is empty.
[0115] Step 307: Determine whether the abstract generation task is completed. If yes, execute Step 308; otherwise, execute Step 306.
[0116] If the time-consuming of the abstract generation module to generate the abstract is relatively high, there may be a situation where the abstract generation module has not completed the generation of the abstract, but the abstract vectorization queue is empty. Since the index construction module needs to perform vectorization processing on the newly generated abstract after the abstract generation module completes the generation of the abstract, after Step 306, the electronic device can determine whether the abstract generation task is completed. If it is completed, then execute Step 308 to further determine whether the index construction module can be closed and the vectorization model can be unloaded; otherwise, execute Step 306 to store the newly generated abstract in the abstract vectorization queue after the abstract generation module completes the generation of the abstract to continue constructing the abstract index. In this way, unnecessary repeated closing / starting of the index construction module and unloading / loading of the vectorization model can be avoided.
[0117] Step 308: Determine whether the vectorization task is completed. If yes, execute Step 309; otherwise, unload the abstract generation model from the memory, close the abstract generation module, and execute Step 308 again.
[0118] Feasibly, the index construction module can be used to construct the abstract index and the shard index. In the case where the abstract index construction is completed, if the shard index is also completed (for example, the shard vectorization queue is empty), then it can be considered that the vectorization task is completed. If the vectorization task is not completed, then maintain the startup of the index construction module and the loading of the vectorization model to continue constructing the shard index, and only close the abstract generation module and unload the abstract generation model.
[0119] Step 309: Unload the vectorization model and the abstract generation model from the memory, and close the index construction module and the abstract generation module.
[0120] If the vectorization task is completed, the electronic device can close the index construction module and the abstract generation module, and unload the vectorization model and the abstract generation model.
[0121] As described above, during the process of building the abstract index, the electronic device can load / unload the abstract generation model and the vectorization model as needed, and start / stop the abstract generation module and the index building module as needed. In this way, unnecessary model loading / unloading operations and module start / stop operations can be reduced, thereby reducing unnecessary waste of device resources.
[0122] In an embodiment of the present application, referring to Figure 4 , the process of the electronic device building the abstract index may include the following steps 401 to 407.
[0123] Step 401, the AI search system service (such as AISearchSysService) sends the document path and document status to the abstract plugin (such as Abstract Plugin).
[0124] Exemplarily, when a new document is stored in the electronic device, the AI search system service may send the document path and document status of the new document (such as the new document being in the state of waiting to build the abstract index) to the abstract plugin.
[0125] Step 402, the abstract plugin forwards the received document path and document status to the abstract service (such as AbstractService.exe).
[0126] Step 403, the abstract service preprocesses the corresponding document according to the received document path and document status (such as parsing, cleaning, risk control, etc.), and sends the preprocessed document to the AI plugin engine (such as AIPluginEngine) to request the use of the abstract generation module and the vectorization model.
[0127] Feasibly, the abstract service may include the abstract generation module and the index building module described in other embodiments of the present application.
[0128] Step 404, the AI plugin engine uses the abstract generation model to generate the abstract of the document, uses the vectorization model to generate the vectorization result of the abstract, and returns the abstract of the document and the vectorization result of the abstract to the abstract service.
[0129] Step 405, the abstract service saves the abstract of the document and builds the abstract index of the document according to the vectorization result of the abstract.
[0130] Feasibly, the abstract of the document can be used for display to meet the user's need to view the abstract content.
[0131] Feasibly, the abstract index of the document can be used to meet the user's semantic search needs.
[0132] In one example, the vectorized result of the abstract can be used as the abstract index of the corresponding document. In other examples, the vectorized result of the abstract can be processed, and the processed result can be used as the abstract index of the corresponding document.
[0133] In one embodiment, referring to Figure 5 , the processing process of the abstract service may include the following:
[0134] According to the received document status, store the received document path into the document path queue;
[0135] Store the document content under each document path in the document path queue into the document content queue;
[0136] Use the document parsing module to parse each document content in the document content queue;
[0137] Use the data cleaning module to perform data cleaning, risk control, etc. on the parsed document content;
[0138] Use the abstract generation module to send the cleaned document content to the AI plugin engine to request the abstract of the document content, and send the abstract returned by the AI plugin engine to the vectorization module;
[0139] Use the vectorization module to send the abstract of the document content to the AI plugin engine to request the vectorized result of the abstract, and build and store the abstract index of the corresponding document according to the vectorized result of the abstract returned by the AI plugin engine.
[0140] Feasibly, the abstract generation module described in other embodiments of this application may include Figure 5 the abstract generation module shown in Figure 5 the vectorization module shown in
[0141] In one embodiment, referring to Figure 5 , the AI plugin engine can use the deployment tool to load the abstract generation model and use the abstract generation model to generate the abstract of the document content, and can also use the deployment tool to load the vectorization model and use the vectorization model to generate the vectorized result of the abstract.
[0142] Exemplarily, the above deployment tool can be Openvino. Openvino is an open-source tool suite that can be used to optimize and accelerate the inference process of deep learning models.
[0143] Step 406, the abstract service returns a success flag to the abstract plugin.
[0144] Feasibly, when the summary service successfully saves the summary and constructs the summary index, it can return a flag indicating successful summary generation and successful summary index construction.
[0145] Step 407, the summary plugin returns a success flag to the AI search system service.
[0146] If the summary index of the document has been constructed, when the user subsequently requests a search, the electronic device searches according to the summary index of the document to obtain the search result of the summary index of the document.
[0147] Exemplarily, the search result of the summary index of the document can be reflected in: whether the search result of the summary index contains the document and the sorting of the document in the search result of the summary index.
[0148] In an embodiment of the present application, refer to Figure 6 , the index construction process of the electronic device may include the following steps 310 to step 313. Figure 6 The illustrated embodiment reflects that during the process of constructing the shard index, the electronic device loads / unloads the summary generation model and the vectorization model as needed, and starts / stops the index construction module as needed.
[0149] Among them, the electronic device includes a summary generation module and an index construction module, and the index construction module includes a summary vectorization queue and a shard vectorization queue. Exemplarily, the electronic device may be Figure 2 the illustrated electronic device.
[0150] Step 310, initiate a shard task.
[0151] Exemplarily, when there is a new document, the electronic device can initiate a shard task for the new document to shard the new document. The generated shard content can be used to construct the shard index.
[0152] Step 311, determine whether the index construction module has been started. If so, execute step 312. Otherwise, start the index construction module and load the vectorization model, and execute step 313.
[0153] Feasibly, the index construction module can shard the document and generate the shard index of the document according to the shard content. Then, when initiating the shard task, the electronic device can start the index construction module and load the vectorization model to achieve the on-demand start of the index construction module and the on-demand loading of the vectorization model.
[0154] Step 312, determine whether the vectorization model has been loaded. If so, execute step 313. Otherwise, load the vectorization model and execute step 313.
[0155] Feasibly, the index construction module may use a vectorization model to construct a shard index of a document. Then, when the index construction module has been started, the electronic device may load the vectorization model to achieve on-demand loading of the vectorization model.
[0156] Step 313: Fetch the shard content from the shard task database into the shard vectorization queue to construct a shard index.
[0157] Feasibly, the shard content of a document may be stored in the shard task database. Then, the index construction module may add the shard content in the shard task database to the shard vectorization queue, and perform vectorization processing on each piece of shard content in the shard vectorization queue to construct the shard index of the corresponding document until the shard vectorization queue is empty.
[0158] The time-consuming of the document sharding module for document sharding is relatively low. Then, it can be considered that generally there is no situation where the document sharding module has not completed document sharding but the shard vectorization queue is empty. Thus, if the shard vectorization queue is empty, it can indicate that there is no document for which a shard index needs to be constructed.
[0159] In one embodiment, after the electronic device completes the construction of the shard index by executing step 313, it may execute the above step 308 to determine whether the vectorization task is ended in combination with whether there is a document for which an abstract index needs to be constructed, and close / maintain the startup of the index construction module and unload / maintain the loading of the vectorization model according to the judgment result.
[0160] As can be seen from the above, the electronic device may load / unload the vectorization model on demand and start / close the abstract generation module and the index construction module on demand during the process of constructing the shard index. In this way, unnecessary model loading / unloading operations and module startup / shutdown operations can be reduced, thereby reducing unnecessary waste of device resources.
[0161] In one embodiment of the present application, referring to Figure 7 , the process of the electronic device constructing the shard index may include the following steps 701 to 707.
[0162] Step 701: The AI search system service (such as AISearchSysService) sends the document path and document status to the AI document search plugin (such as AIDocumentSearchPlugin).
[0163] Exemplarily, when a new document is stored in the electronic device, the AI search system service may send the document path and document status of the new document (such as the new document being in the state of waiting to construct a shard index) to the AI document search plugin.
[0164] Step 702, the AI document search plug-in forwards the received document path and document status to the AI document search service (such as AIDocumentSearch.exe).
[0165] Step 703, the AI document search service slices and preprocesses (such as parsing, slicing, cleaning, etc.) the corresponding document according to the received document path and document status, and sends the sliced content to the AI plug-in engine (such as AIPluginEngine) to request the use of the vectorization model from the AI plug-in engine.
[0166] Feasibly, the AI document search service may include the document slicing module and the index construction module described in other embodiments of the present application. Among them, the document slicing module may be in the index construction module or outside the index construction module.
[0167] Step 704, the AI plug-in engine uses the vectorization model to generate the vectorization result of the sliced content and returns the vectorization result of the sliced content to the AI document search service.
[0168] Step 705, the AI document search service constructs the sliced index of the document according to the vectorization result of the sliced content.
[0169] Feasibly, the sliced index of the document can be used to meet the semantic search needs of users.
[0170] In one example, the vectorization result of the sliced content can be used as the sliced index of the corresponding document. In other examples, the vectorization result of the sliced content can be processed and the processing result can be used as the sliced index of the corresponding document.
[0171] In one embodiment, referring to Figure 8 , the processing process of the AI document search service may include the following:
[0172] According to the received document status, store the received document path in the document path queue;
[0173] Use the document parsing module to parse the document content under each document path in the document path queue;
[0174] Use the document slicing module to slice the parsed document content to obtain a set of sliced content of the document content, and store the obtained set of sliced content in the sliced content queue;
[0175] Use the index storage module to construct the BM25 index of the corresponding document according to each set of sliced content in the sliced content queue (such as Figure 8 the sliced content 1 and sliced content 2 shown in
[0176] Use the vectorization module to send each piece of fragmented content in the fragmented content queue to the AI plug-in engine to request the vectorization result of the fragmented content, and store the vectorization results of each piece of fragmented content returned by the AI plug-in engine into the vectorization result queue;
[0177] Use the index storage module to construct and store the fragmented index of the corresponding document according to the vectorization results of each group in the vectorization result queue (such as Figure 8 the vectorization 1 and vectorization 2 shown in
[0178] Feasibly, the AI document search service may further include a data cleaning module, which can be used to clean the data of each piece of fragmented content in the fragmented content queue before the index storage module constructs the BM25 index and the vectorization module sends each piece of fragmented content, etc.
[0179] Feasibly, the index construction module described in other embodiments of the present application may include Figure 5 the document fragmentation module, vectorization module, and index storage module shown in
[0180] In one embodiment, referring to Figure 8 , the AI plug-in engine can use the deployment tool to load the vectorization model and use the vectorization model to generate the vectorization result of the fragmented content.
[0181] Step 706, the AI document search service returns a success flag to the AI document search plug-in.
[0182] Feasibly, the AI document search service can return a flag indicating the successful construction of the fragmented index when the fragmented index is successfully constructed.
[0183] Step 707, the AI document search plug-in returns a success flag to the AI search system service.
[0184] If the fragmented index of the document has been constructed, when the user makes a subsequent search request, the electronic device searches according to the fragmented index of the document to obtain the fragmented index search result of the document.
[0185] Exemplarily, the fragmented index search result of the document can be reflected in: whether the fragmented index search result contains the document, and the sorting of the document in the fragmented index search result.
[0186] Feasibly, the electronic device can perform non-semantic search when the user issues a search request to obtain a non-semantic search result. For example, the non-semantic search result may include each file whose file title contains the search information, and the sorting of these files.
[0187] Feasibly, in addition to performing non-semantic searches, the electronic device can also use various types of built indexes to perform file semantic searches to obtain semantic search results. Among them, the semantic search results can include various files that semantically match the user's search information, as well as the sorting of these files. Feasibly, the sorting of files can be related to the degree of semantic matching between the files and the search information.
[0188] Since there are differences in the time consumption of different index construction branches, for example, the time consumption of constructing the BM25 index is very low, the time consumption of constructing the shard index is relatively low, and the time consumption of constructing the abstract index is relatively high. When the user requests to search for files, there may be a situation where the electronic device has not constructed the abstract indexes and / or shard indexes of some files.
[0189] In a feasible implementation manner, the search strategy can be dynamically matched according to the construction status of various indexes to obtain one or more paths of search results, and then the semantic search results can be obtained based on the obtained search results of each path. For example, the search results of multiple paths obtained can be weighted and fused to obtain the fused search results as the semantic search results.
[0190] Exemplarily, the search results of each path obtained can be processed by reciprocal rank fusion (RRF) to obtain the semantic search results.
[0191] For example, when the user requests to search for files, if the electronic device has constructed the BM25 indexes of all files, but has not constructed the shard indexes of some files and has not constructed the abstract indexes of some files, the electronic device can search for files according to the BM25 indexes to obtain the BM25 index search results, that is, obtain one path of search results. After that, the electronic device can generate and display the semantic search results based on the one path of search results.
[0192] Feasibly, the BM25 index search results can include the sorting of some files matched based on the BM25 indexes.
[0193] Exemplarily, for the case of one path of search, the RRF score of the searched files is calculated using the following formula (1). Among them, the size of the file RRF score can determine the sorting of the file in the file semantic search results.
[0194]
[0195] Among them, k is a constant, for example, it can be set to 60; D is the document set, which contains each searched file; taking the one path of search results obtained as the BM25 index search results as an example, can represent the ranking of any document d in the document set D in the BM25 index search results.
[0196] For another example, when the user requests to search for files, if the electronic device has constructed the BM25 index and shard index for all files but has not constructed the abstract index for some files, the electronic device can perform file searches based on the BM25 index and shard index respectively, and obtain the BM25 index search results and shard index search results correspondingly, that is, obtain two-way search results. Then, the electronic device can fuse these two-way search results to generate and display semantic search results.
[0197] Feasibly, the shard index search results may include the sorting of some files matched based on the shard index.
[0198] Exemplarily, for the case of two-way search, the RRF score of the searched files is calculated according to the following formula (2).
[0199]
[0200] Where k is a constant, for example, it can be set to 60; D is the document collection, which contains each of the searched files; taking the two-way search results obtained as the BM25 index search results and shard index search results as an example, can represent the ranking of any document d in the document collection D in the BM25 index search results, can represent the ranking of document d in the shard index search results. and are the weighting coefficients corresponding to the BM25 index and shard index respectively, and the sum of the two is 1.
[0201] For another example, when the user requests to search for files, if the electronic device has constructed the BM25 index, shard index, and abstract index for all files, the electronic device can perform file searches based on the BM25 index, shard index, and abstract index respectively, and obtain the BM25 index search results, shard index search results, and abstract index search results correspondingly, that is, obtain three-way search results. Then, these three-way search results can be fused to generate and display semantic search results.
[0202] Feasibly, the abstract index search results may include the sorting of some files matched based on the abstract index.
[0203] Exemplarily, for the case of three-way search, the RRF score of the searched files is calculated according to the following formula (3).
[0204]
[0205] Where k is a constant, which can be set to 60, for example; D is a document set that contains each of the searched files. Taking the obtained three-way search results as the BM25 index search result, the shard index search result, and the abstract index search result as examples, can represent the ranking of any document d in the document set D in the BM25 index search result, can represent the ranking of document d in the shard index search result, can represent the ranking of document d in the abstract index search result. and are the weighting coefficients corresponding to the BM25 index, the shard index, and the abstract index respectively, and the sum of the three is 1.
[0206] The shard index and the abstract index are file indexes obtained based on vectorization processing. Then, the electronic device can perform vectorization processing on the user's search information, and based on the vectorization result of the search information, use the shard index and the abstract index to perform file search. For example, the vectorization result of the search information can be matched in the shard index database to obtain the shard index search result, and the vectorization result of the search information can be matched in the abstract index database to obtain the abstract index search result.
[0207] Different types of index information can reflect the matching situation between the file and the user's search information from different corresponding perspectives. Then, the more the number of search result paths, the better the effect of the obtained file semantic search result usually is. Since there are differences in the time consumption of different index construction branches, the above dynamic matching search strategy cannot achieve full-path search (that is, cannot obtain the search results of various indexes) before all types of indexes of all files are constructed, which is not conducive to improving the search effect.
[0208] To improve the file semantic search effect before all types of indexes of all files are completed, in an embodiment of the present application, regardless of whether all types of indexes of each file are completed, the electronic device always uses the full-path search strategy to perform file search to obtain the search results of various indexes (that is, obtain the full-path search results), and when fusing the full-path search results, according to the current index construction situation of each file, dynamically match the fusion strategy to perform targeted full-path search result fusion processing on each file to obtain the fusion search result of each file, and further obtain the semantic search result.
[0209] Taking the various indexes of files as BM25 index, shard index and abstract index as examples, in one example, when the BM25 index and shard index of each file have been constructed, and the abstract index of some documents (excluding document 4) has been constructed, the electronic device can perform file search in the databases corresponding to the various indexes according to the currently constructed various indexes, and obtain the full-path search results (i.e., three-way search results) as shown in Table 1 below. Furthermore, the three-way search results can be fused using the above formula (3) to obtain the semantic search results.
[0210] Table 1
[0211]
[0212] Taking Table 1 above as an example, when calculating the RRF scores of the searched files, the document set D contains each of the searched documents (i.e., documents 1 to 4). Thus, the RRF scores of documents 1 to 4 can be calculated respectively.
[0213] For documents 1 to 3, since the electronic device has constructed the various indexes of documents 1 to 3, the electronic device can use the above formula (3) to calculate the RRF scores of documents 1 to 3 respectively.
[0214] In the case where the BM25 index and shard index of all files have been constructed, but the abstract index of some documents has not been constructed, different from the implementation method of performing two-way search and correspondingly using formula (2) to fuse the full-path search results of documents 1 to 3, the embodiments of the present application can perform full-path search and, according to the current index construction situation of documents 1 to 3, dynamically use formula (3) to fuse the full-path search results of documents 1 to 3 respectively, that is, introduce the abstract index search results of documents 1 to 3 to calculate the RRF scores of documents 1 to 3. This helps to improve the accuracy of the RRF scores and makes the document semantic search results more in line with the actual needs of users.
[0215] For document 4, since the electronic device has constructed the BM25 index and shard index of document 4, but has not constructed the abstract index of document 4, the electronic device can use the above formula (2) to calculate the RRF score of document 4.
[0216] By dynamically using formula (2) instead of formula (3) according to the current index construction situation of document 4 to fuse the full-path search results of document 4, the influence of the non-construction of the abstract index of document 4 on the RRF score of document 4 can be reduced. This helps to improve the accuracy of the RRF scores and makes the document semantic search results more in line with the actual needs of users.
[0217] In one embodiment, the electronic device may dynamically adjust the fusion weights of various types of indexes according to the current index construction status of each file. For the search results of any type of index, when the electronic device has constructed the index of this type, the fusion weight corresponding to this type of index may be relatively higher, while when the electronic device has not constructed the index of this type, the fusion weight corresponding to this type of index may be relatively lower, so as to reduce the adverse impact of the partial absence of this type of index on the fusion result.
[0218] Exemplarily, assume that if the abstract index of document 4 has been constructed, the search results of the abstract index may include document 4, document 2, and document 1 in descending order. Referring to Table 1 above, since the abstract index of document 4 has not been constructed currently, when the electronic device searches based on the currently constructed abstract indexes, document 4 cannot be searched. Then, as shown in Table 1, the search results of the abstract index obtained by the search do not include document 4, and specifically include document 2 and document 1 in descending order.
[0219] It can be seen that the partial absence of the abstract index may affect the accuracy of the search results of the abstract index, so the fusion weight corresponding to the abstract index can be reduced.
[0220] Referring to the above formula (3), assume that the default value of the fusion weight corresponding to the abstract index (i.e., the above weight coefficient ) is x1. In the case where the indexes of various types of each file have been constructed, the value of the weight coefficient can be x1. In the case where the abstract indexes of some files have not been constructed, the value of the weight coefficient can be x2, and x2 < x1.
[0221] In one embodiment of the present application, referring to Figure 9 , taking the searched file as a document as an example, the process of the electronic device performing document search may include the following steps 901 to step 911.
[0222] Step 901, receive the search request of the user.
[0223] Step 902, search according to the constructed indexes of various types to obtain the full-path search results.
[0224] Referring to Figure 9 , the full-path search results may be three-way search results, and the three-way search results may specifically be BM25 index search results, shard index search results, and abstract index search results.
[0225] Feasibly, for the specific technical implementation of the electronic device performing full-path search according to the search request, reference can be made to the relevant descriptions in other embodiments of the present application, which will not be elaborated here.
[0226] Step 903, i = 1.
[0227] Feasibly, i can represent the number of loops for calculating the RRF score of the retrieved documents. Then the maximum value of i can be the number of retrieved documents len(D), where D is the set of retrieved documents. Thus, after the electronic device performs a full-path search based on the user's search information, i = 1 can be set to start the calculation of the RRF score for the first time.
[0228] Exemplarily, referring to Table 1 above, the set D can include Documents 1 to 4.
[0229] Step 904, determine whether i < len(D) holds. If so, execute Step 905; otherwise, execute Step 910.
[0230] If i < len(D), it can indicate that the RRF scores of all retrieved documents have not been calculated yet, so the calculation of the RRF score for the current loop can continue. Conversely, it can indicate that the RRF scores of all retrieved documents have been calculated, so the retrieved documents can be re-sorted according to the RRF scores of each document to obtain the fused search result.
[0231] Step 905, d = D(i).
[0232] When i < len(D), the electronic device can start calculating the RRF score of the i-th document d in the set D.
[0233] Step 906, determine whether the shard index of document d has been constructed. If so, execute Step 907; otherwise, calculate the RRF score of the one-way search of document d and execute Step 909.
[0234] The time consumed by the electronic device to construct the BM25 index is usually very low, the time consumed to construct the shard index is usually relatively low, and the time consumed to construct the abstract index is usually relatively high. Then when the user requests to search for a file, the BM25 indexes of all files have usually been constructed, but there may be a situation where the electronic device has not constructed the abstract index and / or shard index of some files.
[0235] Thus, it can first be determined whether the shard index of document d has been constructed. If not, it can indicate that only the BM25 index of document d has been constructed, so the RRF score of the one-way search of document d can be calculated based on the BM25 index search result of document d. Exemplarily, the RRF score of the one-way search of document d can be calculated using the above formula (1).
[0236] Step 907, determine whether the abstract index of document d has been constructed. If so, execute Step 908; otherwise, calculate the RRF score of the two-way search of document d and execute Step 909.
[0237] Step 908, calculate the RRF score of the three-way search for document d.
[0238] If the shard index of document d has been constructed, it is possible to continue to determine whether the abstract index of document d has been constructed, and according to the judgment result, calculate the RRF score of the two-way search or the RRF score of the three-way search for document d correspondingly. Exemplarily, the RRF score of the two-way search for document d can be calculated using the above formula (2), and the RRF score of the three-way search for document d can be calculated using the above formula (3).
[0239] Exemplarily, referring to Table 1 above, since various indexes of documents 1 to 3 have been constructed, when calculating the RRF scores of documents 1 to 3, the above formula (3) is used for calculation, regardless of whether documents 1 to 3 are included in the search results of various indexes.
[0240] For example, although neither the shard index search result nor the abstract index search result includes document 3, the RRF score of the three-way search for document 3 is still calculated using the above formula (3). Feasibly, since document 3 is not in the shard index search result and the abstract index search result, it can be indicated that the rankings of document 3 in the shard index search result and the abstract index search result are both infinite. When calculating the RRF score of document 3 using the above formula (3), the last two terms in formula (3) can be approximated to zero.
[0241] Exemplarily, referring to Table 1 above, since the abstract index of document 4 has not been constructed, when calculating the RRF score of document 4, the above formula (2) is used for calculation.
[0242] Step 909, i = i + 1, and execute Step 904.
[0243] After the electronic device calculates the RRF score of the i-th document in document D, the value of i can be incremented by 1 to calculate the RRF score of the (i + 1)-th document in document D again, and so on in a loop until the RRF scores of all the searched documents are calculated.
[0244] Step 910, sort according to the RRF scores of all the documents in set D to obtain a sorting result.
[0245] Step 911, output the sorting result. This sorting result can be displayed as the semantic search result of the user's search information.
[0246] Figure 9In the illustrated embodiment, before the construction of various indexes of all documents is completed, the electronic device can use the search strategy of full-path search to implement document search, so as to make full use of the constructed index information of each document. When fusing the full-path search results, according to the current index construction situation of each document, targeted full-path search result fusion processing is performed on each document, so that the fusion effect can be improved.
[0247] In an embodiment of the present application, referring to Figure 10 , the file search process of the electronic device may include the following steps 1001 to 1007.
[0248] Step 1001, the AI search main service (such as AISearchMainService) sends the user search information to the AI document search plugin.
[0249] Exemplarily, when the user issues a search request, the AI search main service can extract the user search information and send it to the AI document search plugin.
[0250] Step 1002, the AI document search plugin forwards the received document path and document status to the AI document search service.
[0251] Step 1003, the AI document search service sends the user search information to the AI plugin engine to request the use of the vectorization model.
[0252] Step 1004, the AI plugin engine uses the vectorization model to generate the vectorization result of the user search information and returns the vectorization result of the user search information to the AI document search service.
[0253] Step 1005, the AI document search service performs document search and fuses the search results according to the vectorization result of the user search information.
[0254] In one embodiment, referring to Figure 11 , the processing process of the AI document search service may include the following content:
[0255] Use the user search information acquisition module to acquire the user's search information;
[0256] Use the vectorization module to send the user search information to the AI plugin engine to request the vectorization result of the user search information and receive the vectorization result of the user search information returned by the AI plugin engine;
[0257] Use the index storage module to perform document search based on the constructed BM25 index and user search information to obtain the BM25 index search results, perform document search based on the constructed shard index and the vectorized result of the user search information to obtain the shard index search results, and perform document search based on the constructed abstract index and the vectorized result of the user search information to obtain the abstract index search results, that is, obtain the three-way search results;
[0258] Use the search result fusion module to fuse the three-way search results.
[0259] Feasibly, for the specific technical implementation of fusing the three-way search results, reference can be made to Figure 9 the relevant descriptions in the embodiments shown, which will not be elaborated here.
[0260] In one embodiment, refer to Figure 11 that the AI plugin engine can use the deployment tool to load the vectorization model and use the vectorization model to generate the vectorized result of the user search information.
[0261] Step 1006, the AI document search service returns the fused search results to the AI document search plugin.
[0262] Step 1007, the AI document search plugin returns the fused search results to the AI search main service. The fused search results can be displayed as the semantic search results of the user search information.
[0263] Feasibly, the user can input search keywords or sentences to send a search request. The electronic device can extract the user search information according to the user input information, and perform semantic search based on the user search information and the constructed various indexes to obtain the full-path search results, and then fuse the full-path search results to obtain the semantic search results for responding to the user search request.
[0264] In addition, the electronic device can also perform non-semantic search according to the user search information, so as to obtain and display the non-semantic search results for responding to the user search request.
[0265] In one example, as Figure 12 shown, the electronic device can display the search page 1201 for the user to input search information and display the search results. Refer to Figure 12 that the user can input the search information of the search keyword "deep learning". The electronic device can respectively perform non-semantic search and semantic search, and can display the file information such as the name, type, path, modification date, size, etc. of each searched file for the user to view the search results.
[0266] In another example, as Figure 13As shown, the electronic device can display a search page 1301 for the user to input search information and display search results. Refer to Figure 13 , the user can input the search information of the keyword "papers from last semester" for searching. The electronic device can respectively display the names of the files found through non-semantic search and semantic search for the user to view the search results.
[0267] Feasibly, refer to Figure 12 , for each file whose file name contains the keyword "deep learning", the electronic device can also highlight the term "deep learning" in the file name. Refer to Figure 13 , for each file whose file name contains the keyword "papers from last semester", the electronic device can also highlight the term "papers from last semester" in the file name.
[0268] Refer to Figure 12 , in one embodiment, the user can click on the search application icon 1202 in the task bar to trigger the electronic device to display the search page. In another embodiment, the user can click on the application icon 1203 of the intelligent assistant displayed on the desktop to trigger the electronic device to display the search page. For example, if the user triggers the application icon 1203 of the intelligent assistant with a mouse, the intelligent assistant can display a smart search entry through a pop-up window for the user to enter the search page through the smart search entry.
[0269] Feasibly, the electronic device can build index information for various files (such as documents, pictures, applications, etc.), so that it can search for various files that match the user's search information according to the built index information.
[0270] Refer to Figure 12 , in one embodiment, identification items of various files can be displayed on the search page 1201. If the user clicks on the identification item of any kind of file, the electronic device can display the search results corresponding to that kind of file.
[0271] In one example, as Figure 12 shown, if the user clicks on the document identification item 1204, the electronic device can display the various documents found that match the user's search information. In other examples, the electronic device can default to giving priority to displaying the search results of documents.
[0272] In one embodiment, the electronic device can support the user to view the search results and also support the user to view the file content of the searched files. Feasibly, for any file in the search results displayed by the electronic device, if the user clicks on the file, the electronic device can display the file content of the file for the user to view.
[0273] Such as Figure 13As shown, if the user clicks on Document 1301 with the document name "The Development of Microeconomics", the electronic device can display the content of Document 1301 on the search page for the user to preview the document content.
[0274] Feasibly, when the electronic device displays the document content, it can default to not displaying the abstract of the document. In this case, if the user clicks on the abstract preview icon 1302 and the abstract of Document 1301 has been constructed, the electronic device can display the abstract content of Document 1301, and the corresponding display page can be as Figure 13 shown.
[0275] See Figure 14 , an embodiment of the present application provides an index construction method, which is applied to an electronic device. The electronic device includes a first module and a second module; the first module is used to generate first information of a first file, and the first file is any file for which an index needs to be constructed; this index construction method may include the following steps 1401 to step 1403.
[0276] Exemplarily, the first file may be a document, a picture, a video, a web page, etc.
[0277] In one embodiment, the first file may be a file in the electronic device. In other embodiments, the first file may be a file in other devices.
[0278] Step 1401, if at least one of the first type index and the second type index of the first file needs to be constructed and the first model has not been loaded, then load the first model.
[0279] Exemplarily, if a new file is stored in the electronic device, and this new file is a file for which an index needs to be constructed.
[0280] In one embodiment, the electronic device may include the first model. In other embodiments, the first model may be in other devices.
[0281] In one embodiment of the present application, the file type of the first file includes a document; the first information includes the abstract of the document; the first model includes a vectorization model. In this way, it supports the electronic device to respond to the user's file search request based on the abstract of the document, which can improve the semantic search effect.
[0282] In this way, in a feasible implementation manner, see Figure 2 , the first type index may be an abstract index, the second type index may include a shard index, the first model may be a vectorization model, and the first module may be Figure 2 the abstract generation module 201 shown in Figure 2 , and the second module may be
[0283] In other embodiments, the first model may include other models, such as a text extraction model. For files such as pictures, videos, and PPT documents containing text content, the first module may use the text extraction model to extract the text content in the files. Feasibly, the extracted text content can be used for display or for vectorization to build an index of the file.
[0284] Step 1402, by running the second module, perform at least one of the first operation and the second operation;
[0285] The first operation includes: if a first-type index of the first file is to be constructed, then generate a first-type index of the first file according to the first information and the first model of the first file;
[0286] The second operation includes: if a second-type index of the first file is to be constructed, then generate a second-type index of the first file according to the first file and the first model.
[0287] Figure 14 In the illustrated embodiment, the second module uses the first model to construct different types of indexes respectively, realizing the reuse of the first model by the same module, so that the model utilization rate can be improved.
[0288] Step 1403, if there is no file for which a first-type index is to be constructed, no file for which a second-type index is to be constructed, and the first model has been loaded, then unload the first model.
[0289] Feasibly, the operation of the electronic device to unload the first model can generally be to unload the first model from the memory to end the loading of the first model, that is, no longer load the first model. If there are files for which a first-type index and / or a second-type index are to be constructed again later, the electronic device can load the first model again.
[0290] Figure 14 In the illustrated embodiment, the electronic device loads / unloads the first model on demand in combination with the construction requirements of various indexes, so that when any type of index is to be constructed, the model is always loaded, and the model is unloaded only when no indexes of any type need to be constructed, so as to avoid overly frequent loading / unloading of the model, reduce unnecessary model loading / unloading operations, and thus reduce unnecessary waste of device resources.
[0291] In addition to loading / unloading the first model on demand, the second module can also be started / stopped on demand. In an embodiment of the present application, the index construction method may further include: if at least one of the first-type index and the second-type index of the first file is to be constructed and the second module has not been started, then start the second module; if there is no file for which a first-type index is to be constructed, no file for which a second-type index is to be constructed, and the second module has been started, then stop the second module.
[0292] By starting / stopping the second module on demand, unnecessary module start / stop operations can be reduced, thereby reducing unnecessary waste of device resources.
[0293] In addition to starting / stopping the second module on demand, the first module can also be started / stopped on demand. In an embodiment of the present application, the index construction method may further include: if a first-type index of a first file is to be constructed and the first module is not started, start the first module; if there is no file for which a first-type index is to be constructed and the first module has been started, stop the first module.
[0294] By starting / stopping the first module on demand, unnecessary module start / stop operations can be reduced, thereby reducing unnecessary waste of device resources.
[0295] In an embodiment of the present application, the second module includes a first queue and a second queue; the first queue is used to temporarily store first information of a first file; the second queue is used to temporarily store a first file or second information of the first file, and the second information is used to generate a second-type index of the first file. Based on this, the absence of a file for which a first-type index is to be constructed includes: the first queue is empty; the absence of a file for which a second-type index is to be constructed includes: the second queue is empty.
[0296] Feasibly, if the first queue is not empty, it can indicate that a first-type index of the corresponding file is to be constructed, and if the second queue is not empty, it can indicate that a second-type index of the corresponding file is to be constructed.
[0297] In one example, the first file may be a document, that is, the full text of the document, and the electronic device can vectorize the full text of the document to generate a full-text index of the document.
[0298] In another example, the first file may be a document, and the electronic device can slice the document and vectorize the sliced content of the document to generate a sliced index of the document.
[0299] In yet another example, the second information of the first file may be the sliced content of the document, and the electronic device can vectorize the sliced content of the document to generate a sliced index of the document. Thus, the electronic device may include a document slicing module, and the document slicing module is used to slice the document, and the generated sliced content can be stored in the second queue. As Figure 2 shown, the first queue may be the abstract vectorization queue 204, and the second queue may be the sliced vectorization queue 205.
[0300] By according to the queue situation, it can be accurately judged whether there is a file for which a corresponding index is to be constructed, which helps to accurately execute the on-demand opening / closing of modules and on-demand loading / unloading of models.
[0301] In an embodiment of the present application, generating the first information of the first file includes: generating the first information of the first file according to the second model; the index construction method further includes: if the first information of the first file is to be generated and the second model is not loaded, then load the second model; if there is no file for which the first information is to be generated and the second model has been loaded, then unload the second model.
[0302] See Figure 2 , the second model may be the abstract generation module 208, and specifically may be a large language model.
[0303] In one embodiment, the electronic device may include the second model. In other embodiments, the second model may be in other devices.
[0304] The electronic device can load / unload the second model as needed in combination with the generation requirement of the first information, which can avoid overly frequent loading / unloading of the model, reduce unnecessary model loading / unloading operations, and thus reduce unnecessary waste of device resources.
[0305] In an embodiment of the present application, generating the first information of the first file includes: generating the first information of the first file according to the second model; the processing priority of the first operation is lower than that of the second operation.
[0306] Since the first module uses the second model to generate the first information, the time-consuming for constructing the first type of index is usually high. Thus, the second operation can be preferentially executed to preferentially construct the second type of index.
[0307] Exemplarily, see Figure 2 , the first operation can be used to construct the abstract index, and the second operation can be used to construct the shard index. Then, compared with the abstract vectorization queue, the index construction module can preferentially process the shard vectorization queue to preferentially construct the shard index, which helps to complete the construction of the shard index of all files as early as possible.
[0308] Compared with the shard index search results obtained when searching based on the shard index of some documents, the shard index search results obtained when searching based on the shard index of all documents can be more accurate, which helps to improve the search effect.
[0309] In addition, since the time-consuming for the first module to generate the first information using the second model is usually high, there may be a situation where the first module has not completed the information generation but the first queue is empty. Since the electronic device needs to generate the first type of index based on this after the first module generates the first information, in a feasible implementation manner, the above situation where there is no file for which the first type of index is to be constructed may further include: the first module is in a working state.
[0310] Thus, if the first queue is empty and the first module is not working, it can indicate that there are no files for which the first type of index needs to be constructed. If the second queue is empty, resulting in no files for which the second type of index needs to be constructed, the first model can be unloaded, thus avoiding unnecessary loading / unloading of the first model.
[0311] In an embodiment of the present application, the index construction method may further include: obtaining search information; according to the search information and various types of indexes already constructed by the electronic device, obtaining the search results corresponding to each type of index among the various types of indexes to obtain multiple search results; and generating the search result of the search information according to the multiple search results.
[0312] Taking documents as an example, referring to Figure 11 , the various types of indexes already constructed may include BM25 indexes, shard indexes, and summary indexes, and the multiple search results may correspondingly include BM25 index search results, shard index search results, and summary index search results.
[0313] Regardless of whether all types of indexes of all files have been constructed, before all types of indexes of all files are completed, the electronic device always uses the search strategy of full-path search to implement file search. In this way, the information of each constructed index can be fully utilized, which helps to improve the search effect.
[0314] In an embodiment of the present application, generating the search result of the search information according to the multiple search results includes: performing weighted fusion processing according to the first result of the target file in one or more target search results to obtain the second result of the target file; where the target file is any file among the multiple search results; where the multiple search results include one or more target search results, the electronic device has constructed an index of the type corresponding to the target search result for the target file, and the sum of the weights corresponding to the one or more target search results is 1; and generating the search result of the search information according to the second result of the target file.
[0315] Feasibly, the above first result may be a ranking, and the above second result may be an RRF score.
[0316] Referring to Table 1 above, the above multiple search results are 3 search results, and the target file may be any one of the 3 search results, that is, any one of Documents 1 to 4.
[0317] If the target file is any one of Documents 1 to 3, since the electronic device has constructed 3 types of indexes for Documents 1 to 3, there are 3 target search results for Documents 1 to 3. In this way, the above formula (3) can be used to calculate the RRF scores of Documents 1 to 3 respectively. In formula (2), the sum of the weights corresponding to the 3 target search results is 1, that is .
[0318] If the target file is Document 4, since the BM25 index and shard index of Document 4 have been built by the electronic device, but the abstract index of Document 4 has not been built, there are 2 types of target search results for Document 4 (i.e., BM25 index search results and shard index search results). Thus, the above formula (2) can be used to calculate the RRF score of Document 4. In formula (2), the sum of the weights corresponding to the 2 types of target search results is 1, that is .
[0319] By fusing the full-path search results and performing targeted full-path search result fusion processing on each file according to the current index construction situation of each file, the fusion effect can be improved.
[0320] The method provided by any embodiment of the present application can be applied to electronic devices such as mobile phones, tablet computers, personal digital assistants (PDAs), desktops, laptops, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, and wearable devices. The present application does not impose special restrictions on the specific forms of the above electronic devices.
[0321] The index construction method provided by any embodiment of the present application can be applied to Figure 15 the electronic device 100 shown. Figure 15 FIG. shows a schematic structural diagram of the electronic device 100.
[0322] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor, a gyroscope sensor, a barometric pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
[0323] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figures, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0324] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors. The controller can generate operation control signals according to the instruction operation code and timing signals to complete the control of fetching and executing instructions.
[0325] In some embodiments, the processor 110 may be a system-on-chip (SOC). The processor 110 may include a central processing unit (CPU) and may further include other types of processors. In some embodiments, the processor 110 may be a PWM control chip.
[0326] The processor 110 may also include necessary hardware accelerators or logic processing hardware circuits, such as ASIC, or one or more integrated circuits for controlling the execution of the technical solution program. In addition, the processor 110 may have the function of operating one or more software programs, and the software programs may be stored in a storage medium.
[0327] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be directly called from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0328] In some embodiments, the memory of the electronic device 100 may be a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), or other types of dynamic storage devices that can store information and instructions. It may also be an electrically erasable programmable read-only memory (EEPROM), or any computer-readable medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer.
[0329] In some embodiments, the processor 110 and the memory may be integrated into a processing device, or they may be independent components. The processor 110 can be used to execute the program code stored in the memory. Specifically, the memory may also be integrated in the processor 110, or independent of the processor 110.
[0330] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0331] It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only for illustrative purposes and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0332] The internal memory 121 can be used to store computer-executable program codes, and the executable program codes include instructions. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor.
[0333] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0334] The touch sensor, also known as a "touch control device". The touch sensor can be disposed on the display screen 194, and the touch sensor and the display screen 194 form a touch screen, also known as a "touch control screen". The touch sensor is used to detect a touch operation acting on it or nearby. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor can also be disposed on the surface of the electronic device 100, at a different position from the display screen 194.
[0335] In addition, on top of the above components, the electronic device runs an operating system. For example, iOS ® Operating system, Android ® Operating system, Windows ® Operating systems, etc. Application programs can be installed and run on the operating system.
[0336] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of the present application, taking the layered architecture as an example, the software structure of the electronic device 100 is exemplarily described.
[0337] Figure 16It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application. The layered architecture can divide the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the operating system of the electronic device is divided into multiple layers, from top to bottom, which are the application layer, the application framework layer (Framework, FWK), the native service layer (Native), the hardware abstraction layer (hardware abstraction layer, HAL), and the kernel layer (Kernel).
[0338] The application layer may include a series of application packages. Taking the electronic device 100 as a PC (personal computer) as an example, the application layer of the PC may include Figure 16 the PC search application and the PC document application shown in. In this way, the user can use the PC search application to send a file search request, and can use the PC document application to store documents, view stored documents, etc.
[0339] The application framework layer provides application programming interfaces (Application Programming Interface, API) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions. The application framework layer may include a view system, a notification manager, a resource manager, a window manager, a content provider, etc.
[0340] The view system includes visible controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon may include a view for displaying text and a view for displaying pictures.
[0341] The notification manager enables applications to display notification information in the status bar, can be used to convey message types of notifications, and can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform that the download is completed, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or a scroll bar text, such as a notification of a background running application, and can also be a notification that appears on the screen in the form of a dialogue window. For example, prompting text information in the status bar, emitting a prompt tone, vibrating the terminal device, flashing the indicator light, etc.
[0342] The resource manager provides various resources for applications, such as localized strings, icons, pictures, layout files, video files, etc.
[0343] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0344] The content provider is used to store and obtain data, and make this data accessible to application programs. Taking a smartphone as an example of an electronic device, the data may include videos, images, audio, incoming and outgoing calls, browsing history and bookmarks, phone books, etc.
[0345] See Figure 16 , the local service layer may further include a service layer, a model layer, and an inference deployment layer.
[0346] The service layer may include AI middle platform services, and the AI middle platform services may include a search service supporting PC search applications and a document service supporting PC document applications.
[0347] The model layer may include large language models, which can be used to generate abstracts of documents. The generated document abstracts can be used for display or for building an abstract index of the documents.
[0348] Feasibly, the electronic device can display the abstract of the document through the PC document application to meet the user's need to view the document abstract.
[0349] Feasibly, the electronic device can perform a file search based on the constructed abstract index through the search service to obtain the search results of the abstract index, and then fuse the search results of the abstract index and the search results of other types of indexes to obtain the search results of the user's search information. After that, the electronic device can display the search results of the user's search information through the PC search application to meet the user's file search needs.
[0350] The inference deployment layer may include a large model deployment acceleration service (such as Openvino), which can be used to accelerate and optimize large speech models, etc.
[0351] The hardware abstraction layer acts as a bridge between software and hardware. It encapsulates the underlying hardware drivers and provides a general interface for the application framework layer to call the drivers.
[0352] The kernel layer is the layer between hardware and software. The kernel layer at least includes a camera driver, a display driver, a Bluetooth driver, an audio driver, and a sensor driver.
[0353] It can be understood that Figure 16 The layers in the shown software structure and the components included in each layer do not constitute a specific limitation on the electronic device 100. In some other embodiments of the present application, the electronic device 100 may include more or fewer layers than shown, and each layer may include more or fewer components, which are not limited in the present application.
[0354] The embodiment of the present application further provides an index construction device, which is applied to an electronic device. The electronic device includes a first module and a second module. The first module is used to generate first information of a first file, and the first file is any file for which an index needs to be constructed. The device includes: a first processing module, configured to load a first model if at least one of a first type index and a second type index of the first file needs to be constructed and the first model has not been loaded; a second processing module, configured to perform at least one of a first operation and a second operation by running the second module. The first operation includes: if a first type index of the first file needs to be constructed, generating a first type index of the first file according to the first information and the first model. The second operation includes: if a second type index of the first file needs to be constructed, generating a second type index of the first file according to the first file and the first model. A third processing module, configured to unload the first model if there is no file for which a first type index and a second type index need to be constructed and the first model has been loaded.
[0355] The embodiment of the present application further provides a chip. The task processing chip is installed in an electronic device. The chip includes: a processor, which is configured to execute computer program instructions stored in a memory. When the computer program instructions are executed by the processor, the chip is triggered to execute the method steps provided in any method embodiment of the present application.
[0356] The embodiment of the present application further proposes a terminal device. The terminal device includes a communication module, a memory for storing computer program instructions, and a processor for executing the program instructions. When the computer program instructions are executed by the processor, the terminal device is triggered to execute the method steps provided in any method embodiment of the present application.
[0357] The embodiment of the present application further proposes a server device. The server device includes a communication module, a memory for storing computer program instructions, and a processor for executing the program instructions. When the computer program instructions are executed by the processor, the server device is triggered to execute the method steps provided in any method embodiment of the present application.
[0358] The embodiment of the present application further provides an electronic device. The electronic device includes multiple antennas, a memory for storing computer program instructions, a processor for executing the computer program instructions, and a communication device (such as a communication module that can implement 5G communication based on the NR protocol). When the computer program instructions are executed by the processor, the electronic device is triggered to execute the method steps provided in any method embodiment of the present application.
[0359] Specifically, in the embodiment of the present application, one or more computer programs are stored in the above-mentioned memory. The one or more computer programs include instructions. When the instructions are executed by the above-mentioned device, the above-mentioned device is caused to execute the method steps described in the embodiment of the present application.
[0360] Furthermore, the devices, apparatuses, and modules described in the embodiments of the present application can be specifically implemented by computer chips or entities, or by products with certain functions.
[0361] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, apparatuses, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media containing computer-usable program code.
[0362] In several embodiments provided by the present application, if any function 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. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application.
[0363] Specifically, the embodiments of the present application also provide a computer-readable storage medium, in which a computer program is stored. When it runs on a computer, it causes the computer to execute the method steps provided by the embodiments of the present application.
[0364] The embodiments of the present application also provide a computer program product, which includes a computer program. When it runs on a computer, it causes the computer to execute the method steps provided by the embodiments of the present application.
[0365] In several embodiments provided by the present application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of the units is only a logical functional division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be an indirect coupling or communication connection through some interfaces, apparatuses, or units, and can be in electrical, mechanical, or other forms.
[0366] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0367] In addition, in each embodiment of the present application, each functional unit can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a combination of hardware and software functional units.
[0368] The integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit stored in a storage medium includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories, random access memories, magnetic disks, or optical discs.
[0369] In the embodiments of the present application, the term "including", "comprising" or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, commodity or device. Without further limitation, the element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, commodity or device including the said element.
[0370] The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in a distributed computing environment where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0371] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments of the present application can be implemented by electronic hardware, computer software, or a combination of both. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0372] Those skilled in the art can clearly understand that for the sake of convenience and brevity of description, the similar parts among the various embodiments in the present application can be referred to each other. For example, for the specific working processes of the systems, devices, and units described in the embodiments of the present application, reference can be made to the corresponding processes in the method embodiments of the present application, which will not be elaborated herein.
[0373] The above are only specific embodiments of the present application and are not intended to limit the present application. The protection scope of the present application should be subject to the claims.
Claims
1. An index construction method, characterized in that, Applied to an electronic device, the electronic device includes a first module and a second module; The first module is used to generate first information of a first file, the first file being any file for which an index needs to be constructed, and the first information includes an abstract; The method includes: If at least one of a first type index and a second type index of the first file needs to be constructed and the first model is not loaded, then load the first model; the first model includes a vectorization model; By running the second module, perform at least one of a first operation and a second operation; The first operation includes: If the first type index of the first file needs to be constructed, then generate the first type index of the first file according to the first information of the first file and the first model; The second operation includes: If the second type index of the first file needs to be constructed, then generate the second type index of the first file according to the first file and the first model; If there is no file for which the first type index needs to be constructed, no file for which the second type index needs to be constructed, and the first model has been loaded, then unload the first model.
2. The method according to claim 1, wherein The method further includes: If at least one of the first type index and the second type index of the first file needs to be constructed and the second module is not started, then start the second module; If there is no file for which the first type index needs to be constructed, no file for which the second type index needs to be constructed, and the second module has been started, then close the second module.
3. The method according to claim 1, characterized in that, The method further includes: If the first type index of the first file needs to be constructed and the first module is not started, then start the first module; If there is no file for which the first type index needs to be constructed and the first module has been started, then close the first module.
4. The method according to claim 1, wherein The second module includes a first queue and a second queue; The first queue is used to temporarily store the first information of the first file; The second queue is used to temporarily store the first file or second information of the first file, and the second information is used to generate the second type index of the first file; The situation where there is no file for which the first type index needs to be constructed includes: the first queue is empty; The situation where there is no file for which the second type index needs to be constructed includes: the second queue is empty.
5. The method according to claim 1, wherein Generating the first information of the first file includes: generating the first information of the first file according to a second model; The method further includes: If the first information of the first file needs to be generated and the second model is not loaded, then load the second model; If there is no file for which the first information needs to be generated and the second model has been loaded, then unload the second model.
6. The method according to claim 1, characterized in that, Generating the first information of the first file includes: Generating the first information of the first file according to a second model; The processing priority of the first operation is lower than that of the second operation.
7. According to the method described in any one of claims 1-6, characterized in that, The method further includes: Obtain search information; According to the search information and various types of indexes already constructed by the electronic device, obtain search results corresponding to each type of index among the various types of indexes, and obtain multiple search results; Generate a search result of the search information according to the multiple search results.
8. The method according to claim 7, wherein Generate a search result of the search information according to the multiple search results, including: Perform weighted fusion processing on a first result of a target file in one or more target search results to obtain a second result of the target file; wherein the target file is any file in the multiple search results; wherein the multiple search results include the one or more target search results, the electronic device has constructed an index of the target file corresponding to the type of the target search result, and the sum of the weights corresponding to the one or more target search results is one; Generate a search result of the search information according to the second result of the target file.
9. A chip, characterized in that, Including: A processor for executing computer program instructions stored on a memory, wherein when the computer program instructions are executed by the processor, the chip is triggered to execute the method according to any one of claims 1-8.
10. An electronic device, characterized in that, The electronic device includes one or more memories for storing computer program instructions and one or more processors, wherein when the computer program instructions are executed by the one or more processors, the electronic device is triggered to execute the method according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and when the computer program runs on a computer, the computer is caused to execute the method according to any one of claims 1-8.
12. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program runs on a computer, the computer is caused to execute the method according to any one of claims 1-8.
Citation Information
Patent Citations
Advanced retrieval enhanced blocking and vectoring method based on large model
CN118312579A
Multi-modal data search method, device and equipment based on generative AI large model, storage medium and product
CN119226575A