Text annotation method and device, electronic device, storage medium
Semantic spatial transformation, clustering and classification through cross-language text annotation model, the problem of cross-language text annotation is solved, and automatic labeling and rapid iteration are realized.
Patent Information
- Application Number
- CN202011518702.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2040-12-21
AI Technical Summary
The existing technology cannot effectively solve the problem of cross-language text annotation, which leads to the need for a large amount of manual annotation in the early stage of the product, which consumes time and wastes manpower, affecting the speed of product iteration.
By obtaining the trained text labeling model of the actual language and target language of the text to be marked, semantic spatial transformation, clustering and classification processing are performed to automatically label the text type.
Cross-language text annotation is realized, saving time and human resources, and supporting rapid product iteration.
Smart Images

Figure CN113392179B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence, and particularly to a text annotation method, apparatus, electronic device, and storage medium. Background Art
[0002] Text classification is widely used in content-related products, such as news classification, article classification, intent classification, etc. Generally, text classification is for texts in a certain language, such as Chinese, English, etc. However, when a product needs to expand its business in other languages, there will be a problem of insufficient labeled texts at the initial stage of the product.
[0003] Although in the long run, these texts in other languages can gradually accumulate a certain amount of labeled data through manual operation and other means, and then model training can be carried out. But in the early stage, only relying on manual labor to label these texts in other languages is very time-consuming and wasteful of manpower, which is not conducive to the rapid iteration of the product. Therefore, at the initial stage of the product, it is necessary to rely on the labeled texts in the existing language to achieve automatic annotation of a large number of texts in other languages.
[0004] However, the existing technical solutions are all for text classification in the same language, solving the problem of text annotation in the same language, and still cannot solve the technical problem of cross-language text annotation. Summary of the Invention
[0005] Embodiments of this application provide a text annotation method, apparatus, electronic device, and storage medium to solve the current technical problem of inability to perform cross-language text annotation.
[0006] To solve the above technical problem, the embodiments of this application provide the following technical solutions:
[0007] A text annotation method includes:
[0008] Obtain the text to be annotated and the actual language of the text to be annotated;
[0009] Obtain the trained text annotation model corresponding to the actual language and the target language;
[0010] Perform semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language;
[0011] Perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the text to be annotated;
[0012] Perform classification processing on the clustering result through the trained text annotation model to obtain the text type information of the text to be annotated;
[0013] Perform text type annotation on the to-be-annotated text according to the text type information.
[0014] A recommendation method, comprising:
[0015] Obtain historical text data of the to-be-recommended user;
[0016] Process the historical text data by using the text annotation method provided in this application to obtain the text type of the historical text data;
[0017] Based on the trained recommendation model, determine the predicted search data of the to-be-recommended user according to the text type of the historical text data;
[0018] Perform data recommendation for the to-be-recommended user according to the predicted search data of the to-be-recommended user.
[0019] A text annotation device, comprising:
[0020] A first acquisition unit, configured to acquire the to-be-annotated text and the actual language of the to-be-annotated text;
[0021] A second acquisition unit, configured to acquire the trained text annotation model corresponding to the actual language and the target language;
[0022] A semantic conversion unit, configured to perform semantic space conversion processing on the actual semantic features of the to-be-annotated text through the trained text annotation model to obtain the target semantic features of the to-be-annotated text in the target language;
[0023] A clustering unit, configured to perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the to-be-annotated text;
[0024] A classification unit, configured to perform classification processing on the clustering result through the trained text annotation model to obtain the text type information of the to-be-annotated text;
[0025] An annotation unit, configured to perform text type annotation on the to-be-annotated text according to the text type information.
[0026] A recommendation device, comprising:
[0027] An acquisition unit, configured to acquire historical behavior data of a sample user, where the historical behavior data includes text data and search data;
[0028] A processing unit, configured to process the text data by using the text annotation method provided in this application to obtain the text type of the text data;
[0029] A training unit for training a recommendation model using the text type of the text data and the search data to obtain a trained recommendation model;
[0030] A recommendation unit for making data recommendations for a user to be recommended based on the trained recommendation model.
[0031] An electronic device, the device comprising:
[0032] A processor and a memory;
[0033] The memory is used for storing program code and transmitting the program code to the processor;
[0034] The processor is used for executing the text annotation method or the recommendation method provided by the embodiments of the present application according to the instructions in the program code.
[0035] A computer-readable storage medium storing multiple instructions, the instructions being suitable for being loaded by a processor to execute the steps in the text annotation method or the recommendation method provided by the embodiments of the present application.
[0036] Advantageous effects: In the embodiments of the present application, a text annotation method is provided. First, the text to be annotated and the actual language of the text to be annotated are obtained. Then, the trained text annotation model corresponding to the actual language and the target language is obtained. Then, the actual semantic features of the text to be annotated are subjected to semantic space conversion processing through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language. The target semantic features are subjected to clustering processing through the trained text annotation model to obtain the clustering result of the text to be annotated. The clustering result of the text to be annotated is subjected to classification processing through the trained text annotation model to obtain the text type information of the text to be annotated. Finally, the text to be annotated is annotated according to this text type information. Through the above method, the text type of the text to be annotated in any language can be automatically annotated based on the text in the target language with a large number of existing annotation samples, and then the training of the recommendation model in other languages can be realized, solving the problem of cross-language text annotation, saving time and human resources, and being beneficial to the rapid iteration of products. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The technical solutions and other advantageous effects of the present application will become obvious by describing the specific embodiments of the present application in detail with reference to the accompanying drawings.
[0038] Figure 1 It is a schematic diagram of the environment of the text annotation system provided in the embodiments of the present application;
[0039] Figure 2Schematic diagram of the interface applied to the scenario of automatic annotation of Chinese news in the embodiments of this application;
[0040] Figure 3 Schematic diagram of the interface applied to the scenario of sentiment analysis of English comments in the embodiments of this application;
[0041] Figure 4 Schematic diagram of the interface applied to the scenario of automatic filtering of Japanese spam in the embodiments of this application;
[0042] Figure 5 Flowchart of the text annotation method provided in the embodiments of this application;
[0043] Figure 6 Schematic diagram of the training process of the text annotation model provided in the embodiments of this application;
[0044] Figure 7 Schematic diagram of the structure of the text annotation model provided in the embodiments of this application;
[0045] Figure 8 Schematic diagram of the training process of the classification model provided in the embodiments of this application;
[0046] Figure 9 Schematic diagram of the structure of the classification model provided in the embodiments of this application;
[0047] Figure 10 Schematic diagram of the training process of the semantic space conversion model provided in the embodiments of this application;
[0048] Figure 11 Flowchart of the recommendation method provided in the embodiments of this application;
[0049] Figure 12 Schematic diagram of the training process of the recommendation model provided in the embodiments of this application;
[0050] Figure 13 Schematic diagram of the scenario of the recommendation method provided in the embodiments of this application;
[0051] Figure 14 Schematic diagram of the interface of the client provided in the embodiments of this application;
[0052] Figure 15 Schematic diagram of the structure of the text annotation device provided in the embodiments of this application;
[0053] Figure 16 Schematic diagram of the structure of the recommendation device provided in the embodiments of this application;
[0054] Figure 17 Schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed implementation manners
[0055] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0056] The terms "first", "second", "third", etc. (if any) in the specification and claims of the present application and the above-mentioned accompanying drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such used data may be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "corresponding to" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily need to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0057] Flowcharts are used in the present application to illustrate the operations performed according to the embodiments of the present application. It should be understood that the operations before or below do not necessarily need to be executed precisely in order. On the contrary, various steps can be processed in reverse order or simultaneously as needed. At the same time, other operations can also be added to these processes, or one or more steps can be removed from these processes.
[0058] In the technical solutions provided by the present application, natural language processing (NLP) technology in the field of artificial intelligence (AI) can be used to implement text annotation methods and recommendation methods.
[0059] Artificial intelligence is to use a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, a theory, method, technology and application system that perceives the environment, acquires knowledge and uses knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
[0060] Artificial intelligence is an interdisciplinary subject with a wide range of fields, involving both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation / interaction systems, and mechatronics. The software technologies of artificial intelligence mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0061] Natural language processing is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can enable effective communication between humans and computers in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, that is, the language people use daily, so it has a close connection with the research of linguistics. Natural language processing technologies usually include technologies such as text processing, semantic understanding, machine translation, robot question answering, and knowledge graphs.
[0062] Machine learning (ML) is an interdisciplinary subject that involves multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize the existing knowledge structure to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent, and its applications cover all fields of artificial intelligence. Machine learning and deep learning usually include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formal learning.
[0063] With the research and progress of artificial intelligence technologies, artificial intelligence technologies are being studied and applied in multiple fields. For example, common ones include smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, driverless, autonomous driving, drones, robots, smart healthcare, smart customer service, etc. It is believed that with the development of technology, artificial intelligence technologies will be applied in more fields and play an increasingly important role.
[0064] Please refer to Figure 1 , Figure 1 which shows an environmental schematic diagram of an exemplary text annotation system to which the text annotation method and device provided in the embodiments of the present application can be applied. As Figure 1 shown, the text annotation system may include a user terminal 101, a network 102, and a server 103. The network 102 is used to provide a medium for the communication link between the user terminal 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0065] The user terminal 101 can be any other type of electronic device capable of performing data processing, which may include, but is not limited to, desktop computers, laptop computers, tablet computers, smart phones, smart home devices, wearable devices, etc.
[0066] The network 102 can be a single network or a combination of at least two different networks. For example, the network 102 can include, but is not limited to, a combination of one or more of a local area network, a wide area network, a public network, a private network, etc.
[0067] The server 103 can be a single server or a server group, and each server in the group is connected through a wired or wireless network. A server group can be centralized, such as a data center, or distributed. The server 103 can be local or remote.
[0068] In one embodiment, a text annotation device is integrated in the server 103. The server 103 performs annotation processing on the text to be annotated and feeds back the processing result to the client, where the client can be deployed on the user terminal 101. For example, there are one hundred thousand texts to be classified (including contents such as sentences and articles). The server 103 performs annotation processing on each of these one hundred thousand texts to obtain the annotation result of each text, and then feeds back the annotation result of each text to the client. Optionally, the text annotation device can also be integrated in the user terminal 101, and then the user terminal 101 performs annotation processing on the text to be annotated, obtains the annotation result, and feeds back the annotation result to the client.
[0069] In one embodiment, the user terminal 101 can be used to receive the text to be processed and implement text processing by using the text annotation method provided in this application. For example, the user terminal 101 can receive the text to be processed through its connected input device (such as a keyboard, a mouse, a graphics tablet, a touch screen, etc.). For another example, the user terminal 101 can also receive the text to be processed from the server 103 via the network 102. For still another example, the user terminal 101 can also receive the audio data corresponding to the text to be processed and perform speech recognition on the audio data to obtain the text to be processed. The user terminal 101 can receive the corresponding audio data by using an input device such as a microphone or receive the corresponding audio data from the server 103 via the network 102.
[0070] In one embodiment, the user terminal 101 can execute the text annotation method by using a built-in application program, or the user terminal 101 can execute the text annotation method by calling an externally stored application program.
[0071] In one embodiment, the user terminal 101 may send the received text to be processed to the server 103 via the network 102, and the server 103 executes the text annotation method.
[0072] It should be understood that the text annotation method provided in this application can infer the label or set of labels of a given text (such as words, sentences, or documents, etc.), and can be widely applied to various products involving text content in various languages, such as news, e-commerce, community forums, and user comment analysis and other products. The following will be introduced with three specific scenarios as examples:
[0073] Scenario 1: Automatic annotation of news texts:
[0074] For a large number of news, a text annotation system can be used to automatically annotate these news. The bases for annotation include but are not limited to news titles, news content, and author information, etc. After the annotation is completed, the news content under relevant categories can be displayed through the client or the web page. Please refer to Figure 2 , Figure 2 which is a schematic diagram of an interface applied to the scenario of automatic annotation of Chinese news in an embodiment of this application. As Figure 2 [ shown, the text annotation system adopts the text annotation method provided in this application and can annotate News 1 as "Sports". Similarly, based on the title "The Great Revolution of Artificial Intelligence", News 2 can be annotated as "Technology", based on the title "Start Learning Finance from Now On", News 3 can be annotated as "Finance", and based on the title "The Top Ten Brain-Burning TV Dramas of the Year", News 4 can be annotated as "Film and Television".
[0075] Scenario 2: Sentiment analysis of user comments:
[0076] For user comments, the text annotation method provided in this application can be used to perform sentiment analysis on the comment content, and then statistical processing can be performed based on the analysis results. Please refer to Figure 3 , Figure 3 which is a schematic diagram of an interface applied to the scenario of sentiment analysis of English comments in an embodiment of this application. As Figure 3As shown, specifically, the comment posted by netizen A is "amazing, hope to see it!", and the text annotation method provided by this application is used to obtain the text type of this comment as "very positive"; the comment posted by netizen B is "It's ok, I just watch it to kill the time", and it can be obtained that the text type of this comment belongs to "positive", the comment posted by netizen C is "Alittle boring, nothing attractive", and it can be obtained that the text type of this comment belongs to "very negative", and the comment posted by netizen D is "awful, It's awaste of time", and it can be obtained that the text type of this comment belongs to "negative".
[0077] Scenario 3: Automatic spam filtering:
[0078] For email systems, they usually identify some text in emails to determine whether the email is spam. The identification basis includes but is not limited to the email title, email body and sender information. Figure 4 , Figure 4 This is a schematic diagram of an interface used in the Japanese spam automatic filtering scenario in an embodiment of the present application. Figure 4 As shown, taking the identification of email titles as an example, the text annotation method provided by this application is used to annotate "New Year's Great Benefit, Limited Quantity Celebration", and the email corresponding to the title is found to be of the "spam" type, so the email can be annotated with the text type.
[0079] The method provided in this application involves technologies such as natural language processing of artificial intelligence. In combination with the above introduction, the method provided in this application will be specifically introduced in combination with the embodiments of this application.
[0080] See also Figure 5 , Figure 5 A flow chart of the text annotation method provided in the embodiment of the present application is shown as follows: Figure 2 As shown, the text annotation method provided by this application includes:
[0081] 501: Obtain the text to be annotated and the actual language of the text to be annotated.
[0082] In one embodiment, the text to be annotated may include but is not limited to words, sentences, paragraphs, and articles, and the actual language of the text to be annotated includes but is not limited to English, Japanese, Korean, and Chinese.
[0083] In one embodiment, the method for obtaining the text to be annotated can be through a terminal device or crawled from a network. The method for obtaining the text to be annotated is not limited herein. For example, the terminal device can obtain the text to be annotated through its connected input devices (such as keyboards, mice, digitizing tablets, touchscreens, etc.). Also for example, the terminal device can receive audio data corresponding to the text to be annotated and perform speech recognition on the audio data to obtain the text to be annotated.
[0084] 502: Obtain the trained text annotation model corresponding to the actual language and the target language.
[0085] In one embodiment, the trained text annotation model can include a trained semantic space conversion model, a clustering model, and a trained classification model. Among them, the trained semantic space conversion model and the trained classification model can be trained by collecting corresponding training samples, and the clustering model can be optimized by using a clustering model such as Gaussian Mixed Model (GMM).
[0086] 503: Perform semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language.
[0087] In one embodiment, the actual semantic features of the text to be annotated can be the actual semantics of the text to be annotated in its actual language. For example, for a text “wave a red flag”, obviously, the actual language of this text is English, then the actual semantics corresponding to this text in the English language is “do something that makes people angry”.
[0088] It should be noted that a text refers to the manifestation form of written language. From a literary perspective, it is usually a combination of a complete and systematic sentence or multiple sentences. A text can be a sentence, a paragraph, or a passage. The written language adopted by the text manifestation can be understood as the actual language of the text, and the actual semantics of the text can be understood as the semantics of the text in its corresponding actual language.
[0089] In one embodiment, the trained semantic space conversion model can be used to perform semantic space conversion processing on the actual semantic features of the text to be annotated, so as to obtain the target semantic features of the text to be annotated. The target semantic features can be the target semantics of the text to be annotated in the target language. The trained semantic space conversion model can be a neural network model that takes the actual semantic features of the text to be annotated as input and the target semantic features of the text to be annotated in the target language as output. For example, the actual semantic features of the text to be annotated can be English semantic features, and the target language is Chinese. Then, through the semantic space conversion model, the English text to be annotated can be converted into the Chinese semantic space, that is, the corresponding semantic features of the English text to be annotated in Chinese are obtained. Through the semantic space conversion model, two different language texts can be standardized into the same semantic space, enabling the dissemination and integration of information between two different language texts in the same semantic space.
[0090] It should be noted that the semantic space, that is, the world of language meaning. Generally speaking, information is the unity of meaning and symbol, and the inherent meaning can only be expressed through certain external forms (symbols such as actions, expressions, words, sounds, pictures, images, etc.). Therefore, each symbol system is a language for conveying meaning in a broad sense, and the meanings they express constitute a specific semantic space. The dissemination of information takes place both in the social space and in the semantic space. A prerequisite for the realization of dissemination is that both the sender and the receiver must have a common semantic space, that is, a common understanding of the symbol meaning or a common cultural background. Otherwise, the dissemination process itself cannot be established, or the message cannot be conveyed, or misunderstandings may occur.
[0091] 504: Perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the text to be annotated.
[0092] In one embodiment, the clustering result of the text to be annotated can be the probability distribution of each text to be annotated with respect to all clustering clusters. The clustering model can be a non-probability-related model, such as the K-Means clustering model, or a probability model, such as the Gaussian Mixed Model (GMM) clustering model. Specifically, for example, the classification training samples can be clustered by the K-Means clustering model: First, the number of clusters to be clustered is set to K, that is, K clustering clusters are required, where K can be arbitrarily specified as needed. For example, K can be set to 100. Then, 100 samples are randomly selected from the classification training samples as the initial clustering centers U. By calculating the distance between each sample and each U, the samples are divided and associated with the U that is closest to them. All the samples associated with the same U are clustered into one cluster. Then, according to this division result, the clustering center of each cluster is recalculated to obtain the final clustering center R. After taking the reciprocal of the distance value between each sample and each R and normalizing it, the probability distribution P of each sample on these 100 clusters can be obtained. Another example is that the GMM clustering model can be used to cluster the classification training samples. Among them, the GMM clustering model is a mixed probability model composed of multiple sub-Gaussian distribution models. It assumes that each cluster is a sub-Gaussian distribution model. Then, through the GMM clustering model, the probability distribution of each sample on all clusters can be obtained. For example, if the number of clusters to be clustered is also set to 100, through the GMM clustering model, the probability distribution of each sample on these 100 clustering clusters can be obtained.
[0093] 505: Classify the clustering result through the trained text model to obtain the text type information of the text to be annotated.
[0094] In one embodiment, the trained classification model can be used to classify the clustering result of the text to be annotated to obtain the text type information of the text to be annotated. The trained classification model can be a neural network model that takes the clustering result of the text to be annotated as the input and the text type information of the text to be annotated as the output, and can be used to represent the mapping relationship between the clustering result of the text to be annotated and its text type. For example, the clustering result of the text to be annotated can be (0.2, 0.1, 0.5, 0.3), where the text type corresponding to 0.2 is A, the text type corresponding to 0.1 is B, the text type corresponding to 0.5 is C, and the text type corresponding to 0.3 is D. The mapping relationship between the clustering result of the text to be annotated and its text type can be to use the text type corresponding to the maximum probability value in the clustering result as the text type of the text to be annotated. Specifically, for example, when the clustering result (0.2, 0.1, 0.5, 0.3) of the text to be annotated is input into the classification model, the text type C corresponding to the maximum value 0.5 can be output as the text type information of this text to be annotated.
[0095] In one embodiment, the text type information of the text to be annotated can be the text type obtained after classifying the text to be annotated. For example, the text type obtained by classifying the text "Watermelon is really delicious" can be "Food", and the text type obtained by classifying the text "Learn finance with xx" can be "Finance".
[0096] 506: According to the text type information, perform text type annotation on the text to be annotated.
[0097] In one embodiment, the text type information of the text to be annotated can be used to annotate the text to be annotated in the form of a text label. For example, if the text type information of a certain text to be annotated is "Entertainment", then the text label "Entertainment" can be annotated on the text to be annotated.
[0098] In one embodiment, as Figure 5 shown, before obtaining the trained text annotation model corresponding to the actual language and the target language, it may further include:
[0099] Obtain training samples, where the training samples include unannotated first texts and annotated first texts in the first language, and unannotated second texts and annotated second texts in the second language. The number of the annotated first texts is greater than the number of the annotated second texts. The first language includes the target language, and the second language includes the actual language;
[0100] Obtain the text annotation model to be trained;
[0101] Use the training samples to train the text annotation model to be trained to obtain the trained text annotation model.
[0102] In one embodiment, it is first necessary to obtain training samples and the text annotation model to be trained. The text annotation model to be trained may include a semantic space conversion model, a clustering model, and a classification model. Among them, the semantic space conversion model and the classification model can be trained by constructing corresponding training samples to obtain the trained semantic space conversion model and the trained classification model. The clustering model, the trained semantic space conversion model, and the trained classification model can be determined as the trained text annotation model.
[0103] In one embodiment, the training samples can be a text set crawled from the network. Among them, the first language can be Chinese or Japanese, etc., and the second language can be English or Korean, etc. For example, the training texts can be the crawled Chinese text set and English text set, including Chinese annotated texts and Chinese unannotated texts, as well as English annotated texts and English unannotated texts, and the number of Chinese text annotated texts is greater than the number of English annotated texts.
[0104] In one embodiment, the steps of using training samples to train the text annotation model to be trained to obtain the trained text annotation model may include:
[0105] Extract features from the first unannotated text and the first annotated text to obtain first text feature data;
[0106] Extract features from the second unannotated text and the second annotated text to obtain second text feature data;
[0107] Use the semantic space conversion model to perform semantic space conversion on the second text feature data to obtain third text feature data;
[0108] Use the clustering model to cluster the first text feature data and the third text feature data to obtain cluster information;
[0109] Determine the clustering results of the first annotated text and the second annotated text according to the cluster information, and the clustering results include the cluster distribution probability corresponding to the text;
[0110] Jointly train the semantic space conversion model and the classification model according to the clustering results of the first annotated text and the second annotated text and the corresponding text types to obtain the trained semantic space conversion model and the trained classification model;
[0111] Determine the trained semantic space conversion model, the clustering model, and the trained classification model as the text annotation model.
[0112] In one embodiment, the training texts obtained may be Chinese annotated texts, Chinese unannotated texts, English annotated texts, and English unannotated texts, where the number of Chinese annotated texts is greater than the number of English annotated texts.
[0113] In one embodiment, the annotated text may be a text with a text label, and the text label may be label information that can indicate the type to which the text belongs. This text label is generally the result of manual operation or algorithm annotation, and can also be used to describe target objects such as short videos, news, articles, and commodities. For example, for a certain short video, its video title is "The best-selling lipstick, promoted by a certain star!", then this short video may correspond to the text labels of "beauty" and "star".
[0114] In one embodiment, the way to extract features from the first unlabeled text and the first labeled text to obtain the first text feature data can be to perform vectorization processing on the first unlabeled text and the first labeled text to obtain the text representations of the first unlabeled text and the first labeled text, and use the text representations of the first unlabeled text and the first labeled text as the first text feature data; similarly, the way to extract features from the second unlabeled text and the second labeled text to obtain the second text feature data can be to perform vectorization processing on the second unlabeled text and the second labeled text to obtain the text representations of the second unlabeled text and the second labeled text, and use the text representations of the second unlabeled text and the second labeled text as the second text feature data.
[0115] In one embodiment, using a semantic space conversion model to perform semantic space conversion on the second text feature data, the obtained third text feature data can be the target semantic feature data of the second unlabeled text and the second labeled text in the target language.
[0116] In one embodiment, the cluster distribution probability can be the probability distribution of each text on each clustering cluster. For example, the clustering result of a certain labeled text can be (0.4, 0.2, 0.5, 0.3), where (0.4, 0.2, 0.5, 0.3) can be the probability distribution of this labeled text on clustering clusters A, B, C, and D. Specifically, such as 0.4 being the probability that this labeled text belongs to cluster A, 0.2 being the probability that this labeled text belongs to cluster B, 0.5 being the probability that this labeled text belongs to cluster C, and 0.3 being the probability that this labeled text belongs to cluster D.
[0117] It should be understood that during the training process, it is usually necessary to use a large number of training texts to train the model, and often need to continuously perform multiple repeated trainings to obtain the final required model. For the convenience of explanation, the following takes a training process as an example for introduction. In actual training, each text in the training texts is trained in a similar manner, and each training process follows a similar process.
[0118] Please refer to Figure 6 , Figure 6 which shows a schematic diagram of a training process of a text annotation model.
[0119] As Figure 6 shown, the training process of the text annotation model can include:
[0120] Obtain training samples 601; the training samples 601 can include, for example, the first labeled text 602, the first unlabeled text 603, the second labeled text 604, and the second unlabeled text 605;
[0121] Feature extraction is performed on the first labeled text 602 and the first unlabeled text 603 to obtain the first text feature data 606;
[0122] Feature extraction is performed on the second labeled text 604 and the second unlabeled text 605 to obtain the second text feature data 607;
[0123] The second text feature data 607 is input into the semantic space conversion model 608, and the third text feature data 609 can be obtained;
[0124] The third text feature data 609 and the first text feature data 606 are input into the clustering model 610 together, and the corresponding clustering result 611 can be output;
[0125] Then, the clustering result 612 of the first labeled text 602 and the clustering result 613 of the second labeled text 604 are selected from the obtained clustering result 611 and input into the classification model 614, and the predicted text types 615 of each text output by the classification model 614 are obtained;
[0126] Calculate the error 616 between the predicted text type 615 of each output text and the text type of this text, and adjust the model parameters of the semantic space conversion model 608 and the classification model 614 according to the calculated error 616 until the training ends, obtaining the trained semantic space conversion model and the trained classification model. The trained semantic space conversion model, the trained classification model, and the clustering model are combined to obtain the trained text annotation model.
[0127] Please refer to Figure 7 , Figure 7 which shows a schematic structural diagram of the text annotation model obtained through the above training.
[0128] In one embodiment, the process of performing text type annotation on the text to be annotated by the text annotation model as shown in Figure 7 can be: input the text to be annotated into the semantic space conversion model 701 to obtain the target semantic feature of the text to be annotated in the target language, then input this target semantic feature into the clustering model 702 to obtain the clustering result of the text to be annotated, input this clustering result into the classification model 703 to obtain the text type information of the text to be annotated, and annotate the text to be annotated according to the text type information output by the classification model 703.
[0129] In one embodiment, the steps of jointly training the semantic space conversion model and the classification model according to the clustering results and the corresponding text types of the first labeled text and the second labeled text to obtain the trained semantic space conversion model and the trained classification model can include:
[0130] Train the semantic space conversion model according to the clustering results of texts of the same text type to obtain a trained semantic space conversion model;
[0131] Train the classification model according to the correspondence between the clustering results of the first annotated text and the second annotated text and the text type to obtain a trained classification model.
[0132] In one embodiment, the step of training the classification model according to the correspondence between the clustering results of the first annotated text and the second annotated text and the text type to obtain a trained classification model may include:
[0133] Construct classification training samples according to the correspondence between the clustering results of the first annotated text and the second annotated text and the text type;
[0134] Obtain the clustering results and actual text types of the classification training samples;
[0135] Input the clustering results of the classification training samples into the classification model to obtain the first predicted text type of the classification training samples;
[0136] Train the classification model according to the first predicted text type and the actual text type to obtain a trained classification model.
[0137] In one embodiment, the trained classification model may be a neural network model that takes the clustering results of the text to be annotated as input and the text type information of the text to be annotated as output, and can be used to represent the mapping relationship between the clustering results of the text to be annotated and its text type.
[0138] In one embodiment, the step of training the classification model according to the first predicted text type and the actual text type to obtain a trained classification model may include:
[0139] Obtain the association relationship between the actual text type and the first predicted text type;
[0140] Construct an objective loss function according to the first predicted text type and the association relationship;
[0141] Input the first predicted text type into the objective loss function to obtain the first loss value of the objective loss function;
[0142] Adjust the parameters of the classification model according to the first loss value of the objective loss function to obtain a classification model with adjusted parameters;
[0143] Determine the classification model with adjusted parameters as the trained classification model.
[0144] In one embodiment, the classification model can be a neural network model that takes the clustering result of classification training samples as input and outputs the first predicted text type of the classification training samples.
[0145] In one embodiment, by inputting the first predicted text type output by the classification model into the target loss function, the first loss value of the target loss function can be obtained. With the goal of achieving the minimum first loss value, the parameters of the classification model can be continuously adjusted to obtain the classification model after parameter adjustment, and the classification model after parameter adjustment is determined as the trained classification model.
[0146] In one embodiment, the correlation relationship between the actual text type and the first predicted text type of the classification training samples can be obtained by calculating the similarity between the actual text type and the first predicted text type of the classification training samples, where the correlation relationship indicates the difference between the actual text type and the first predicted text type of the classification training samples.
[0147] Please refer to Figure 8 , Figure 8 which shows a schematic diagram of a training process of the classification model.
[0148] 801: Construct classification training samples according to the correspondence between the clustering result of the first labeled text and the second labeled text and the text type.
[0149] In one embodiment, the way to construct classification training samples can be to randomly select 80% of the text in the first labeled text and the second labeled text as classification training samples, and use the other 20% of the text as test samples.
[0150] In one embodiment, the classification training samples can be used to train the classification model to obtain the trained classification model, and then the generalization ability of the trained classification model can be tested using the test samples.
[0151] 802: Obtain the clustering result and the actual text type of the classification training samples.
[0152] In one embodiment, a clustering model can be used to perform clustering processing on the classification training samples to obtain the clustering result of the classification training samples. The clustering result can be the probability distribution of each sample relative to all clustering clusters. The clustering model can be a non-probability-related model, such as the K-Means clustering model, or a probability model, such as the GMM clustering model.
[0153] 803: Input the clustering result of the classification training samples into the classification model to obtain the first predicted text type of the classification training samples.
[0154] In one embodiment, the classification model can be a neural network model with randomly initialized parameters. For example, the classification model can be a neural network model with two network parameters, weights and biases. After initializing both the weights and biases, the training of the neural network model can begin.
[0155] In one embodiment, the first predicted text type can be the prediction result of the text type of the classification training sample output by the classification model. This prediction result of the text type may not be consistent with the actual text type of the classification training sample. For example, the actual text type of a certain classification training sample can be "entertainment", while its first predicted text type can be "entertainment" or "food".
[0156] 804: Obtain the association relationship between the actual text type and the first predicted text type.
[0157] In one embodiment, the association relationship between the actual text type and the first predicted text type of the classification training sample can be used to indicate the difference between the actual text type and the first predicted text type of the classification training sample.
[0158] In one embodiment, the similarity between the actual text type and the first predicted text type of the classification training sample can be used as the association relationship between the two. Among them, the similarity between the actual text type and the first predicted text type can be obtained by calculating the Euclidean distance or cosine distance between the text vectors corresponding to the actual text type and the first predicted text type. For example, the first predicted text type of a certain classification training sample can be "entertainment", while the actual text type of this classification training sample can be "food". Then, both "entertainment" and "food" can be vectorized to obtain their text vectors, and the similarity between the two can be obtained by calculating the Euclidean distance between the two text vectors. Specifically, if the Euclidean distance between the two obtained text vectors is greater than the set distance upper limit, it can be considered that the two text vectors are very different, that is, it shows that the difference between the first predicted text type and the actual text type of this classification training sample is very large.
[0159] In one embodiment, an association relationship between the actual text type and the first predicted text type of the classification training samples can be constructed based on the transition matrix, where the transition matrix can be used to indicate the probability of transitioning from the first predicted text type of the classification training samples to the corresponding actual text type. For example, the association relationship can be constructed in the following manner: Initialize the transition matrix corresponding to the nth sample, multiply the transition matrix corresponding to the nth sample by the actual text type, and use the determined product as the first predicted text type corresponding to the nth sample, thereby establishing an association relationship between the first predicted text type and the actual text type. Specifically, the association relationship between the first predicted text type and the actual text type can be represented by the following formula (1):
[0160] p n =w n *T (1)
[0161] where n represents the nth sample in the training set, p n represents the first predicted text type corresponding to the nth sample output by the classification model, T represents the actual text type corresponding to the nth sample, and w n represents the transition matrix corresponding to the nth sample, and this transition matrix represents the probability of transitioning from the first predicted text type corresponding to the nth sample output by the classification model to the corresponding actual text type. That is, the transition matrix characterizes the association relationship between the actual text type and the first predicted text type of the classification training samples.
[0162] 805: Construct an objective loss function according to the first predicted text type and the association relationship.
[0163] In one embodiment, the objective loss function can be used to evaluate the degree of difference between the predicted value and the actual value of the model. The better the loss function, the better the performance of the model usually is. For example, according to the first predicted text type and the association relationship, a cross-entropy loss function or an exponential loss function can be used to construct the corresponding objective loss function, which is not limited herein.
[0164] In one embodiment, the objective loss function constructed according to the first predicted text type and the association relationship can be characterized by the sum of the cross-entropies of the corresponding first predicted text types based on the association relationship between the actual text type and the first predicted text type of the classification training samples. For example, taking the example of obtaining the association relationship between the actual text type and the first predicted text type of the classification training samples based on the transition matrix, the objective loss function constructed can be represented by the following formula (2):
[0165]
[0166] Taking the transition matrix shown in formula (1) as an example, the objective loss function constructed can also be represented by the following formula (3):
[0167]
[0168] where y n can be a set of classification results represented numerically, such as [0, 1], and its meaning can be that "0" indicates that the first predicted text type is different from the actual text type, and "1" indicates that the first predicted text type is the same as the actual text type.
[0169] 806: Input the first predicted text type into the target loss function to obtain the first loss value of the target loss function.
[0170] In one embodiment, the process of inputting the first predicted text type into the target loss function and calculating the first loss value of the target loss function can be as follows: Assume that in a 5-classification task, the classification result of sample 1 is y = [0, 0, 0, 1, 0], which means that the actual text type of sample 1 is 4. Assume that the transition matrix corresponding to the first predicted text type output by the classification model is w = [0.1, 0.15, 0.05, 0.6, 0.1]. It can be considered that this prediction is correct. Then, the corresponding first loss value calculated using the loss function shown in formula (2) can be Loss = -log(0.6). That is, when sample 1 passes through the classification model and outputs the predicted first text type p1 of this sample, the corresponding first loss value can be -log(0.6). Assume that the transition matrix w corresponding to the first predicted text type output by the classification model is [0.15, 0.2, 0.4, 0.1, 0.15]. Then, it can be considered that this prediction is wrong because the actual text type annotation is 4, and the probability that sample 1 is 4 is only 0.1. In this case, the classification model will predict that this sample belongs to category 3, and the corresponding first loss value can be Loss = -log(0.1)). Similarly, assume that w = [0.05, 0.15, 0.4, 0.3, 0.1]. Although this prediction result is also wrong, the degree of error is not as high as that when w = [0.15, 0.2, 0.4, 0.1, 0.15]. The corresponding first loss value can be Loss = -log(0.3). And the log function is a negative number when the input is less than 1, and the log function is an increasing function. Therefore, -log(0.6) < -log(0.3) < -log(0.1). It can be seen that when the prediction is wrong, the first loss value is larger than when the prediction is correct, and when the degree of prediction error is high, the first loss value is larger than when the degree of prediction error is low.
[0171] 807: Adjust the parameters of the classification model according to the first loss value of the target loss function to obtain the classification model with adjusted parameters.
[0172] 808: Determine the classification model after the parameters are adjusted as the trained classification model.
[0173] In one embodiment, the classification model can be a neural network model. When the first loss value of the target loss function of the model exceeds a preset threshold, a corresponding error signal can be determined based on the first loss value of the target loss function, the error signal can be back-propagated in the classification model, and the parameters of the classification model can be updated during the back-propagation process, and the classification model with adjusted parameters can be determined as the trained classification model.
[0174] Here is an explanation of back propagation: the training sample is input into the input layer of the neural network, passes through the hidden layer, and finally reaches the output and outputs the result. This is the forward propagation process of the neural network model. Since there is an error between the output result of the neural network model and the actual result, the error between the output result and the actual result is calculated, and the error is backpropagated from the output layer to the hidden layer until it propagates to the input layer. During the back propagation process, the value of the model parameter is adjusted according to the error, and this back propagation process is continuously iterated until convergence.
[0175] In one embodiment, taking the loss function shown in formula (2) as an example, an error signal is determined based on the loss function, and the error signal is back-propagated layer by layer starting from the output layer of the model can be: when the error signal reaches each layer, the gradient is solved in combination with the transmitted error signal, wherein the gradient can be the partial derivative of the loss function with respect to the parameters of the layer, and the parameters of the layer are updated to the corresponding gradient values.
[0176] See also Figure 9 , Figure 9 The structural diagram of the classification model is shown. Figure 9 Describe the classification model's prediction process for classification training samples:
[0177] like Figure 9 As shown, in one embodiment, the classification model 900 includes an input layer 902, a hidden layer 903 and an output layer 904. The classification training sample 901 is input into the classification model 900 through the input layer 902, and then based on the mapping relationship between the clustering result and the text type, the text type of the classification training sample 901 is predicted through the hidden layer 903 to obtain the first predicted text type of the classification training sample 901, and the obtained first predicted text type is output through the output layer 904.
[0178] In one embodiment, the step of training the semantic space conversion model based on the clustering results of texts of the same text type to obtain the trained semantic space conversion model may include:
[0179] Input the clustering results of texts of the same text type into a classification model to obtain the second predicted text type of texts of the same text type;
[0180] Train the semantic space transformation model according to the second predicted text type and the same text type to obtain a trained semantic space transformation model.
[0181] In one embodiment, the step of training the semantic space transformation model according to the second predicted text type and the same text type may specifically include:
[0182] Obtain the second loss value of the objective loss function of the classification model according to the second predicted text type and the same text type;
[0183] Obtain a conversion error signal according to the second loss value;
[0184] Backpropagate the conversion error signal in the semantic space transformation model and adjust the parameters of the semantic space transformation model during the backpropagation process to obtain a trained semantic space transformation model.
[0185] Please refer to Figure 10 , Figure 10 which shows a schematic diagram of a training process of the semantic space transformation model.
[0186] 1001: Input the clustering results of texts of the same text type into a classification model to obtain the second predicted text type of texts of the same text type.
[0187] In one embodiment, the classification model adopted during the training process of the semantic space transformation model may be the classification model provided in the previous embodiment.
[0188] 1002: Obtain the second loss value of the objective loss function of the classification model according to the second predicted text type and the same text type.
[0189] In one embodiment, the loss function shown in formula (2) may be used as the objective loss function of the classification model. Based on the output result of the classification model, the process of calculating the loss value of the corresponding objective loss function is similar to the process of calculating the loss value in the previous embodiment and will not be elaborated here.
[0190] 1003: Obtain a conversion error signal according to the second loss value.
[0191] In one embodiment, the method of determining the conversion error signal based on the second loss value may be that when the second loss value exceeds a set threshold, the derivative of the loss function corresponding to this second loss value with respect to each model parameter is obtained to obtain the conversion error signal.
[0192] 1004: Back-propagating the conversion error signal in the semantic space conversion model, and adjusting the parameters of the semantic space conversion model during the back-propagation process to obtain a trained semantic space conversion model.
[0193] In one embodiment, the parameters of the semantic space conversion model can be adjusted using a gradient descent method. For example, if the semantic space conversion model is a neural network model, the error signal is back-propagated layer by layer. When it reaches each layer, the gradient is calculated based on the propagated error signal, and the parameters of that layer are updated to the corresponding gradient value. The gradient can be the partial derivative of the loss function with respect to the parameters of that layer.
[0194] In one embodiment, the semantic space conversion model may be a neural network model or a mapping matrix after parameters are randomly initialized.
[0195] In one embodiment, a semantic space conversion model can be used to normalize texts in two different languages into the same semantic space, enabling information dissemination and integration within the same semantic space. For example, consider a text whose actual language is English and whose target language is Chinese. For example, consider a text titled "wave a red flag." The meaning of this text in the English semantic space is "do something that makes people angry." However, the meaning of this text in the Chinese semantic space, output by the semantic space conversion model, is "do something that makes people angry." This indicates that the English semantics of this text are derogatory, and the Chinese semantics output by the semantic space conversion model also maintain this understanding. Conversely, if the text is directly interpreted using Chinese semantics without the semantic space conversion model, the meaning might be interpreted as "waving a red flag." However, the Chinese semantics interpret this meaning as neutral or commendatory, rather than derogatory. This can lead to misunderstandings between the two languages, hindering information dissemination.
[0196] In one embodiment, after obtaining the text to be annotated, the following steps may be further included:
[0197] (1) Preprocess the text to be annotated to obtain the word segments included in the text to be annotated.
[0198] In one embodiment, the annotated text can be pre-processed based on the actual needs of text processing, including but not limited to: removing special symbols and vulgar marks to make the format clear and unified; removing stop words to reduce the interference of meaningless words on text features, making the features clear and prominent. Targeted pre-processing can be performed for different languages, such as stemming for English and word segmentation for Chinese.
[0199] Stop words are words that appear frequently and frequently in text but lack practical meaning or value for text processing. These words, such as particles, interjections, prepositions, and onomatopeia, are often distracting for subsequent text processing and can be removed through preprocessing. Stemming is a common text preprocessing method, primarily used in languages such as English. These languages are characterized by multiple morphological variations of the same word. Stemming can restore these variations to a unified state, or to their original form. For example, the English word "happen" can have various variations in different contexts, such as "happens," "happening," and "happened." While these variations differ, their meaning and function remain the same. Stemming can restore these variations to their original form, "happen." A significant benefit of this is that the number of features extracted after lemmatization is significantly reduced. Word segmentation is a necessary step in text processing for languages such as Chinese, where words are linked together. For example, in a Chinese sentence, all words are linked together. Word segmentation can separate these basic units of semantic meaning and form the features needed for text processing. Through preprocessing, we can lay a good foundation for subsequent text processing.
[0200] In one embodiment, for example, the text to be annotated is "I have eaten dinner". After processing the text to be annotated, the segmented words included in the text to be annotated may be: "I", "eat", "dinner", and "done", a total of 4 words.
[0201] (2) Vectorizing the word segmentation to obtain the word vector corresponding to the word segmentation.
[0202] In one embodiment, the word segmentation is vectorized to obtain the word vector corresponding to the word segmentation, which can be: inputting the word segmentation included in the text to be annotated into a word vector conversion model to obtain a word vector sequence of the text to be annotated. The word vector conversion model can be one or more combinations of the Word2vec model, the Glove model, and the N-gram model. The word vector is a distributed representation of words in deep learning, which can represent words as a fixed-length continuous dense vector.
[0203] In one embodiment, the word segmentation included in the text to be annotated can be vectorized through the Word2vec model to obtain the word vector sequence of the text to be annotated. Among them, Word2vec is an efficient algorithm model that represents words as real-valued vectors. Using the idea of deep learning, it can simplify the processing of text content into vector operations in a K-dimensional vector space, and the similarity in the vector space can be used to represent the similarity in text semantics. For example, through the Word2vec model, the word segmentation included in the text to be annotated is vectorized, and the obtained word vector sequence can be: {"Emb1(I)", "Emb1(eat)", "Emb1(dinner)", "Emb1(already)"}. Among them, "Emb1(I)" is the word vector of "I", "Emb1(eat)" is the word vector of "eat", "Emb1(dinner)" is the word vector of "dinner", and "Emb1(already)" is the word vector of "already".
[0204] (3) Generate the actual semantic features of the text to be annotated according to the word vectors corresponding to the word segmentation.
[0205] In one embodiment, the actual semantic features of the text to be annotated can be a text representation generated according to the word vectors of the word segmentation included in the text to be annotated.
[0206] In one embodiment, the way to generate the actual semantic features of the text to be annotated can be: taking the average value of the word vectors of all the word segmentation included in the annotated text as the text representation of the text to be annotated; or, it can be to input the word vectors of the word segmentation included in the text to be annotated into the Doc2vec model to obtain the text representation corresponding to the text to be annotated, where Doc2vec is an algorithm model that can learn a fixed-length text vector representation according to the word vectors of the text.
[0207] In the embodiment of this application, the provided text annotation method first obtains the text to be annotated and the actual language of the text to be annotated. Then, it obtains the trained text annotation model corresponding to the actual language and the target language. Next, it performs semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language. It performs clustering processing on this target semantic feature through the trained text annotation model to obtain the clustering result of the text to be annotated. It performs classification processing on the clustering result of the text to be annotated through the trained text annotation model to obtain the text type information of the text to be annotated. Finally, it annotates the text to be annotated based on this text type information. Through the above method, it is possible to automatically annotate the text type of the text to be annotated in any language based on the text in the target language with a large number of existing annotation samples, and then it is possible to train the recommendation model in other languages, solving the problem of cross-language text annotation, saving time and human resources, and being beneficial to the rapid iteration of products.
[0208] Combined with the above introduction, the recommendation method provided by this application will be introduced below. Please refer to Figure 11 , Figure 11 which shows the schematic flowchart of the recommendation method provided by this application:
[0209] 1101: Obtain the historical behavior data of the sample user.
[0210] In one embodiment, the sample user may refer to a user who mainly or passively participates in a recommendation application, such as a user of an application like Douyin or a certain shopping APP. The historical behavior data of the sample user may include text data and search data. For example, the historical behavior data of the user may be data generated by the user's own active search. Specifically, if the user actively searches for the keyword "dress", this search text "dress" can be used as the historical behavior data of the user. Another example is that the historical behavior data of the user may be data generated by the user's web click operation. Specifically, for example, if the user clicks on an article titled "Autumn and Winter Fashion Guide" to read, then the title text "Autumn and Winter Fashion Guide" can be used as the historical behavior data of the user.
[0211] 1102: Process the text data using the text annotation method to obtain the text type of the text data.
[0212] In one embodiment, the text annotation method used may be the text annotation method provided in the embodiment of this application.
[0213] 1103: Train the recommendation model using the text type of the text data and the search data to obtain the trained recommendation model.
[0214] In one embodiment, an algorithm based on content filtering can be used to train a recommendation model. Among them, the algorithm based on content filtering can construct a recommendation model based on the information related to the target, the information related to the user, and the historical behavior data of the user on the target. Among them, the target can be a content object to be recommended, such as a commodity, an article, a video, etc. The information related to the target can be the information that describes the target in words, including but not limited to the manually labeled information, user comments, and tags, etc., and can also be extensive information such as videos, pictures, voice information, etc. The information related to the user can be demographic information, including but not limited to age, gender, region, and income, etc. The historical behavior data of the user on the target can be data such as comments, clicks, views, purchases, collections, and searches.
[0215] 1104: Perform data recommendation for the user to be recommended based on the trained recommendation model.
[0216] In one embodiment, the process of performing data recommendation for the user to be recommended based on the trained recommendation model can be: obtaining the historical text data of the user to be recommended; processing the historical text data by using the text annotation method provided in the embodiments of the present application to obtain the text type of the historical text data; based on the trained recommendation model, determining the predicted search data of the user to be recommended according to the text type of the historical text data; and performing data recommendation for the user to be recommended according to the predicted search data of the user to be recommended.
[0217] In one embodiment, please refer to Figure 12 , Figure 12 shows a schematic diagram of a training process of a recommendation model. As Figure 12 shown, taking the training of a recommendation model by using an algorithm based on content filtering as an example, the process of training the recommendation model can be:
[0218] 1201: Obtain the text type of the user text data and the user search data.
[0219] In one embodiment, the text type of the user text data can be obtained by using the text annotation method provided in the embodiments of the present application. The user text data can be the information related to the target, and the search data can be the data generated by the user's search behavior on the target. For example, if the target is an article with the title "Exquisite Skin Care", then the information related to the target can be the title text "Exquisite Skin Care", and the data generated by the user's search behavior on this target can be the user's search text such as "skin care".
[0220] 1202: Construct the text type feature representation and the search data feature representation of the user text data.
[0221] In one embodiment, the text type of the user text data and the search data can be vectorized to obtain the search data feature representation and the text type feature representation of the user text data. For example, if the user text data is labeled using the text annotation method in the embodiments of the present application and the text type of the user text data is obtained as "entertainment", then the text type "entertainment" can be processed by the Doc2vec model to obtain its corresponding text type feature representation.
[0222] 1203: Calculate the similarity between the text type feature representation and the search data feature representation.
[0223] In one embodiment, the similarity between the text type feature representation and the search data feature representation can be calculated using cosine similarity, Euclidean distance, or Manhattan distance, which is not limited herein.
[0224] 1204: Adjust the parameters of the recommendation model according to the similarity to obtain the trained recommendation model.
[0225] In one embodiment, with the goal of minimizing the similarity between the text type feature representation and the search data feature representation, the training process can be continuously iterated to adjust the parameters of the recommendation model to obtain the trained recommendation model.
[0226] In one embodiment, the method of using the text type of the text data and the search data to train the recommendation model can also be to train the recommendation model based on a collaborative filtering algorithm, which is not limited herein.
[0227] Please refer to Figure 13 , Figure 13 which shows a schematic diagram of a scenario of the recommendation method provided by the embodiments of the present application.
[0228] As Figure 13As shown, user 1301 can input text in user terminal 1302. The text can be, for example, comment content, search content, etc. Based on these input texts, historical behavior data 1303 of the user can be generated. User terminal 1302 can interact with server 1304. For example, server 1304 can obtain historical behavior data 1303 of user 1301 through user terminal 1302. Among them, historical behavior data 1303 can include text data and search data. Server 1304 can call the built-in application to execute the text annotation method provided in the embodiments of the present application to process the text data in historical behavior data 1303, and obtain the text type of the text data. Then, server 1304 can use the text type of the text data and the search data to train and obtain a recommendation model, and generate corresponding predicted recommendation data 1305 based on the trained recommendation model, and send predicted recommendation data 1305 to user terminal 1302. User terminal 1302 can display the received predicted recommendation data 1305 on the interface of client 1306. User 1301 can read predicted recommendation data 1305 in the interface of client 1306 in user terminal 1302.
[0229] Please refer to Figure 14 , Figure 14 shows a schematic diagram of the interface of the client provided in the embodiments of the present application.
[0230] Next, in combination with Figure 13 and Figure 14 , a specific application environment of the recommendation method provided in the embodiments of the present application will be described in detail: For example, user 1301 has input text in the search box 1401 of client 1306 in user terminal 1302 to search for goods in the past period of time. The corresponding text data can be "new style boots for women", "mid-calf boots that don't reach the knees", "slimming long boots". These historical search records will be displayed in the historical display area 1404 below historical search 1402. Server 1304 obtains these text data through user terminal 1302, and calls the built-in application to execute the text annotation method provided in the embodiments of the present application to process these text data, and obtains the text type of these text data. Then, server 1304 processes the text type of the obtained text data through the trained recommendation model, and can obtain the predicted search data of user 1301, and send this predicted search data to user terminal 1302. User terminal 1302 can display the received predicted search data on the interface of client 1306. User 1301 can read these predicted search data through client 1306. For example, the predicted search data can be "mid-calf women's slimming boots", "new style high-heel riding boots", "slimming boots for short people", "mid-calf boots made of genuine leather", etc. As Figure 14As shown, the user terminal 1302 can display the predicted search data in the recommendation display area 1405 below the search discovery 1403 of the client 1306 for the data recommendation for the user 1301.
[0231] In the embodiment of the present application, the recommendation method provided obtains the historical behavior data of the sample user. Among them, the historical behavior data of the user may include text data and search data. The text annotation method provided in the embodiment of the present application is used to process the text data to obtain the text type of the text data. The text type of the text data and the search data are used to train the recommendation model, and the trained recommendation model is obtained. Based on the trained recommendation model, data recommendation is performed for the user to be recommended. Through the above method, the historical behavior data of the sample user can be used to train the recommendation model, and data recommendation for the user to be recommended can be realized based on the trained recommendation model. By using the recommendation method provided in the embodiment of the present application, the user's preference can be predicted according to the user's historical behavior, and the content required by the user can be recommended under the premise of meeting the user's preference, so as to achieve accurate recommendation of information.
[0232] The embodiment of the present application also provides a text annotation device, which can be integrated in an electronic device, and the electronic device can be a server or a terminal or other devices.
[0233] The following describes the text annotation device provided in the present application. Please refer to Figure 15 , Figure 15 is a schematic structural diagram of the text annotation device provided in the embodiment of the present application. As Figure 15 shown, the text annotation device 1500 may include:
[0234] The first acquisition unit 1501 is used to acquire the text to be annotated and the actual language of the text to be annotated;
[0235] The second acquisition unit 1502 is used to acquire the trained text annotation model corresponding to the actual language and the target language;
[0236] The semantic conversion unit 1503 is used to perform semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language;
[0237] The clustering unit 1504 is used to perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the text to be annotated;
[0238] The classification unit 1505 is used to perform classification on the clustering result through the trained text annotation model to obtain the text type information of the text to be annotated;
[0239] The annotation unit 1506 is configured to perform text type annotation on the text to be annotated according to the text type information.
[0240] In one embodiment, the second acquisition unit 1502 may include:
[0241] The first sub-acquisition unit is configured to acquire training samples;
[0242] The second sub-acquisition unit is configured to acquire the text annotation model to be trained;
[0243] The training unit is configured to use the training samples to train the text annotation model to be trained, and obtain the trained text annotation model.
[0244] In one embodiment, the training samples include the first unannotated text and the first annotated text in the first language, and the second unannotated text and the second annotated text in the second language. The number of the first annotated texts is greater than the number of the second annotated texts. The first language includes the target language, and the second language includes the actual language.
[0245] In one embodiment, the text annotation model to be trained may include a semantic space conversion model, a clustering model, and a classification model.
[0246] In one embodiment, feature extraction is performed on the first unannotated text and the first annotated text to obtain first text feature data; feature extraction is performed on the second unannotated text and the second annotated text to obtain second text feature data; the second text feature data is subjected to semantic space conversion using the semantic space conversion model to obtain third text feature data; the first text feature data and the third text feature data are clustered using the clustering model to obtain cluster information; the clustering results of the first annotated text and the second annotated text are determined according to the cluster information, and the clustering results include the cluster distribution probability corresponding to the text; according to the clustering results of the first annotated text and the second annotated text and the corresponding text types, the semantic space conversion model and the classification model are jointly trained to obtain the trained semantic space conversion model and the trained classification model; the clustering model, the trained semantic space conversion model, and the trained classification model may be determined as the trained text annotation model.
[0247] In one embodiment, the semantic space conversion model may be trained according to the clustering results of texts of the same text type to obtain the trained semantic space conversion model; the classification model may be trained according to the correspondence between the clustering results of the first annotated text and the second annotated text and the text types to obtain the trained classification model.
[0248] In one embodiment, classification training samples can be constructed according to the correspondence between the clustering results of the first labeled text and the second labeled text and the text types; the clustering results and the actual text types of the classification training samples can be obtained; the clustering results of the classification training samples are input into a classification model to obtain the first predicted text type of the classification training samples; the first predicted text type can be input into a target loss function to obtain the first loss value of the target loss function; the parameters of the classification model can be adjusted according to the first loss value of the target loss function to obtain a classification model with adjusted parameters; the classification model with adjusted parameters can be determined as the trained classification model.
[0249] In one embodiment, the association relationship between the actual text type and the first predicted text type of the classification training samples can be obtained, where the association relationship indicates the difference between the actual text type and the first predicted text type of the classification training samples; a target loss function can be constructed according to the first predicted text type and the association relationship.
[0250] In one embodiment, the clustering results of texts of the same text type can be input into the classification model to obtain the second predicted text type of the texts of the same text type; the semantic space conversion model can be trained according to the second predicted text type and the same text type to obtain the trained semantic space conversion model.
[0251] In one embodiment, preprocessing the text to be labeled can obtain the word segments included in the text to be labeled; vectorizing the word segments can obtain the word vectors corresponding to the word segments; the actual semantic features of the text to be labeled can be generated according to the word vectors corresponding to the word segments.
[0252] In specific implementation, each of the above units can be implemented as an independent entity, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of each of the above units, reference can be made to the method embodiments described above, which will not be elaborated here.
[0253] An embodiment of the present application further provides a recommendation device, which can be specifically integrated in an electronic device. The electronic device can be a server or a terminal device, etc.
[0254] The following describes the recommendation device provided in the present application. Please refer to Figure 16 , Figure 16 which is a schematic structural diagram of the recommendation device provided in an embodiment of the present application. As Figure 16 shown, the recommendation device 1600 can include:
[0255] An acquisition unit 1601, configured to acquire the historical behavior data of a sample user;
[0256] A processing unit 1602, configured to process the text data by using the text annotation method provided in the embodiment of the present application, so as to obtain the text type of the text data;
[0257] A training unit 1603, configured to train a recommendation model by using the text type of the text data and search data, so as to obtain a trained recommendation model;
[0258] A recommendation unit 1604, configured to perform data recommendation for a user to be recommended based on the trained recommendation model.
[0259] In one embodiment, the recommendation unit 1604 may include:
[0260] An obtaining unit, configured to obtain the historical text data of the user to be recommended;
[0261] A processing subunit, configured to process the historical text data of the user to be recommended by using the text annotation method provided in the embodiment of the present application, so as to obtain the text type of the historical text data of the user to be recommended;
[0262] A prediction unit, configured to determine the predicted search data of the user to be recommended based on the trained recommendation model and according to the text type of the historical text data of the user to be recommended;
[0263] A recommendation subunit, configured to perform data recommendation for the user to be recommended according to the predicted search data of the user to be recommended.
[0264] In specific implementation, each of the above units may be implemented as an independent entity, or may be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of each of the above units, reference may be made to the method embodiments described above, which will not be elaborated herein.
[0265] In addition, an embodiment of the present application further provides an electronic device. Please refer to Figure 17 , Figure 17 which shows a schematic structural diagram of the electronic device involved in the embodiment of the present application.
[0266] As Figure 17 shown, the electronic device may include components such as a processor 1701 with one or more processing cores, a memory 1702 with one or more computer-readable storage media, a power supply 1703, and an input unit 1704.
[0267] Those skilled in the art can understand that Figure 17 the structural diagram of the electronic device shown in
[0268] In one embodiment, the processor 1701 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 1702, and invoking the data stored in the memory 1702, it executes various functions of the electronic device and processes data, thereby exercising overall control over the electronic device.
[0269] In one embodiment, the processor 1701 may include one or more processing cores.
[0270] In one embodiment, the processor 1701 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communications. It can be understood that the above-mentioned modem processor may not be integrated into the processor 1701 either.
[0271] In one embodiment, the memory 1702 can be used to store software programs and modules. The processor 1701 executes various functional applications and data processing by running the software programs and modules stored in the memory 1702.
[0272] In one embodiment, the memory 1702 may mainly include a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.), etc.; the data storage area can store the data created according to the use of the electronic device, etc. In addition, the memory 1702 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 1702 may also include a memory controller to provide the processor 1701 with access to the memory 1702.
[0273] In one embodiment, the power supply 1703 can be logically connected to the processor 1701 through a power management system, so as to manage functions such as charging, discharging, and power consumption management through the power management system.
[0274] In one embodiment, the power supply 1703 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, a power status indicator, etc.
[0275] In one embodiment, the electronic device may further include an input unit 1704, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0276] Although not shown, the electronic device may further include a display unit and the like, which will not be elaborated herein.
[0277] In one embodiment, the processor 1701 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 1702 according to the following instructions, and the processor 1701 will run the application programs stored in the memory 1702 to implement the text annotation function:
[0278] Obtain the text to be annotated and the actual language of the text to be annotated;
[0279] Obtain the trained text annotation model corresponding to the actual language and the target language;
[0280] Perform semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language;
[0281] Perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the text to be annotated;
[0282] Perform classification processing on the clustering result through the trained text annotation model to obtain the text type information of the text to be annotated;
[0283] Perform text type annotation on the text to be annotated according to the text type information.
[0284] In one embodiment, the processor 1701 in the electronic device will also load the executable files corresponding to the processes of one or more application programs into the memory 1702 according to the following instructions, and the processor 1701 will run the application programs stored in the memory 1702 to implement the recommendation function:
[0285] Obtain the historical behavior data of the sample user, and the historical behavior data includes text data and search data;
[0286] Process the text data by using the text annotation method to obtain the text type of the text data;
[0287] Use the text type of the text data and the search data to train the recommendation model to obtain the trained recommendation model;
[0288] Perform data recommendation for the user to be recommended based on the trained recommendation model.
[0289] For the specific implementation of each of the above operations, reference may be made to the previous embodiments, which will not be elaborated herein.
[0290] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling relevant hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0291] Therefore, an embodiment of the present application further provides a computer-readable storage medium, in which multiple instructions are stored. These instructions can be loaded by a processor to execute the steps in any text annotation method or recommendation method provided by the embodiments of the present application.
[0292] For example, the instructions can execute the following steps:
[0293] Obtain the text to be annotated and the actual language of the text to be annotated;
[0294] Obtain the trained text annotation model corresponding to the actual language and the target language;
[0295] Perform semantic space conversion processing on the actual semantic features of the text to be annotated through the trained text annotation model to obtain the target semantic features of the text to be annotated in the target language;
[0296] Perform clustering processing on the target semantic features through the trained text annotation model to obtain the clustering result of the text to be annotated;
[0297] Perform classification on the clustering result through the trained text annotation model to obtain the text type information of the text to be annotated;
[0298] Perform text type annotation on the text to be annotated according to the text type information.
[0299] For another example, the instructions can execute the following steps:
[0300] Obtain the historical behavior data of the sample user, and the historical behavior data includes text data and search data;
[0301] Process the text data using a text annotation method to obtain the text type of the text data;
[0302] Use the text type of the text data and the search data to train a recommendation model to obtain a trained recommendation model;
[0303] Perform data recommendation for the user to be recommended based on the trained recommendation model.
[0304] For the specific implementation of each of the above operations, reference can be made to the previous embodiments, which will not be elaborated here.
[0305] Among them, the computer-readable storage medium may include: Read Only Memory (ROM), Random Access Memory (RAM), magnetic disk or optical disk, etc.
[0306] Since the instructions stored in the computer-readable storage medium can execute the steps in any of the text annotation methods or recommendation methods provided in the embodiments of the present application, the beneficial effects achievable by any of the text annotation methods or recommendation methods provided in the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.
[0307] The above has introduced in detail a text annotation method and device provided in the embodiments of the present application. Specific examples are used in this article to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation on the technical solutions provided in the present application.
Claims
1. A text annotation method, characterized in that: include: Obtaining the text to be annotated and the actual language of the text to be annotated; Obtaining trained text annotation models corresponding to the actual language and the target language, wherein the trained text annotation models include a trained semantic space conversion model, a clustering model, and a trained classification model, wherein the trained semantic space conversion model is trained based on clustering results of texts of the same text type; The steps of training the semantic space conversion model based on the clustering results of texts of the same text type to obtain the trained semantic space conversion model include: Inputting the clustering result of texts of the same text type into the classification model to obtain a second predicted text type of the texts of the same text type; Training a semantic space conversion model according to the second predicted text type and the same text type to obtain a trained semantic space conversion model; Performing semantic space conversion processing on the actual semantic features of the text to be annotated using the trained semantic space conversion model to obtain target semantic features of the text to be annotated in the target language; Performing clustering processing on the target semantic features using the trained clustering model to obtain a clustering result of the text to be annotated; Classify the clustering results using the trained classification model to obtain text type information of the text to be annotated; The text to be annotated is annotated with respect to the text type according to the text type information.
2. The text annotation method according to claim 1, wherein: Before the step of obtaining the trained text annotation models corresponding to the actual language and the target language, the method further includes: Acquire training samples, the training samples including a first unlabeled text and a first labeled text in a first language, and a second unlabeled text and a second labeled text in a second language, the number of the first labeled texts being greater than the number of the second labeled texts, the first language including the target language, and the second language including the actual language; Get the text annotation model to be trained; The training sample is used to train the text annotation model to be trained to obtain the trained text annotation model.
3. The text annotation method according to claim 2, wherein: The text annotation model to be trained includes a semantic space conversion model, a clustering model, and a classification model. The step of using the training samples to train the text annotation model to be trained to obtain the trained text annotation model includes: Performing feature extraction on the first unannotated text and the first annotated text to obtain first text feature data; Performing feature extraction on the second unannotated text and the second annotated text to obtain second text feature data; Performing semantic space conversion on the second text feature data using the semantic space conversion model to obtain third text feature data; Clustering the first text feature data and the third text feature data using the clustering model to obtain cluster information; Determine a clustering result of the first annotated text and the second annotated text according to the cluster information, wherein the clustering result includes cluster distribution probabilities corresponding to the texts; Jointly training the semantic space conversion model and the classification model according to the clustering results and corresponding text types of the first annotated text and the second annotated text to obtain a trained semantic space conversion model and a trained classification model; The trained semantic space conversion model, the clustering model and the trained classification model are determined as the text annotation model.
4. The text annotation method according to claim 3, wherein: The step of jointly training the semantic space conversion model and the classification model according to the clustering results and corresponding text types of the first annotated text and the second annotated text to obtain a trained classification model includes: The classification model is trained according to the corresponding relationship between the clustering results of the first annotated text and the second annotated text and the text types to obtain a trained classification model.
5. The text annotation method according to claim 4, wherein: The step of training the classification model according to the correspondence between the clustering results of the first annotated text and the second annotated text and the text types to obtain a trained classification model includes: Constructing classification training samples based on the clustering results of the first annotated text and the second annotated text and the correspondence between the text types; Obtaining the clustering results and actual text types of the classification training samples; Inputting the clustering result of the classification training sample into the classification model to obtain a first predicted text type of the classification training sample; The classification model is trained according to the first predicted text type and the actual text type to obtain a trained classification model.
6. The text annotation method according to any one of claims 1 to 5, characterized in that: After the step of obtaining the text to be annotated, the method further includes: Preprocessing the text to be annotated to obtain the word segments included in the text to be annotated; Performing vectorization processing on the word segmentation to obtain a word vector corresponding to the word segmentation; The actual semantic features of the text to be annotated are generated according to the word vectors corresponding to the word segments.
7. A text annotation device, characterized in that: include: A first acquiring unit, configured to acquire the text to be annotated and the actual language of the text to be annotated; a second acquisition unit, configured to acquire a trained text annotation model corresponding to the actual language and the target language, wherein the trained text annotation model includes a trained semantic space conversion model, a clustering model, and a trained classification model, wherein the trained semantic space conversion model is trained based on clustering results of texts of the same text type; The second acquisition unit includes a training unit, and the training unit is used to train the text annotation model to be trained using the training samples to obtain a trained text annotation model; The training unit is used to: input the clustering result of texts of the same text type into the classification model to obtain a second predicted text type of the texts of the same text type; Training a semantic space conversion model according to the second predicted text type and the same text type to obtain a trained semantic space conversion model; A semantic conversion unit, configured to perform semantic space conversion processing on the actual semantic features of the text to be annotated using the trained semantic space conversion model to obtain target semantic features of the text to be annotated in the target language; A clustering unit, configured to perform clustering processing on the target semantic features using the trained clustering model to obtain a clustering result of the text to be annotated; A classification unit, configured to classify the clustering result using the trained classification model to obtain text type information of the text to be annotated; The marking unit is used to mark the text type of the text to be marked according to the text type information.
8. The text annotation device according to claim 7, characterized in that: The second acquisition unit further includes: a first sub-acquisition unit, configured to acquire the training sample; The second sub-acquisition unit is used to acquire the text annotation model to be trained.
9. An electronic device, characterized in that: include: processor and memory; The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the text annotation method according to any one of claims 1 to 6 according to the instructions in the program code.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps of the text annotation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Optimization method and device for data annotation
CN108241662A
Text processing method and device
CN111563381A