Acquisition of language recognition model, language recognition method, device, equipment and medium

By acquiring and updating the feature vectors of the language recognition model, the accuracy problem of language recognition for languages ​​with fewer characters and low resources is solved, and the accuracy and effect of language recognition are improved.

CN117556812BActive Publication Date: 2025-09-09TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210918596.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-01
Publication Date
2025-09-09
Estimated Expiration
2042-08-01

AI Technical Summary

Technical Problem

In the existing technology, language recognition has poor accuracy for languages ​​with fewer characters and low resources, resulting in low matching degree.

Method used

By obtaining the feature vectors of the first text, the second text, and the third text, the target language recognition model is updated using the initial language recognition model. The segment vector, position vector, and length vector are considered to shorten the distance between the same language and increase the distance between different languages.

Benefits of technology

The accuracy of language recognition is improved, the matching degree between feature vectors and text is enhanced, and the recognition effect is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117556812B_ABST
    Figure CN117556812B_ABST
Patent Text Reader

Abstract

The present application discloses a method, apparatus, device, and medium for acquiring a language recognition model, and belongs to the field of computer technology. The method includes: acquiring a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are of the same language, and the first text and the third text are of different languages; calling the initial language recognition model to acquire a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the languages ​​of the first text, the second text, and the third text; determining a first loss value based on the first feature vector, the second feature vector, and the third feature vector; and updating the initial language recognition model based on the fact that the first loss value is greater than a loss threshold to obtain a target language recognition model. This method improves the accuracy of language recognition and achieves better language recognition results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to acquisition of a language recognition model, a language recognition method, an apparatus, a device, and a medium. Background Art

[0002] Language recognition refers to the process by which a computer device automatically determines the language of input text data, such as Chinese, English, French, and Japanese.

[0003] In the related art, a target text to be language-recognized is obtained, and the target text is segmented to obtain multiple segments; a target segment that can represent the target text is determined among the multiple segments; a feature vector corresponding to the target segment is determined, and the feature vector is used to characterize the language of the target segment; and based on the feature vector corresponding to the target segment, the language corresponding to the target text is determined.

[0004] However, when the target text has fewer words and / or the language of the target text is a low-resource language, that is, a minority language, the language corresponding to the target text determined according to the above method has a low match with the actual language of the target text, which results in poor accuracy in language recognition. Summary of the Invention

[0005] The present application provides a method, apparatus, device, and medium for acquiring a language recognition model, which can be used to solve the problem of poor accuracy in language recognition in related technologies. The technical solution is as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for acquiring a language recognition model, the method comprising:

[0007] Obtaining a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are in the same language, and the first text and the third text are in different languages;

[0008] Invoking the initial language identification model to obtain a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the language of the first text, the second text, and the third text, and the feature vector corresponding to each text is determined based on a segment vector of each segment included in each text, a position vector of each segment included in each text, and a length vector of each text;

[0009] Determining a first loss value based on the first feature vector, the second feature vector, and the third feature vector, where the first loss value is used to represent a relationship between a first similarity and a second similarity, where the first similarity is the similarity between the languages ​​of the first text and the second text, and the second similarity is the similarity between the languages ​​of the first text and the third text;

[0010] Based on the first loss value being greater than a loss threshold, the initial language recognition model is updated to obtain a target language recognition model, where the target language recognition model is used to recognize the language corresponding to the text.

[0011] In a second aspect, an embodiment of the present application provides a language identification method, the method comprising:

[0012] Obtaining a target text to be language-recognized and a target language recognition model, wherein the target language recognition model is obtained by the language recognition model acquisition method described in the first aspect;

[0013] Calling the target language recognition model to obtain a target feature vector corresponding to the target text, the target feature vector being used to characterize the language of the target text, the target feature vector being determined based on segment vectors of each segment included in the target text, position vectors of each segment included in the target text, and a length vector of the target text;

[0014] The language corresponding to the target text is determined according to the target feature vector.

[0015] In a third aspect, an embodiment of the present application provides a device for acquiring a language recognition model, the device comprising:

[0016] an acquisition module, configured to acquire a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are in the same language, and the first text and the third text are in different languages;

[0017] The acquisition module is further configured to call the initial language identification model to acquire a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the language of the first text, the second text, and the third text, and the feature vector corresponding to each text is determined based on a segment vector of each segment included in each text, a position vector of each segment included in each text, and a length vector of each text;

[0018] a determination module, configured to determine a first loss value based on the first feature vector, the second feature vector, and the third feature vector, wherein the first loss value is used to represent a relationship between a first similarity and a second similarity, wherein the first similarity is the similarity between the languages ​​of the first text and the second text, and the second similarity is the similarity between the languages ​​of the first text and the third text;

[0019] An updating module is configured to update the initial language recognition model based on the first loss value being greater than a loss threshold to obtain a target language recognition model, wherein the target language recognition model is used to identify the language corresponding to the text.

[0020] In one possible implementation, the acquisition module is used to call the initial language recognition model to obtain a first text feature vector corresponding to the first text, where the first text feature vector includes a first length vector of the first text, first segment vectors corresponding to each segment in the first text, and first position vectors corresponding to each segment in the first text; and determine the first feature vector corresponding to the first text based on the first length vector, the first segment vectors corresponding to each segment, and the first position vectors corresponding to each segment.

[0021] In one possible implementation, the acquisition module is used to obtain a weight vector based on the first length vector and the first fragment vectors corresponding to the each fragment, where the weight vector includes weights corresponding to the each fragment, and the weights corresponding to the each fragment are used to characterize the importance of the each fragment; and determine the first feature vector corresponding to the first text based on the weight vector, the first fragment vector corresponding to the each fragment, and the first position vector corresponding to the each fragment.

[0022] In a possible implementation, the acquisition module is configured to perform nonlinear processing on the first length vector to obtain a first reference eigenvector; and perform cross multiplication of the first reference eigenvector with the first fragment vector corresponding to each fragment to obtain the weight vector.

[0023] In one possible implementation, the acquisition module is used to determine a second reference feature vector based on the first segment vectors corresponding to each segment and the first position vectors corresponding to each segment, where the second reference feature vector is used to characterize the language of the first text; and multiply the weight vector and the numerical values ​​in the same dimension in the second reference feature vector to obtain the first feature vector corresponding to the first text.

[0024] In one possible implementation, the acquisition module is used to determine the target vector corresponding to each fragment based on the first fragment vector corresponding to each fragment and the first position vector corresponding to each fragment, and the target vector corresponding to each fragment is used to characterize each fragment; and the target vectors corresponding to each fragment are combined into the second reference feature vector.

[0025] In one possible implementation, the acquisition module is used to add the values ​​of the same dimension in the first fragment vector corresponding to any one of the fragments and the first position vector corresponding to any one of the fragments to obtain an intermediate vector corresponding to any one of the fragments; and obtain a target vector corresponding to any one of the fragments based on the intermediate vector corresponding to any one of the fragments.

[0026] In one possible implementation, the determination module is configured to determine a first similarity based on the first feature vector and the second feature vector, where the first similarity is used to indicate the similarity between the language of the first text and the language of the second text; determine a second similarity based on the first feature vector and the third feature vector, where the second similarity is used to indicate the similarity between the language of the first text and the language of the third text; and call a target loss function based on the first similarity and the second similarity to determine the first loss value.

[0027] In one possible implementation, the updating module is configured to update the initial language recognition model based on the first loss value being greater than the loss threshold to obtain an intermediate language recognition model; call the intermediate language recognition model to obtain a first intermediate vector corresponding to the first text, a second intermediate vector corresponding to the second text, and a third intermediate vector corresponding to the third text, wherein the first intermediate vector, the second intermediate vector, and the third intermediate vector respectively represent the languages ​​of the first text, the second text, and the third text; determine a second loss value based on the first intermediate vector, the second intermediate vector, and the third intermediate vector; and use the intermediate language recognition model as the target language recognition model based on the second loss value being no greater than the loss threshold.

[0028] In a fourth aspect, an embodiment of the present application provides a language recognition device, the device comprising:

[0029] an acquisition module, configured to acquire a target text to be language-recognized and a target language recognition model, wherein the target language recognition model is acquired by the language recognition model acquisition device described in the third aspect;

[0030] The acquisition module is further configured to call the target language recognition model to obtain a target feature vector corresponding to the target text, the target feature vector being used to characterize the language of the target text, and the target feature vector being determined based on the segment vectors of each segment included in the target text, the position vectors of each segment included in the target text, and the length vector of the target text;

[0031] A determination module is used to determine the language corresponding to the target text according to the target feature vector.

[0032] In one possible implementation, the acquisition module is used to call the target language recognition model to obtain a target text feature vector corresponding to the target text, where the target text feature vector includes a target length vector of the target text, target segment vectors corresponding to each segment in the target text, and target position vectors corresponding to each segment in the target text; and the target feature vector corresponding to the target text is determined based on the target length vector, the target segment vectors corresponding to each segment, and the target position vectors corresponding to each segment.

[0033] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor and a memory, wherein the memory stores at least one program code, and the at least one program code is loaded and executed by the processor so that the computer device implements the method for acquiring a language recognition model described in the first aspect or any possible implementation of the first aspect, or enables the computer device to implement the language recognition method described in the second aspect or any possible implementation of the second aspect.

[0034] In the sixth aspect, a computer-readable storage medium is also provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to enable the computer to implement the method for acquiring the language recognition model described in the first aspect or any possible implementation of the first aspect, or to enable the computer to implement the language recognition method described in the second aspect or any possible implementation of the second aspect.

[0035] In the seventh aspect, a computer program or a computer program product is also provided, wherein the computer program or the computer program product stores at least one computer instruction, and the at least one computer instruction is loaded and executed by a processor to enable the computer to implement the method for acquiring the language recognition model described in the first aspect or any possible implementation of the first aspect, or to enable the computer to implement the language recognition method described in the second aspect or any possible implementation of the second aspect.

[0036] The technical solutions provided by the embodiments of the present application bring at least the following beneficial effects:

[0037] The feature vectors corresponding to each text determined by the technical solution provided in the embodiments of this application are determined based on the segment vectors of each segment included in the text, the position vectors of each segment included in each text, and the length vector of each text. This takes into account a variety of factors, resulting in a higher degree of match between the feature vectors corresponding to the text and the text, enabling better text characterization. Furthermore, due to the high degree of match between the feature vectors corresponding to the text and the text, the accuracy of the loss value determined using the feature vectors corresponding to each text is also high, thereby increasing the recognition accuracy of the target language recognition model determined based on the loss value.

[0038] In addition, since the language of the first text is the same as the language of the second text, and the language of the first text is different from the language of the third text, the initial language recognition model is updated according to the feature vectors corresponding to the first text, the second text, and the third text respectively. The resulting target language recognition model can narrow the distance between the same languages ​​and widen the distance between different languages, thereby making the language recognition accuracy of the target language recognition model higher and the language recognition effect better. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0040] Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present application;

[0041] Figure 2 This is a flow chart of a method for obtaining a language recognition model provided in an embodiment of the present application;

[0042] Figure 3 This is a schematic diagram of the language distribution of text corresponding to a game provided in an embodiment of the present application;

[0043] Figure 4 This is a word count distribution diagram of a text corresponding to a game provided in an embodiment of the present application;

[0044] Figure 5 is a schematic diagram of a process for determining a first feature vector corresponding to a first text provided in an embodiment of the present application;

[0045] Figure 6 is a schematic diagram of a process for determining a first loss value provided in an embodiment of the present application;

[0046] Figure 7This is a flow chart of a language recognition method provided in an embodiment of the present application;

[0047] Figure 8 This is a flow chart of a language recognition method provided in an embodiment of the present application;

[0048] Figure 9 This is a language recognition improvement curve provided by an embodiment of the present application;

[0049] Figure 10 This is a structural diagram of a device for acquiring a language recognition model provided in an embodiment of the present application;

[0050] Figure 11 This is a structural diagram of a language recognition device provided in an embodiment of the present application;

[0051] Figure 12 This is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0052] Figure 13 This is a structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0054] It should be noted that the terms "first," "second," and the like in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are merely examples of devices and methods consistent with certain aspects of the present application as detailed in the appended claims.

[0055] In an exemplary embodiment, the language recognition model acquisition method and language recognition method provided in the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, games, etc.

[0056] Artificial Intelligence (AI) is the theory, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and create new intelligent machines that can respond in a manner similar to human intelligence. AI also studies the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0057] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and smart transportation.

[0058] The solution provided in the embodiment of the present application relates to machine learning technology in artificial intelligence technology. Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include technologies such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.

[0059] With the research and progress of artificial intelligence technology, artificial intelligence technology has been studied and applied in many fields, such as common smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, unmanned driving, automatic driving, drones, robots, smart medical care, smart customer service, Internet of Vehicles, automatic driving, smart transportation, etc. It is believed that with the development of technology, artificial intelligence technology will be applied in more fields and play an increasingly important role.

[0060] Figure 1 This is a schematic diagram of an implementation environment provided by an embodiment of the present application. Figure 1 As shown, the implementation environment may include: a terminal device 101 and a server 102 .

[0061] The method for obtaining a language recognition model provided in the embodiment of the present application can be executed by the terminal device 101, can be executed by the server 102, or can be jointly executed by the terminal device 101 and the server 102, and the embodiment of the present application does not limit this. In the case where the method for obtaining a language recognition model provided in the embodiment of the present application is jointly executed by the terminal device 101 and the server 102, the server 102 undertakes the primary computing work and the terminal device 101 undertakes the secondary computing work; or, the server 102 carries out the secondary computing work and the terminal device 101 undertakes the primary computing work; or, the server 102 and the terminal device 101 adopt a distributed computing architecture to perform collaborative computing.

[0062] The language recognition method provided in the embodiment of the present application can be executed by the terminal device 101, can be executed by the server 102, or can be jointly executed by the terminal device 101 and the server 102, and the embodiment of the present application does not limit this. In the case where the language recognition method provided in the embodiment of the present application is jointly executed by the terminal device 101 and the server 102, the server 102 undertakes the primary computing work and the terminal device 101 undertakes the secondary computing work; or, the server 102 undertakes the secondary computing work and the terminal device 101 undertakes the primary computing work; or, the server 102 and the terminal device 101 adopt a distributed computing architecture to perform collaborative computing.

[0063] It should be noted that the execution device of the method for acquiring the language recognition model and the execution device of the language recognition method may be the same as or different from each other, and the embodiments of the present application do not limit this.

[0064] Optionally, the terminal device 101 can be any electronic product that can interact with the user through one or more methods such as a keyboard, touchpad, touch screen, remote control, voice interaction or handwriting device. The terminal device 101 includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The server 102 is a server, or a server cluster composed of multiple servers, or any one of a cloud computing platform and a virtualization center, which is not limited in the embodiments of the present application. The server 102 is communicatively connected to the terminal device 101 via a wired network or a wireless network. The server 102 has a data receiving function, a data processing function and a data sending function. Of course, the server 102 can also have other functions, which are not limited in the embodiments of the present application.

[0065] Those skilled in the art should understand that the above-mentioned terminal device 101 and server 102 are merely examples, and other existing or future terminal devices or servers, if applicable to the present application, should also be included in the scope of protection of the present application and are incorporated herein by reference.

[0066] The present invention provides a method for obtaining a language recognition model, which can be applied to the above Figure 1 The method for obtaining the language recognition model is executed by a computer device, which may be a terminal device 101 or a server 102, and the present embodiment of the application does not limit this. Figure 2 Taking the flowchart of a method for acquiring a language recognition model provided in an embodiment of the present application as an example, the method includes the following steps 201 to 204.

[0067] In step 201 , a first text, a second text, a third text and an initial language recognition model are obtained. The first text and the second text are in the same language, while the first text and the third text are in different languages.

[0068] The embodiments of the present application do not limit the method for obtaining the first text, the second text, and the third text. Optionally, a computer device may store multiple texts and the languages ​​corresponding to the texts in its storage space. The computer device may randomly select a text from its storage space as the first text, randomly select a text from the texts in the same language as the first text as the second text, and randomly select at least one text from the texts in a different language than the first text as the third text.

[0069] It should be noted that the number of third texts can be one or more, and this embodiment of the present application does not limit this. When the number of third texts is multiple, the languages ​​of the multiple third texts can be the same or different, and this embodiment of the present application does not limit this. For example, 32 texts are obtained, of which one text is the first text, one text is the second text, and the remaining 30 texts are third texts. The language of the first text is Chinese, the language of the second text is Chinese, and the language of the third texts is English. For another example, the language of the first text is Chinese, the language of the second text is Chinese, and the language of any two third texts in the 30 third texts are different.

[0070] In one possible implementation, multiple texts input by the user can be used as the first text, the second text, and the third text, respectively. For example, a computer device displays an input page, and the input page displays at least three input boxes, wherein the first input box is an input box for the first text, the second input box is an input box for the second text, and the remaining at least one input box is an input box for the third text. The content input by the user in the first input box is used as the first text, the content input by the user in the second input box is used as the second text, and the content input by the user in the other input boxes is used as the third text. The computer device thus obtains the first text, the second text, and at least one third text.

[0071] In a possible implementation, the computer device may also obtain the first text, the second text, and at least one third text from the browser.

[0072] It should be noted that any of the above methods can be selected to obtain the first text, the second text, and the third text. The embodiment of the present application does not limit the method for obtaining the first text, the second text, and the third text.

[0073] Optionally, the initial language identification model is a model capable of determining the language corresponding to a text, and includes a contrastive learning module and a language classification module. The contrastive learning module is configured to obtain a feature vector representing the language corresponding to the text, and the language classification module is configured to determine the language corresponding to the text based on the feature vector corresponding to the text.

[0074] In the gaming field, the language distribution of the text corresponding to each game needs to be displayed to users. This is also one of the applications of language recognition in product functions. Only after the language of each text is identified can statistical display analysis be performed to provide users with analysis from a language perspective. Figure 3 The figure shows a language distribution diagram of the text corresponding to a game provided by an embodiment of the present application. Figure 3 The languages ​​of the game texts mainly include Chinese, English, Spanish, Portuguese, Japanese, French, Turkish, Arabic, Thai and other languages. Figure 3 Only the time distribution graphs for Chinese, English and Thai are shown in the figure, and the time distribution graphs for other languages ​​are not shown yet.

[0075] The texts corresponding to the game are mostly short texts, such as Figure 4 The figure shows the word count distribution diagram of a text corresponding to a game provided by an embodiment of the present application. Figure 4 Among them, there are more than 400,000 texts with 60 characters, more than 100,000 texts with 120 characters, less than 100,000 texts with 180 characters, less than 100,000 texts with 250 characters, and less than 100,000 texts with more than 250 characters.

[0076] In step 202, an initial language recognition model is called to obtain a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text.

[0077] Among them, the first feature vector, the second feature vector and the third feature vector represent the language of the first text, the second text and the third text respectively. The feature vector corresponding to each text is determined based on the segment vector of each segment included in each text, the position vector of each segment included in each text and the length vector of each text. That is, the first feature vector is determined based on the segment vector of each segment included in the first text, the position vector of each segment included in the first text and the length vector of the first text. The second feature vector is determined based on the segment vector of each segment included in the second text, the position vector of each segment included in the second text and the length vector of the second text. The third feature vector is determined based on the segment vector of each segment included in the third text, the position vector of each segment included in the third text and the length vector of the third text.

[0078] The process of calling the initial language recognition model to obtain the second feature vector corresponding to the second text and the process of calling the initial language recognition model to obtain the third feature vector corresponding to the third text are similar to the process of calling the initial language recognition model to obtain the first feature vector corresponding to the first text. This embodiment of the application only uses the process of calling the initial language recognition model to obtain the first feature vector corresponding to the first text as an example for explanation.

[0079] In one possible implementation, the process of calling the initial language recognition model to obtain a first feature vector corresponding to the first text includes: calling the initial language recognition model to obtain a first text feature vector corresponding to the first text, the first text feature vector including a first length vector of the first text, first segment vectors corresponding to each segment in the first text, and first position vectors corresponding to each segment in the first text, wherein each segment includes the same number of characters, and the number of characters included in each segment is no greater than the total number of characters in the first text. The first feature vector corresponding to the first text is determined based on the first length vector, the first segment vectors corresponding to each segment, and the first position vectors corresponding to each segment.

[0080] Optionally, the initial language recognition model performs segmentation processing on the first text to obtain multiple segments, and then determines the first segment vector corresponding to each segment and the first position vector corresponding to each segment. In the segmentation processing, a target number of words can be used as a segment, and the target number is not greater than the total number of words in the first text. The target number can be set based on experience and can also be adjusted according to the implementation environment, which is not limited in the embodiments of the present application. For example, the target number is 1. For another example, the target number is 2.

[0081] For example, the first text is "Translate this text into English" and the target value is 1, then the first text is segmented to obtain multiple segments, namely "will", "this", "paragraph", "text", "word", "translate", "for", "English", and "text".

[0082] For another example, if the first text is "Translate this text into English" and the target value is 2, the first text is segmented to obtain multiple segments, namely "translate this", "this paragraph", "paragraph", "text", "word translation", "translation", "translate into", "into English", and "English".

[0083] For another example, the first text is "Translate this text into English" and the target value is 3. Then the first text is segmented to obtain multiple segments, namely "Translate this paragraph", "This paragraph of text", "Paragraph of text", "Text translation", "Word translation", "Translate into", "Translate into English", and "Into English".

[0084] It should be noted that the dimension of the first fragment vector is the same as the dimension of the first position vector, and the dimension of the first length vector is smaller than the dimension of the first fragment vector. Exemplarily, the dimension of the first fragment vector and the dimension of the first position vector are both 64, and the dimension of the first length vector is 16.

[0085] In one possible implementation, the process of determining the first feature vector corresponding to the first text based on the first length vector, the first fragment vectors corresponding to each fragment, and the first position vector corresponding to each fragment includes: obtaining a weight vector based on the first length vector and the first fragment vectors corresponding to each fragment, the weight vector including the weights corresponding to each fragment, and the weights corresponding to each fragment are used to characterize the importance of each fragment; determining the first feature vector corresponding to the first text based on the weight vector, the first fragment vectors corresponding to each fragment, and the first position vector corresponding to each fragment.

[0086] The weight of a segment is proportional to its importance. That is, the higher the weight of a segment, the more important it is. Conversely, the lower the weight of a segment, the less important it is.

[0087] In one possible implementation, the process of obtaining a weight vector based on the first length vector and the first fragment vectors corresponding to each fragment includes: performing nonlinear processing on the first length vector to obtain a first reference feature vector; cross-multiplying the first reference feature vector with the first fragment vectors corresponding to each fragment to obtain the weight corresponding to each fragment; and obtaining a weight vector based on the weight corresponding to each fragment.

[0088] Optionally, the initial language recognition model includes fully connected layers (FCs), and the first length vector is input into the FCs to obtain a first reference feature vector. The first reference feature vector has a better representation capability than the first length vector. The dimension of the first reference feature vector is the same as the dimension of the first length vector. The fully connected layers are primarily used to perform a mapping operation on the first length vector.

[0089] Exemplarily, the first reference eigenvector is determined according to the following formula (1).

[0090] L=tanh(W W P+b W ) Formula (1)

[0091] In the above formula (1), L is the first reference eigenvector, tanh is the nonlinear function, P is the first length vector, and W is the W is the first model parameter, b W The first model parameter and the second model parameter are both set based on experience or adjusted according to the implementation environment, which is not limited in the present embodiment.

[0092] Optionally, the weight corresponding to each segment is determined according to the following formula (2) based on the first reference feature vector and the first segment vector corresponding to each segment.

[0093] W i =softmax(UL) Formula (2)

[0094] In the above formula (2), W i is the weight corresponding to the i-th segment, softmax is an activation function, U is the first segment vector of the i-th segment, and L is the first reference feature vector.

[0095] It should be noted that the process of determining the weight corresponding to each segment can be determined according to the above formula (2), which will not be described in detail here.

[0096] After obtaining the weights corresponding to each fragment, the position of the weight corresponding to each fragment in the weight vector is determined according to the position of each fragment in the first text, and the weight vector is obtained according to the position of the weight corresponding to each fragment in the weight vector. The position of the weight corresponding to each fragment in the weight vector is the same as the position of each fragment in the first text.

[0097] Exemplarily, the multiple segments included in the first text are respectively "将", "这", "段", "文", "字", "翻", "译", "为", "英", "文". Among them, the weight corresponding to the segment "将" is 0.1, the weight corresponding to the segment "这" is 0.2, the weight corresponding to the segment "段" is 0.3, the weight corresponding to the segment "文" is 0.4, the weight corresponding to the segment "字" is 0.5, the weight corresponding to the segment "翻" is 0.6, the weight corresponding to the segment "译" is 0.7, the weight corresponding to the segment "为" is 0.8, the weight corresponding to the segment "英" is 0.9, and the weight corresponding to the segment "文" is 0.1. Furthermore, according to the positions of each segment and the weights corresponding to each segment, the weight vector is obtained as (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1).

[0098] Optionally, after obtaining the weights corresponding to each segment, a candidate vector can also be determined according to the weights corresponding to each segment and the positions of each segment in the first text. The positions of the weights corresponding to each segment in the candidate vector are the same as the positions of each segment in the first text, and the candidate vector is normalized to obtain the weight vector.

[0099] The embodiments of this application do not limit the process of determining the first feature vector corresponding to the first text according to the weight vector, the first segment vectors corresponding to each segment, and the first position vectors corresponding to each segment. In a possible implementation, according to the first segment vectors corresponding to each segment and the first position vectors corresponding to each segment, a second reference feature vector is determined, and the second reference feature vector is used to characterize the language of the first text; the values in the same dimension of the weight vector and the second reference feature vector are multiplied to obtain the first feature vector corresponding to the first text.

[0100] Among them, the process of determining the second reference feature vector according to the first segment vectors corresponding to each segment and the first position vectors corresponding to each segment includes: determining the target vectors corresponding to each segment according to the first segment vectors corresponding to each segment and the first position vectors corresponding to each segment, and the target vectors corresponding to each segment are used to characterize each segment; the target vectors corresponding to each segment are combined to form the second reference feature vector.

[0101] The embodiments of this application do not limit the process of determining the target vectors corresponding to each segment. For the target vector corresponding to any one of the segments, the values in the same dimension of the first segment vector corresponding to any one of the segments and the first position vector corresponding to any one of the segments are added to obtain the intermediate vector corresponding to any one of the segments, and the target vector corresponding to any one of the segments is obtained according to the intermediate vector corresponding to any one of the segments.

[0102] Optionally, the initial language recognition model includes a convolutional layer. The process of obtaining a target vector corresponding to any segment based on the intermediate vector corresponding to any segment includes inputting the intermediate vector corresponding to any segment into the convolutional layer to obtain the target vector corresponding to any segment. The convolutional layer is primarily used to perform a convolution operation on the intermediate vector to extract features.

[0103] Exemplarily, the first fragment vector corresponding to any fragment is (1, 2, 3, 3, 4, 5), and the first position vector corresponding to any fragment is (0, 1, 0, 0, 0, 0), then the intermediate vector corresponding to any fragment is (1, 3, 3, 3, 4, 5).

[0104] After determining the target vectors corresponding to the respective segments, the process of combining the target vectors corresponding to the respective segments into a second reference feature vector includes: splicing the target vectors corresponding to the respective segments according to their positions in the first text to obtain the second reference feature vector.

[0105] Optionally, the first feature vector corresponding to the first text is determined according to the following formula (3) based on the weight vector and the second reference feature vector. The first feature vector is a vector for representing the language of the first text obtained after considering the importance of each segment included in the first text.

[0106] Z=H*W=(W1Q1,W2Q2,W3Q3,…,W N Q N ) Formula (3)

[0107] In the above formula (3), Z is the first feature vector corresponding to the first text, H is the second reference feature vector, W is the weight vector, and the weight vector is (W1, W2, W3, ..., W N ), the second reference eigenvector is (Q1,Q2,Q3,…,Q N ).

[0108] It should be noted that the process of determining the second feature vector corresponding to the second text and the third feature vector corresponding to the third text is similar to the process of determining the first feature vector corresponding to the first text, and will not be described in detail here.

[0109] like Figure 5 The diagram shows a process of determining the first feature vector corresponding to the first text provided by the embodiment of the present application. Figure 5In the first text, the first segment vector, first position vector, and first length vector of each segment are obtained. The first length vector is input into the FC layer to obtain the first reference feature vector (L vector). The first segment vector and first position vector of each segment are summed and input into the convolution layer to obtain the second reference feature vector (H vector). The H vector and L vector are input into the attention layer to obtain the first feature vector of the first text. The attention layer can be replaced by a gate.

[0110] In step 203 , a first loss value is determined based on the first eigenvector, the second eigenvector, and the third eigenvector.

[0111] The first loss value is used to represent the relationship between the first similarity and the second similarity. The first similarity is the language similarity between the first and second texts, and the second similarity is the language similarity between the first and third texts. A smaller first loss value indicates a larger gap between the first and second similarities, while a larger first loss value indicates a smaller gap between the first and second similarities.

[0112] Optionally, the process of determining the first loss value according to the first eigenvector, the second eigenvector and the third eigenvector includes: determining a first similarity according to the first eigenvector and the second eigenvector, the first similarity being used to indicate the similarity between the language of the first text and the language of the second text; determining a second similarity according to the first eigenvector and the third eigenvector, the second similarity being used to indicate the similarity between the language of the first text and the language of the third text; calling a target loss function according to the first similarity and the second similarity to determine the first loss value. Wherein, the target loss function can be any loss function, and the embodiment of the present application does not limit this. Exemplarily, the target loss function is a logarithmic loss (Log-likelihood Loss) function, and the log function is also called a logistic regression loss (Logistic Loss) function or a cross-entropy loss (cross-entropy Loss) function, which is a 0-1 loss function.

[0113] In a possible implementation, the first loss value is determined according to the following formula (4) based on the first eigenvector, the second eigenvector, and the third eigenvector.

[0114]

[0115] In the above formula (4), Loss is the first loss value, r i is the first eigenvector, r j is the second eigenvector, r kis the third eigenvector, τ is the model parameter, sim is the similarity, and 2N is the number of the third eigenvector.

[0116] Figure 6 FIG. 1 is a schematic diagram of a process for determining a first loss value provided by an embodiment of the present application, as shown in FIG. Figure 6 As shown, through the encoding layer and the pooling layer, a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text are obtained. Then, a first similarity is determined based on the first feature vector and the second feature vector, a second similarity is determined based on the first feature vector and the third feature vector, and a first loss value is determined based on the first similarity and the second similarity.

[0117] In step 204 , based on the first loss value being greater than the loss threshold, the initial language recognition model is updated to obtain a target language recognition model.

[0118] The target language recognition model is used to identify the language corresponding to the text. The loss threshold is set based on experience or adjusted according to the implementation environment, and is not limited in this embodiment of the present application. For example, the loss threshold is 0.8.

[0119] Optionally, based on the first loss value being greater than the loss threshold, the initial language recognition model is updated to obtain the target language recognition model. The process includes: based on the first loss value being greater than the loss threshold, the initial language recognition model is updated to obtain an intermediate language recognition model; calling the intermediate language recognition model to obtain a first intermediate vector corresponding to the first text, a second intermediate vector corresponding to the second text, and a third intermediate vector corresponding to the third text, where the first intermediate vector, the second intermediate vector, and the third intermediate vector respectively represent the language of the first text, the second text, and the third text, and each intermediate vector is determined based on the segment vectors of each segment included in each text, the position vectors of each segment included in each text, and the length vector of each text; determining a second loss value based on the first intermediate vector, the second intermediate vector, and the third intermediate vector, where the second loss value is used to represent the relationship between the first similarity and the second similarity; and based on the second loss value being not greater than the loss threshold, using the intermediate language recognition model as the target language recognition model. Based on the fact that the second loss value is still greater than the loss threshold, the intermediate language recognition model continues to be updated until the first text, the second text, and the third text are processed based on the updated language recognition model to obtain the vectors corresponding to each text. The loss value determined based on the vectors corresponding to each text is not greater than the loss threshold, and the updated language recognition model is used as the target language recognition model.

[0120] Optionally, based on the first loss value being greater than the loss threshold, the initial language recognition model is updated to obtain the intermediate language recognition model. The process includes: based on the first loss value being greater than the loss threshold, the parameters included in the contrastive learning module in the initial language recognition model are updated to obtain the intermediate language recognition model.

[0121] The feature vectors corresponding to each text determined by the above method are based on the segment vectors of each segment included in the text, the position vectors of each segment included in each text, and the length vector of each text. This takes into account a number of factors, resulting in a higher degree of match between the feature vectors corresponding to the text and the text, enabling better text representation. Furthermore, due to the high degree of match between the feature vectors corresponding to the text and the text, the accuracy of the loss value determined using the feature vectors corresponding to each text is also high, which in turn increases the recognition accuracy of the target language recognition model determined based on the loss value.

[0122] In addition, since the language of the first text is the same as the language of the second text, and the language of the first text is different from the language of the third text, the initial language recognition model is updated according to the feature vectors corresponding to the first text, the second text, and the third text respectively. The resulting target language recognition model can narrow the distance between the same languages ​​and widen the distance between different languages, thereby making the language recognition accuracy of the target language recognition model higher and the language recognition effect better.

[0123] The present invention provides a method for language recognition, which can be applied to the above Figure 1 The language recognition method is executed by a computer device, which may be a terminal device 101 or a server 102, and the present embodiment does not limit this. Figure 7 Taking the flowchart of a language recognition method provided in the embodiment of the present application as an example, the method includes the following steps 701 to 703.

[0124] In step 701, the target text to be recognized and the target language recognition model are obtained. The target language recognition model is Figure 2 The embodiment shown provides a method for obtaining a language recognition model.

[0125] The embodiment of the present application does not limit the method for obtaining the target text. Exemplarily, there are the following four methods for obtaining the target text.

[0126] Method 1: A plurality of candidate texts to be language recognized are stored in the storage space of the computer device, and a candidate text is randomly determined in the storage space of the computer device as the target text.

[0127] Exemplarily, three candidate texts are stored in the storage space of the computer device, and one candidate text is randomly determined from the three candidate texts as the target text.

[0128] Method 2: Use the text entered by the user as the target text.

[0129] Optionally, a text input box and a confirmation control are displayed, the text input box is used for the user to input text, and in response to an operation instruction for the confirmation control, the computer device detects whether there is content in the text input box. Based on the content in the text input box, the computer device uses the content in the text input box as the target text.

[0130] Method 3: Determine a text from the browser as the target text.

[0131] Method 4: Obtain the target speech, convert the target speech, obtain the text corresponding to the target speech, and use the text corresponding to the target speech as the target text.

[0132] The embodiment of the present application does not limit the method for converting the target speech. Optionally, an application for converting speech to text is installed and running in the computer device, and the application is called to convert the target speech to obtain text corresponding to the target speech.

[0133] Among them, the application can be any type of application. The application can be an application that needs to be downloaded and installed, or it can refer to an embedded program that relies on a host program to run, such as a mini-program. The embodiments of the present application do not limit this. An embedded program is an application developed based on a programming language and relies on a host program to run. An embedded program does not need to be downloaded and installed, but can be run by dynamically loading it in the host program. Users can find the embedded program they need by searching, scanning, etc., click to open it, and it will not occupy the terminal's memory after closing it after use, which is very convenient.

[0134] It should be noted that any of the above methods can be selected to obtain the target text, and the embodiments of the present application do not limit this.

[0135] In step 702, a target language recognition model is called to obtain a target feature vector corresponding to the target text. The target feature vector is used to represent the language of the target text.

[0136] Optionally, the target feature vector is determined based on the segment vectors of each segment included in the target text, the position vectors of each segment included in the target text, and the length vector of the target text. The process of calling the target language recognition model to obtain the target feature vector corresponding to the target text includes: calling the target language recognition model to obtain the target text feature vector corresponding to the target text, the target text feature vector includes the target length vector of the target text, the target segment vector corresponding to each segment in the target text, and the target position vector corresponding to each segment in the target text, and the number of characters included in each segment is the same and is not greater than the total number of characters in the target text. The target feature vector corresponding to the target text is determined based on the target length vector, the target segment vector corresponding to each segment, and the target position vector corresponding to each segment.

[0137] Among them, the process of calling the target language recognition model to obtain the target text feature vector corresponding to the target text is similar to the process of calling the initial language recognition model in the above step 202 to obtain the first text feature vector corresponding to the first text. The process of determining the target feature vector corresponding to the target text according to the target length vector, the target segment vectors corresponding to each segment, and the target position vector corresponding to each segment is similar to the process of determining the first feature vector corresponding to the first text according to the first length vector, the first segment vector corresponding to each segment, and the first position vector corresponding to each segment in the above step 202, and will not be repeated here.

[0138] In step 703, the language corresponding to the target text is determined based on the target feature vector.

[0139] In one possible implementation, the process of obtaining the language corresponding to the target text based on the target feature vector includes: there are language feature vectors corresponding to each language in the target language recognition model, determining the similarity between the target feature vector and each language feature vector, and taking the language corresponding to the language feature vector whose similarity with the target feature vector meets the similarity requirements as the language corresponding to the target text.

[0140] The language feature vector whose similarity to the target feature vector meets the similarity requirement refers to the language feature vector with the highest similarity to the target feature vector.

[0141] The target language recognition model obtained in the above method has high recognition accuracy and good recognition effect. Therefore, the target language recognition model with high recognition accuracy and good recognition effect is used to recognize the target text, so that the accuracy of the language corresponding to the obtained target text is high.

[0142] Figure 8The figure shows a flow chart of a language identification method provided by an embodiment of the present application. The method includes a training phase and a prediction phase. In the training phase, the annotated text (text annotated with a language) is sent to a contrastive learning module for pre-training of feature vectors. The main purpose of this step is to widen the distance between similar languages ​​from the feature vector layer. The input of the contrastive learning module is the text annotated with a language, and the input is the feature vector corresponding to the pre-trained text. Through the contrastive learning module, the feature vector corresponding to the text is obtained, and the classification model is trained based on the feature vector corresponding to the text. The input of this module is the feature vector corresponding to the text, and the output is the classification model, so as to predict the language corresponding to the text.

[0143] In the prediction stage, for a large amount of unlabeled text (text not labeled with language), prediction is performed using the model obtained in the training stage to obtain the language corresponding to the text.

[0144] Figure 9 This is a language recognition improvement curve provided by the embodiment of this application. Figure 9 It can be seen that the recognition accuracy of the baseline model is 0.5, the recognition accuracy of the preprocessing model is 0.64, the recognition accuracy of the low-frequency mining model is 0.72, the recognition accuracy of the data enhancement model is 0.78, and the recognition accuracy of the comparative learning model is 0.81.

[0145] Table 1 below shows the recognition accuracy of various language recognition models provided in the embodiments of the present application in various languages.

[0146] Table 1

[0147]

[0148] As shown in Table 1, the baseline model achieved recognition accuracy of 0.47 for English, 0.73 for Indonesian, 0.29 for Italian, 0.75 for German, 0.46 for Persian, and 0.33 for Dutch. The average recognition accuracy of the baseline model was 0.5. The recognition accuracy and average accuracy of the other models for each language are shown in Table 1 and are not detailed here.

[0149] It should be noted that the average recognition accuracy of the preprocessing model increased by 0.14 compared to the average recognition accuracy of the baseline model. The average recognition accuracy of the low-frequency mining model increased by 0.086 compared to the average recognition accuracy of the preprocessing model. The average recognition accuracy of the data augmentation model increased by 0.062 compared to the average recognition accuracy of the low-frequency mining model. The average recognition accuracy of the comparative learning model increased by 0.023 compared to the average recognition accuracy of the data augmentation model.

[0150] Figure 10 FIG. 1 is a schematic diagram of a structure of a device for acquiring a language recognition model provided in an embodiment of the present application. Figure 10 As shown, the device includes:

[0151] An acquisition module 1001 is configured to acquire a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are in the same language, and the first text and the third text are in different languages;

[0152] The acquisition module 1001 is further configured to call an initial language identification model to acquire a first feature vector corresponding to a first text, a second feature vector corresponding to a second text, and a third feature vector corresponding to a third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the language of the first text, the second text, and the third text, and the feature vector corresponding to each text is determined based on a segment vector of each segment included in each text, a position vector of each segment included in each text, and a length vector of each text;

[0153] Determining module 1002, configured to determine a first loss value based on the first eigenvector, the second eigenvector, and the third eigenvector, where the first loss value is used to represent a relationship between a first similarity and a second similarity, where the first similarity is the similarity between the languages ​​of the first text and the second text, and the second similarity is the similarity between the languages ​​of the first text and the third text;

[0154] The updating module 1003 is configured to update the initial language recognition model based on the first loss value being greater than the loss threshold to obtain a target language recognition model, where the target language recognition model is used to identify the language corresponding to the text.

[0155] In one possible implementation, the acquisition module 1001 is used to call the initial language recognition model to obtain a first text feature vector corresponding to the first text, where the first text feature vector includes a first length vector of the first text, first fragment vectors corresponding to each fragment in the first text, and first position vectors corresponding to each fragment in the first text; and determine the first feature vector corresponding to the first text based on the first length vector, the first fragment vectors corresponding to each fragment, and the first position vectors corresponding to each fragment.

[0156] In one possible implementation, the acquisition module 1001 is used to obtain a weight vector based on the first length vector and the first fragment vector corresponding to each fragment, where the weight vector includes the weight corresponding to each fragment, and the weight corresponding to each fragment is used to characterize the importance of each fragment; and determine the first feature vector corresponding to the first text based on the weight vector, the first fragment vector corresponding to each fragment, and the first position vector corresponding to each fragment.

[0157] In a possible implementation, the acquisition module 1001 is configured to perform nonlinear processing on the first length vector to obtain a first reference eigenvector; and perform cross-product on the first reference eigenvector and the first segment vector corresponding to each segment to obtain a weight vector.

[0158] In one possible implementation, the acquisition module 1001 is used to determine a second reference feature vector based on the first segment vector corresponding to each segment and the first position vector corresponding to each segment, where the second reference feature vector is used to represent the language of the first text; and the weight vector and the numerical values ​​in the same dimension in the second reference feature vector are multiplied to obtain the first feature vector corresponding to the first text.

[0159] In one possible implementation, the acquisition module 1001 is used to determine the target vector corresponding to each fragment based on the first fragment vector corresponding to each fragment and the first position vector corresponding to each fragment, and the target vector corresponding to each fragment is used to characterize each fragment; the target vectors corresponding to each fragment are combined into a second reference feature vector.

[0160] In one possible implementation, the acquisition module 1001 is used to add the values ​​of the same dimension in the first fragment vector corresponding to any fragment and the first position vector corresponding to any fragment for any fragment to obtain an intermediate vector corresponding to any fragment; and obtain a target vector corresponding to any fragment based on the intermediate vector corresponding to any fragment.

[0161] In one possible implementation, the determination module 1002 is used to determine a first similarity based on the first feature vector and the second feature vector, where the first similarity is used to indicate the similarity between the language of the first text and the language of the second text; determine a second similarity based on the first feature vector and the third feature vector, where the second similarity is used to indicate the similarity between the language of the first text and the language of the third text; and call a target loss function based on the first similarity and the second similarity to determine a first loss value.

[0162] In one possible implementation, the updating module 1003 is configured to update the initial language recognition model based on the first loss value being greater than the loss threshold to obtain an intermediate language recognition model; call the intermediate language recognition model to obtain a first intermediate vector corresponding to the first text, a second intermediate vector corresponding to the second text, and a third intermediate vector corresponding to the third text, where the first intermediate vector, the second intermediate vector, and the third intermediate vector respectively represent the languages ​​of the first text, the second text, and the third text; determine the second loss value based on the first intermediate vector, the second intermediate vector, and the third intermediate vector; and use the intermediate language recognition model as the target language recognition model based on the second loss value being no greater than the loss threshold.

[0163] The feature vectors corresponding to each text determined by the above-mentioned device are based on the segment vectors of each segment included in the text, the position vectors of each segment included in each text, and the length vector of each text. This takes into account a variety of factors, resulting in a higher degree of match between the feature vectors corresponding to the text and the text, enabling better text representation. Furthermore, due to the high degree of match between the feature vectors corresponding to the text and the text, the accuracy of the loss value determined using the feature vectors corresponding to each text is also high, thereby increasing the recognition accuracy of the target language recognition model determined based on the loss value.

[0164] In addition, since the language of the first text is the same as the language of the second text, and the language of the first text is different from the language of the third text, the initial language recognition model is updated according to the feature vectors corresponding to the first text, the second text, and the third text respectively. The resulting target language recognition model can narrow the distance between the same languages ​​and widen the distance between different languages, thereby making the language recognition accuracy of the target language recognition model higher and the language recognition effect better.

[0165] Figure 11 FIG. 1 is a schematic diagram of the structure of a language recognition device provided in an embodiment of the present application. Figure 11 As shown, the device includes:

[0166] The acquisition module 1101 is used to obtain the target text to be recognized and the target language recognition model. Figure 10 The language recognition model acquisition device obtains;

[0167] The acquisition module 1101 is further configured to call the target language recognition model to obtain a target feature vector corresponding to the target text. The target feature vector is used to represent the language of the target text. The target feature vector is determined based on the segment vectors of each segment included in the target text, the position vectors of each segment included in the target text, and the length vector of the target text.

[0168] The determination module 1102 is configured to determine the language corresponding to the target text according to the target feature vector.

[0169] In one possible implementation, the acquisition module 1101 is used to call the target language recognition model to obtain the target text feature vector corresponding to the target text, where the target text feature vector includes the target length vector of the target text, the target segment vectors corresponding to each segment in the target text, and the target position vector corresponding to each segment in the target text; the target feature vector corresponding to the target text is determined based on the target length vector, the target segment vectors corresponding to each segment, and the target position vector corresponding to each segment.

[0170] The target language recognition model obtained in the above device has high recognition accuracy and high recognition effect. Therefore, the target language recognition model with high recognition accuracy and good recognition effect is used to recognize the target text, so that the language corresponding to the obtained target text has high accuracy.

[0171] It should be understood that the above-mentioned device is merely an example of the division of the above-mentioned functional modules when implementing its functions. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments are based on the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0172] Figure 12 The following is a block diagram of a terminal device 1200 according to an exemplary embodiment of the present application. Terminal device 1200 may be a portable mobile terminal, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. Terminal device 1200 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other similar names.

[0173] Typically, the terminal device 1200 includes a processor 1201 and a memory 1202 .

[0174] The processor 1201 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1201 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1201 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1201 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1201 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0175] The memory 1202 may include one or more computer-readable storage media, which may be non-transitory. The memory 1202 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1202 is used to store at least one instruction, which is used to be executed by the processor 1201 to implement the present application. Figure 2 The method for obtaining the language recognition model provided by the method embodiment shown, and / or, to implement the present application Figure 7 The illustrated method embodiment provides a language recognition method.

[0176] In some embodiments, terminal device 1200 may optionally include a peripheral device interface 1203 and at least one peripheral device. The processor 1201, memory 1202, and peripheral device interface 1203 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1203 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1204, a display screen 1205, a camera assembly 1206, an audio circuit 1207, and a power supply 1209.

[0177] The peripheral device interface 1203 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1201 and the memory 1202. In some embodiments, the processor 1201, the memory 1202, and the peripheral device interface 1203 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1201, the memory 1202, and the peripheral device interface 1203 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0178] The RF circuit 1204 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1204 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1204 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the RF circuit 1204 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. The RF circuit 1204 can communicate with other terminal devices via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1204 may also include circuitry related to Near Field Communication (NFC), which is not limited in this application.

[0179] The display screen 1205 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1205 is a touch screen display, the display screen 1205 also has the ability to collect touch signals on the surface or above the surface of the display screen 1205. The touch signal can be input as a control signal to the processor 1201 for processing. In this case, the display screen 1205 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there can be one display screen 1205, which is set on the front panel of the terminal device 1200; in other embodiments, there can be at least two display screens 1205, which are respectively set on different surfaces of the terminal device 1200 or in a folding design; in other embodiments, the display screen 1205 can be a flexible display screen, which is set on the curved surface or folding surface of the terminal device 1200. Even more, the display screen 1205 can be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1205 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0180] The camera assembly 1206 is used to capture images or videos. Optionally, the camera assembly 1206 includes a front camera and a rear camera. Typically, the front camera is arranged on the front panel of the terminal device 1200, and the rear camera is arranged on the back of the terminal device 1200. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 1206 may also include a flash. The flash can be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0181] The audio circuit 1207 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input into the processor 1201 for processing, or input into the RF circuit 1204 to achieve voice communication. For the purpose of stereo sound collection or noise reduction, there can be multiple microphones, each located in different parts of the terminal device 1200. The microphone can also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert electrical signals from the processor 1201 or the RF circuit 1204 into sound waves. The speaker can be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 1207 may also include a headphone jack.

[0182] The power supply 1209 is used to power the various components in the terminal device 1200. The power supply 1209 can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When the power supply 1209 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.

[0183] In some embodiments, the terminal device 1200 further includes one or more sensors 1210 , including but not limited to: an acceleration sensor 1211 , a gyroscope sensor 1212 , a pressure sensor 1213 , an optical sensor 1215 , and a proximity sensor 1216 .

[0184] The accelerometer 1211 can detect the magnitude of acceleration along the three coordinate axes of the coordinate system established by the terminal device 1200. For example, the accelerometer 1211 can be used to detect the components of gravity acceleration along the three coordinate axes. The processor 1201 can control the display screen 1205 to display the user interface in a landscape or portrait view based on the gravity acceleration signal collected by the accelerometer 1211. The accelerometer 1211 can also be used to collect game or user motion data.

[0185] The gyroscope sensor 1212 can detect the body orientation and rotation angle of the terminal device 1200. The gyroscope sensor 1212 can work with the acceleration sensor 1211 to collect the user's 3D movements of the terminal device 1200. Based on the data collected by the gyroscope sensor 1212, the processor 1201 can implement the following functions: motion sensing (such as changing the UI based on the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.

[0186] The pressure sensor 1213 can be set on the side frame of the terminal device 1200 and / or the lower layer of the display screen 1205. When the pressure sensor 1213 is set on the side frame of the terminal device 1200, it can detect the user's grip signal of the terminal device 1200, and the processor 1201 performs left and right hand recognition or shortcut operations based on the grip signal collected by the pressure sensor 1213. When the pressure sensor 1213 is set on the lower layer of the display screen 1205, the processor 1201 controls the operable controls on the UI interface based on the user's pressure operation on the display screen 1205. The operable controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.

[0187] Optical sensor 1215 is used to detect ambient light intensity. In one embodiment, processor 1201 can control the display brightness of display screen 1205 based on the ambient light intensity detected by optical sensor 1215. Specifically, when the ambient light intensity is high, the display brightness of display screen 1205 is increased; when the ambient light intensity is low, the display brightness of display screen 1205 is decreased. In another embodiment, processor 1201 can also dynamically adjust the shooting parameters of camera assembly 1206 based on the ambient light intensity detected by optical sensor 1215.

[0188] Proximity sensor 1216, also known as a distance sensor, is typically located on the front panel of terminal device 1200. Proximity sensor 1216 is used to detect the distance between the user and the front of terminal device 1200. In one embodiment, when proximity sensor 1216 detects that the distance between the user and the front of terminal device 1200 is gradually decreasing, processor 1201 controls display screen 1205 to switch from the screen-on state to the screen-off state. When proximity sensor 1216 detects that the distance between the user and the front of terminal device 1200 is gradually increasing, processor 1201 controls display screen 1205 to switch from the screen-off state to the screen-on state.

[0189] Those skilled in the art will understand that Figure 12 The structure shown in the figure does not constitute a limitation on the terminal device 1200, and the terminal device 1200 may include more or fewer components than shown in the figure, or combine certain components, or adopt a different component arrangement.

[0190] Figure 13The server 1300 may have different configurations or performances, and may include one or more processors (CPUs) 1301 and one or more memories 1302. The one or more memories 1302 store at least one program code, which is loaded and executed by the one or more processors 1301 to implement the above-mentioned Figure 2 The method embodiment shown provides a method for obtaining a language recognition model, and / or to achieve the above Figure 7 The language recognition method provided by the method embodiment shown. Of course, the server 1300 may also have components such as a wired or wireless network interface, a keyboard, and an input / output interface for input and output. The server 1300 may also include other components for implementing device functions, which will not be described in detail here.

[0191] In an exemplary embodiment, a computer-readable storage medium is further provided, wherein at least one program code is stored in the storage medium, and the at least one program code is loaded and executed by a processor to enable the computer to implement the above Figure 2 The method embodiment shown provides a method for obtaining a language recognition model, and / or to achieve the above Figure 7 The illustrated method embodiment provides a language recognition method.

[0192] Optionally, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, or the like.

[0193] In an exemplary embodiment, a computer program or a computer program product is further provided. The computer program or the computer program product stores at least one computer instruction, and the at least one computer instruction is loaded and executed by a processor to enable the computer to implement the above Figure 2 The method embodiment shown provides a method for obtaining a language recognition model, and / or to achieve the above Figure 7 The illustrated method embodiment provides a language recognition method.

[0194] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, storage, display, etc.), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the text involved in this application was obtained with full authorization.

[0195] It should be understood that the term "plurality" used herein refers to two or more. "And / or" describes a relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates an "or" relationship between the associated objects.

[0196] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0197] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.

Claims

1. A method for obtaining a language recognition model, characterized in that: The method comprises: Obtaining a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are in the same language, and the first text and the third text are in different languages; Invoking the initial language identification model to obtain a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the language of the first text, the second text, and the third text, and the feature vector corresponding to each text is determined based on a segment vector of each segment included in each text, a position vector of each segment included in each text, and a length vector of each text; Determining a first loss value based on the first feature vector, the second feature vector, and the third feature vector, where the first loss value is used to represent a relationship between a first similarity and a second similarity, where the first similarity is the similarity between the languages ​​of the first text and the second text, and the second similarity is the similarity between the languages ​​of the first text and the third text; Based on the first loss value being greater than a loss threshold, the initial language recognition model is updated to obtain a target language recognition model, where the target language recognition model is used to recognize the language corresponding to the text.

2. The method according to claim 1, characterized in that The calling the initial language recognition model to obtain a first feature vector corresponding to the first text includes: Invoking the initial language recognition model to obtain a first text feature vector corresponding to the first text, where the first text feature vector includes a first length vector of the first text, a first segment vector corresponding to each segment in the first text, and a first position vector corresponding to each segment in the first text; A first feature vector corresponding to the first text is determined according to the first length vector, the first segment vectors corresponding to the respective segments, and the first position vectors corresponding to the respective segments.

3. The method according to claim 2, characterized in that The determining, based on the first length vector, the first segment vectors corresponding to the respective segments, and the first position vectors corresponding to the respective segments, of the first feature vector corresponding to the first text includes: Obtaining a weight vector according to the first length vector and the first fragment vectors corresponding to the respective fragments, wherein the weight vector includes weights corresponding to the respective fragments, and the weights corresponding to the respective fragments are used to represent the importance of the respective fragments; A first feature vector corresponding to the first text is determined according to the weight vector, the first segment vector corresponding to each segment, and the first position vector corresponding to each segment.

4. The method according to claim 3, characterized in that The obtaining of a weight vector according to the first length vector and the first segment vectors corresponding to the segments includes: Performing nonlinear processing on the first length vector to obtain a first reference eigenvector; The first reference feature vector is cross-multiplied with the first segment vector corresponding to each segment to obtain the weight vector.

5. The method according to claim 3, characterized in that Determining the first feature vector corresponding to the first text according to the weight vector, the first segment vector corresponding to each segment, and the first position vector corresponding to each segment includes: determining a second reference feature vector according to the first segment vectors corresponding to the respective segments and the first position vectors corresponding to the respective segments, wherein the second reference feature vector is used to represent the language of the first text; The weight vector and the values ​​in the same dimension in the second reference feature vector are multiplied to obtain a first feature vector corresponding to the first text.

6. The method according to claim 5, characterized in that The determining of the second reference feature vector according to the first segment vector corresponding to each segment and the first position vector corresponding to each segment includes: Determining a target vector corresponding to each fragment according to the first fragment vector corresponding to each fragment and the first position vector corresponding to each fragment, wherein the target vector corresponding to each fragment is used to represent each fragment; The target vectors corresponding to the respective segments are combined into the second reference feature vector.

7. The method according to claim 6, characterized in that The determining, based on the first fragment vectors corresponding to the respective fragments and the first position vectors corresponding to the respective fragments, the target vectors corresponding to the respective fragments includes: For any one of the segments, add the values ​​of the first segment vector corresponding to the segment and the first position vector corresponding to the segment, which are located in the same dimension, to obtain an intermediate vector corresponding to the segment; According to the intermediate vector corresponding to any one of the segments, a target vector corresponding to the any one of the segments is obtained.

8. The method according to any one of claims 1 to 7, characterized in that: The determining a first loss value according to the first eigenvector, the second eigenvector, and the third eigenvector includes: determining a first similarity based on the first feature vector and the second feature vector, wherein the first similarity is used to indicate a similarity between a language of the first text and a language of the second text; determining a second similarity based on the first feature vector and the third feature vector, wherein the second similarity is used to indicate a similarity between the language of the first text and the language of the third text; According to the first similarity and the second similarity, a target loss function is called to determine the first loss value.

9. The method according to any one of claims 1 to 7, characterized in that: The updating of the initial language recognition model based on the first loss value being greater than a loss threshold to obtain a target language recognition model includes: Based on the first loss value being greater than the loss threshold, updating the initial language recognition model to obtain an intermediate language recognition model; Invoking the intermediate language recognition model to obtain a first intermediate vector corresponding to the first text, a second intermediate vector corresponding to the second text, and a third intermediate vector corresponding to the third text, where the first intermediate vector, the second intermediate vector, and the third intermediate vector represent the languages ​​of the first text, the second text, and the third text, respectively; determining a second loss value according to the first intermediate vector, the second intermediate vector, and the third intermediate vector; Based on the second loss value being no greater than the loss threshold, the intermediate language recognition model is used as the target language recognition model.

10. A language identification method, characterized in that: The method comprises: Obtaining a target text to be language-recognized and a target language recognition model, wherein the target language recognition model is obtained by the language recognition model acquisition method according to any one of claims 1 to 9; Calling the target language recognition model to obtain a target feature vector corresponding to the target text, the target feature vector being used to characterize the language of the target text, the target feature vector being determined based on segment vectors of each segment included in the target text, position vectors of each segment included in the target text, and a length vector of the target text; The language corresponding to the target text is determined according to the target feature vector.

11. The method according to claim 10, characterized in that The calling of the target language recognition model to obtain a target feature vector corresponding to the target text includes: Calling the target language recognition model to obtain a target text feature vector corresponding to the target text, wherein the target text feature vector includes a target length vector of the target text, a target segment vector corresponding to each segment in the target text, and a target position vector corresponding to each segment in the target text; A target feature vector corresponding to the target text is determined according to the target length vector, the target segment vectors corresponding to the respective segments, and the target position vectors corresponding to the respective segments.

12. A device for acquiring a language recognition model, characterized in that: The device comprises: an acquisition module, configured to acquire a first text, a second text, a third text, and an initial language recognition model, wherein the first text and the second text are in the same language, and the first text and the third text are in different languages; The acquisition module is further configured to call the initial language identification model to acquire a first feature vector corresponding to the first text, a second feature vector corresponding to the second text, and a third feature vector corresponding to the third text, wherein the first feature vector, the second feature vector, and the third feature vector respectively represent the language of the first text, the second text, and the third text, and the feature vector corresponding to each text is determined based on a segment vector of each segment included in each text, a position vector of each segment included in each text, and a length vector of each text; a determination module, configured to determine a first loss value based on the first feature vector, the second feature vector, and the third feature vector, wherein the first loss value is used to represent a relationship between a first similarity and a second similarity, wherein the first similarity is the similarity between the languages ​​of the first text and the second text, and the second similarity is the similarity between the languages ​​of the first text and the third text; An updating module is configured to update the initial language recognition model based on the first loss value being greater than a loss threshold to obtain a target language recognition model, wherein the target language recognition model is used to identify the language corresponding to the text.

13. A language recognition device, characterized in that: The device comprises: an acquisition module, configured to acquire a target text to be language-recognized and a target language recognition model, wherein the target language recognition model is acquired by the language recognition model acquisition device according to claim 12; The acquisition module is further configured to call the target language recognition model to obtain a target feature vector corresponding to the target text, the target feature vector being used to characterize the language of the target text, and the target feature vector being determined based on the segment vectors of each segment included in the target text, the position vectors of each segment included in the target text, and the length vector of the target text; A determination module is used to determine the language corresponding to the target text according to the target feature vector.

14. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one program code, and the at least one program code is loaded and executed by the processor so that the computer device implements the method for acquiring a language recognition model as described in any one of claims 1 to 9, or so that the computer device implements the language recognition method as described in claim 10 or 11.

15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to enable the computer to implement the method for obtaining a language recognition model as described in any one of claims 1 to 9, or to enable the computer to implement the language recognition method as described in claim 10 or 11.

Citation Information

Patent Citations

  • Model training method, related device and equipment

    CN114330372A

  • Language recognition model training method and device, language recognition method and device and electronic equipment

    CN114462397A