Translation model training and translating method and device, equipment and storage medium
By constructing a terminology translation dictionary and fine-tuning the pre-trained model, the problem of insufficient accuracy of machine translation models in professional fields was solved, achieving efficient translation model training and accurate translation of professional terms.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-10-12
- Publication Date
- 2026-04-14
AI Technical Summary
Existing machine translation models are inaccurate and inefficient when processing documents containing technical terms, making it difficult to adapt to rapidly changing professional fields. Traditional methods require periodic retraining and consume a lot of resources.
A terminology translation dictionary is constructed, and multilingual training prompt samples are built based on this dictionary. The pre-trained model is then fine-tuned to form a fine-tuned translation model that can adapt to the translation needs of different language environments.
It improves the professionalism and accuracy of the translation model, saves training time and computing resources, and enhances the ability to respond to specific technical terms.
Smart Images

Figure CN121859928A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a translation model training and translation method, apparatus, device and storage medium. Background Technology
[0002] In the field of machine translation, objects can be translated by machines to achieve conversion between multiple languages. This can significantly reduce human costs and facilitate the reading of texts in different languages. With the rapid development of language models, large-scale translation models can be used for text translation to improve the overall quality of translation.
[0003] In fields like science and medicine, there is a large amount of specialized terminology, and this terminology is constantly being updated. This often causes translation models to exhibit insufficient accuracy when processing complex documents containing specialized terminology. Current solutions involve periodically retraining the entire translation model. However, periodically retraining the entire model is inefficient and yields unsatisfactory translation accuracy. Summary of the Invention
[0004] This application provides a translation model training and translation method, apparatus, device, and storage medium, which can improve the training efficiency of the translation model and the translation accuracy of the translation model.
[0005] Firstly, this application provides a method for training a translation model, including:
[0006] Obtain a terminology translation dictionary, which includes the different language names of professional terms in different business fields;
[0007] Based on the terminology translation dictionary, training prompt samples in multiple languages are constructed. The training prompt samples include the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language.
[0008] The pre-trained translation model is fine-tuned using training cue samples from the aforementioned multiple languages to obtain the fine-tuned translation model.
[0009] Secondly, this application provides a translation method, including:
[0010] Obtain a translation request, wherein the translation request includes a first text to be translated;
[0011] A target translation model is selected from K translation models, including a fine-tuned translation model. The fine-tuned translation model is obtained by fine-tuning a pre-trained translation model using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. The training prompt samples include at least one source language name and target language name of a technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer.
[0012] Based on the first text to be translated, the input information of the target translation model is determined;
[0013] The input information is processed by the target translation model to obtain the translated text of the first text to be translated.
[0014] Thirdly, this application provides a translation model training device, comprising:
[0015] The acquisition unit is used to acquire a terminology translation dictionary, which includes the different language names of professional terms in different business fields;
[0016] The construction unit is used to construct training prompt samples in multiple languages based on the terminology translation dictionary. The training prompt samples include the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language name of the at least one technical term in the text to be translated into the target language when translating the text to be translated into the target language.
[0017] The fine-tuning unit is used to fine-tune the pre-trained translation model using training cue samples from the multiple languages, resulting in a fine-tuned translation model.
[0018] In some embodiments, the acquisition unit is specifically used to acquire text data from multiple different business domains; extract the professional terms included in each text data based on the business domain to which each text data belongs, thereby obtaining the professional terms included in different business domains; determine the different language names of the professional terms included in different business domains; and arrange the professional terms included in the same business domain in the different business domains together based on the different language names of the professional terms included in different business domains to construct the terminology translation dictionary.
[0019] In some embodiments, the construction unit is specifically configured to construct at least one of N1 first training prompt samples and N2 second training prompt samples based on the terminology translation dictionary, wherein N1 and N2 are both positive integers and the sum of N1 and N2 equals N, the first training prompt sample includes the source language name and target language name of a technical term, and the second training prompt sample includes the source language names and target language names of multiple technical terms; and based on at least one of the N1 first training prompt samples and N2 second training prompt samples, training prompt samples for the multiple languages are obtained.
[0020] In some embodiments, if the training prompt sample includes the first training prompt sample, the construction unit is specifically configured to, for the i-th first training prompt sample among the N1 first training prompt samples, obtain the i-th text to be translated from the plurality of text data that includes a technical term, and determine the source language name of the technical term from the i-th text to be translated, where i is a positive integer less than or equal to N1; based on the source language name of the technical term, query the terminology translation dictionary to obtain the target language name corresponding to the source language name of the technical term; based on the source language name and target language name of the technical term, translate the i-th text to be translated from the source language into the target language to obtain the i-th translated text; and construct the i-th first training prompt sample based on the source language name and target language name of the technical term, the i-th text to be translated from the source language, and the i-th translated text from the target language.
[0021] In some embodiments, if the training prompt sample includes the second training prompt sample, the construction unit is specifically configured to, for the j-th second training prompt sample among the N2 second training prompt samples, select the source language names and target language names of M professional terms from the terminology translation dictionary, where M is a positive integer greater than 1 and j is a positive integer less than or equal to N2; construct the j-th text to be translated in the source language based on the source language names of the M professional terms, wherein the j-th text to be translated includes the source language names of R professional terms among the M professional terms, where R is a positive integer less than or equal to M and greater than 1; translate the j-th text to be translated in the source language into the target language based on the source language names and target language names of the M professional terms, to obtain the j-th translated text in the target language; and construct the j-th second training prompt sample based on the source language names and target language names of the M professional terms, the j-th text to be translated in the source language, and the j-th translated text in the target language.
[0022] In some embodiments, the fine-tuning unit is specifically configured to, for each training prompt sample in the multiple languages, translate the text to be translated in the training prompt sample using the pre-trained translation model, based on the terminology translation dictionary and the source language name and target language name of at least one technical term included in the training prompt sample, to obtain a translation result of the text to be translated; determine the loss of the pre-trained translation model based on the translation result of the text to be translated and the translated text included in the training prompt sample; and fine-tune the pre-trained translation model based on the loss to obtain a fine-tuned translation model.
[0023] In some embodiments, the acquisition unit is specifically used to collect relevant data from different business areas; preprocess the relevant data from the different business areas to obtain multiple text data from different business areas, wherein the length of the text data meets a preset length.
[0024] Fourthly, this application provides a translation device, comprising:
[0025] The acquisition unit is used to acquire a translation request, wherein the translation request includes a first text to be translated;
[0026] The selection unit is used to select a target translation model from K translation models, including a fine-tuned translation model. The fine-tuned translation model is obtained by fine-tuning a pre-trained translation model using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. The training prompt samples include at least one source language name and target language name of a technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer.
[0027] The determining unit is used to determine the input information of the target translation model based on the first text to be translated;
[0028] The translation unit is used to process the input information through the target translation model to obtain the translated text of the first text to be translated.
[0029] In some embodiments, the determining unit is specifically configured to determine the input information of the target translation model based on the type of the target translation model and the first text to be translated.
[0030] In some embodiments, the determining unit is specifically configured to determine the first text to be translated as the input information if the target translation model is the fine-tuned translation model; or, if the target translation model is the fine-tuned translation model or a pre-trained translation model, obtain the source language names and target language names of Q technical terms based on the first text to be translated, and determine translation prompt samples based on the source language names and target language names of the Q technical terms and the first text to be translated, and then determine the input information based on the translation prompt samples, wherein the translation prompt samples are used to indicate that when translating the first text to be translated from the source language to the target language, the translation is performed based on the source language names and target language names of the Q technical terms, where Q is a positive integer.
[0031] In some embodiments, the determining unit is specifically configured to parse the translation request to obtain the source language names and target language names of the Q technical terms input by the object, wherein the first text to be translated includes at least one of the Q technical terms; or, to extract the source language names of the Q technical terms from the first text to be translated, determine the business domain to which the first text to be translated belongs, and then, based on the source language names of the Q technical terms, query the target language names of the Q technical terms from the different language names of each technical term included in the business domain in the terminology translation dictionary.
[0032] In some embodiments, the determining unit is specifically configured to determine the translation prompt sample as the input information; or, to obtain P examples and, based on the P examples and the translation prompt sample, obtain the input information, wherein the examples include the source language name and target language name of at least one technical term, as well as a second text to be translated and the translated text of the second text to be translated, wherein the translated text of the second text to be translated is obtained by translating the source language of the second text to be translated into the target language based on the source language name and target language name of the at least one technical term, and wherein P is a positive integer.
[0033] In some embodiments, if the input information includes the P examples, the translation unit is specifically used to learn the P examples in the input information through the target translation model, and translate the first text to be translated in the source language into the translated text in the target language based on the terminology translation dictionary and the source language names and target language names of the Q professional terms included in the translation prompt sample.
[0034] In some embodiments, the selection unit is specifically used to receive a model selection operation input by an object; and based on the model selection operation, to select the target translation model from the K translation models.
[0035] In some embodiments, the processing unit is further configured to extract a first technical term from the first text to be translated; if the term translation dictionary does not include the first technical term, then extract the target language name of the first technical term from the translated text of the first text to be translated; and add the source language name and target language name of the first technical term to the term translation dictionary.
[0036] Fifthly, an electronic device is provided, including a processor and a memory. The memory is used to store a computer program, and the processor is used to invoke and run the computer program stored in the memory to perform the methods described in the first or second aspect and their respective implementations.
[0037] Sixthly, a chip is provided for implementing the methods of either the first or second aspect and their respective implementations. Specifically, the chip includes a processor for retrieving and running a computer program from a memory, causing a device equipped with the chip to perform the methods of either the first or second aspect and their respective implementations.
[0038] In a seventh aspect, a computer-readable storage medium is provided for storing a computer program that causes a computer to perform the methods described in the first or second aspect and their respective implementations.
[0039] Eighthly, a computer program product is provided, including computer program instructions that cause a computer to perform the methods described in the first or second aspect and their respective implementations.
[0040] Ninthly, a computer program is provided that, when run on a computer, causes the computer to perform the methods of the first or second aspect and their respective implementations described above.
[0041] In summary, this application embodiment obtains a terminology translation dictionary, which includes different language names of professional terms in different business fields. Then, based on the terminology translation dictionary, it constructs training prompt samples in multiple languages. These training prompt samples include at least one professional term with two different language names, namely the source language name and the target language name, as well as the source language text to be translated and the target language translation text. The translation text is obtained by translating the source language text to be translated into the target language by translating the source language text to be translated into the target language text. In other words, the training prompt samples are used to instruct that when translating the source language text to be translated into the target language translation text, the source language name of at least one professional term in the text to be translated into the target language name should be translated into the target language name. Finally, the pre-trained translation model is fine-tuned using the training prompt samples in multiple languages to obtain a fine-tuned translation model. Therefore, the terminology translation dictionary in this application includes different language names of professional terms in different business fields. Based on this terminology translation dictionary, a rich set of multilingual training prompts can be constructed. Then, using these rich multilingual training prompts, the pre-trained translation model can be optimized and fine-tuned in a targeted manner. This allows the fine-tuned translation model to translate in different language environments without having to train the translation model from scratch. This not only saves a lot of time and computing resources, but also significantly improves the translation model's professionalism and accuracy by finely adjusting the pre-trained translation model's response to specific professional terms. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A schematic diagram of an implementation environment for the translation model training and translation method provided in this application embodiment;
[0044] Figure 2 A schematic flowchart illustrating a translation model training method provided in an embodiment of this application;
[0045] Figure 3 This is a schematic diagram illustrating the training of a translation model involved in an embodiment of this application;
[0046] Figure 4 This is another schematic diagram illustrating the translation model training involved in the embodiments of this application;
[0047] Figure 5A flowchart illustrating a translation method provided in an embodiment of this application;
[0048] Figure 6 This is a schematic diagram of a translation information input interface according to an embodiment of this application;
[0049] Figure 7 This is a schematic diagram of another translation information input interface involved in an embodiment of this application;
[0050] Figure 8 This is a schematic diagram of another translation information input interface according to an embodiment of this application;
[0051] Figure 9 This is a schematic diagram illustrating the list of translation models involved in the embodiments of this application;
[0052] Figure 10 This is a schematic diagram illustrating the selection of the target translation model involved in an embodiment of this application;
[0053] Figure 11 This is a schematic diagram of the translation information input interface and translation interface involved in the embodiments of this application;
[0054] Figure 12 This is a schematic diagram of a translation prompt sample involved in an embodiment of this application;
[0055] Figure 13 This is a schematic diagram illustrating one selection of translation prompt samples involved in an embodiment of this application;
[0056] Figure 14 This is an illustration of another option for the translation prompt sample involved in the embodiments of this application;
[0057] Figure 15 A flowchart illustrating a translation method provided in an embodiment of this application;
[0058] Figure 16 This is a schematic block diagram of a translation model training device provided in one embodiment of this application;
[0059] Figure 17 This is a schematic block diagram of a translation apparatus provided in one embodiment of this application;
[0060] Figure 18 This is a schematic block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0061] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0062] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in sequences other than those illustrated or described herein. In embodiments of the invention, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices. In the description of this application, unless otherwise stated, "a plurality of" means two or more.
[0063] The technical solution proposed in this application can be applied to the fields of machine translation, model training, etc., to improve the translation professionalism and accuracy of translation models.
[0064] The relevant concepts involved in the embodiments of this application are introduced below.
[0065] Prompts are text instructions used to activate and guide specific functions of large-scale language models. They can guide the language model to generate specific types of output to achieve specific tasks. They play a crucial role by activating and guiding the model along specific lines of thought or tasks through well-designed questions and scenarios.
[0066] In the field of machine translation, although the emergence of large-scale language models in recent years has significantly improved the overall quality of translation, many challenges remain when handling proper nouns, emerging terms, and technical texts. Current translation methods, mainly including statistical machine translation and rule-based methods, often fall short in accuracy for specific contexts and terminology, especially in rapidly changing fields (such as science and medicine). Furthermore, while neural machine translation models can learn and generate fluent translations, their knowledge bases are not updated in a timely manner, and their effectiveness is limited when handling unseen terms or new words. Current large-scale language models typically require periodic retraining or continuous online learning to absorb new vocabulary and expressions. This approach is not only resource-intensive but also unable to respond quickly to the emergence of new terms. In practical applications, this time lag often leads to inconsistent translation quality, especially in specialized fields. Moreover, while current model tuning methods can partially address these issues, they often require adjustments to the entire model, which is not only costly but also inefficient in practice. For example, traditional translation methods often rely on fixed vocabulary databases and grammatical rules. These methods struggle to accurately handle the polysemy and contextual relevance of specialized terminology, especially in rapidly updated terminology or domain-specific terms. Because specialized terminology is frequently updated, dictionaries in traditional methods require regular manual updates, leading to a lag between translated content and actual usage. When processing documents containing a large number of emerging terms, traditional translation methods require significant manual intervention to ensure accuracy, increasing costs and significantly reducing processing speed. Furthermore, current methods are often designed for specific languages or domains, making them ill-suited for multi-domain or multilingual translation needs, thus limiting their application. Traditional machine translation methods often face numerous challenges when dealing with emerging terms and specialized vocabulary. These methods include lexical statistics, semantic analysis, or machine learning, which are often limited in new word identification and translation accuracy, resulting in poor translation quality. For example, lexical statistics methods rely on the frequency of word occurrence in text to determine its importance. While simple and easy to implement, they often fail to identify low-frequency but important new terms. For example, in the medical field, "heart disease" is a key term, but if its frequency of occurrence is low, traditional lexical statistical methods may overlook such terms. Semantic analysis methods: This method identifies and translates terms by analyzing the semantic relationships between words. While relatively accurate in handling known words, it struggles with identifying and translating new or complex terms. For instance, although the semantic relationships of the term "heart disease" are clear, the inherent connections in newly emerging professional terms may exceed the scope of traditional semantic analysis. Machine learning methods: Although machine learning models can learn term extraction rules from training data, these methods require large amounts of labeled data.Emerging or rapidly changing terms, such as those appearing in new medical research, may be difficult to translate accurately due to a lack of sufficient training samples. Furthermore, these traditional machine translation methods are often designed for specific domains or languages, making it difficult to adapt to cross-domain or multilingual environments. For example, "heart disease" is a medical term but may be a common word in legal documents. This domain dependence limits the application of traditional methods in new domains or multilingual texts, making it difficult to accurately identify and translate emerging terms from different fields.
[0067] To address this technical problem, this application first obtains a terminology translation dictionary, which includes different language names of professional terms from different business fields. Next, based on the terminology translation dictionary, training prompt samples in multiple languages are constructed. Each training prompt sample includes at least one professional term with two different language names: the source language name and the target language name, as well as the source language text to be translated and the target language translation text. The translation text is obtained by translating the source language text to be translated into the target language by translating the source language text to be translated into the target language text. In other words, the training prompt sample is used to instruct that when translating the source language text to be translated into the target language translation text, the source language name of at least one professional term in the text to be translated into the target language name should be translated into the target language name. Then, using the training prompt samples in multiple languages, the pre-trained translation model is fine-tuned to obtain the fine-tuned translation model. Therefore, the terminology translation dictionary in this application includes different language names of professional terms in different business fields. Based on this terminology translation dictionary, a rich set of multilingual training prompts can be constructed. Then, using these rich multilingual training prompts, the pre-trained translation model can be optimized and fine-tuned in a targeted manner. This allows the fine-tuned translation model to translate in different language environments without having to train the translation model from scratch. This not only saves a lot of time and computing resources, but also significantly improves the translation model's professionalism and accuracy by finely adjusting the pre-trained translation model's response to specific professional terms.
[0068] The following describes the implementation environment for the translation model training and translation method provided in the embodiments of this application.
[0069] Figure 1 This is a schematic diagram of an implementation environment for the translation model training and translation method provided in this application, including a terminal device 101 and a server 102. The terminal device 101 and the server 102 can communicate with each other via wired or wireless means.
[0070] In this embodiment, the object and the terminal device 101 can interact with each other. For example, the object can load a pre-trained translation model on the terminal device 101 or input text to be translated. The terminal device 101 can also present the translation result to the object, for example, presenting the translated text of the first text to be translated to the object. The server 102 has data processing functions.
[0071] In this embodiment, server 102 includes a pre-trained translation model, which can be trained using the method described in this embodiment. Specifically, server 102 constructs a terminology translation dictionary, which includes different language names of professional terms from different business domains. Next, based on the terminology translation dictionary, server 102 constructs training prompt samples in multiple languages. Each training prompt sample includes the source language name and target language name of at least one professional term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of at least one professional term in the text to be translated into the target language. Finally, server 102 uses the training prompt samples in multiple languages to fine-tune the pre-trained translation model, obtaining a fine-tuned translation model. Therefore, the constructed terminology translation dictionary includes different language names of professional terms from different business fields. Based on this terminology translation dictionary, a rich set of multilingual training prompts can be constructed. Then, using these rich multilingual training prompts, the pre-trained translation model can be optimized and fine-tuned in a targeted manner. This allows the fine-tuned translation model to achieve translation in different language environments without having to train the translation model from scratch. This not only saves a lot of time and computing resources, but also significantly improves the translation model's professionalism and accuracy by finely adjusting the pre-trained translation model's response to specific professional terms.
[0072] It should be noted that, in this embodiment, the terminology translation dictionary can be dynamically updated, and the server 102 can reconstruct training prompt samples for different languages based on the dynamically updated terminology translation dictionary, and use these reconstructed training prompt samples to further fine-tune the aforementioned fine-tuned translation model. By dynamically updating the terminology translation dictionary and the translation model, the translation accuracy of the dictionary can be further guaranteed.
[0073] In this embodiment of the application, the server 102 can save the fine-tuned translation model locally or send the fine-tuned translation model to the terminal device 101.
[0074] In this embodiment, server 102 and / or terminal device 101 may use the finely tuned translation model described above to perform text translation.
[0075] In some embodiments, when the translation method of this application is executed by terminal device 101, terminal device 101 obtains the first text to be translated sent by the target. Then, terminal device 101 selects a target translation model from K translation models. If the target translation model is the fine-tuned translation model described above, terminal device 101 sends a model acquisition request to the server, and server 102 sends the fine-tuned translation model to terminal device 101. In this way, terminal device 101 can determine the input information of the target translation model based on the first text to be translated, and then process the input information through the target translation model to obtain the translated text of the first text to be translated.
[0076] In some embodiments, when the translation method of this application is executed by terminal device 101, the user inputs a first text to be translated on terminal device 101, and terminal device 101 sends the first text to be translated to server 102. Server 102 selects a target translation model from K translation models, determines the input information of the target translation model based on the first text to be translated, and then processes the input information through the target translation model to obtain the translated text of the first text to be translated. Next, server 102 sends the translated text of the first text to be translated to terminal device 101 for display.
[0077] This application does not limit the specific type of the terminal device 101. In some embodiments, the terminal device 101 may include, but is not limited to: mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, wearable smart devices, medical devices, etc. The device is often equipped with a display device, which may also be a monitor, display screen, touch screen, etc., and the touch screen may also be a touch screen, touch panel, etc.
[0078] In some embodiments, server 102 can be one or more servers. When there are multiple servers, at least two servers are used to provide different services, and / or at least two servers are used to provide the same service, such as providing the same service in a load-balanced manner. This application embodiment does not limit this. The aforementioned servers can be independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Servers can also become nodes in a blockchain.
[0079] In this embodiment, the terminal device 101 and the server 102 can be directly or indirectly connected through wired or wireless communication, and this application does not impose any restrictions.
[0080] It should be noted that the implementation environment of this application embodiment includes, but is not limited to, Figure 1 As shown.
[0081] The technical solutions of the embodiments of this application will be described in detail below through some examples. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.
[0082] First, the training process of the translation model will be introduced.
[0083] Figure 2 This is a flowchart illustrating a translation model training method provided in one embodiment of this application. The execution entity in this embodiment is a device with model training functionality, such as a model training apparatus. In some embodiments, the model training apparatus in this embodiment may be... Figure 1 The server in, or for Figure 1 Terminal devices in, or for Figure 1 The system consists of a server and terminal devices. For ease of description, this application uses an electronic device as an example for illustration.
[0084] like Figure 2 As shown, the translation model training process in this embodiment includes:
[0085] S101. Obtain a terminology translation dictionary.
[0086] The terminology translation dictionary includes the different language names of professional terms from different business fields.
[0087] In this embodiment of the application, in order to enable the translation model to translate in different language environments, a terminology translation dictionary is obtained, which includes the different language names of professional terms in different business fields. This embodiment of the application does not limit the business fields or language types included in the terminology translation dictionary.
[0088] In one example, the terminology translation dictionary of this application includes F different language names of the professional terms included in each of E different business areas. Where E and F are both positive integers greater than or equal to 1.
[0089] For example, the terminology translation dictionary of this application embodiment is shown in Table 1:
[0090] Table 1
[0091]
[0092] As can be seen from Table 1 above, in the embodiments of the present application, the term translation dictionary includes different language names of different professional terms included in different business fields. For example, in the medical field, the Chinese name of the professional term "heart" is "心脏", the English name is "heart", and the French name is The Arabic name is and so on. Based on this term translation dictionary, conversion between different languages of different professional terms in different business fields can be achieved, thereby improving the accuracy of translation.
[0093] In some embodiments, the term translation dictionary of the embodiments of the present application can also support small languages in addition to Chinese and English, for example, support the small languages shown in Table 2:
[0094] Table 2
[0095]
[0096]
[0097] It should be noted that the term translation dictionary of the embodiments of the present application is dynamically updated to determine the accuracy of the term translation dictionary.
[0098] The process of the electronic device obtaining the term translation dictionary will be introduced below.
[0099] In some embodiments, the above term translation dictionary is created by an electronic device. At this time, the above S101 includes the following steps of S101-A to S101-D:
[0100] S101-A. Obtain text data of multiple different business fields;
[0101] S101-B. Based on the business field to which each text data belongs, extract the professional terms included in each text data to obtain the professional terms included in different business fields;
[0102] S101-C. Determine different language names of the professional terms included in different business fields;
[0103] S101-D. Based on the different language names of the professional terms included in different business fields, arrange the professional terms included in the same business field in different business fields together to construct a term translation dictionary.
[0104] In the embodiments of the present application, when the electronic device fine-tunes the pre-trained translation model, it first creates a term translation dictionary. Specifically, the electronic device obtains multiple text data of different business fields.
[0105] This application does not limit the specific methods by which electronic devices acquire multiple text data from different business areas.
[0106] In one possible implementation, the electronic device downloads different text data from multiple professional databases covering different business areas.
[0107] In one possible implementation, the electronic device collects relevant data from different business areas, preprocesses the relevant data from different business areas, and obtains multiple text data from different business areas, wherein the length of the text data meets a preset length.
[0108] For example, electronic devices use web scraping technology to crawl text data related to a specific domain from the internet. Ensuring high data quality is crucial during data collection, as it directly impacts the training performance of subsequent models and the accuracy of translations. Accuracy and completeness are ensured through manual annotation and automated quality control procedures. Manual annotation plays a key role, especially in specialized fields such as medicine and law, where data requires high accuracy and expertise. Furthermore, ensuring a sufficiently large amount of collected data is essential for training a high-performing model. In machine learning and natural language processing, the amount of data often directly affects model performance. Domain relevance is also crucial; the collected data must be closely linked to the domain of the translation task. Mismatched data can lead to degraded model performance, making the selection of data relevant to the target task paramount. In addition to data acquired through web scraping, the system can also process various file formats, including PDF, Excel, and TXT, expanding the dataset by extracting text data from these files.
[0109] Next, the collected text data is cleaned to remove special symbols and numbers, as these elements may interfere with the model's learning process. Furthermore, long texts are cut into lengths suitable for model processing, ensuring the standardization of the input data, which helps the model learn and predict more effectively.
[0110] The following section describes how electronic devices crawl web data and the process of preprocessing that data.
[0111] For example, an electronic device crawls text data related to a specific domain from the internet, using MongoDB to store the crawled data. This leverages MongoDB's high performance and scalability, offering more flexible data indexing and querying capabilities compared to traditional CSV file storage. Request header management utilizes Redis to store request headers, leveraging its fast data access speed and rich data structures to manage large amounts of request header information, which is more efficient and reliable than traditional hash table storage. Anti-crawling strategies implement a linear testing paid IP strategy. Compared to the traditional strategy of random testing IPs, the linear strategy utilizes each IP address more efficiently, reducing IP resource waste and improving the overall efficiency of the crawler. Next, based on URL filtering mechanisms, the crawled network data is filtered. For example, by setting specific URL filtering rules, such as whitelists and blacklists, high-quality content sources are selected. Whitelists cover reputable websites, while blacklists exclude URLs related to advertising and spam, thus ensuring the quality and relevance of the crawled data. Furthermore, efficient web scraping tools, such as BeautifulSoup, are used to accurately extract core text information from the filtered URLs. This is achieved by filtering HTML tags, such as... <content>This process excludes non-critical content such as advertisements and navigation information, allowing focus on the main content of the article. Furthermore, quality control is performed at the paragraph and sentence levels, using algorithms to remove duplicate or low-quality content, ensuring data purity and usability. For example, sentences containing irrelevant keywords (such as "follow," "share," "like") are automatically deleted, as well as numbers and special characters are removed from the text. Optionally, the above text data can also be deduplicated. For example, an improved MinHash algorithm combined with URL analysis can be used for deep deduplication to ensure content uniqueness. This method not only improves data processing efficiency but also guarantees the value and uniqueness of each article.
[0112] After the above processing, text data from multiple different business domains can be obtained, and a terminology translation dictionary can be constructed based on the text data from multiple different business domains.
[0113] In this embodiment, the text data from the various business domains mentioned above may be multilingual data, from which specialized data is extracted. For example, for each piece of text data, such as text data 1, the business domain to which text data 1 belongs is determined, and then, based on the characteristics of the business domain to which text data 1 belongs, the specialized terms included in text data 1 are extracted. For instance, assuming the business domain to which text data 1 belongs is the medical field, based on the characteristics of the medical field, the electronic device will utilize terminology extraction tools such as Named Entity Recognition (NER) functionality in an NLP library to identify and extract the medical specialized terms included in text data 1. Next, the electronic device determines the different language names of the specialized terms included in text data 1.
[0114] In this embodiment, the electronic device determines the different language names of the technical terms included in text data 1 in the following ways: if text data 1 includes multiple language names of the technical terms, the multiple language names of the technical terms can be directly extracted from the text data 1. The remaining language names of the technical terms can be constructed through human translation or machine translation, thereby obtaining the different language names of the technical terms included in text data 1. For example, if the different language names of the technical terms in this application are assumed to be 5, and if text data 1 includes 2 language names of the technical terms, the remaining 3 language names of the technical terms can be obtained through human translation or machine translation plus human calibration.
[0115] Using the same processing method as described above for text data 1, the electronic device can extract the technical terms included in each piece of text data from the multiple different business domains, as well as the different language names of these technical terms. This allows for the acquisition of the different language names of the technical terms included in different business domains, and subsequently, a terminology translation dictionary can be constructed based on these different language names of the technical terms included in different business domains.
[0116] In one example, as shown in Table 1, in this embodiment of the application, to facilitate dictionary lookups, the electronic device can arrange the professional terms included in the same business domain together. For example, in Table 1, the professional terms of business domain 1 are arranged together, and the professional terms of business domain 2 are arranged together.
[0117] Through this method, the embodiments of this application can not only effectively handle various data types and formats, but also accurately perform term extraction and translation tasks in a multilingual environment, laying a solid foundation for subsequent machine translation processes.
[0118] In this embodiment, the terminology translation dictionary constructed above is dynamically updated. For example, when it detects that an object has inputted two different language names for a technical term, the terminology translation dictionary can be updated using the language names of the technical term input by the object. Alternatively, the electronic device periodically collects new text data, extracts new technical terms included in the new text data, determines the different language names of the new technical term, and then updates the terminology translation dictionary based on the different language names of the new technical term.
[0119] Therefore, in some embodiments, the above-mentioned electronic device can obtain the terminology translation dictionary by directly obtaining the updated terminology translation dictionary.
[0120] In this embodiment of the application, after obtaining the terminology translation dictionary based on the above steps, the electronic device performs the following step S102.
[0121] S102. Based on a terminology translation dictionary, construct training prompt samples in multiple languages.
[0122] The training prompt samples include at least one source language name and target language name for a technical term, as well as the source language text to be translated and the target language translated text. The translated text is obtained by translating the source language text to be translated into the target language by translating at least one technical term in the source language text into the target language text.
[0123] In this embodiment, training prompts in multiple languages are used to generate Supervised Fine-Tuning (SFT) data, which is then used to fine-tune the pre-trained translation model. In this embodiment, the training prompts play a crucial role; they are text instructions used to activate and guide the translation model to achieve specific functions. These training prompts not only activate specific functions of the model but also precisely guide the model along a predetermined line of thought or task, thereby greatly improving the efficiency and accuracy of task execution. These training prompts are designed as SFT data for terminology translation using a dictionary. They include not only direct guidance for dictionary terminology translation but also processing instructions for the text content to be translated. This process involves precisely controlling the form and content of the training prompts to optimize the input to the translation model.
[0124] In the training samples mentioned above, the source language can be understood as the language to be translated, i.e., the language before translation, and the target language is the language to which the translation is required, i.e., the language after translation. For example, in Chinese-English translation, when the requirement is to translate Chinese into English, the source language is Chinese and the target language is English.
[0125] The training prompt samples in multiple languages in this application embodiment can be understood as multiple training prompt samples in different languages. That is, at least two of the constructed training prompt samples involve different languages. For example, training prompt sample 1 involves language 1 as the source language and language 2 as the target language; training prompt sample 2 involves language 1 as the source language and language 3 as the target language; training prompt sample 3 involves language 4 as the source language and language 5 as the target language, and so on. The types of languages involved in the training prompt samples can be preset or specified by the object; this application embodiment does not impose any limitations on this. By using training prompt samples in multiple languages to train the translation model, the translation model can learn different languages, thereby enabling translation into multiple languages instead of just two fixed languages, thus expanding the application scenarios of the translation model.
[0126] In some embodiments, when an electronic device constructs training prompt samples in multiple languages, it may construct one or more training prompt samples for a single language. For example, it may construct one training prompt sample in both Chinese and English, or it may construct multiple training prompt samples in both Chinese and English. This application embodiment does not impose any limitations on this.
[0127] In some embodiments, the total number of training prompt samples to be constructed by the electronic device, the languages involved in the training prompt samples, and the number of training prompt samples corresponding to the same language, etc., these construction parameters can be default or specified by the object, and this application embodiment does not limit them. For example, suppose the construction parameters of the training prompt samples indicate that 1000 training prompt samples are to be constructed, involving languages including Chinese-English, Chinese-Arabic, French-English, and German-Spanish, which are four language types. Suppose that the number of training prompt samples corresponding to each of the four language types is 250. In this way, the electronic device can construct 250 Chinese-English training cue samples (the source language of these 250 Chinese-English training cue samples is Chinese, and the target language is English), 250 Chinese-Arabic training cue samples (the source language of these 250 Chinese-Arabic training cue samples is Chinese, and the target language is Arabic), 250 French-English training cue samples (the source language of these 250 French-English training cue samples is French, and the target language is English), and 250 German-Spanish training cue samples (the source language of these 250 German-Spanish training cue samples is German, and the target language is Spanish).
[0128] In this embodiment, each training prompt sample in the multiple languages includes at least one technical term with two different language names, namely the source language name and the target language name, as well as the source language text to be translated and the target language translation text. When the source language text to be translated is translated into the target language translation text, the source language name of at least one technical term in the source language text is directly replaced with the target language name. In other words, the training prompt samples in this embodiment not only include guidance for terminology dictionary translation but also the text content to be translated. By precisely controlling the form and content of the training prompt samples, the input to the translation model is optimized to improve output quality, and the document language can be automatically identified to generate SFT data for the corresponding language. When the pre-trained translation model is fine-tuned using this SFT data, the translation model can accurately learn the source and target language names of technical terms.
[0129] For example, suppose training prompt sample 1 includes: {the source language name of term 1 is a Chinese name, the target language name of term 1 is an English name, the Chinese text to be translated is 1, and the English translation of the text to be translated is 1}. When translating the Chinese text to be translated into English, the Chinese name of term 1 in the text to be translated is directly replaced with the aforementioned English name.
[0130] Example 1, training prompt sample 1 is: {"source entity":"amino acid", "target entity":"amino acid", "source":"Proteins are the material basis of life, organic macromolecules, the basic organic substances that make up cells, and the main carriers of life activities. Without protein, there is no life. Amino acids are the fundamental building blocks of proteins. It is a substance closely linked to life and various forms of life activities. Every cell and all important components in the body are involved in proteins."}
[0131] Example 2, training hint sample 2 is: {"source entity":"hemoglobin","target entity": "source": "Red blood cells contain hemoglobin, which gives blood its red color. Hemoglobin contains iron, so people with anemia should eat more iron-rich foods and protein to replenish their blood. Hemoglobin can bind with oxygen in the air, so red blood cells can transport oxygen inhaled into the alveoli to the tissues via hemoglobin. Some carbon dioxide produced by metabolism in the tissues is also transported to the lungs via red blood cells, where it exchanges gas with oxygen outside the body through the alveoli, expelling the carbon dioxide. Hemoglobin is more likely to bind with carbon monoxide (CO), and once bound, it is not easily separated. When the CO content in the air increases and persists for a long time, it can cause carbon monoxide poisoning." "target":
[0132] In Examples 1 and 2 above, "source entity" represents the source language name of the technical term, "target entity" represents the target language name of the technical term, "source" represents the text to be translated, and "target" represents the translation text of the text to be translated.
[0133] In Example 1 above, the source language name of the technical term is the Chinese name, and the target language name is the English name. Training hint sample 1 is used to instruct that when translating the Chinese text to be translated into English, the Chinese name of the technical term (amino acid) in the text to be translated should be replaced with the above English name (amino acid). In this way, when using training hint sample 1 to train the translation model, the translation model can effectively learn the English name "target entity" of the technical term "amino acid", so that it can accurately translate the technical term "amino acid" into the corresponding English name "target entity" in subsequent Chinese-English translations.
[0134] In Example 2 above, the source language name of the technical term is the Chinese name, and the target language name is the Arabic name. Training hint sample 2 instructs that when translating the Chinese text to be translated into Arabic, the Chinese name of the technical term (hemoglobin) in the text to be translated should be replaced with the aforementioned Arabic name. Using this training cue sample 2 to train the translation model allows the model to correctly identify the Arabic name for the technical term "hemoglobin". Effective learning will be conducted to ensure accurate translation of the technical term "hemoglobin" into its corresponding Arabic name in subsequent Chinese-Arabic translations.
[0135] Examples 1 and 2 above illustrate the case where the training prompt sample includes one technical term. However, the training prompt samples in this application embodiment may also include one or more technical terms, and this application embodiment does not impose any limitations on this. For example, each training prompt sample in the above multilingual training prompt samples includes three or four technical terms.
[0136] In some embodiments, the training prompt samples for multiple languages in this application include N1 first training extraction samples and N2 second training prompt samples. In this case, S102 above includes the following steps:
[0137] S102-A. Based on a terminology translation dictionary, construct at least one of N1 first training prompt samples and N2 second training prompt samples, where N1 and N2 are both positive integers and the sum of N1 and N2 equals N. The first training prompt sample includes the source language name and target language name of a technical term, and the second training prompt sample includes the source language name and target language name of multiple technical terms.
[0138] S102-B: Based on at least one of N1 first training cue samples and N2 second training cue samples, training cue samples for multiple languages are obtained.
[0139] In this embodiment, assuming the total number of training prompt samples in multiple languages constructed by the electronic device is N, the training prompt samples in multiple languages in this embodiment of the application include at least the following cases:
[0140] Case 1: In this embodiment of the application, the training prompt samples for multiple languages consist of N1 first training prompt samples, where N is less than or equal to N1. That is, the training prompt samples constructed in this embodiment are all first training prompt samples that include a technical term. For example, as shown in Examples 1 and 2 above.
[0141] Case 2: In this embodiment, the training prompt samples for multiple languages consist of N² second training prompt samples, where N is less than or equal to N². That is, the training prompt samples constructed in this embodiment are all second training prompt samples including multiple technical terms. For example, see Examples 3 and 4 below:
[0142] Example 3, the second training prompt sample a is: {"source entity1":"amino acid", "target entity1":"amino acid", "source entity2":"protein", "target entity2":"protein", "source":"Proteins are the material basis of life, organic macromolecules, the basic organic substances that make up cells, and the main carriers of life activities. Without protein, there is no life. Amino acids are the fundamental building blocks of proteins. It is a substance closely linked to life and various forms of life activities. Every cell and all important components in the body are involved in proteins."}
[0143] Example 4, the second training suggestion sample b is: {"source entity1":"hemoglobin","target entity1": "source entity2":"red blood cell", "target entity2": "source entity3": "anemia", "target entity3": "source": "Red blood cells contain hemoglobin, which gives blood its red color. Hemoglobin contains iron, so people with anemia should eat more iron-rich foods and protein to replenish their blood. Hemoglobin can bind with oxygen in the air, so red blood cells can transport oxygen inhaled into the alveoli to the tissues via hemoglobin. Some carbon dioxide produced by metabolism in the tissues is also transported to the lungs via red blood cells, where it exchanges gas with oxygen outside the body through the alveoli, expelling the carbon dioxide. Hemoglobin is more likely to bind with carbon monoxide (CO), and once bound, it is not easily separated. When the CO content in the air increases and persists for a long time, it can cause carbon monoxide poisoning." "target":
[0144] The second training cue sample a in Example 3 above includes two technical terms: amino acids and proteins. The second training cue sample b in Example 4 above includes three technical terms: hemoglobin, red blood cells, and anemia.
[0145] Case 3: In this embodiment of the application, the training prompt samples for multiple languages consist of N1 first training prompt samples and N2 second training prompt samples, where N is less than or equal to N1 + N2. That is, the training prompt samples constructed in this embodiment include one or more first training prompt samples containing only one technical term, and one or more second training prompt samples containing multiple technical terms.
[0146] The following describes the specific process of constructing N1 first training prompt samples based on a terminology translation dictionary for electronic devices.
[0147] In some embodiments, if the training prompt samples include the first training prompt samples, then the construction of N1 first training prompt samples based on the terminology translation dictionary in S102-A includes at least the following methods:
[0148] Method 1: When constructing each of the N1 first training prompt samples, the electronic device selects a technical term from a terminology translation dictionary, along with its source language name and target language name. Next, the electronic device uses the source language name of the technical term to construct a source language sentence, which serves as the text to be translated. Then, based on the target language name of the technical term, the electronic device translates the text to be translated into the target language, thus obtaining the translated text. In this way, the source language name and technical term name of the technical term, along with the text to be translated and the translated text, constitute a first training prompt sample. Following this method, the electronic device can create N1 first training prompt samples.
[0149] Method 2: The electronic device can construct N1 first training cue samples through the following steps S102-A-a1 to S102-A-a4:
[0150] S102-A-a1, For the i-th first training prompt sample among N1 first training prompt samples, obtain the i-th text to be translated that includes a technical term from multiple text data, and determine the source language name of the technical term from the i-th text to be translated, where i is a positive integer less than or equal to N1;
[0151] S102-A-a2: Based on the source language name of a technical term, retrieve the target language name corresponding to the source language name of the technical term from the terminology translation dictionary;
[0152] S102-A-a3: Based on the source language name and target language name of this technical term, translate the i-th text to be translated from the source language into the target language to obtain the i-th translated text;
[0153] S102-A-a4. Based on the source language name and target language name of the term, the i-th text to be translated in the source language and the i-th translated text in the target language, the i-th first training prompt sample is constructed.
[0154] In this embodiment, the process of constructing each of the N1 first training prompt samples based on the terminology translation dictionary is basically the same. For ease of description, the construction of the i-th first training prompt sample will be used as an example.
[0155] In this method 2, when the electronic device constructs the i-th first training prompt sample based on the terminology translation dictionary, it first obtains a text data containing only one professional term from the multiple text data used in constructing the terminology translation dictionary, and then records this text data as the i-th text to be translated.
[0156] For example, suppose that when constructing a terminology translation dictionary, an electronic device acquires 10,000 text data from different fields and extracts specialized terms from these 10,000 text data. For instance, a medical term A is extracted from text data 1, and the different language names of this medical term A are determined. These different language names of medical term A are then mapped to text data 1 and stored in the terminology translation dictionary. When constructing the i-th first training prompt sample, the electronic device queries the stored text data, such as the text data stored in the terminology translation dictionary, for text data containing only one specialized term. For example, if the above-mentioned text data 1 contains a specialized term A, then text data 1 is identified as the i-th text to be translated, and the language name of the specialized term A included in text data 1 is identified as the source language name of specialized term A. Next, based on the source language name of specialized term A, the target language name of specialized term A is retrieved from the terminology translation dictionary. At this time, the target language can be random or indicated by configuration information. Then, based on the source language name and target language name of the technical term A, the electronic device translates the aforementioned source language text data 1 into the target language, thereby obtaining the i-th translated text. In this way, the electronic device can combine the source language name and target language name of the technical term A, the i-th source language text to be translated, and the i-th target language translated text to obtain the i-th first training prompt sample.
[0157] In one possible implementation, when constructing the i-th first training prompt sample, the electronic device can first acquire an instruction, denoted as the first instruction. This first instruction indicates the source and target languages involved in the first training prompt sample, as well as the format information of the first training prompt sample. Thus, the electronic device can, based on the source and target languages indicated by the first instruction, acquire the i-th text to be translated from multiple text data, including a technical term, and determine the source language name of the technical term from the i-th text to be translated. Then, it can query the terminology translation dictionary to obtain the target language name corresponding to the source language name of the technical term. Next, based on the source and target language names of the technical term, the i-th text to be translated in the source language is translated into the target language to obtain the i-th translated text. Finally, according to the format of the first training prompt sample indicated by the first instruction, the source and target language names of the technical term, the i-th text to be translated in the source language, and the i-th translated text in the target language are processed to obtain the i-th first training prompt sample.
[0158] For example, suppose the first indication information of the first training prompt sample is as follows, including system prompt information and user prompt information:
[0159] System prompt: You are a bilingual user whose native language is Chinese and whose native language is {lang_name}. You will be given a Chinese source span and its context sentence. Its format is: {{"source entity": "", "target entity": "", "source": "", "target": ""}}. Please translate the Chinese context sentence represented by "source" into {lang_name} using "target entity" to help fill in "target". Please note that you should only output the span's translation pairs and the translation of the context sentence in JSON format. Please note that you should not generate any illustrations or demos.
[0160] User prompt: {"Source entity": "##src_instance##", "Target entity": "##tgt_entity##", "Source": "##src##", "Target": ""}.
[0161] It should be noted that the `{lang_name}` above can be replaced with the target language you wish to translate to. For example, let's assume the desired translation is: Chinese -> Target Language.
[0162] ##src_entity##: Source term in the dictionary, i.e., the source language name of the technical term.
[0163] ##tgt_entity##: The target word in the dictionary (translation of the source word), that is, the target language name of the technical term.
[0164] ##src##: Text collected from specific domains, that is, one of the text data from the multiple different business domains mentioned above, i.e., the text to be translated.
[0165] For example, assuming the source language is Chinese and the target language (i.e., lang_name) is Arabic, the electronic device can, based on the source language being Chinese, extract Chinese text data containing a technical term from multiple text data sets as the i-th text to be translated. Let's assume this i-th text to be translated is: "Red blood cells contain hemoglobin, which makes blood red. Hemoglobin contains iron, so people with anemia should eat more iron-rich foods and protein to replenish their blood. Hemoglobin can combine with oxygen in the air, therefore red blood cells can be inhaled into the alveoli through hemoglobin." Oxygen is transported to tissues, while some carbon dioxide produced by metabolism in tissues is also transported to the lungs via red blood cells. In the alveoli, carbon dioxide is exchanged with oxygen outside the body and expelled. Hemoglobin readily binds to carbon monoxide (CO), and once bound, it is difficult to separate. When CO levels in the air are high and remain elevated for an extended period, carbon monoxide poisoning may occur. The technical term "hemoglobin" in the i-th text to be translated is found to be its Arabic name in a terminology dictionary. Furthermore The target language name for the technical term was determined. Next, the Arabic name for the electronic device based on the technical term "hemoglobin" was... Translate the i-th text to be translated into Arabic to obtain the i-th translated text. This yields the i-th first training prompt sample as shown below:
[0166] For example, the i-th first training cue sample is: {"source entity":"hemoglobin","target entity": "source": "Red blood cells contain hemoglobin, which gives blood its red color. Hemoglobin contains iron, so people with anemia should eat more iron-rich foods and protein to replenish their blood. Hemoglobin can bind with oxygen in the air, so red blood cells can transport oxygen inhaled into the alveoli to the tissues via hemoglobin. Some carbon dioxide produced by metabolism in the tissues is also transported to the lungs via red blood cells, where it exchanges gas with oxygen outside the body through the alveoli, expelling the carbon dioxide. Hemoglobin is more likely to bind with carbon monoxide (CO), and once bound, it is not easily separated. When the CO content in the air increases and persists for a long time, it can cause carbon monoxide poisoning." "target":
[0167] Using the method described above, the electronic device can identify N1 first training cue samples.
[0168] The following describes the specific process of constructing N2 second training prompt samples based on a terminology translation dictionary for electronic devices.
[0169] In some embodiments, if the training prompt samples include second training prompt samples, then the construction of N2 second training prompt samples based on the terminology translation dictionary in S102-A includes at least the following methods:
[0170] Method 1: When constructing each of the N2 second training prompt samples, the electronic device acquires text data containing multiple technical terms from multiple text data sets as the text to be translated. The source language names of these technical terms are determined from the text data. Based on these source language names, the target language names corresponding to these technical terms are retrieved from a terminology translation dictionary. Based on these source language names and target language names, the text to be translated in the source language is translated into the target language to obtain the translated text. Finally, based on the aforementioned source language names and target language names of the technical terms, the text to be translated in the source language, and the translated text in the target language, the second training prompt sample is constructed.
[0171] Method 2: The electronic device can construct N2 second training cue samples through the following steps S102-A-b1 to S102-A-b4:
[0172] S102-A-b1. For the j-th second training prompt sample among N2 second training prompt samples, select the source language name and target language name of M professional terms from the terminology translation dictionary, where M is a positive integer greater than 1 and j is a positive integer less than or equal to N2.
[0173] S102-A-b2: Based on the source language names of M technical terms, construct the j-th text to be translated in the source language. The j-th text to be translated includes the source language names of R technical terms out of the M technical terms, where R is a positive integer less than or equal to M and greater than 1.
[0174] S102-A-b3: Based on the source language names and target language names of M technical terms, translate the j-th text to be translated in the source language into the target language to obtain the j-th translated text in the target language;
[0175] S102-A-b4. Based on the source language name and target language name of M technical terms, as well as the j-th text to be translated in the source language and the j-th translated text in the target language, the j-th second training prompt sample is constructed.
[0176] In this embodiment, the process of constructing each of the N2 second training prompt samples based on the terminology translation dictionary is basically the same. For ease of description, the construction of the j-th second training prompt sample will be used as an example.
[0177] In Method 2, when constructing the j-th second training prompt sample based on the terminology translation dictionary, the electronic device first selects the source language names and target language names of M specialized terms from the terminology translation dictionary. Next, based on the source language names of the M specialized terms, it constructs the j-th text to be translated in the source language, which includes the source language names of R specialized terms from the aforementioned M specialized terms. Then, based on the source language names and target language names of the M specialized terms, the electronic device translates the j-th text to be translated in the source language into the target language, obtaining the j-th translated text in the target language. Finally, based on the source language names and target language names of the M specialized terms, as well as the j-th text to be translated in the source language and the j-th translated text in the target language, the j-th second training prompt sample is constructed.
[0178] Method 2 not only improves the model's generalization ability but also introduces certain interference terms, thereby enhancing the model's ability to process complex text.
[0179] In one possible implementation, when constructing the j-th second training prompt sample, the electronic device can first obtain an instruction, denoted as the second instruction. This second instruction indicates the generation method of the second training prompt sample, the source and target languages involved in the second training prompt sample, and the format information of the second training prompt sample. Thus, the electronic device can retrieve the source and target language names of M technical terms from a terminology translation dictionary based on the source and target languages indicated by the second instruction. Next, based on the source language names of these M technical terms, a sentence containing at least two technical terms from the M technical data is constructed, and this sentence is denoted as the j-th text to be translated. Then, based on the source and target language names of these M technical terms, the j-th text to be translated is translated to obtain a translated text, i.e., the j-th translated text. Finally, based on the format of the second training prompt sample indicated by the second instruction, the electronic device combines the source and target language names of the M technical terms, the j-th text to be translated, and the j-th translated text to obtain the j-th second training prompt sample.
[0180] For example, the indication information of the second training prompt sample is as follows, including system prompt information and user prompt information:
[0181] The system prompts: "You are a bilingual speaker whose native language is Chinese and whose native language is {lang_name}. If you only have one word-pair dictionary with translations, you need to construct a Chinese sentence using those words and then translate it into {lang_name} using the same dictionary with the corresponding translations. The format is {"dictionary": {"}, "source": "", "target": "}. As needed, construct the Chinese "source" sentence using the words from the dictionary, then translate that sentence into {lang_name} and fill in the "target" sentence. Ensure the translation accurately reflects the provided dictionary entries. Please output the final JSON format containing the source and target sentences, ensuring that no illustrations or demos are included."
[0182] User prompt: {"dicts": ##dicts##, "source": "", "target": ""}.
[0183] Here, ##dicts##: A dictionary extracted from a terminology translation dictionary to form a dictionary format, for example, a dictionary consisting of the source language names and target language names of M technical terms. The format is: {source1:target1, source2:target2, source3:target3…}.
[0184] "source": This is a sentence to be translated generated from several words in a useful dictionary. For example, a sentence generated from a combination of R terms out of M technical terms is the text to be translated.
[0185] "target": The sentence translated from "source", i.e., the translated text.
[0186] For example, assuming the source language is Chinese and the target language (lang_name) is English, the electronic device selects five technical terms from the terminology translation dictionary. The Chinese names of these five terms are: ribonucleic acid, ribonucleic acid, adenine, pentose sugar, and guanine. The English names of these five terms are: Ribonucleotide, ribonucleic acid, adenine, pentose sugar, and guanine. Using the source language names of these five terms, a sentence is constructed: "Ribonucleic acid is a constituent of ribonucleic acid (RNA), composed of one base, one pentose sugar, and one phosphate molecule." This sentence is denoted as the j-th text to be translated. Then, based on the English names of these five terms, the j-th text to be translated is translated into English, resulting in the j-th translated text. Thus, the j-th second training hint sample is obtained as shown below:
[0187] For example, the j-th second training hint sample is: {"dicts":{Ribonucleotide, ribonucleic acid, adenine, pentose sugar, guanine}, "source":"Ribonucleotides are the building blocks of ribonucleic acid (RNA), consisting of one molecule of base, one molecule of pentose sugar, and one molecule of phosphate," "target":"Ribonucleotides are the building blocks of ribonucleic acid (RNA), consisting of one molecule of base, one molecule of pentose sugar, and one molecule of phosphate."}
[0188] Using the method described above, the electronic device can identify N2 second training cue samples.
[0189] In some embodiments, when constructing training prompt samples, the present application embodiments can use a filtering mechanism to remove translation results that do not effectively utilize the terminology translation dictionary from the above-mentioned translation results (e.g., the translation result of the i-th text to be translated or the translation result of the j-th text to be translated) to ensure the high quality and reliability of the final output translation results, thereby improving the accuracy of the constructed training prompt samples.
[0190] In this embodiment of the application, after the electronic device determines N1 first training prompt samples and / or N2 second training prompt samples based on the above steps, it executes the above steps S102-B to obtain training prompt samples for multiple languages based on the N1 first training prompt samples and / or N2 second training prompt samples.
[0191] In one example, N1 first training cue samples and / or N2 second training cue samples are determined as training cue samples for multiple languages.
[0192] In one example, the N1 first training cue samples and / or N2 second training cue samples are filtered, for example, training cue samples with too short text length or too many special characters are deleted, and finally training cue samples in multiple languages are obtained.
[0193] In this embodiment, the application of these two training prompt samples enables flexible handling of various translation needs, ranging from simple to complex, while maintaining efficiency and accuracy in the translation process. This method not only significantly improves translation quality but also provides customized translation solutions to meet the professional translation needs of different fields and languages.
[0194] In addition, the embodiments of this application use an automated method to generate training prompt samples in the above-mentioned multiple languages, which reduces the need for manual annotation, increases the manual cost of model training, and improves the efficiency of model training.
[0195] In this embodiment of the application, after the electronic device constructs training prompt samples in multiple languages based on the above steps, it executes the following step S103.
[0196] S103. Using training cue samples in multiple languages, fine-tune the pre-trained translation model to obtain the fine-tuned translation model.
[0197] In this embodiment of the application, there are no restrictions on the type of pre-trained translation model.
[0198] In some embodiments, the pre-trained translation model described above can be an open-source large-scale language model, such as GLM or LLaMA, which has acquired deep text understanding and generation capabilities through pre-training on massive datasets.
[0199] In the embodiments of this application, such as Figure 3 As shown, the pre-trained translation model is fine-tuned using training prompts in multiple languages constructed above, enhancing its ability to accurately translate using the terminology dictionary provided in the input. This fine-tuning process not only improves the model's translation accuracy but also enables the model to precisely replace terms in the dictionary based on context, ensuring the professionalism and accuracy of the translation.
[0200] In some embodiments, to improve the efficiency and effectiveness of fine-tuning, a vLLM (very large language model) framework can be employed, which supports efficient model training while maintaining underlying complexity. For example, using ZeRO (zero redundancy optimizer) and LoRA (low rank adapter) optimizes the model's training process, enabling the model to adapt to specific translation tasks in a shorter time. Through this approach, the fine-tuned translation model not only learns language patterns but is also trained to recognize and apply terminology translation information provided in the model's input, making it particularly suitable for processing domain-specific texts such as medical, legal, or technical documents.
[0201] The following section describes the specific process of fine-tuning the pre-trained translation model using training prompts in multiple languages to obtain the fine-tuned translation model.
[0202] The embodiments of this application do not limit the specific method of fine-tuning the pre-trained translation model based on training prompt samples in multiple languages for electronic devices to obtain the fine-tuned translation model.
[0203] In some embodiments, as described above, the training prompt sample includes the source language name and target language name of the technical term, as well as the text to be translated and the corresponding translated text. When this training prompt sample is input into a pre-trained translation model, the pre-trained translation model can learn the source language name and target language name of the technical term, as well as the text to be translated and the corresponding translated text, thereby obtaining a fine-tuned translation model.
[0204] In some embodiments, such as Figure 4 As shown, for each training prompt sample in multiple languages, a pre-trained translation model, based on a terminology translation dictionary and the source and target language names of at least one specialized term included in the training prompt sample, translates the text to be translated in the training prompt sample, obtaining the translation result. Based on the translation result and the translated text included in the training prompt sample, the loss of the pre-trained translation model is determined. Based on the loss, the pre-trained translation model is fine-tuned to obtain the fine-tuned translation model. For example, based on the loss corresponding to each training prompt sample in multiple languages, the overall loss of the model is determined, and then based on the overall loss of the model, the parameters of the fine-tuned translation model are updated to obtain the fine-tuned translation model.
[0205] In this embodiment, the pre-trained translation model is supervised and fine-tuned using training cue samples in multiple languages generated above to improve the model's ability to translate using a terminology translation dictionary.
[0206] In this embodiment, training prompts in multiple languages are used to fine-tune a pre-trained translation model, resulting in a fine-tuned model. This fine-tuned model not only enables rapid and accurate training but also allows for translation in multiple languages, thus achieving accurate translation of terminology in specific domains. By leveraging the powerful text understanding capabilities of large language models, it achieves automated and efficient extraction and translation of domain-specific terminology from text. Compared to traditional methods, the method in this embodiment offers higher efficiency, processing power, and scalability (the same method can be implemented using different large language models), and has broad application prospects in areas such as machine translation, text mining, and knowledge graph construction.
[0207] The translation model training method provided in this application involves acquiring a terminology translation dictionary, which includes different language names of professional terms from different business fields. Then, based on the terminology translation dictionary, training prompt samples in multiple languages are constructed. These training prompt samples include at least one professional term with two different language names, namely the source language name and the target language name, as well as the source language text to be translated and the target language translation text. The translation text is obtained by translating the source language text to be translated into the target language by translating the source language text to be translated into the target language text. In other words, the training prompt samples are used to instruct that when translating the source language text to be translated into the target language translation text, the source language name of at least one professional term in the text to be translated into the target language name should be translated into the target language name. Finally, the pre-trained translation model is fine-tuned using the training prompt samples in multiple languages to obtain a fine-tuned translation model. Therefore, the terminology translation dictionary in this application includes different language names of professional terms in different business fields. Based on this terminology translation dictionary, a rich set of multilingual training prompts can be constructed. Then, using these rich multilingual training prompts, the pre-trained translation model can be optimized and fine-tuned in a targeted manner. This allows the fine-tuned translation model to translate in different language environments without having to train the translation model from scratch. This not only saves a lot of time and computing resources, but also significantly improves the translation model's professionalism and accuracy by finely adjusting the pre-trained translation model's response to specific professional terms.
[0208] The training process of the translation model in the embodiments of this application has been described above. The following section will combine... Figure 5 The translation method provided in the embodiments of this application will be further described.
[0209] Figure 5 This is a flowchart illustrating a translation method provided in one embodiment of this application. The executing entity in this embodiment is a device with translation functionality, such as a translation apparatus. In some embodiments, the translation apparatus in this embodiment may be... Figure 1 The server in, or for Figure 1 Terminal devices in, or for Figure 1 The system consists of a server and terminal devices. For ease of description, this application uses an electronic device as an example for illustration.
[0210] like Figure 5 As shown, the translation method of this application embodiment includes the following steps:
[0211] S201. Obtain translation request.
[0212] The translation request includes a first text to be translated. This translation request is used to request that the first text to be translated be translated into a translated text in the target language.
[0213] In this embodiment, the pre-trained translation model can be fine-tuned using the method described in the above embodiments to obtain the fine-tuned translation model. This fine-tuned translation model can accurately translate specialized terms from different fields. Thus, the fine-tuned translation model can be used to translate the first text to be translated.
[0214] In this application embodiment, the specific methods by which the electronic device acquires the first text to be translated include at least the following:
[0215] Example 1: If the electronic device is a terminal device, the user can input the first text to be translated on the terminal device. For example, the terminal device in this embodiment of the application has a translation platform client installed. It should be noted that the translation platform client can be a standalone client, meaning the user needs to download and install the translation platform client. Optionally, the translation platform can also be hosted in other applications or browsers. Figure 6 As shown, assuming that the translation platform in this application embodiment has an independent client, when an object needs to translate, the client of the translation platform on the terminal device can be triggered, and then the translation information input interface can be entered. The object can input the first text to be translated in the translation information input interface, and then the terminal device obtains the translation request.
[0216] Example 2: If the electronic device is a server, the object can input the first text to be translated on the terminal device. For example... Figure 7 As shown, the object triggers the client of the translation platform on the terminal device, which then enters the translation information input interface, where the object can input the first text to be translated. Next, the terminal device sends a translation request to the server, which includes the first text to be translated.
[0217] In some embodiments, in addition to inputting the first text to be translated, the object can also input the source language and the target language. For example, as described above. Figure 6 and Figure 7 The translation information input interface shown also includes options for source language and target language. The user can select the source language and target language. Optionally, the terminal device can automatically identify the source language based on the first text to be translated entered by the user.
[0218] In some embodiments, the translation request of this application may include, in addition to the first text to be translated, the source language names and target language names of Q technical terms input by the object. It should be noted that these Q technical terms are technical terms related to the first text to be translated; for example, the first text to be translated may contain at least one of these Q technical terms. This guides the translation model to accurately translate the first text to be translated based on the source language names and target language names of these Q technical terms.
[0219] In this embodiment of the application, after the electronic device receives the translation request, it executes the following step S202.
[0220] S202. Select the target translation model from the K translation models.
[0221] Among them, the K translation models include fine-tuned translation models, which are obtained by fine-tuning pre-trained translation models using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. Each training prompt sample includes the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer.
[0222] The embodiments of this application include K translation models, which include the fine-tuned translation model described above, and may also include other translation models, such as pre-trained translation models.
[0223] In this embodiment, the electronic device can select one translation model from these K translation models as the target translation model to perform the subsequent translation process.
[0224] This application does not limit the specific method by which the electronic device selects the target translation model from K translation models.
[0225] In some embodiments, the electronic device may default one of the above K translation models as the target translation model, for example, the above fine-tuned translation model may be defaulted as the target translation model.
[0226] In some embodiments, the electronic device receives a model selection operation from object input, and then selects a target translation model from K translation models based on the model selection operation.
[0227] In this embodiment, the translation system comprised of a terminal device and a server integrates the APIs of K translation models, including the API of the finely tuned translation model mentioned above, as well as APIs of other translation models, such as the GPT-4 model. This integration not only significantly improves task execution efficiency and system scalability but also enables precise calculation and control of the input text length by supporting token counting. This feature is crucial because it helps optimize resource usage and save costs. This embodiment provides K API call options during operation, offering flexibility and allowing objects to select the most suitable translation service based on specific needs. By effectively managing the length and complexity of the input text, not only is high efficiency ensured but also the consumption of API tokens is minimized, thereby guaranteeing the system's economy and sustainability.
[0228] For example, such as Figure 8 As shown, the translation information input interface in this embodiment includes a target translation model option in addition to the text input box to be translated. Figure 9 As shown, when an object triggers the target translation model option, the terminal device responds to the object's triggering operation by displaying a list of K translation models. The object can then select a target translation model from this list. For example, as... Figure 10 As shown, if an object triggers a fine-tuned translation model in the list, the terminal device responds to the object's triggering operation on the fine-tuned translation model by displaying the selected target model as the fine-tuned translation model in the target translation model selection box.
[0229] In this embodiment, by setting APIs for K translation models, flexible selection of different models can be achieved. For example, for large amounts of text requiring rapid processing, OpenAI's GPT API can be used. As another example, for tasks requiring high accuracy and industry-specific terminology processing, the finely tuned translation model described above can be selected.
[0230] In some embodiments, the system interface allows objects to easily switch between and compare the translation effects of different translation models, and supports real-time feedback and modification.
[0231] In one example, the K translation models mentioned above include pre-trained translation models and fine-tuned translation models. For example... Figure 11 As shown, the translation information input interface can directly include options for a pre-trained translation model and a fine-tuned translation model. Users can switch between these two model options to evaluate the translation performance of each model. For example, Figure 11 As shown, in this embodiment of the application, the translation information input interface and the translation interface can be located on the same page. For example, the translation information input interface is on the left side of the page, and the translation interface can be on the right side of the page. Thus, after an object inputs the first text to be translated in the translation information input interface, it can select the pre-trained translation model option. In response to the object's triggering operation on the pre-trained translation model option, the terminal device uses the pre-trained translation model to translate the first text to be translated, obtains the translation result of the first translated text, and sends the translation result to the terminal device, which displays it in the translation interface. Optionally, the object can also select the fine-tuned translation model option. In response to the object's triggering operation on the fine-tuned translation model option, the terminal device uses the fine-tuned translation model to translate the first text to be translated, obtains the translation result of the first translated text, and sends the translation result to the terminal device, which displays it in the translation interface. Of course, the translation information input interface and the translation interface may not be located on the same page.
[0232] In some embodiments, during the generation of SFT data, the electronic device can automatically generate term-related translation input based on carefully designed training prompts by calling the API of the GPT-4 model. This step is crucial for ensuring translation accuracy and timeliness. Furthermore, when highly customized translation is required, the device can select a fine-tuned translation model optimized for specific terms and contexts, providing more professional and accurate translation output. This flexible API calling strategy not only enhances the user experience but also expands the system's application breadth and depth.
[0233] In this embodiment of the application, after the electronic device determines the target translation model based on the above steps, it executes the following step S203.
[0234] S203. Based on the first text to be translated, determine the input information of the target translation model.
[0235] This application does not limit the specific method by which the electronic device determines the input information of the target translation model based on the first text to be translated.
[0236] In some embodiments, the translation request may include, in addition to the first text to be translated, indication information of the source language and the target language. In this way, the electronic device can determine the first text to be translated, the indication information of the source language and the target language, as the input information for the target translation model.
[0237] In some embodiments, S203 above includes the following steps S203-A:
[0238] S203-A: Based on the type of the target translation model and the first text to be translated, determine the input information of the target translation model.
[0239] As described above, the target translation model in this embodiment can be a fine-tuned translation model or a pre-trained translation model, such as GPT-4. In this way, the electronic device can determine the input information of the target translation model based on the type of the target translation model and the first text to be translated.
[0240] In one possible embodiment, if the target translation model is the fine-tuned translation model, the first text to be translated can be directly determined as the input information of the model.
[0241] In one possible implementation, if the target translation model is a fine-tuned translation model or a pre-trained translation model, then the above S203-A includes the following steps S203-A1 to S203-A3:
[0242] S203-A1. Based on the first text to be translated, obtain the source language names and target language names of Q technical terms, where Q is a positive integer;
[0243] S203-A2, Based on the source language names and target language names of Q technical terms, and the first text to be translated, determine a translation prompt sample, wherein the translation prompt sample is used to instruct that when translating the first text to be translated from the source language into the translated text of the target language, the translation should be based on the source language names and target language names of Q technical terms;
[0244] S203-A3: Determine the input information of the model based on translation prompt samples.
[0245] In this implementation, if the target translation model is a fine-tuned translation model or a pre-trained translation model, then based on the first text to be translated, the source language names and target language names of Q technical terms are obtained, wherein the first text to be translated includes at least one of these Q technical terms.
[0246] In this embodiment of the application, obtaining the source language names and target language names of Q technical terms based on the first text to be translated includes at least the following methods:
[0247] Method 1: The translation request includes the source language names and target language names of Q technical terms. In this way, the electronic device can obtain the source language names and target language names of the Q technical terms input by the object by parsing the translation request.
[0248] For example, such as Figure 12 As shown in the embodiment of this application, in addition to the first text to be translated, the object also inputs the source language names and target language names of Q technical terms.
[0249] For example, the source language name of the technical term input by the object is "tumor stem cells," and the target language name is "Tumor stem cells." The first text to be translated by the object input is: "Hematopoietic stem cells are adult stem cells in the blood system. They are a heterogeneous population with the ability to self-renew for a long time and the potential to differentiate into various mature blood cells. They are the most historically and deeply studied type of adult stem cells, and have important guiding significance for the study of various stem cells, including tumor stem cells."
[0250] This application embodiment does not restrict the specific method of inputting the source language names and target language names of Q technical terms and the first text to be translated.
[0251] Method 2: The electronic device extracts the source language names of Q technical terms from the first text to be translated, determines the business domain to which the first text to be translated belongs, and then, based on the source language names of the Q technical terms, queries the different language names of the technical terms included in the business domain to which the first text to be translated belongs in the terminology translation dictionary to obtain the target language names of these Q technical terms. In Method 2, the object can indicate the type of target language.
[0252] In this embodiment of the application, after obtaining the source language names and target language names of Q technical terms based on the above steps, the electronic device determines a translation prompt sample based on the source language names and target language names of the Q technical terms and the first text to be translated.
[0253] The translation prompt sample in this application includes the source language names and target language names of Q technical terms, as well as a first text to be translated.
[0254] This application does not limit the specific representation of the translation prompt samples in its embodiments.
[0255] In one example, the translation prompt sample is formatted as: "In this text, \"###src_term1###\" is usually translated as \"###tgt_term1###\"\nText: ###source_text###, use the given translation dictionary to convert the following text to English."
[0256] In one example, the translation prompt sample is formatted as: "When you encounter \"###src_term1###\", translate it to \"###tgt_term1###\"\nText: ###source_text###, use the provided translation dictionary to convert subsequent text to English."
[0257] In one example, the translation prompt sample is formatted as: "\"###src_term1###\" is translated as "###tgt_term1###\"\n###source_text###, using the provided translation dictionary to convert the following text into English.
[0258] The electronic device can use any of the formats shown in the examples above to combine the source language names and target language names of Q technical terms with the first text to be translated to obtain a translation prompt sample. This translation prompt sample is used to instruct that when translating the first text to be translated from the source language to the target language, the translation should be based on the source language names and target language names of the Q technical terms.
[0259] In some embodiments, the terminal device can directly provide multiple translation prompt samples. Users can replace the technical terms in the samples with their own required technical terms and input the sentence to be translated (i.e., the first text to be translated) to obtain the translation result using a terminology translation dictionary. A key advantage of this method is that different translation prompt samples may produce different translation results, so users can choose the optimal translation result by changing the sample. Furthermore, the translation samples in this application embodiment support not only Chinese and English but also other common less commonly spoken languages, thus greatly expanding the applicability and coverage of the translation method provided in this application embodiment. This multilingual support enables the translation method provided in this application embodiment to serve a diverse range of users, especially those in fields requiring accurate translation of technical terms, such as academic research, international legal and technical document translation. This application embodiment, through carefully designed translation prompt samples and a powerful translation model, not only simplifies the translation process using complex terminology dictionaries but also ensures high accuracy and professionalism in translation. Users can easily customize and optimize the translation process to meet the translation needs of various professionals and individuals, making the translation process more intelligent and automated.
[0260] For example, such as Figure 13 As shown, the translation information input interface in this embodiment includes a sample selection box for translation prompts. When an object triggers this selection box, various translation prompt samples are displayed. When an object triggers another sample, such as sample 2, the following is displayed: Figure 14 The sample template shown allows users to fill in the source and target language names of Q technical terms, along with the first text to be translated, to obtain a translation suggestion sample. The terminal device can then send this translation suggestion sample to the server.
[0261] Next, the electronic device determines the model's input information based on the translation prompt samples.
[0262] In one example, the electronic device can directly identify the translated prompt sample as input information for the model.
[0263] In one example, the electronic device acquires P examples, and then obtains input information based on these P examples and translation prompt samples. Each of the P examples includes a source language name and a target language name of at least one technical term, as well as a second text to be translated and a translated text of the second text to be translated. The translated text of the second text to be translated is obtained by translating the source language second text to be translated into the target language based on the source language name and target language name of the aforementioned at least one technical term, where P is a positive integer.
[0264] For example, assuming the translation goal of this application embodiment is to translate Chinese into English, and assuming P equals 3, the following three examples are shown:
[0265] Example 1: {"source entity":"amino acid", "target entity":"amino acid", "source":"Amino acids are the fundamental building blocks of proteins."};
[0266] Example 2: {"source entity":"protein", "target entity":"Proteins", "source":"Proteins are the material basis of life, organic macromolecules, basic organic substances that make up cells, and the main carriers of life activities", "target":"Amino acids are the fundamental building blocks of proteins."};
[0267] Example 3: {"source entity":"cell", "target entity":"cell", "source":"Every cell and all important components in the body are involved in proteins."};
[0268] The translation prompt is as follows: "The translation of 'protein' is 'Proteins'. 'DNA carries the genetic information necessary for the synthesis of RNA and proteins, and is an essential biological macromolecule for the development and normal functioning of organisms.'" Using the provided terminology dictionary, translate the above text into English.
[0269] The technical term used in the above translation sample is "protein," and the English name for protein is "Proteins." The first text to be translated is: DNA carries the genetic information necessary for the synthesis of RNA and proteins, and is an essential biological macromolecule for the development and normal functioning of organisms.
[0270] The electronic device combines the above three examples and translation prompt samples to obtain the model's input information. Next, it executes step S204 as follows.
[0271] S204. The input information is processed by the target translation model to obtain the translated text of the first text to be translated.
[0272] In this embodiment of the application, after the electronic device determines the target translation model and the input information of the model through the above steps, it inputs the input information of the model into the target translation model for translation processing, and can obtain the translated text of the first text to be translated.
[0273] In some embodiments, as described above, when the input information of the model may include P examples and translation prompt samples, the electronic device can learn from the P examples in the input information through the target translation model, and translate the first text to be translated in the source language into the translated text in the target language based on the terminology translation dictionary and the source language names and target language names of the Q professional terms included in the translation prompt samples.
[0274] In some embodiments, the electronic device can further extract a first technical term from the first text to be translated; if the first technical term is not included in the terminology translation dictionary, the target language name of the first technical term is extracted from the translated text of the first text to be translated; and the source language name and target language name of the first technical term are added to the terminology translation dictionary. Optionally, the fine-tuned translation model can be fine-tuned again based on the updated terminology translation dictionary, and this process can be repeated cyclically to achieve dynamic updating and fine-tuning of the terminology translation dictionary and the translation model, which can further improve the translation effect.
[0275] In some embodiments, the translated terminology results are carefully sorted and stored locally for subsequent use and in-depth analysis. These high-quality translation results can not only be directly applied to real-time translation tasks, improving the speed and accuracy of translating similar texts in the future, but also serve as valuable data resources that can be integrated into a wider range of translation systems. Such integration enriches existing terminology dictionaries, particularly by supplementing them with new words and domain-specific terminology. Furthermore, the system will continuously update its terminology dictionary translation database and utilize this newly acquired data to construct new SFT data. This process includes part-of-speech tagging and domain-specific professionalism verification of the source terms, ensuring that the stored and applied terms truly reflect the unique terminology within the specific domain. These steps not only improve translation quality but also provide the model with opportunities for continuous learning and updating.
[0276] In some embodiments, the template style of the above-mentioned translation prompt samples can be continuously updated and optimized based on user feedback. This dynamic feedback mechanism allows for continuous adaptation to the specific needs of the user, fine-tuning of translation strategies and output. This continuous optimization process ensures that the system maintains high efficiency and adheres to the latest industry standards when providing translation services.
[0277] The translation method provided in this application involves obtaining a translation request, which includes a first text to be translated; selecting a target translation model from K translation models, including a fine-tuned translation model; determining the input information of the target translation model based on the translation request; and then processing the input information through the target translation model to obtain the translated text of the first text to be translated, thereby achieving accurate translation.
[0278] The translation method provided in the embodiments of this application has been generally introduced above. The following section uses the interaction between a terminal device and a server as an example to describe the translation method in the embodiments of this application.
[0279] Figure 15 This is a flowchart illustrating a translation method provided in one embodiment of this application.
[0280] like Figure 15 As shown, the translation method of this application embodiment includes the following steps:
[0281] S301, The terminal device receives the first text to be translated and the source language names and target language names of Q technical terms input by the object, and determines the translation prompt sample based on the source language names and target language names of the Q technical terms and the first text to be translated.
[0282] S302. The terminal device sends the translation prompt sample to the server.
[0283] S303. The terminal device receives the model selection operation from the object input, and selects the target translation model from K translation models based on the model selection operation.
[0284] S304. The terminal device sends the identification information of the target translation model to the server.
[0285] S305. The server determines the input information for the target translation model based on the translation prompt samples.
[0286] For example, the server identifies the translation prompt sample as the input information.
[0287] For example, the server obtains P examples and, based on the P examples and the translation prompt samples, obtains the input information.
[0288] S306. The server processes the input information using the target translation model to obtain the translated text of the first text to be translated.
[0289] For example, the server learns from the P examples in the input information using the target translation model, and translates the first text to be translated in the source language into the translated text in the target language based on the terminology translation dictionary and the source language names and target language names of the Q technical terms included in the translation prompt samples.
[0290] S307. The server sends the translated text of the first text to be translated to the terminal device.
[0291] S308, The terminal device displays the translated text.
[0292] In one example, the input information for the target translation model is: using the provided translation dictionary (i.e., the Chinese and English names of the following technical terms), translate the following text into English. In this paper, "tumor stem cells" is generally translated as "Tumor stem cells". The text (i.e., the first text to be translated) is: Hematopoietic stem cells are adult stem cells in the blood system. They are a heterogeneous population with the ability to self-renew for a long time and the potential to differentiate into various types of mature blood cells. They are the oldest and most thoroughly studied type of adult stem cells, and have important guiding significance for the study of various stem cells, including tumor stem cells.
[0293] The output of the target translation model is: Hematopoietic stem cells are adult stem cells in the blood system, a heterogeneous population with the ability for long-term self-renewal and the potential to differentiate into various mature blood cells. It is the longest and most in-depth study of adult stem cells, and has important guiding significance for the research of various types of stem cells, including tumor stem cells.
[0294] In one example, the input to the target translation model is: to convert subsequent text into Korean with the help of a given translation dictionary. Dictionary: {"dicts":{"grain drying center": Electric vehicles: Zhang San: Li Si: Talent Showdown: Wang Wu: Zhao Liu: The text (i.e., the first text to be translated) is: Zhang San and Li Si saw an electric vehicle at the grain drying center and decided to participate in a talent competition.
[0295] The output of the target translation model is:
[0296] The translation method provided in this application not only supports bilingual translation such as Chinese and English, but can also be extended to translation between other multilingual languages. Furthermore, it is applicable to text data processing in various fields, such as science, technology, medicine, and finance, demonstrating broad application potential. Additionally, the translation method in this application is based on translation prompt samples, enabling the target translation model to perform more refined contextual analysis and adaptive learning, thereby providing more accurate translations when translating new words and proper nouns, thus improving translation accuracy. Therefore, the translation method provided in this application is highly automated, efficient, accurate, and highly versatile and adaptable, demonstrating powerful translation effects in terminology translation and professional text processing.
[0297] The above text combined Figures 2 to 15 The present application describes in detail embodiments of its translation model training and translation method. The following section combines... Figure 16 The following describes in detail the device embodiments of this application.
[0298] Figure 16 This is a schematic block diagram of a translation model training device provided in one embodiment of this application.
[0299] like Figure 16 As shown, the translation model training device 10 includes:
[0300] Acquisition unit 11 is used to acquire a terminology translation dictionary, which includes different language names of professional terms in different business fields;
[0301] The construction unit 12 is used to construct training prompt samples in multiple languages based on the terminology translation dictionary. The training prompt samples include the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language name of the at least one technical term in the text to be translated into the target language when translating the text to be translated into the target language.
[0302] The fine-tuning unit 13 is used to fine-tune the pre-trained translation model using training cue samples from the multiple languages to obtain the fine-tuned translation model.
[0303] In some embodiments, the acquisition unit 11 is specifically used to acquire text data from multiple different business domains; extract the professional terms included in each text data based on the business domain to which each text data belongs, to obtain the professional terms included in different business domains; determine the different language names of the professional terms included in different business domains; and arrange the professional terms included in the same business domain in the different business domains together based on the different language names of the professional terms included in different business domains to construct the terminology translation dictionary.
[0304] In some embodiments, the construction unit 12 is specifically configured to construct at least one of N1 first training prompt samples and N2 second training prompt samples based on the terminology translation dictionary, wherein N1 and N2 are both positive integers and the sum of N1 and N2 equals N, the first training prompt sample includes the source language name and target language name of a technical term, and the second training prompt sample includes the source language names and target language names of multiple technical terms; and based on at least one of the N1 first training prompt samples and N2 second training prompt samples, training prompt samples for the multiple languages are obtained.
[0305] In some embodiments, if the training prompt sample includes the first training prompt sample, then the construction unit 12 is specifically configured to, for the i-th first training prompt sample among the N1 first training prompt samples, obtain the i-th text to be translated from the plurality of text data that includes a technical term, and determine the source language name of the technical term from the i-th text to be translated, where i is a positive integer less than or equal to N1; based on the source language name of the technical term, query the term translation dictionary to obtain the target language name corresponding to the source language name of the technical term; based on the source language name and target language name of the technical term, translate the i-th text to be translated from the source language into the target language to obtain the i-th translated text; and construct the i-th first training prompt sample based on the source language name and target language name of the technical term, the i-th text to be translated from the source language, and the i-th translated text from the target language.
[0306] In some embodiments, if the training prompt sample includes the second training prompt sample, then the construction unit 12 is specifically configured to, for the j-th second training prompt sample among the N2 second training prompt samples, select the source language names and target language names of M professional terms from the terminology translation dictionary, where M is a positive integer greater than 1 and j is a positive integer less than or equal to N2; based on the source language names of the M professional terms, construct the j-th text to be translated in the source language, where the j-th text to be translated includes the source language names of R professional terms among the M professional terms, where R is a positive integer less than or equal to M and greater than 1; based on the source language names and target language names of the M professional terms, translate the j-th text to be translated in the source language into the target language to obtain the j-th translated text in the target language; and based on the source language names and target language names of the M professional terms, as well as the j-th text to be translated in the source language and the j-th translated text in the target language, construct the j-th second training prompt sample.
[0307] In some embodiments, the fine-tuning unit 13 is specifically configured to, for each training prompt sample in the multiple languages, translate the text to be translated in the training prompt sample using the pre-trained translation model, based on the terminology translation dictionary and the source language name and target language name of at least one technical term included in the training prompt sample, to obtain a translation result of the text to be translated; determine the loss of the pre-trained translation model based on the translation result of the text to be translated and the translated text included in the training prompt sample; and fine-tune the pre-trained translation model based on the loss to obtain a fine-tuned translation model.
[0308] In some embodiments, the acquisition unit 11 is specifically used to collect relevant data from different business areas; preprocess the relevant data from the different business areas to obtain multiple text data from different business areas, wherein the length of the text data meets a preset length.
[0309] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, further details will not be provided here. Specifically, Figure 16 The apparatus shown can execute the embodiments of the above-described model training method, and the foregoing and other operations and / or functions of each module in the apparatus are respectively for implementing the method embodiments corresponding to the electronic device, which will not be described in detail here for the sake of brevity.
[0310] Figure 17 This is a schematic block diagram of a translation device provided in an embodiment of this application.
[0311] like Figure 17 As shown, the translation device 20 includes:
[0312] Acquisition unit 21 is used to acquire a translation request, wherein the translation request includes a first text to be translated;
[0313] Selection unit 22 is used to select a target translation model from K translation models. The K translation models include a fine-tuned translation model, which is obtained by fine-tuning a pre-trained translation model using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. The training prompt samples include at least one source language name and target language name of a technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer.
[0314] The determining unit 23 is used to determine the input information of the target translation model based on the first text to be translated;
[0315] Translation unit 24 is used to process the input information through the target translation model to obtain the translated text of the first text to be translated.
[0316] In some embodiments, the determining unit 23 is specifically used to determine the input information of the target translation model based on the type of the target translation model and the first text to be translated.
[0317] In some embodiments, the determining unit 23 is specifically used to determine the first text to be translated as the input information if the target translation model is the fine-tuned translation model; or, if the target translation model is the fine-tuned translation model or a pre-trained translation model, it obtains the source language names and target language names of Q technical terms based on the first text to be translated, and determines translation prompt samples based on the source language names and target language names of the Q technical terms and the first text to be translated, and then determines the input information based on the translation prompt samples, wherein the translation prompt samples are used to indicate that when translating the first text to be translated in the source language into the translated text in the target language, the translation is performed based on the source language names and target language names of the Q technical terms, where Q is a positive integer.
[0318] In some embodiments, the determining unit 23 is specifically used to parse the translation request to obtain the source language names and target language names of the Q technical terms input by the object, wherein the first text to be translated includes at least one of the Q technical terms; or, to extract the source language names of the Q technical terms from the first text to be translated, determine the business domain to which the first text to be translated belongs, and then, based on the source language names of the Q technical terms, query the target language names of the Q technical terms from the different language names of each technical term included in the business domain in the terminology translation dictionary.
[0319] In some embodiments, the determining unit 23 is specifically used to determine the translation prompt sample as the input information; or, to obtain P examples and, based on the P examples and the translation prompt sample, to obtain the input information, wherein the examples include the source language name and target language name of at least one technical term, as well as a second text to be translated and the translated text of the second text to be translated, wherein the translated text of the second text to be translated is obtained by translating the second text to be translated from the source language to the target language based on the source language name and target language name of the at least one technical term, and wherein P is a positive integer.
[0320] In some embodiments, if the input information includes the P examples, the translation unit 24 is specifically used to learn the P examples in the input information through the target translation model, and translate the first text to be translated in the source language into the translated text in the target language based on the terminology translation dictionary and the source language names and target language names of the Q professional terms included in the translation prompt sample.
[0321] In some embodiments, the selection unit 22 is specifically used to receive a model selection operation input by an object; and to select the target translation model from the K translation models based on the model selection operation.
[0322] In some embodiments, the processing unit 24 is further configured to extract a first technical term from the first text to be translated; if the term translation dictionary does not include the first technical term, then extract the target language name of the first technical term from the translated text of the first text to be translated; and add the source language name and target language name of the first technical term to the term translation dictionary.
[0323] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be referred to the method embodiments. To avoid repetition, further details will not be provided here. Specifically, Figure 17 The apparatus shown can perform the above-described translation method embodiments, and the foregoing and other operations and / or functions of each module in the apparatus are respectively for implementing the method embodiments corresponding to the electronic device, which will not be described in detail here for the sake of brevity.
[0324] The apparatus of this application embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this application can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application embodiment can be directly embodied as being executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. Optionally, the software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.
[0325] Figure 18 This is a schematic block diagram of the electronic device provided in the embodiments of this application. Figure 18 The electronic device can be a terminal device or a server, and can be used to execute the above method embodiments.
[0326] like Figure 18 As shown, the electronic device 30 may include:
[0327] The system includes a memory 31 and a processor 32. The memory 31 stores a computer program 33 and transfers the program code 33 to the processor 32. In other words, the processor 32 can retrieve and run the computer program 33 from the memory 31 to implement the methods described in the embodiments of this application.
[0328] For example, the processor 32 can be used to execute the steps in the above method according to the instructions in the computer program 33.
[0329] In some embodiments of this application, the processor 32 may include, but is not limited to:
[0330] General-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0331] In some embodiments of this application, the memory 31 includes, but is not limited to:
[0332] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0333] In some embodiments of this application, the computer program 33 may be divided into one or more modules, which are stored in the memory 31 and executed by the processor 32 to complete the page recording method provided in this application. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program 33 in the electronic device.
[0334] like Figure 18 As shown, the electronic device 30 may further include:
[0335] Transceiver 34, which can be connected to processor 32 or memory 31.
[0336] The processor 32 can control the transceiver 34 to communicate with other devices; specifically, it can send information or data to other devices or receive information or data sent by other devices. The transceiver 34 may include a transmitter and a receiver. The transceiver 34 may further include antennas, and the number of antennas may be one or more.
[0337] It should be understood that the various components in the electronic device 30 are connected through a bus system, which includes a data bus, a power bus, a control bus, and a status signal bus.
[0338] According to one aspect of this application, a computer storage medium is provided that stores a computer program thereon, which, when executed by a computer, enables the computer to perform the methods of the above-described method embodiments. Alternatively, embodiments of this application also provide a computer program product containing instructions that, when executed by a computer, cause the computer to perform the methods of the above-described method embodiments.
[0339] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method described in the above-described method embodiments.
[0340] In other words, when implemented using software, it can be implemented wholly or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0341] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0342] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0343] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0344] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.< / content>
Claims
1. A method for training a translation model, characterized in that, include: Obtain a terminology translation dictionary, which includes the different language names of professional terms in different business fields; Based on the terminology translation dictionary, training prompt samples in multiple languages are constructed. The training prompt samples include the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The pre-trained translation model is fine-tuned using training cue samples from the aforementioned multiple languages to obtain the fine-tuned translation model.
2. The method according to claim 1, characterized in that, The acquisition of the terminology translation dictionary includes: Acquire text data from multiple different business areas; Based on the business domain to which each piece of text data belongs, the professional terms included in each piece of text data are extracted to obtain the professional terms included in different business domains; Determine the different language names for the technical terms included in different business areas; Based on the different language names of professional terms included in different business areas, the professional terms included in the same business area within the different business areas are arranged together to construct the terminology translation dictionary.
3. The method according to claim 2, characterized in that, The construction of training prompt samples in multiple languages based on the terminology translation dictionary includes: Based on the terminology translation dictionary, at least one of N1 first training prompt samples and N2 second training prompt samples is constructed, where N1 and N2 are both positive integers and the sum of N1 and N2 equals N. The first training prompt sample includes the source language name and target language name of a technical term, and the second training prompt sample includes the source language names and target language names of multiple technical terms. Training prompt samples for the multiple languages are obtained based on at least one of the N1 first training prompt samples and the N2 second training prompt samples.
4. The method according to claim 3, characterized in that, If the training prompt samples include the first training prompt samples, then constructing N1 first training prompt samples based on the terminology translation dictionary includes: For the i-th first training prompt sample among the N1 first training prompt samples, obtain the i-th text to be translated that includes a technical term from the plurality of text data, and determine the source language name of the technical term from the i-th text to be translated, where i is a positive integer less than or equal to N1; Based on the source language name of the term, the target language name corresponding to the source language name of the term is obtained from the term translation dictionary; Based on the source language name and target language name of the aforementioned technical term, the i-th text to be translated from the source language is translated into the target language to obtain the i-th translated text; Based on the source language name and target language name of the term, the i-th text to be translated in the source language and the i-th translated text in the target language, the i-th first training prompt sample is constructed.
5. The method according to claim 3, characterized in that, If the training prompt sample includes the second training prompt sample, then based on the terminology translation dictionary, N2 second training prompt samples are constructed, including: For the j-th second training prompt sample among the N2 second training prompt samples, select the source language name and target language name of M professional terms from the terminology translation dictionary, where M is a positive integer greater than 1 and j is a positive integer less than or equal to N2; Based on the source language names of the M technical terms, construct the j-th text to be translated in the source language. The j-th text to be translated includes the source language names of R technical terms among the M technical terms, where R is a positive integer less than or equal to M and greater than 1. Based on the source language names and target language names of the M technical terms, the j-th text to be translated in the source language is translated into the target language to obtain the j-th translated text in the target language; Based on the source language names and target language names of the M technical terms, as well as the j-th text to be translated in the source language and the j-th translated text in the target language, the j-th second training prompt sample is constructed.
6. The method according to any one of claims 1-5, characterized in that, include: The process of fine-tuning the pre-trained translation model using training prompts from the multiple languages to obtain a fine-tuned translation model includes: For each training prompt sample in the multiple languages, the pre-trained translation model, based on the terminology translation dictionary and the source language name and target language name of at least one technical term included in the training prompt sample, translates the text to be translated in the training prompt sample to obtain the translation result of the text to be translated. Based on the translation result of the text to be translated and the translated text included in the training prompt samples, the loss of the pre-trained translation model is determined; Based on the loss, the pre-trained translation model is fine-tuned to obtain the fine-tuned translation model.
7. The method according to claim 2, characterized in that, The acquisition of text data from multiple different business domains includes: Collect relevant data from different business areas; The relevant data from the different business areas are preprocessed to obtain multiple text data from different business areas, and the length of the text data meets the preset length.
8. A translation method, characterized in that, include: Obtain a translation request, wherein the translation request includes a first text to be translated; A target translation model is selected from K translation models, including a fine-tuned translation model. The fine-tuned translation model is obtained by fine-tuning a pre-trained translation model using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. The training prompt samples include at least one source language name and target language name of a technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer. Based on the first text to be translated, the input information of the target translation model is determined; The input information is processed by the target translation model to obtain the translated text of the first text to be translated.
9. The method according to claim 8, characterized in that, The step of determining the input information of the target translation model based on the first text to be translated includes: Based on the type of the target translation model and the first text to be translated, the input information of the target translation model is determined.
10. The method according to claim 9, characterized in that, The step of determining the input information of the target translation model based on the type of the target translation model and the first text to be translated includes: If the target translation model is the fine-tuned translation model, then the first text to be translated is determined as the input information; or, If the target translation model is the fine-tuned translation model or the pre-trained translation model, then based on the first text to be translated, the source language names and target language names of Q technical terms are obtained, and based on the source language names and target language names of the Q technical terms, and the first text to be translated, translation prompt samples are determined, and then based on the translation prompt samples, the input information is determined. The translation prompt samples are used to indicate that when translating the first text to be translated from the source language to the target language, the translation is performed based on the source language names and target language names of the Q technical terms, where Q is a positive integer.
11. The method according to claim 10, characterized in that, The step of obtaining the source language names and target language names of Q technical terms based on the first text to be translated includes: Parsing the translation request yields the source language names and target language names of the Q technical terms input by the object, wherein the first text to be translated includes at least one of the Q technical terms; or, The source language names of the Q technical terms are extracted from the first text to be translated, and the business domain to which the first text to be translated belongs is determined. Then, based on the source language names of the Q technical terms, the target language names of the Q technical terms are obtained from the different language names of each technical term included in the business domain in the terminology translation dictionary.
12. The method according to claim 10, characterized in that, The process of determining the input information based on the translation prompt sample includes: The translation prompt sample is identified as the input information; or, Obtain P examples, and based on the P examples and the translation prompt samples, obtain the input information. The examples include the source language name and target language name of at least one technical term, as well as a second text to be translated and the translated text of the second text to be translated. The translated text of the second text to be translated is obtained by translating the source language of the second text to be translated into the target language based on the source language name and target language name of the at least one technical term. P is a positive integer.
13. The method according to claim 12, characterized in that, If the input information includes the P examples, the step of processing the input information through the target translation model to obtain the translated text of the first text to be translated includes: The target translation model learns from the P examples in the input information and, based on the terminology translation dictionary and the source and target language names of the Q technical terms included in the translation prompt samples, translates the first text to be translated from the source language into the translated text in the target language.
14. The method according to any one of claims 8-13, characterized in that, The selection of the target translation model from the K translation models includes: The model selection operation is received from the object's input; Based on the model selection operation, the target translation model is selected from the K translation models.
15. The method according to any one of claims 8-13, characterized in that, The method further includes: Extract the first technical term from the first text to be translated; If the terminology translation dictionary does not include the first professional term, then the target language name of the first professional term is extracted from the translated text of the first text to be translated. Add the source language name and target language name of the first technical term to the terminology translation dictionary.
16. A translation model training device, characterized in that, include: The acquisition unit is used to acquire a terminology translation dictionary, which includes the different language names of professional terms in different business fields; The construction unit is used to construct training prompt samples in multiple languages based on the terminology translation dictionary. The training prompt samples include the source language name and target language name of at least one technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language name of the at least one technical term in the text to be translated into the target language when translating the text to be translated into the target language. The fine-tuning unit is used to fine-tune the pre-trained translation model using training cue samples from the multiple languages, resulting in a fine-tuned translation model.
17. A translation device, characterized in that, include: The acquisition unit is used to acquire a translation request, wherein the translation request includes a first text to be translated; The selection unit is used to select a target translation model from K translation models, including a fine-tuned translation model. The fine-tuned translation model is obtained by fine-tuning a pre-trained translation model using training prompt samples in multiple languages. The training prompt samples in multiple languages are constructed based on a terminology translation dictionary. The training prompt samples include at least one source language name and target language name of a technical term, as well as the text to be translated in the source language and the translated text in the target language. The translated text is obtained by translating the source language text to be translated into the target language by translating the source language name of the at least one technical term in the text to be translated into the target language. The terminology translation dictionary includes the correspondence between the source language names and target language names of different technical terms. K is a positive integer. The determining unit is used to determine the input information of the target translation model based on the first text to be translated; The translation unit is used to process the input information through the target translation model to obtain the translated text of the first text to be translated.
18. An electronic device, characterized in that, Including processor and memory; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method as described in any one of claims 1 to 7 or 8 to 15.
19. A computer-readable storage medium, characterized in that, Used to store computer programs; The computer program causes the computer to perform the method as described in any one of claims 1 to 7 or 8 to 15.