Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
In the method provided by the embodiment of the present application, the execution subject of each step may be a Computer device, which refers to an electronic device with data calculation, processing and storage capabilities, such as a PC (Personal Computer) or a server.
According to the technical scheme, content recommendation is achieved by means of a machine learning technology in the field of AI (Artificial Intelligence), so that time consumption for scoring can be reduced, time consumption for content recommendation is further reduced, and content recommendation efficiency is improved.
The artificial intelligence is a theory, method, technology and application system for simulating, extending and expanding human intelligence by using a digital computer or a machine controlled by the digital computer, sensing the environment, acquiring knowledge and obtaining the best result by using the knowledge. In other words, artificial intelligence is a comprehensive technique of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence is the research of the design principle and the implementation method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making.
The artificial intelligence technology is a comprehensive subject and relates to the field of extensive technology, namely the technology of a hardware level and the technology of a software level. The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The ML (Machine Learning) is a multi-domain cross subject, and relates to multiple subjects such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, and the like. The method specially studies how a computer simulates or realizes the learning behavior of human beings so as to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve the performance of the computer. Machine learning is the core of artificial intelligence, is the fundamental approach for computers to have intelligence, and is applied to all fields of artificial intelligence. Machine learning and deep learning generally include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formal education learning.
With the research and progress of artificial intelligence technology, the artificial intelligence technology is developed and applied in a plurality of fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, unmanned aerial vehicles, robots, smart medical care, smart customer service, and the like.
The scheme provided by the embodiment of the application relates to technologies such as artificial intelligence (ML), and is specifically explained by the following embodiment.
Please refer to fig. 1, which schematically shows a flowchart of a content recommendation method provided by the present application. After the working thread acquires the candidate content corresponding to the recommendation request, the candidate content is subjected to scoring processing in parallel through n (n is an integer larger than 1) scoring threads to obtain a scoring result corresponding to the recommendation request; wherein, the n scoring threads respectively process partial candidate contents in the candidate contents; and then, the working thread can recommend the content to the target user account according to the scoring result corresponding to the recommendation request.
The technical solution of the present application will be described below by means of several embodiments.
Referring to fig. 2, a flowchart of a content recommendation method according to an embodiment of the present application is shown. In the present embodiment, the method is mainly exemplified by being applied to the computer device described above. The method may include the steps of:
step 201, a first recommendation request is obtained.
The computer device may obtain the first recommendation request, where the first recommendation request is used to request to recommend content to the target user account.
The first recommendation request may be generated by a target user trigger. For example, when the computer device is a terminal such as a mobile phone, a tablet computer, a PC, etc., a client of a content recommendation application (e.g., a news recommendation application, a shopping recommendation application, a music recommendation application, etc.) may be installed in the terminal, a target user may log in the target user account at the client, and when the target user opens the client or refreshes a page of the client, the first recommendation request is triggered to be generated; correspondingly, the client may receive the first recommendation request. When the computer device is a server, the first recommendation request can be generated by a target user through a client of a content recommendation application program in the terminal, and is sent to the server by the terminal.
Optionally, the first recommendation request may include identification information of the target user, such as a target user account.
Optionally, the computer device further includes a main thread, where the main thread is configured to receive the first recommendation request, and schedule a work thread and a scoring thread according to the first recommendation request.
Step 202, obtaining candidate content corresponding to the first recommendation request through the first working thread.
After the first recommendation request is acquired, the computer device may acquire the candidate content corresponding to the first recommendation request through a first work thread.
The candidate content corresponding to the first recommendation request refers to content that may be of interest to the target user, and the content may be an image, a text, a video, and the like, which is not limited in this embodiment of the application. Taking the text as an example, the candidate content may further include detail information of the candidate content, such as identification information of the text, title information of the text, time information of the text, subject information of the text, and the like.
Optionally, the first worker thread may further obtain user data corresponding to the first recommendation request, that is, user data of a target user corresponding to the target user account. The user data is used to characterize the basic characteristics of the user. The user data may include user portrait information and user behavior information; the user portrait information is a tagged user model abstracted according to the information such as the social attribute, the living habit, the consumption behavior and the like of the user, namely, the user portrait information can be used for representing the preference of the user; and the user behavior information records the content that the user has viewed or clicked, and can be history browsing records.
In an example, the first recommendation request includes identification information of the target user, such as a target user account, and the computer device may obtain, according to the identification information, user data stored in correspondence with the identification information.
And step 203, performing scoring processing on the candidate contents in parallel through n scoring threads to obtain a scoring result corresponding to the first recommendation request, wherein n is an integer greater than 1.
After the candidate content is obtained, the candidate content can be subjected to scoring processing in parallel through the n scoring threads, and therefore a scoring result corresponding to the first recommendation request is obtained. The scoring result is used for representing the possibility that the candidate content corresponding to the recommendation request is recommended to the target user account, and further, the scoring result can also represent the matching degree of the candidate content corresponding to the recommendation request and the target user account.
The scoring result corresponding to the first recommendation request may include a score of each candidate content corresponding to the first recommendation request, where the score of each candidate content is used to characterize a possibility that the candidate content is recommended to the target user account, and further, the score of each candidate content may also characterize a matching degree between the candidate content and the target user account.
Wherein, the n scoring threads respectively process partial candidate contents in the candidate contents; for example, scoring thread 1 processes a portion of the candidate content, while scoring thread 2 processes the remaining portion of the candidate content.
It should be noted that, among the n scoring threads, the candidate contents processed by different scoring threads are not overlapped, and the total of the candidate contents processed by the n scoring threads is all the candidate contents corresponding to the first recommendation request acquired by the first worker thread.
In addition, the number of candidate contents processed by different scoring threads may be the same or different, and the embodiment of the present application is not limited.
Optionally, the above scoring the candidate content in parallel by the n scoring threads to obtain a scoring result corresponding to the first recommendation request may include: extracting feature information of candidate contents, feature information of user data and cross feature information between the candidate contents and the user data through n scoring threads; then, for each of the n scoring threads, feature information of the candidate content, feature information of the user data, and cross feature information between the candidate content and the user data processed by the scoring thread may be input to a recommendation model, the candidate content is scored according to the feature information by the recommendation model to obtain scores of the candidate content processed by the scoring thread, and scores of the candidate content processed by the n scoring threads are further obtained, so as to obtain a scoring result corresponding to the first recommendation request.
The recommendation model is used for scoring the candidate contents according to the feature information to obtain scores of the candidate contents. The recommendation model may be an LR (Logistic Regression), a CNN (Convolutional Neural Network), a KNN (K-Nearest Neighbor) model, or another model that can realize the function of scoring candidate contents according to the feature information, which is not limited in the embodiment of the present application.
And step 204, recommending content to the target user account through the second working thread according to the scoring result corresponding to the first recommendation request.
Because the scoring result can reflect candidate contents which are interesting to the target user and have high click possibility in the candidate contents, after the scoring result corresponding to the first recommendation request is obtained, the content recommendation can be performed on the target user account through the second working thread according to the scoring result.
In an example, when the computer device is a server, the server may obtain candidate content of the first recommendation request, and after obtaining the candidate content, perform scoring processing on the candidate content in parallel through n scoring threads to obtain a scoring result corresponding to the first recommendation request; then, the server may select at least one candidate content from the candidate contents as a recommended content according to the scoring result, convert the recommended content into a data protocol between network communications, and send the data protocol to the terminal generating the first recommendation request through the network, where the terminal may recommend the recommended content acquired from the data protocol to the target user account. The recommended content may be a candidate content whose scoring result is in a target range, such as at least one candidate content located at the front after being sorted from high to low.
It should be noted that, the above-mentioned obtaining of candidate content and the scoring of the candidate content may be performed on the same server or different servers, which is not limited in this embodiment of the present application.
In summary, according to the technical scheme provided by the embodiment of the application, after the working thread acquires the candidate content corresponding to the recommendation request, the n scoring threads are used for concurrently scoring the candidate content, wherein each scoring thread processes part of the candidate content, so as to obtain a scoring result corresponding to the recommendation request, and then the working thread can recommend the content to the target user account according to the scoring result corresponding to the recommendation request. Compared with the prior art, when the obtained features are more, the calculation of the score by the recommendation model is longer, and the recommendation speed of the recommendation system is slow. According to the technical scheme provided by the embodiment of the application, the candidate contents are subjected to scoring processing in parallel through the plurality of scoring threads, and the task amount of single-thread scoring processing is reduced, so that the time consumed by scoring is reduced, and the content recommendation efficiency is improved.
In an optional embodiment provided based on the embodiment in fig. 2, the first worker thread and the second worker thread are the same worker thread. In this case, after the step 202 acquires the candidate content corresponding to the first recommendation request through the first worker thread, the method may further include the following steps: and in the process that the n scoring threads score the candidate content in parallel, detecting whether the scoring processing of the n scoring threads is finished or not through the working thread, wherein after waiting for the scoring processing of the n scoring threads to be finished, the working thread carries out content recommendation to the target user account according to a scoring result corresponding to the first recommendation request.
That is, in this case, one recommendation request is processed by one worker thread and n scoring threads. After the working thread acquires the candidate content corresponding to the first recommendation request, the subsequent content recommendation step can be executed only after the scoring processing of the n scoring threads is finished. During the waiting process, the worker thread may detect whether the scoring processing of the n scoring threads is completed.
Illustratively, as shown in FIG. 3, a schematic diagram of a worker thread and a scoring thread is illustrated. As can be seen from fig. 3, one worker thread corresponds to n scoring threads for processing one recommendation request. Taking a working thread 1, a scoring thread 1-a, scoring threads 1-b, … … and a scoring thread 1-n as examples, the working thread 1 first obtains candidate content corresponding to a first recommendation request, then the scoring thread 1-a to the scoring thread 1-n perform scoring processing on the candidate content in parallel, in the process of performing scoring processing on the candidate content in parallel by the n scoring threads, the working thread 1 waits for the scoring processing of the n scoring threads, and after the scoring processing of the n scoring threads is detected to be completed, content recommendation is performed on a target user account according to a scoring result corresponding to the first recommendation request.
It should be noted that the n scoring threads corresponding to the worker threads may be fixedly allocated or dynamically allocated, and this embodiment of the present application is not limited thereto.
When the n scoring threads are fixedly allocated, for example, a plurality of thread groups may be set in the computer device in advance, and each thread group may include 1 worker thread and a plurality of scoring threads. In this case, after receiving a recommendation request, the computer device may select a thread group from the thread groups to process the recommendation request.
Optionally, the number of scoring threads included in each thread group may be the same or different, and this is not limited in this embodiment of the present application.
And if the number of the scoring threads in each thread group is the same, responding to the received first recommendation request, and selecting any one thread group from at least one thread group. That is, when the number of scoring threads included in each thread group is the same, for example, each thread group includes 1 worker thread and 10 scoring threads, if a recommendation request is received, the computer device may randomly select one thread group from the thread groups to process the recommendation request.
If the number of the scoring threads in each thread group is different, responding to the received first recommendation request, selecting a first working thread from the working thread pool, and acquiring candidate contents corresponding to the first recommendation request through the first working thread; and selecting a target scoring thread group matched with the number of the candidate contents from a scoring thread pool according to the number of the candidate contents, wherein the scoring thread pool comprises at least one scoring thread group, and the number of the scoring threads in each scoring thread group is different. That is, the computer device includes a work thread pool and a scoring thread pool, a number of fixedly allocated scoring thread groups are preset in the scoring thread pool, and the number of each scoring thread group may be different, for example, 5 scoring threads in the scoring thread group 1, 10 scoring threads in the scoring thread group 2, 20 scoring threads in the scoring thread group 3, and the like. If a recommendation request is received, the computer equipment can randomly select a working thread from the working thread pool to obtain candidate contents corresponding to the recommendation request; then, according to the number of the candidate contents, a scoring thread group matched with the number of the candidate contents can be selected from the scoring thread pool, for example, if the number of the candidate contents corresponding to the recommendation request is larger, a scoring thread group comprising the larger number of scoring threads can be selected, so that the scoring time is saved.
When the n scoring threads are dynamically allocated, in response to acquiring the first recommendation request, determining the number of scoring threads for processing the first recommendation request. That is, the computer device may decide to select some scoring threads for scoring after receiving a recommendation request. For example, the number of scoring threads may be determined according to the number of candidate contents corresponding to the recommendation request, and for example, the greater the number of candidate contents, the greater the number of scoring threads may be allocated. For another example, the number of scoring threads may be determined according to the priority of the recommendation request, and for example, the higher the priority of the recommendation request is, the more number of scoring threads may be allocated; wherein the priority of the recommendation request is used to indicate the urgency of the recommendation request. For example, the number of scoring threads may be determined according to the tolerance duration of the target user account corresponding to the recommendation request, and if the tolerance duration is shorter, a greater number of scoring threads may be allocated. Of course, there may be other ways to allocate the number of scoring threads, which is not limited in the embodiment of the present application.
In this embodiment, one recommendation request is processed by one work thread and n scoring threads, so that the flow is completely isolated, and the requests are not affected by each other, and the overall implementation is relatively simple.
In another optional embodiment provided based on the embodiment of fig. 2, in the step 202, after the candidate content corresponding to the first recommendation request is obtained by the first worker thread, the method may further include the following steps:
(1) and generating n scoring tasks corresponding to the first recommendation request through the first working thread.
After acquiring the candidate content corresponding to the first recommendation request through the first work thread, the computer device may generate n scoring tasks corresponding to the first recommendation request through the first thread. And one scoring task is executed by one scoring thread and is used for scoring partial candidate contents in the candidate contents. That is, one scoring task refers to scoring a portion of the candidate content among the candidate content.
It should be noted that, among the n scoring tasks, the candidate contents included in different scoring tasks are not repeated, and the total sum of the candidate contents in the n scoring tasks is all the candidate contents corresponding to the first recommendation request acquired by the first worker thread.
In addition, the number of candidate contents processed by different scoring threads may be the same or different, and the embodiment of the present application is not limited.
Optionally, the generating, by the first worker thread, n scoring tasks corresponding to the first recommendation request may include the following two types:
the first method comprises the following steps: and averagely dividing the candidate content corresponding to the first recommendation request into n parts through the first working thread to generate n scoring tasks.
In this case, the candidate contents corresponding to the recommendation request are directly and averagely divided, and the number of the candidate contents included in each scoring task is equal. In this case, the number of candidates processed by different scoring threads is the same.
For example, assuming that the candidate content corresponding to the first recommendation request includes 100, the candidate content may be divided into 10 equally, resulting in 10 scoring tasks.
And the second method comprises the following steps: and dividing the candidate content corresponding to the first recommendation request into n parts according to the processing capacity of the n scoring threads through the first working thread to generate n scoring tasks.
Since the processing capabilities of the n scoring threads may be different, for example, the n scoring threads may run on different computer devices, which results in different processing capabilities of the different scoring threads, and thus the candidate content may be divided according to the processing capabilities of the n scoring threads. In this case, the number of candidates processed by different scoring threads is not the same.
Exemplarily, it is assumed that the candidate content corresponding to the first recommendation request includes 100, and there are scoring thread 1, scoring thread 2 and scoring thread 3, where the processing capability of scoring thread 1 is strong, the processing capability of scoring thread 2 is medium, and the processing capability of scoring thread 3 is poor. The first working thread can divide 100 candidate contents into 3 parts according to the processing capacity of the 3 scoring threads to generate 3 scoring tasks; the scoring task corresponding to the scoring thread 1 comprises 55 candidate contents, the scoring task corresponding to the scoring thread 2 comprises 28 candidate contents, and the scoring task corresponding to the scoring thread 3 comprises 17 candidate contents.
(2) Adding n scoring tasks to the scoring task queue through the first worker thread.
After generating the n scored tasks, the n scored tasks may be added to the scored task queue by the first worker thread. The scoring task queue is used for recording scoring tasks of recommendation requests.
Optionally, in the scoring task queue, each scoring task is stored in correspondence with a recommendation request corresponding to the scoring task. For example, a recommendation request 1 and a recommendation request 2 are provided, scoring tasks corresponding to the recommendation request 1 include scoring tasks 1-1, scoring tasks 1-2 and scoring tasks 1-3, and scoring tasks corresponding to the recommendation request 2 include scoring tasks 2-1, scoring tasks 2-2 and scoring tasks 2-3. Then in the scoring task queue, the following method can be adopted for recording: scoring task 1-recommendation request 1, scoring task 1-2-recommendation request 1, scoring task 1-3-recommendation request 1, scoring task 2-1-recommendation request 2, scoring task 2-recommendation request 2, scoring task 2-3-recommendation request 2.
And the scoring thread is used for acquiring the scoring tasks from the scoring task queue to execute, and adding the scoring results of the scoring tasks to the scoring result queue. The scoring result queue is used for recording scoring results of all scoring tasks.
And the second working thread is used for recommending content to the target user account according to the scoring result corresponding to the first recommendation request after the scoring results of the n scoring tasks are obtained from the scoring result queue, wherein the scoring result corresponding to the first recommendation request comprises the scoring results of the n scoring tasks.
It should be noted that the scoring task queue and the scoring result queue may be the same queue or different queues, which is not limited in this embodiment of the present application.
Illustratively, as shown in FIG. 4, a schematic diagram of another worker thread and scoring thread is illustrated. As can be seen from fig. 4, two types of thread pools are included in the computer device, namely a work thread pool and a scoring thread pool, where the work thread pool includes m work threads (m is an integer greater than 1), and the scoring thread pool includes p scoring threads (p is an integer greater than n). And the working threads in the working thread pool and the scoring threads in the scoring thread pool are communicated through the scoring task queue and the scoring result queue. When a recommendation request is received, such as the first recommendation request described above, a working thread in an idle state (denoted as working thread 1) may be selected from m working threads in a working thread pool, candidate content corresponding to the first recommendation request is obtained, and after the candidate content is obtained, the candidate content is released back to the working thread pool and returns to the idle state; then, the candidate content may be scored in parallel by n scoring threads in the scoring thread pool, and in this process, the worker thread (i.e. worker thread 1) for obtaining the candidate content may also be used to execute other tasks, such as processing a new recommendation request when there is the new recommendation request; after the n scoring threads score the candidate content in parallel and complete the scoring process, one idle working thread (marked as working thread 2) can be selected from the working thread pool again, and content recommendation is performed on the target user account according to the scoring result corresponding to the first recommendation request. The worker thread 1 and the worker thread 2 may be the same worker thread or 2 different worker threads.
Optionally, after the n scoring tasks are added to the scoring task queue by the first worker thread, the method may further include: and releasing the first working thread, and entering an idle state after the first working thread is released.
That is to say, after the first worker thread is used up, the first worker thread may be released to enter an idle state, that is, an idle state, so that the first worker thread may be used to execute other tasks, for example, to process a new recommendation request, and the first worker thread does not need to waste time to wait for all the n scoring tasks to be completed, thereby avoiding waste of worker thread resources due to blind waiting and improving the utilization rate of the worker thread.
Optionally, after the n scoring tasks are added to the scoring task queue by the first worker thread, the method may further include:
1) under the condition that the scoring result queue comprises the scoring result of the scoring task, selecting a second working thread in an idle state from the working thread pool;
2) after the scoring result of the scoring task corresponding to the first recommendation request is obtained from the scoring result queue through the second working thread, whether all the n scoring tasks corresponding to the first recommendation request are completed is detected;
3) and responding to the completion of all the n scoring tasks corresponding to the first recommendation request, and executing a step of recommending the content to the target user account through a second working thread according to the scoring result corresponding to the first recommendation request.
When the computer device detects that the scoring result queue comprises the scoring result of the scoring task through the main thread, a second working thread which is in an idle state can be selected from the working thread pool, wherein the second working thread and the first working thread can be different working threads or the same working thread. If the second working thread obtains the scoring result of the scoring task corresponding to the first recommendation request from the scoring result queue, whether all the n scoring tasks corresponding to the first recommendation request are completed can be detected.
Optionally, the detecting whether all the n scoring tasks corresponding to the first recommendation request are completed may include: detecting whether the number of the scoring results of the scoring tasks corresponding to the first recommendation request is equal to n or not, and if the number of the scoring results is equal to n, indicating that all the n scoring tasks corresponding to the first recommendation request are completed; and if the number of the scoring results is less than n, the result indicates that the n scoring tasks corresponding to the first recommendation request are not completely finished.
Exemplarily, assuming that the first recommendation request corresponds to 10 scoring tasks, that is, the first recommendation request corresponds to 10 scoring results, when the number of the scoring results is less than 10, it indicates that the 10 scoring tasks are not completely completed; when the number of scoring results is equal to 10, it indicates that the 10 scoring tasks have been completed completely.
And when it is detected that all the n scoring tasks corresponding to the first recommendation request are completed, performing content recommendation to the target user account through the second working thread according to the scoring result corresponding to the first recommendation request.
On the contrary, when detecting that the n scoring tasks corresponding to the first recommendation request are not completely completed, the scoring thread continues to process the tasks which are not completed in the n scoring tasks.
In addition, after the fact that all the n scoring tasks corresponding to the first recommendation request are completed is detected, whether the scoring time consumption of the n scoring tasks exceeds a time threshold (timeout check) or not can be detected, and if the time consumption exceeds the time threshold, no response is made; and if the time threshold is not exceeded, executing the subsequent content recommendation step.
In one example, when a first recommendation request is acquired by a main thread, the first recommendation request is in an initial state (run), and the main thread can add the first recommendation request to a scoring task queue; then, the computer device main thread selects a first working thread in an idle (wait _ task) state from the working thread pool, candidate contents corresponding to the first recommendation request are obtained through the first working thread, then n scoring tasks corresponding to the first recommendation request are generated, and the n scoring tasks are added into a scoring task queue; meanwhile, setting the first recommendation request to be in a detection (task _ check) state, releasing the first working thread, and re-entering the released first working thread to be in an idle (wait _ task) state; then, the computer equipment performs scoring processing on the n scoring tasks in parallel through the n scoring threads to obtain a scoring result, and the scoring result is added into a scoring result queue; the computer equipment can select a second working thread in an idle (wait _ task) state from the working thread pool under the condition that the scoring result queue comprises the scoring results of the scoring tasks through the main thread, and detects whether all n scoring tasks corresponding to the first recommendation request are finished after the scoring results of the scoring tasks corresponding to the first recommendation request are obtained from the scoring result queue through the second working thread; and if the n scoring tasks corresponding to the first recommendation request are all completed, performing content recommendation (run finish) to the target user account through the second working thread according to the scoring result corresponding to the first recommendation request.
In this embodiment, after the first worker thread is used, the first worker thread may be released to enter an idle state, that is, an idle state, so that the first worker thread may be used to execute other tasks, for example, to process a new recommendation request, and the first worker thread does not need to waste time to wait for all the n scoring tasks to be completed, thereby avoiding waste of worker thread resources due to blind waiting and improving the utilization rate of the worker thread.
In another optional embodiment provided based on the embodiment of fig. 2, after obtaining, in step 202, candidate content corresponding to the first recommendation request through the first worker thread, the following steps may be further included:
(1) acquiring the tolerance time length of a target user account;
(2) and determining the number n of the scoring threads according to the tolerance time length.
After the candidate content corresponding to the first recommendation request is obtained, the tolerance duration of the target user account can be obtained, wherein the tolerance duration refers to the duration of content recommendation which can be waited by the target user corresponding to the target user account; the number of scored threads, n, may then be determined based on the tolerated duration.
The number n of the scoring threads is the minimum number of the scoring threads under the condition that the time consumed for scoring processing of the scoring threads is less than or equal to the tolerance time length. That is to say, when the time spent on scoring the scoring threads is within the tolerable waiting time of the target user, the scoring threads can be started as little as possible, so that the user requirements are met, and meanwhile, the waste of resources can be avoided.
In another optional embodiment provided based on the embodiment of fig. 2, after obtaining, in step 202, candidate content corresponding to the first recommendation request through the first worker thread, the following steps may be further included:
(1) determining a target time period to which the first recommendation request belongs;
(2) determining the maximum processable number of recommendation requests required to be supported in a target time period;
(3) the number of scored threads, n, is determined from the maximum processable number.
The number of recommendation requests may vary from time period to time period. After the candidate content corresponding to the first recommendation request is obtained, a target time period to which the first recommendation request belongs can be further determined; further, the maximum processable number of recommendation requests that need to be supported in the target time period, that is, the maximum number of recommendation requests that can be processed by the computer device in the target time period, may be determined; the number of scored threads, n, may then be determined from the maximum number.
The number n of the scoring threads is the maximum number of the scoring threads under the condition that the recommended requests required to be supported are the maximum processable number. Therefore, the time consumption of the scoring thread can be reduced as much as possible under the condition of ensuring the maximum processable quantity.
Illustratively, as shown in the following table-1, it can be seen from this table-1 that the scoring time-consuming optimization rate is higher as the number of scoring threads is larger. But when the number of scoring threads is 60, this results in a decrease in the maximum processable number supported by the computer device; when the number of the scoring threads is 40, a better optimization efficiency of 95.6% can be obtained, and the condition that the recommended requests needing to be supported are the maximum processable number can be ensured.
Number of scoring threads
|
60
|
40
|
20
|
10
|
Time spent in scoring
|
10
|
14
|
26
|
46
|
Maximum processable quantity
|
3500
|
4000
|
3500
|
3000
|
Scoring time-consuming optimization ratio
|
96.8%
|
85.6%
|
91.9%
|
85.7% |
TABLE-1
The embodiment provides a method for determining the number of scoring threads, so that time consumption of scoring is reduced, and resources are saved.
The following describes the beneficial effects of the technical solutions provided in the embodiments of the present application by counting the time consumption of the whole content recommendation process.
As shown in table-2 below, the time consumption of each step in the content recommendation flow is shown, as well as the total time consumption.
|
Obtaining candidate content
|
Rating process
|
Content recommendation
|
Total time consumption
|
The prior art solution is time consuming
|
24ms
|
321ms
|
22ms
|
367ms
|
The technical scheme of the application is time-consuming
|
18ms
|
12ms
|
12ms
|
42ms
|
Chemical ratio
|
25%
|
96.2%
|
45.4%
|
88.5% |
TABLE-2
As can be seen from table-2, the time consumption for the final overall content recommendation is reduced by 88.5%, the content recommendation efficiency is improved, the amount of supported data is increased, and a space is provided for the subsequent feature increase.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 5, a block diagram of a content recommendation device according to an embodiment of the present application is shown. The device has the function of implementing the content recommendation method example, and the function can be implemented by hardware or by hardware executing corresponding software. The device may be the computer device described above, or may be provided on a computer device. The apparatus 500 may comprise: a request acquisition module 501, a content acquisition module 502, a scoring processing module 503, and a content recommendation module 504.
The request obtaining module 501 is configured to obtain a first recommendation request, where the first recommendation request is used to request to recommend content to a target user account.
A content obtaining module 502, configured to obtain, through a first worker thread, candidate content corresponding to the first recommendation request.
A scoring processing module 503, configured to perform scoring processing on the candidate content in parallel through n scoring threads, so as to obtain a scoring result corresponding to the first recommendation request; and the n scoring threads respectively process partial candidate contents in the candidate contents, wherein n is an integer greater than 1.
And the content recommendation module 504 is configured to recommend content to the target user account through a second working thread according to the scoring result corresponding to the first recommendation request.
In summary, according to the technical scheme provided by the embodiment of the application, after the working thread acquires the candidate content corresponding to the recommendation request, the n scoring threads are used for concurrently scoring the candidate content, wherein each scoring thread processes part of the candidate content, so as to obtain a scoring result corresponding to the recommendation request, and then the working thread can recommend the content to the target user account according to the scoring result corresponding to the recommendation request. Compared with the prior art, when the obtained features are more, the calculation of the score by the recommendation model takes longer time, and the recommendation speed of the recommendation system is slow. According to the technical scheme provided by the embodiment of the application, the candidate contents are subjected to scoring processing in parallel through the plurality of scoring threads, so that the task amount of single thread for performing scoring processing is reduced, the scoring time is reduced, and the content recommendation efficiency is improved.
In some possible designs, the first worker thread and the second worker thread are the same worker thread; as shown in fig. 6, the apparatus 500 further includes: a score detection module 505.
A scoring detection module 505, configured to detect, by the working thread, whether scoring processing of the n scoring threads is completed in a process in which the n scoring threads concurrently score the candidate content; after waiting for the scoring processing of the n scoring threads to be completed, the working thread recommends content to the target user account according to the scoring result corresponding to the first recommendation request.
In some possible designs, as shown in fig. 6, the apparatus 500 further comprises: a task generating module 506 and a task adding module 507.
A task generating module 506, configured to generate n scoring tasks corresponding to the first recommendation request through the first work thread, where one scoring task is executed by one scoring thread and is used to score part of the candidate contents.
A task adding module 507, configured to add the n scoring tasks to a scoring task queue through the first work thread, where the scoring thread is configured to obtain the scoring tasks from the scoring task queue for execution, and add scoring results of the scoring tasks to a scoring result queue; and after the scoring results of the n scoring tasks are obtained from the scoring result queue, the second worker thread is used for recommending content to the target user account according to the scoring results corresponding to the first recommendation request, and the scoring results corresponding to the first recommendation request comprise the scoring results of the n scoring tasks.
In some possible designs, as shown in fig. 6, the apparatus 500 further comprises: a thread release module 508.
A thread releasing module 508, configured to release the first worker thread, where the first worker thread enters an idle state after being released.
In some possible designs, as shown in fig. 6, the apparatus 500 further comprises: a thread selection module 509 and a task detection module 510.
A thread selecting module 509, configured to select the second work thread in an idle state from a work thread pool when it is detected that the scoring result queue includes the scoring result of the scoring task.
The task detection module 510 is configured to detect, by the second work thread, whether all the n scoring tasks corresponding to the first recommendation request are completed after the scoring result of the scoring task corresponding to the first recommendation request is obtained from the scoring result queue.
The content recommendation module 504 is configured to, in response to that all of the n scoring tasks corresponding to the first recommendation request are completed, execute the step of recommending content to the target user account through the second working thread according to the scoring result corresponding to the first recommendation request.
In some possible designs, the task generating module 506 is configured to averagely divide the candidate content corresponding to the first recommendation request into n parts by the first worker thread, and generate the n scoring tasks; or dividing the candidate content corresponding to the first recommendation request into n parts according to the processing capacity of the n scoring threads through the first working thread, and generating the n scoring tasks.
In some possible designs, as shown in fig. 6, the apparatus 500 further comprises: a duration obtaining module 511 and a number determining module 512.
And a duration obtaining module 511, configured to obtain the tolerance duration of the target user account.
A number determining module 512, configured to determine the number n of the scoring threads according to the tolerance duration, where the number n of the scoring threads is the minimum number of the scoring threads under the condition that the time consumed for scoring the scoring threads is less than or equal to the tolerance duration.
In some possible designs, as shown in fig. 6, the apparatus 500 further comprises: a period determination module 513 and a maximum determination module 514.
A time period determining module 513, configured to determine a target time period to which the first recommendation request belongs;
a maximum determination module 514, configured to determine a maximum processable number of recommendation requests that need to be supported in the target time period;
the number determining module 512 is further configured to determine the number n of the scoring threads according to the maximum processable number, where the number n of the scoring threads is the maximum number of the scoring threads when the recommended request required to be supported is the maximum processable number.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, the division of each functional module is merely used as an example, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 7, a block diagram of a terminal according to an embodiment of the present application is shown. In general, terminal 700 includes: a processor 701 and a memory 702.
Processor 701 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on. The processor 701 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 701 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 701 may be integrated with a GPU (Graphics Processing Unit) that is responsible for rendering and drawing content that needs to be displayed on the display screen. In some embodiments, the processor 701 may further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.
Memory 702 may include one or more computer-readable storage media, which may be non-transitory. Memory 702 may also include high-speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In some embodiments, a non-transitory computer readable storage medium in the memory 702 is used to store at least one instruction, at least one program, set of codes, or set of instructions for execution by the processor 701 to implement the content recommendation method provided by the method embodiments herein.
In some embodiments, the terminal 700 may further optionally include: a peripheral interface 703 and at least one peripheral. The processor 701, the memory 702, and the peripheral interface 703 may be connected by buses or signal lines. Various peripheral devices may be connected to peripheral interface 703 via a bus, signal line, or circuit board. Specifically, the peripheral device may include: at least one of a communication interface 704, a display screen 705, audio circuitry 706, a camera assembly 707, a positioning assembly 708, and a power source 709.
Those skilled in the art will appreciate that the configuration shown in fig. 7 is not intended to be limiting of terminal 700 and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components may be used.
Referring to fig. 8, a schematic structural diagram of a server according to an embodiment of the present application is shown. Specifically, the method comprises the following steps:
the server 800 includes a CPU (Central Processing Unit) 801, a system Memory 804 including a RAM (Random Access Memory) 802 and a ROM (Read Only Memory) 803, and a system bus 805 connecting the system Memory 804 and the Central Processing Unit 801. The server 800 also includes a basic I/O (Input/Output) system 806 that facilitates transfer of information between devices within the computer, and a mass storage device 807 for storing an operating system 813, application programs 814, and other program modules 812.
The basic input/output system 806 includes a display 808 for displaying information and an input device 809 such as a mouse, keyboard, etc. for user input of information. Wherein the display 808 and the input device 809 are connected to the central processing unit 801 through an input output controller 810 connected to the system bus 805. The basic input/output system 806 may also include an input/output controller 810 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input-output controller 810 also provides output to a display screen, a printer, or other type of output device.
The mass storage device 807 is connected to the central processing unit 801 through a mass storage controller (not shown) connected to the system bus 805. The mass storage device 807 and its associated computer-readable media provide non-volatile storage for the server 800. That is, the mass storage device 807 may include a computer-readable medium (not shown) such as a hard disk or CD-ROM (Compact disk Read-Only Memory) drive.
Without loss of generality, the computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM (Erasable Programmable Read Only Memory), flash Memory or other solid state Memory technology, CD-ROM, DVD or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the foregoing. The system memory 804 and mass storage 807 described above may be collectively referred to as memory.
The server 800 may also operate as a remote computer connected to a network through a network, such as the internet, according to various embodiments of the present application. That is, the server 800 may be connected to the network 812 through the network interface unit 811 coupled to the system bus 805, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 811.
The memory also includes at least one instruction, at least one program, set of codes, or set of instructions stored in the memory and configured to be executed by the one or more processors to implement the above-described content recommendation method.
In an exemplary embodiment, a computer device is also provided. The computer device may be a terminal or a server. The computer device comprises a processor and a memory, wherein at least one instruction, at least one program, a set of codes, or a set of instructions is stored in the memory, and the at least one instruction, the at least one program, the set of codes, or the set of instructions is loaded and executed by the processor to implement the content recommendation method.
In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one instruction, at least one program, a set of codes, or a set of instructions is stored, which when executed by a processor, implements the above-mentioned content recommendation method.
In an exemplary embodiment, a computer program product is also provided for implementing the above-mentioned content recommendation method when the computer program product is executed by a processor.
It should be understood that reference herein to "a plurality" means two or more. "and/or" describes the association relationship of the associated object, indicating that there may be three relationships, for example, a and/or B, which may indicate: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The above description is only exemplary of the present application and should not be taken as limiting the present application, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the present application should be included in the protection scope of the present application.