File access method, device, equipment and storage medium
By using neural network prediction models in the file access system to predict the next file access to the user and store the metadata of these files in the cache, the problem of file access delay in the prior art is solved, and faster file access and higher cache hit rate are achieved.
Patent Information
- Application Number
- CN202111600030.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-12-24
AI Technical Summary
Existing file access delays cannot meet users' high requirements for quickly obtaining information.
The neural network prediction model predicts the next file access to the target user and stores the metadata of these files in the cache to improve file access speed.
It effectively improves file access speed, meets users' needs for quickly obtaining information, and improves cache hit rate by predicting the next file access.
Smart Images

Figure CN114443569B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a file access method, device, equipment and storage medium. Background Art
[0002] With the rapid development of big data and cloud computing, a wave of massive data is coming. With the accelerated iteration of information and the faster pace of life, more and more users are using fragmented time to quickly obtain information, which has led to an increase in the demand for information acquisition speed and a decrease in tolerance for file access delays.
[0003] However, users have increasingly higher requirements for file access speed, and the existing access delay no longer meets user requirements, but there is currently no better optimization solution. Summary of the invention
[0004] In view of this, the embodiments of the present invention provide a virtual machine hot migration method, device and storage medium to solve the problem that users have increasingly higher requirements for file access speed and the existing access delay can no longer meet user requirements.
[0005] According to a first aspect, an embodiment of the present invention provides a file access method, comprising:
[0006] receiving an access request for a first target file sent by a target user;
[0007] If it is determined that the metadata of the first target file is not included in the cache, predicting a set number of second target files through a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time;
[0008] Acquire metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache;
[0009] The file content of the first target file is acquired according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0010] In combination with the first aspect, in the first implementation of the first aspect, the following further includes:
[0011] Constructing positive and negative samples according to the historical access data of the target user;
[0012] The neural network prediction model is trained according to the positive and negative samples, wherein the training includes updating the weight matrix using a gradient descent algorithm to obtain a final file vector.
[0013] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, the number of negative samples in the positive and negative samples is greater than the number of positive samples.
[0014] In combination with the first implementation of the first aspect, in the third implementation of the first aspect, the training method adopted by the training includes: a continuous bag of words model CBOW or a Skip-Gram model.
[0015] In combination with the first implementation of the first aspect, in a fourth implementation of the first aspect, predicting a set number of second target files by using a neural network prediction model includes:
[0016] Calculate the similarity between each candidate file and the first target file according to the final file vector;
[0017] The candidate file whose similarity meets the set condition is determined as the second target file.
[0018] In combination with the fourth implementation of the first aspect, in the fifth implementation of the first aspect, the set condition includes: a set similarity threshold, and the second target file is a candidate file greater than the set similarity threshold; or
[0019] Performing a first sorting on the candidate files in descending order of similarity, selecting the set number of candidate files from the beginning of the first sorting in sequence, and the selected candidate files are the second target files; or
[0020] The candidate files are sorted in a second order according to the similarity from small to large, and the set number of candidate files are selected in sequence from the end of the second order, and the selected candidate files are the second target files.
[0021] In combination with the first aspect or the first embodiment of the first aspect or the second embodiment of the first aspect or the third embodiment of the first aspect or the fourth embodiment of the first aspect or the fifth embodiment of the first aspect, in the sixth embodiment of the first aspect, further comprising:
[0022] If it is determined that the cache includes the metadata of the first target file, the file content of the first target file is obtained according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0023] According to a second aspect, an embodiment of the present invention provides a file access device, comprising:
[0024] A receiving module, configured to receive an access request for a first target file sent by a target user;
[0025] A prediction module, configured to predict a set number of second target files by using a neural network prediction model if it is determined that the metadata of the first target file is not included in the cache, wherein the second target files are used to represent the files that the target user will access next time obtained by prediction;
[0026] A storage module, used for acquiring metadata of the first target file and metadata of the second target file, and storing the metadata of the first target file and metadata of the second target file into the cache;
[0027] The first sending module is used to obtain the file content of the first target file according to the metadata of the first target file, and send the file content of the first target file to the target user.
[0028] In conjunction with the second aspect, in the first implementation of the second aspect, further comprising:
[0029] A construction module, used to construct positive and negative samples according to the historical access data of the target user;
[0030] A training module is used to train the neural network prediction model according to the positive and negative samples, wherein the training includes updating the weight matrix using a gradient descent algorithm to obtain a final file vector.
[0031] In combination with the first implementation of the second aspect, in the second implementation of the second aspect, the number of negative samples in the positive and negative samples is greater than the number of positive samples.
[0032] In combination with the first implementation of the second aspect, in the third implementation of the second aspect, the training method adopted by the training includes: a continuous bag of words model CBOW or a Skip-Gram model.
[0033] In combination with the first implementation of the second aspect, in a fourth implementation of the second aspect, the training module includes:
[0034] A calculation submodule, used for calculating the similarity between each candidate file and the first target file according to the final file vector;
[0035] The determination submodule is used to determine the candidate file whose similarity meets the set condition as the second target file.
[0036] In combination with the fourth implementation of the second aspect, in the fifth implementation of the second aspect, the set condition includes: a set similarity threshold, and the second target file is a candidate file greater than the set similarity threshold; or
[0037] Performing a first sorting on the candidate files in descending order of similarity, selecting the set number of candidate files from the beginning of the first sorting in sequence, and the selected candidate files are the second target files; or
[0038] The candidate files are sorted in a second order according to the similarity from small to large, and the set number of candidate files are selected in sequence from the end of the second order, and the selected candidate files are the second target files.
[0039] In combination with the second aspect or the first embodiment of the second aspect or the second embodiment of the second aspect or the third embodiment of the second aspect or the fourth embodiment of the second aspect or the fifth embodiment of the second aspect, in the sixth embodiment of the second aspect, further comprising:
[0040] The second sending module is used to obtain the file content of the first target file according to the metadata of the first target file if it is determined that the cache includes the metadata of the first target file, and send the file content of the first target file to the target user.
[0041] According to the third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the file access method described in the first aspect or any one of the embodiments of the first aspect by executing the computer instructions.
[0042] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the file access method described in the first aspect or any one of the implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present invention in any way. In the accompanying drawings:
[0044] Figure 1 A method flow chart of a file access method is shown.
[0045] Figure 2 A schematic diagram of a training process is shown.
[0046] Figure 3 Another schematic diagram of a training process is shown.
[0047] Figure 4 Another schematic diagram of a training process is shown.
[0048] Figure 5 Another method flow chart of a file access method is shown.
[0049] Figure 6 A structural schematic diagram of a file access device is shown.
[0050] Figure 7 A structural schematic diagram of an electronic device is shown. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0052] Figure 1 A method flow chart of a file access method is shown. The file access method can be used on electronic devices for file access, such as various storage devices in a distributed file storage system.
[0053] like Figure 1 As shown, the file access method may include:
[0054] Step 101: Receive an access request for a first target file sent by a target user.
[0055] Specifically, the first target file refers to a file that the user requests to access. The access request may include a file identifier of the first target file, such as a file name.
[0056] Step 102: If it is determined that the cache does not include metadata of the first target file, a set number of second target files are predicted using a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time.
[0057] Specifically, metadata, also known as intermediary data or relay data, is data about data, mainly information describing data properties, used to support functions such as indicating storage location, historical data, resource search, and file records.
[0058] In order to significantly improve the cache hit rate, when the metadata of the first target file is not included in the cache, the second target file that the target user may access next can be predicted through a neural network prediction model.
[0059] The set number in the set number second target file may be a preset value. Preferably, the set number may be an integer greater than 1.
[0060] Step 103: Obtain metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and the metadata of the second target file in a cache.
[0061] Specifically, in addition to obtaining the metadata of the first target file accessed by the user, additional metadata of a set number (for example: N=3) of predicted second target files are obtained and saved in the cache. This makes it easier for the target user to quickly return the file he needs to access the next time he visits, thereby improving file access speed.
[0062] Step 104: Obtain the file content of the first target file according to the metadata of the first target file, and send the file content of the first target file to the target user.
[0063] Specifically, after the metadata of the first target file and the metadata of the second target file are stored in the cache, the file content of the first target file can be obtained according to the metadata of the first target file, and the file content of the first target file is sent to the target user, thereby meeting the access requirements of the target user.
[0064] In an embodiment of the present application, when an access request for a first target file is received from a target user and the cache does not include metadata of the first target file, a set number of second target files can be predicted through a neural network prediction model, and the metadata of the first target file and the metadata of the second target file can be obtained and stored in the cache. Then, the file content of the first target file is obtained based on the metadata of the first target file, and the file content of the first target file is sent to the target user. In this way, while ensuring that the access needs of the target user are met, the metadata of the second target file that the target user may access next is also saved to the cache, which can greatly improve the cache hit rate, maximize the cache advantage, and speed up file access.
[0065] In an optional embodiment, the file access method may further include:
[0066] (1) Construct positive and negative samples based on the historical access data of the target user;
[0067] (2) The neural network prediction model is trained based on positive and negative samples. The training includes using the gradient descent algorithm to update the weight matrix and obtain the final file vector.
[0068] Specifically, the historical access data of the target user reflects the potential connections between the accessed files and is related to the interests of the target user. When collecting these historical access data, time-series file samples can be formed to construct positive and negative samples.
[0069] Among them, positive sample construction may include constructing positive samples in the following two forms:
[0070] Positive sample form 1: Take a file in the sequence as input (input), and take the subsequent m1 files as output (output).
[0071] Positive sample form 2: Take the first m1 files of a file in the sequence as input (input), and take the file as output (output).
[0072] This application does not limit the above m1, which can be specified based on experience and specific scenarios.
[0073] Negative sample construction can include constructing the following two forms of negative samples:
[0074] Negative sample form 1: specify a file as input, and select m2 files that have not appeared after it as output.
[0075] Negative sample form 2: Take m2 files in the sequence as input (input), and select one of the files that have not appeared after it as output (output).
[0076] This application does not limit the above m2, and it can be specified based on experience and specific scenarios. In addition, when the scale of negative samples is not large, they need to be generated by random generation.
[0077] In addition, when training a neural network prediction model, the training process may include: Figure 2 As shown in the figure, the file is encoded with one-hot code to generate a file vector; it is mapped to a low-dimensional space through the hidden layer of the neural network without any activation function; the hidden layer is fully connected with the output layer; the output layer uses softmax to obtain a probability distribution, where each dimension represents a file. Among them, the Sigmoid function is the inverse function of the standard connection function of the Bernoulli distribution, and it can also convert wx+b into probability p.
[0078] In an embodiment of the present application, a neural network prediction model can be trained based on the historical access data of the target user, so that the prediction result is more in line with the user's behavioral characteristics, the cache hit rate is greatly improved, and the cache advantage is maximized, thereby achieving the purpose of optimizing file access performance, reducing user waiting time, and improving user experience.
[0079] In an optional embodiment, in the above positive and negative sample construction, the number of negative samples in the positive and negative samples is greater than the number of positive samples.
[0080] Specifically, since negative samples reduce the amount of computation in the gradient descent process, in order to increase the training speed and improve the quality of the document vector, the number of negative samples should be more than the positive samples.
[0081] In the embodiment of the present application, in the construction of positive and negative samples, the number of negative samples in the positive and negative samples is greater than the number of positive samples, which can increase the training speed and improve the quality of the file vector, thereby increasing the speed of file access.
[0082] In an optional embodiment, when training the neural network prediction model, the training methods that can be used include but are not limited to the following two training methods:
[0083] Training method 1: Continuous Bag-Of-Words Model (CBOW), such as Figure 3 shown.
[0084] ①Assume that the file one-hot encoding is x ik , the dimension is v; the number of preceding files is m, then the input layer (InputLayer) is:
[0085] x 1k =(x1,x2,...,xv),x 2k =(x1, x2, ..., x υ ),……,x mk =(x1, x2, ..., x v )
[0086] For example, assuming m=5, the input layer is:
[0087] x1=(x1,x2,……,x v )、x2=(x1,x2,......,xu)、……x5=(x1,x2,......,x v )
[0088] ② Initialize the weight matrix W, the scale of W is v×n, and n can be specified according to experience or actual scenarios. Multiply the input layer file encoding with the input weight matrix W to obtain m vectors:
[0089] h 1k =(h1, h2, ..., h n ),h 2k =(h1, h2, ..., h n ),……、h mk =(h1, h2, ..., h n )
[0090] Take the average vector as the latent vector:
[0091]
[0092] For example, three files are input, and their one-hot encodings are [0 0 0 1 0 0], [0 1 0 0 00], and [0 0 0 0 0 1], respectively. The size of the weight matrix is 6×3, then three latent vectors of size 1×3 can be obtained.
[0093]
[0094]
[0095]
[0096] Then the hidden vector is:
[0097]
[0098] ③The latent vector is multiplied by the output weight matrix w′, the scale of w′ is n×v, and the output vector y is obtained. The dimension of y is v. The output layer uses softmax to obtain the probability distribution, and each dimension represents a file.
[0099] ④ Define the loss function as the cross entropy cost function, use the gradient descent algorithm to update the weight matrix w, w′, and finally obtain the input weight matrix w. The file one-hot encoding is multiplied by w to obtain the final file vector
[0100] Training method 2: Skip-Gram model, such as Figure 4 shown.
[0101] ①Assume the one-hot encoding x of the file k , the dimension is v, then the input layer is:
[0102] x k =(x1, x2, ..., xv)
[0103] ② Initialize the input weight matrix W, the scale of W is v×n, and n can be specified according to experience or actual scenarios. Multiply the input layer file encoding with the weight matrix W to obtain the latent vector h k , with dimensions n:h k =(h1, h2, ..., h n )
[0104] For example, assuming that the file one-hot encoding is
[00010] and the size of the weight matrix is 5×3, a latent vector of size 5×3 can be obtained.
[0105]
[0106] ③ Initialize the output weight matrix w′ with a scale of n×υ. Multiply the latent vector by the output weight matrix w′ to obtain n output vectors y with a dimension of v. The activation function is used to obtain the probability distribution. Each vector can predict a file.
[0107] ④ Define the loss function as the cross entropy cost function, and use the gradient descent algorithm to update the weight matrices w and w′. The final input weight matrix w is obtained. The file one-hot encoding is multiplied by w to get the final file vector.
[0108] In the embodiments of the present application, the CBOW or Skip-Gram model can be used for training, which expands the implementation method of training the neural network prediction model, supports large and small files, has strong versatility, and has richer application scenarios.
[0109] In an optional embodiment, when predicting a set number of second target files by using a neural network prediction model in step 102, the following may be included:
[0110] (1) Calculate the similarity between candidate files based on the final file vector;
[0111] (2) The candidate files whose similarity meets the set conditions are determined as the second target files.
[0112] Specifically, when calculating the similarity between candidate files, the calculation formula may be as follows:
[0113]
[0114] in, Euclidean distance can be used to calculate similarity. The smaller the distance, the higher the similarity. The similarities between files are calculated. The higher the similarity, the more likely the user is to access the file after accessing the current file, and the file is more in line with the user's current interests.
[0115] When determining the second target file, T files with the highest similarity to the files to be accessed by the user may be selected. These T files are the files that are predicted to be accessed by the target user later.
[0116] In the embodiment of the present application, the similarity between each candidate file can be calculated based on the final file vector obtained by the neural network prediction model, and the candidate file whose similarity meets the set conditions is determined as the second target file, thereby improving the accuracy of file prediction.
[0117] In an optional embodiment, the above setting conditions may include but are not limited to the following three situations:
[0118] Scenario 1: The set conditions include: a set similarity threshold, and the second target file is a candidate file having a similarity greater than the set similarity threshold;
[0119] Scenario 2: performing a first sorting on each candidate file in descending order of similarity, selecting a set number of candidate files from the beginning of the first sorting, and the selected candidate files are the second target files; or
[0120] Scenario 3: Perform a second sorting on each candidate file in the order of similarity from small to large, and select a set number of candidate files from the end of the second sorting forward in sequence, and the selected candidate files are the second target files.
[0121] In the embodiments of the present application, the second target file may be determined in the manner shown in any of the above situations, thereby expanding the implementation method of file prediction and improving the application scope of file prediction.
[0122] In an optional embodiment, if Figure 5 As shown, the file access method may also include:
[0123] Step 105: If it is determined that the cache includes metadata of the first target file, the file content of the first target file is obtained according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0124] Specifically, if the cache includes metadata of the first target file, the file content of the first target file can be directly sent to the target user, thereby maximizing the cache advantage and accelerating file access speed.
[0125] It can be seen from the above embodiments that the technical effects that can be achieved by the present invention may include:
[0126] (1) The problem that data prefetching can only be achieved by combining small files for storage is optimized, so that the prefetching algorithm does not need to be combined with file merging and is applicable to both large and small files. It has strong versatility and richer application scenarios.
[0127] (2) The unscientific problem of the pre-fetching strategy of adjacent metadata with a fixed step size is optimized. Through the metadata pre-fetching algorithm based on a neural network, the next access can be effectively predicted, thereby improving the hit rate and access speed.
[0128] (3) To address the problems of dimension explosion and difficulty in determining features caused by vectorizing file contents, we optimized the file vectorization by continuously training the neural network, which can avoid dimension explosion and easily determine file features.
[0129] (4) To address the problem that the pre-fetching algorithm does not take into account the user's interest characteristics, we optimized it by using the user's historical access data as samples to train the neural network so that the pre-fetching algorithm meets the user's access characteristics and reduces the read and write latency.
[0130] This application can be applied to the file storage product of the CStor distributed storage system. With the acceleration of information iteration and the faster pace of life, more and more users use fragmented time to quickly obtain information. If the file access performance is not optimized, it will be impossible to meet the requirements of information acquisition speed and file access latency. Using the neural network-based metadata prefetching algorithm of CStor distributed file storage to optimize file access performance can effectively predict the next access, meet user access characteristics, reduce read and write latency, improve hit rate and access speed; avoid dimensionality explosion and easily determine file vectors; support large and small files, strong versatility, and richer application scenarios. Therefore, this application is more suitable for use in CStor distributed file storage.
[0131] Figure 6 FIG. 1 shows a schematic diagram of the structure of a file access device. The file access device may be each storage device in a distributed file storage system. Figure 6 As shown, the file access device may include:
[0132] The receiving module 11 is used to receive an access request for a first target file sent by a target user;
[0133] A prediction module 12 is configured to predict a set number of second target files by using a neural network prediction model if it is determined that the metadata of the first target file is not included in the cache, wherein the second target files are used to represent the files that the target user will access next time obtained by prediction;
[0134] A storage module 13, configured to obtain metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache;
[0135] The first sending module 14 is configured to obtain the file content of the first target file according to the metadata of the first target file, and send the file content of the first target file to the target user.
[0136] In a possible implementation, the method further includes:
[0137] A construction module, used to construct positive and negative samples according to the historical access data of the target user;
[0138] A training module is used to train the neural network prediction model according to the positive and negative samples, wherein the training includes updating the weight matrix using a gradient descent algorithm to obtain a final file vector.
[0139] In a possible implementation manner, the number of negative samples in the positive and negative samples is greater than the number of positive samples.
[0140] In a possible implementation, the training adopts a training method including: a continuous bag of words model CBOW or a Skip-Gram model.
[0141] In a possible implementation, the training module includes:
[0142] A calculation submodule, used for calculating the similarity between each candidate file and the first target file according to the final file vector;
[0143] The determination submodule is used to determine the candidate file whose similarity meets the set condition as the second target file.
[0144] In a possible implementation, the set condition includes: a set similarity threshold, the second target file is a candidate file having a similarity greater than the set similarity threshold; or
[0145] Performing a first sorting on the candidate files in descending order of similarity, selecting the set number of candidate files from the beginning of the first sorting in sequence, and the selected candidate files are the second target files; or
[0146] The candidate files are sorted in a second order according to the similarity from small to large, and the set number of candidate files are selected in sequence from the end of the second order, and the selected candidate files are the second target files.
[0147] In a possible implementation, the method further includes:
[0148] The second sending module is used to obtain the file content of the first target file according to the metadata of the first target file if it is determined that the cache includes the metadata of the first target file, and send the file content of the first target file to the target user.
[0149] It should be noted here that the file access device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned method embodiment and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.
[0150] Figure 7 FIG. 1 shows a schematic diagram of the structure of an electronic device. Figure 7 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the file access method, which includes:
[0151] receiving an access request for a first target file sent by a target user;
[0152] If it is determined that the metadata of the first target file is not included in the cache, predicting a set number of second target files through a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time;
[0153] Acquire metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache;
[0154] The file content of the first target file is acquired according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0155] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0156] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can execute the file access method provided by the above methods, the method comprising:
[0157] receiving an access request for a first target file sent by a target user;
[0158] If it is determined that the metadata of the first target file is not included in the cache, predicting a set number of second target files through a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time;
[0159] Acquire metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache;
[0160] The file content of the first target file is acquired according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0161] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the above-mentioned file access method, the method comprising:
[0162] receiving an access request for a first target file sent by a target user;
[0163] If it is determined that the metadata of the first target file is not included in the cache, predicting a set number of second target files through a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time;
[0164] Acquire metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache;
[0165] The file content of the first target file is acquired according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
[0166] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0167] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0168] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A file access method, characterized in that: include: receiving an access request for a first target file sent by a target user; If it is determined that the metadata of the first target file is not included in the cache, predicting a set number of second target files through a neural network prediction model, where the second target files are used to represent the predicted files that the target user will access next time; Acquire metadata of the first target file and metadata of the second target file, and store the metadata of the first target file and metadata of the second target file into the cache; Acquire the file content of the first target file according to the metadata of the first target file, and send the file content of the first target file to the target user; Forming a time series file sample based on the historical access data of the target user to construct positive and negative samples; the historical access data of the target user is used to reflect the potential connection between files and is related to the interests of the target user; Training the neural network prediction model according to the positive and negative samples, wherein the training includes updating the weight matrix using a gradient descent algorithm to obtain a final file vector; The step of predicting a set number of second target files by using a neural network prediction model includes: Calculating the similarity between each candidate file and the first target file based on the final file vector; the higher the similarity, the more it conforms to the current interests of the target user; The candidate file whose similarity meets the set condition is determined as the second target file.
2. The method according to claim 1, characterized in that The number of negative samples in the positive and negative samples is greater than the number of positive samples.
3. The method according to claim 1, characterized in that The training method used in the training includes: continuous bag of words model CBOW or Skip-Gram model.
4. The method according to claim 1, characterized in that: The set condition includes: a set similarity threshold, the second target file is a candidate file having a similarity greater than the set similarity threshold; or Performing a first sorting on the candidate files in descending order of similarity, selecting the set number of candidate files from the beginning of the first sorting in sequence, and the selected candidate files are the second target files; or The candidate files are sorted in a second order according to the similarity from small to large, and the set number of candidate files are selected in sequence from the end of the second order, and the selected candidate files are the second target files.
5. The method according to any one of claims 1 to 4, characterized in that: Also includes: If it is determined that the cache includes the metadata of the first target file, the file content of the first target file is obtained according to the metadata of the first target file, and the file content of the first target file is sent to the target user.
6. A file access device, characterized in that: include: A receiving module, configured to receive an access request for a first target file sent by a target user; A prediction module, configured to predict a set number of second target files by using a neural network prediction model if it is determined that the metadata of the first target file is not included in the cache, wherein the second target files are used to represent the files that the target user will access next time obtained by prediction; A storage module, used for acquiring metadata of the first target file and metadata of the second target file, and storing the metadata of the first target file and metadata of the second target file into the cache; A first sending module, configured to obtain the file content of the first target file according to the metadata of the first target file, and send the file content of the first target file to the target user; A construction module, used to form a time-series file sample and construct positive and negative samples according to the historical access data of the target user; the historical access data of the target user is used to reflect the potential connection between files and is related to the interests of the target user; A training module, used for training the neural network prediction model according to the positive and negative samples, wherein the training includes updating the weight matrix using a gradient descent algorithm to obtain a final file vector; The training module includes: A calculation submodule, configured to calculate the similarity between each candidate file and the first target file according to the final file vector; a higher similarity indicates that the file is more in line with the current interests of the target user; The determination submodule is used to determine the candidate file whose similarity meets the set condition as the second target file.
7. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the file access method according to any one of claims 1 to 5 by executing the computer instructions.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the file access method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Massive small file-oriented user hotspot data access prediction method
CN108446340A
Metadata prefetching system and method for distributed file system
CN113688113A