Streaming text translation method, computer program product and electronic device
By segmenting and reconstructing streaming data and adjusting the decoder by waiting, adding, and correcting flags, the problem of low translation quality caused by fixed decoding strategies in streaming translation is solved, achieving higher-quality real-time translation.
Patent Information
- Application Number
- CN202510780867.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-26
AI Technical Summary
The decoding strategy in existing streaming translation technology is relatively fixed and lacks flexibility, resulting in low translation quality.
By segmenting the source language data to generate streaming data and reconstructing the dataset based on connection markers to obtain training data, the decoder of the first language model is adjusted, and waiting markers, addition markers, and correction markers are introduced, allowing the model to intelligently determine the translation generation strategy based on contextual information.
It improves the flexibility and intelligence of translation, avoids the mechanical nature of fixed waiting or appending, significantly improves translation quality, and solves the structural rigidity and semantic deviation problems that may occur in the translation under the traditional wait-k strategy.
Smart Images

Figure CN120706442A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing, and in particular to a streaming text translation method, a computer-readable storage medium, a computer program product, and an electronic device. Background Art
[0002] Text streaming translation (real-time translation) is a mode in which corresponding translation results are generated synchronously as input text gradually arrives. This is different from the traditional method of requiring complete input before translation. Its mission objectives focus on multiple aspects. It must ensure real-time performance and start outputting translation the moment input is received to reduce waiting time. It must also take into account accuracy, fluency, and adaptability to accurately convey semantics, make the translation natural and easy to understand, and handle texts from different fields, styles, and languages. This technology is suitable for scenarios with high time requirements, such as real-time conference interpretation and live subtitle translation.
[0003] The current mainstream technical solutions mainly focus on three directions. The first is to improve the encoder-decoder architecture, use incremental decoding to improve real-time performance and reduce latency, and use context-aware mechanisms to improve accuracy, but the problems of information utilization and dynamic change processing must be solved. The second is to guide model translation through optimized prompt engineering based on large language models, and use knowledge distillation and model compression to reduce computing costs and inference latency. However, it is necessary to explore appropriate prompt design and balance model size and translation quality. The third is to use reinforcement learning methods to model it as a reinforcement learning problem, and guide the model to make the best decision by designing a reward function. However, the reasonable design of the reward function and the complex training process bring new difficulties.
[0004] Streaming text translation based on large models is currently a hot research area. However, current solutions primarily focus on optimizing prompt words and adapting model structures to streaming translation, facing numerous challenges. Currently, decoding strategies for streaming translation are almost all based on or extended by wait-k. The core idea of wait-k is that the translation model first reads K source language words and outputs one target language word. Thereafter, each subsequent source language word is output as a target word. This decoding method is relatively rigid and inflexible. Summary of the Invention
[0005] The main purpose of this application is to provide a streaming text translation method, a computer-readable storage medium, a computer program product, and an electronic device, so as to at least solve the problem in the prior art that the decoding of streaming translation is relatively fixed and lacks flexibility, resulting in low translation quality.
[0006] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a streaming text translation method is provided, comprising: obtaining source language data in a business scenario, and segmenting the source language data to generate streaming data; translating the streaming data to obtain target streaming data, wherein the streaming data and the target streaming data constitute a data set; reconstructing the data set based on a connection identifier to obtain training data, wherein the connection identifier is used to indicate the way in which the current translation is connected with the previous translation, and the connection identifier includes at least one of the following: a waiting identifier, an adding identifier, and a correcting identifier, wherein the waiting identifier indicates that the previous translation is maintained and waiting for subsequent input, and the The adding identification representation adds the current translation after the previous translation, the correcting identification representation corrects the previous translation based on the current input, the current input represents the original text that currently needs to be translated, the current translation represents the translation corresponding to the current input, the previous translation represents the translation corresponding to the previous original text, and the previous original text represents the context above the current input; according to the training data, the decoder of the first large language model is adjusted to obtain a target translation model, the first large language model is a large language model; the target source language data is obtained, and the target translation model is used to translate the target source language data to obtain a target translation text.
[0007] Optionally, segmenting the source language data includes segmenting the source language data according to streaming granularity, where the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity, and the free granularity representation determines segmentation points based on the intrinsic semantic structure of the source language data and the coherence of the context.
[0008] Optionally, segmenting the source language data according to the streaming granularity includes: when the streaming granularity includes the word granularity, inputting the source language data into a word segmenter so that the word segmenter segments the source language data; when the streaming granularity includes the short sentence granularity, segmenting the source language data using a preset set of punctuation marks; when the streaming granularity includes the free granularity, inputting the source language data into a second large language model based on a prompt project so that the second large language model segments the source language data, the second large language model being a large language model, and the prompt project is used to guide the second large language model to understand and process the source language data.
[0009] Optionally, segmenting the source language data to generate streaming data includes: segmenting the source language data to obtain a plurality of initial streaming data as [chunk1, chunk2, ..., chunk m ], where chunk mIndicates the mth initial streaming data; integrate multiple initial streaming data, and re-save the initial streaming data based on the prefix appending method to obtain the streaming data d i =[chunk1, chunk1+chunk2, chunk1+chunk2+chunk3,..., text i ], where d i Represents the streaming data, text i Indicates the source language data.
[0010] Optionally, based on the connection identifier, the data set is reconstructed, including: according to the identification rule, the data set is reconstructed so that the training data contains the following information: the previous original text, the previous translation, the current input, the current translation, the connection identifier and the starting position, wherein the identification rule is: when the previous translation is the same as the current translation, the connection identifier corresponding to the previous translation and the current translation is determined to be the waiting identifier, and the current translation is determined to be empty, the current translation represents the translation corresponding to the current original text, and the current original text represents the text obtained by combining the previous original text and the current input; in the current translation, a new translation text is added only after the previous translation without changing the In the case of the original content of the previous translation, the connection identifier corresponding to the previous translation and the current translation is determined to be the added identifier, and the current translation is determined to be the new translation text; in the case of differences between the current translation and the previous translation and the original content of the previous translation is changed, the connection identifier corresponding to the previous translation and the current translation is determined to be the revised identifier, and the first different character position in the first character string and the second character string is determined to be the starting position, and the character string corresponding to the starting position to the end position of the second character string in the second character string is determined to be the current translation, the first character string is all the characters in the previous translation, and the second character string is all the characters in the current translation.
[0011] Optionally, based on the training data, the decoder of the first large language model is adjusted to obtain a target translation model, including: dividing the training data into a training set and a test set, and using the training set to adjust the decoder of the first large language model to obtain the target translation model; using the target translation model, translating the streaming data in the test set to generate a test translation, and using a bilingual evaluation index as an evaluation index, comparing the test translation with a reference translation to obtain a comparison result, where the reference translation is the target streaming data corresponding to the streaming data in the test set; if the comparison result does not meet expectations, optimizing the target translation model.
[0012] Optionally, adjusting the decoder of the first large language model using the training set includes: utilizing knowledge distillation technology to adjust the decoder using the training set.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the streaming text translation methods.
[0014] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, any one of the streaming text translation methods is implemented.
[0015] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of the streaming text translation methods.
[0016] By applying the technical solution of the present application, the source language data is first segmented to generate streaming data, and then the streaming data is translated to obtain target streaming data. Then, based on the connection identifier, the data set consisting of the streaming data and the target streaming data is reconstructed to obtain training data. According to the training data, the decoder of the first language model is adjusted to obtain a target translation model. Finally, the target source language data is translated using the target translation model to obtain a target translation text, wherein the connection identifier includes at least one of the following: a waiting identifier, an adding identifier, and a correcting identifier. The waiting identifier indicates that the previous translation is maintained and waits for subsequent input. The adding identifier indicates that the current translation is added after the previous translation. The correcting identifier indicates that the previous translation is corrected based on the current input. Compared with the existing technology in which the decoding strategy of streaming translation is centered around wait-k, the decoding is relatively fixed and lacks flexibility, resulting in low translation quality, this application reconstructs the data set based on the connection identifier to obtain training data, and adjusts the decoder of the first language model based on the training data. By using three connection identifiers, namely the wait identifier, the add identifier and the correction identifier, the first language model can intelligently determine the translation generation strategy based on the context information in the real-time translation process, avoiding the mechanical nature of fixed waiting or fixed appending, and increasing the flexibility and intelligence of the decoding strategy; in addition, the introduction of the correction identifier allows the model to dynamically correct the generated translation based on the new streaming input, which solves the problems of structural rigidity and semantic deviation that may occur in the translation under the traditional wait-k strategy, thereby significantly improving the translation quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings that constitute part of this application are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation on this application. In the drawings:
[0018] Figure 1 A hardware structure block diagram of a mobile terminal for executing a streaming text translation method provided in an embodiment of the present application is shown;
[0019] Figure 2 A flow chart of a streaming text translation method provided according to an embodiment of the present application is shown.
[0020] The above drawings include the following reference numerals:
[0021] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. DETAILED DESCRIPTION
[0022] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0023] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0024] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0025] As introduced in the background technology, the decoding of streaming translation in the prior art is relatively fixed and lacks flexibility, resulting in low translation quality. To solve the above problems, the embodiments of the present application provide a streaming text translation method, a computer-readable storage medium, a computer program product and an electronic device.
[0026] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0027] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG is a hardware structure block diagram of a mobile terminal of a streaming text translation method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0028] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the streaming text translation method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, implementing the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. The specific example of the above-mentioned network may include a wireless network provided by the communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices via a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0029] In this embodiment, a streaming text translation method running on a mobile terminal, a computer terminal, or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] Figure 2 Flowchart of the method for streaming text translation according to an embodiment of the present application. Figure 2 As shown, the method includes the following steps:
[0031] Step S201: acquiring source language data in a business scenario, and segmenting the source language data to generate streaming data;
[0032] Specifically, source language data for business scenarios is collected, and the collected source language data set is recorded as D, with a total of n source language data, D = [text1...text n ]; For example, in a spoken language scenario, a single source language data example is "The weather is nice today, let's go out for a walk."
[0033] Specifically, the collected source language data set D is divided into streaming data one by one.
[0034] Step S202: translating the streaming data to obtain target streaming data, wherein the streaming data and the target streaming data constitute a data set;
[0035] Specifically, you can use an open source large language model as a translator, such as qwen, deepseek-r1, etc., to translate streaming data.
[0036] Step S203: Reconstructing the dataset to obtain training data based on the connection markers, wherein the connection markers are used to indicate how the current translation connects with the previous translation. The connection markers include at least one of the following: a waiting marker, an adding marker, and a correcting marker. The waiting marker indicates that the previous translation is maintained pending subsequent input. The adding marker indicates that the current translation is added after the previous translation. The correcting marker indicates that the previous translation is corrected based on the current input. The current input indicates the original text to be translated. The current translation indicates the translation corresponding to the current input. The previous translation indicates the translation corresponding to the previous original text. The previous original text indicates the context preceding the current input.
[0037] Specifically, the "current translation" to be output is the result of translating the "current input". When translating, it is necessary to combine the semantic information of the "previous original text" and try to complete the translation by appending and continuing on the basis of the "previous translation". If it is not possible to append directly, you can consider maintaining the status quo or modifying the "previous translation".
[0038] Specifically, the add flag "[add]" indicates appending, the wait flag "[wait]" indicates maintaining the status quo, and the revision flag "[revise]" indicates modification.
[0039] S204, adjusting the decoder of the first language model based on the training data to obtain a target translation model, where the first language model is a large language model;
[0040] Specifically, the first large language model can be qwen, deepseek-r1 or other large language models, and this application does not impose any specific restrictions on this.
[0041] Step S205 : acquiring target source language data, and translating the target source language data using the target translation model to obtain a target translation text.
[0042] Through the above embodiment, the source language data is first segmented to generate streaming data, and then the streaming data is translated to obtain target streaming data. Then, based on the connection identifier, the data set consisting of the streaming data and the target streaming data is reconstructed to obtain training data. The decoder of the first language model is adjusted based on the training data to obtain a target translation model. Finally, the target source language data is translated using the target translation model to obtain a target translation text. The connection identifier includes at least one of the following: a wait identifier, an add identifier, and a correction identifier. The wait identifier indicates that the previous translation is maintained and waits for subsequent input. The add identifier indicates that the current translation is added after the previous translation. The correction identifier indicates that the previous translation is corrected based on the current input. Compared with the existing technology in which the decoding strategy of streaming translation is centered around wait-k, the decoding is relatively fixed and lacks flexibility, resulting in low translation quality, this application reconstructs the data set based on the connection identifier to obtain training data, and adjusts the decoder of the first language model based on the training data. By using three connection identifiers, namely the wait identifier, the add identifier and the correction identifier, the first language model can intelligently determine the translation generation strategy based on the context information in the real-time translation process, avoiding the mechanical nature of fixed waiting or fixed appending, and increasing the flexibility and intelligence of the decoding strategy; in addition, the introduction of the correction identifier allows the model to dynamically correct the generated translation based on the new streaming input, which solves the problems of structural rigidity and semantic deviation that may occur in the translation under the traditional wait-k strategy, thereby significantly improving the translation quality.
[0043] Specifically, assuming there are n source language data, and each source language data is exactly divided into m stream data, then there are n*m data in total, and the format of each data can be uniformly expressed as: Instance_data j =[chunk1+…+chunk j ]. We use an open-source large language model as the translator, and construct the prompt word propmt as "You are a translation expert proficient in ##source language## and ##target language##, and I will give you a ##semantic fragmentInstance_data j ##, please translate it into ##target language##. Please accurately translate text fragments with complete semantics. Parts with incomplete semantics or whose meaning cannot be reasonably inferred will not be translated. During the translation process, the existing context should be combined to ensure that the translation conforms to the ##target language## expression habits and logical coherence. The content wrapped by ## needs to be modified according to actual needs to adapt to the task and produce target streaming data. Save the dataset consisting of the streaming data and the target streaming data. The dataset format is as follows:
[0044] Specifically, for example, “The weather is nice today, let’s go out for a walk.” The generated Chinese-English translation data sample is:
[0045] [["Today","Today"],["The weather today","The weather today"],["The weather today is very nice","The weather today is very nice"],["The weather today is very nice,""The weather today is very nice,"],["The weather today is very nice,go out","The weather today is very nice,go out"],["The weather today is very nice,go out for a walk","The weather today is very nice,let's go out for a walk"],["The weather today is very nice,let's go out fora walk."]].
[0046] In one optional solution, segmenting the source language data includes segmenting the source language data according to a streaming granularity, wherein the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity, wherein the free granularity characterizes the determination of segmentation points based on the intrinsic semantic structure of the source language data and the coherence of the context. In this embodiment, segmentation using different streaming granularities can flexibly adapt to different types of text and translation requirements. Segmented data of different granularities provides rich learning materials for the training model, enabling the model to learn a wider range of translation rules and techniques when processing dynamic input, thereby demonstrating better adaptability and generalization in practical applications.
[0047] In an exemplary embodiment, the source language data is segmented according to the streaming granularity, including: when the streaming granularity includes the word granularity, the source language data is input into a word segmenter so that the word segmenter segments the source language data; when the streaming granularity includes the short sentence granularity, the source language data is segmented using a preset set of punctuation marks; when the streaming granularity includes the free granularity, the source language data is input into a second largest language model based on a prompt project so that the second largest language model segments the source language data, the second largest language model being a large language model, and the prompt project is used to guide the second largest language model to understand and process the source language data. In this embodiment, under word-granularity segmentation, the word segmenter can accurately identify the lexical boundaries of the source language text, provide word-level input for the model, and enhance the model's semantic understanding and context association capabilities at the word level; short sentence granularity segmentation uses a pre-set set of punctuation marks to more accurately identify the logical and semantic boundaries of the text, helping the model to better understand the text structure and context, so that the complete meaning of the sentence can be accurately conveyed during translation; free-granularity segmentation specifically adopts prompt engineering, inputting the source language data into the second largest language model, which dynamically determines the segmentation points based on prompts and context coherence. This strategy enables the model to adapt more flexibly to dynamic changes in text input during the translation process, improve the response speed and accuracy of real-time translation, and reduce the problems of translation fragmentation or insufficient context understanding that may be caused by fixed-granularity segmentation.
[0048] It should be noted that while there is currently a large amount of full-sentence parallel corpus data for translation tasks, there is almost no open-source, directly usable data for streaming translation. Manually constructed solutions are prohibitively expensive, difficult to implement in real-world scenarios, and require high standards for annotation. To address the current data shortage for streaming translation, this application uses granularity control and prompt engineering to cover the data construction requirements in most real-world scenarios.
[0049] In other embodiments, the source language data is segmented to generate streaming data, including: segmenting the source language data to obtain a plurality of initial streaming data as [chunk1, chunk2, ..., chunk m ], where chunk m Indicates the mth initial streaming data; integrate multiple initial streaming data, and re-save the initial streaming data based on the prefix appending method, and obtain the above streaming data as d i =[chunk1, chunk1+chunk2, chunk1+chunk2+chunk3,..., text i], where d i Represents the above streaming data, text i Represents the source language data. In this embodiment, the initial streaming data is integrated by continuously appending prefixes to form a continuous streaming data set. This processing method ensures that at each translation step, the model can obtain all the context information to date, thereby maintaining coherence and consistency when generating the translation, reducing translation errors that may be caused by context breaks.
[0050] Specifically, if the streaming granularity is word granularity, for a text of a given length l i : Input the text into the open source jieba word segmenter for word granularity segmentation to obtain the initial streaming data based on word granularity: word_stream_text i =Jieba(text i ); For example, for “The weather is very good today, let’s go out for a walk.”, the word segmentation result is: [‘today’, ‘weather’, ‘very good’, ‘, ‘, ‘go out’, ‘walk’, ‘let’, ‘. ’].
[0051] Specifically, if the streaming granularity is short sentence granularity, for a text of a given length l i : Define a punctuation set. When the source language is Chinese, consider PUNCTUATION_SET as the division basis. The punctuation set can be modified to adapt to the task according to the language type and requirements: PUNCTUATION_SET = {'.', '!', '?', ';', '.', '?', '!', ';'}. Use regular expressions to segment the text into short sentences using the above punctuation set to obtain the initial streaming data based on the short sentence granularity: sentence_stream_text i =Regex(text i , PUNCTUATION_SET); for example, for “The weather is very good today, let’s go for a walk.”, the short sentence segmentation result is: [″The weather is very good today,”,”The weather is very good today, let’s go for a walk.”].
[0052] Specifically, if the segmentation effect of word granularity and short sentence granularity is not good, or a more flexible granularity is needed, here is a large model segmentation solution with strong scalability and adaptability, which can also achieve word granularity and short sentence granularity. i, input the text into the second largest open source language model (such as qwen, deepseek-r1, etc.) for free granularity segmentation, and obtain the initial streaming data based on free granularity. The prompt word design framework of the prompt project is: Prompt = [role][task][text i ], where role is the role definition, "Suppose you are an expert in text semantic understanding and are very good at text segmentation." Task is the task description, where you need to specify the segmentation granularity and other requirements, for example, "Given a text, please fully extract the semantic information of the sentence and segment it into semantic segments of phrase granularity, so that each segment has relatively complete semantic information, and the segmentation granularity should be controlled as much as possible between words and short sentences.", text i The text that needs to be segmented.
[0053] Specifically, after granular segmentation, each text is represented as: xx_stream_text i =[chunk1, chunk2,..., chunk m ], where xx refers to the granularity. The initial streaming data is integrated and saved as a prefix that is continuously appended to construct training data. Each text message is: d i =[chunk1, chunk1+chunk2, chunk1+chunk2+chunk3,..., text i For example, at the word granularity, the constructed data is: ["today","today's weather","the weather is very good today","the weather is very good today","the weather is very good today, go out","the weather is very good today, go out for a walk","the weather is very good today, let's go out for a walk","the weather is very good today, let's go out for a walk."]
[0054] According to some exemplary embodiments of the present application, the dataset is reconstructed based on the connection identifier, including: reconstructing the dataset according to the identification rule so that the training data contains the following information: the previous original text, the previous translation, the current input, the current translation, the connection identifier and the starting position, wherein the identification rule is: when the previous translation is the same as the current translation, the connection identifier corresponding to the previous translation and the current translation is determined to be the waiting identifier, and the current translation is determined to be empty, the current translation represents the translation corresponding to the current original text, and the current original text represents the text obtained by combining the previous original text with the current input; in the current translation, a new translation text is added only after the previous translation, and When the original content of the previous translation is not changed, the connection marker corresponding to the previous translation and the current translation is determined to be the added marker, and the current translation is determined to be the new translation text; when there is a difference between the current translation and the previous translation and the original content of the previous translation is changed, the connection marker corresponding to the previous translation and the current translation is determined to be the revised marker, and the first different character position between the first character string and the second character string is determined to be the starting position, and the character string corresponding to the starting position to the end position of the second character string in the second character string is determined to be the current translation, the first character string is all the characters in the previous translation, and the second character string is all the characters in the current translation. In this embodiment, by reconstructing the dataset into training data containing "previous original text", "previous translation", "current input", "current translation", "connection marker" and "starting position", the method achieves refined control over the translation process. The introduction of connection markers and starting positions enables the model to intelligently determine how to handle new text input, whether to wait for more context, directly add translation or correct existing translation, further enhancing the model's adaptability and intelligent decision-making capabilities.
[0055] Specifically, the waiting marker indicates that the existing translation is maintained and waiting for subsequent input, which helps to ensure the coherence of the translation and avoid inappropriate translation when there is insufficient information; the adding marker allows the model to directly add a new translation based on the existing translation without changing the translated part, ensuring the naturalness and contextual consistency of the translation; the correction marker allows the model to dynamically correct the generated translation when new information arrives, ensuring the accuracy of the translation results and the coherence of the context. Especially when dealing with semantically complex sentences, this method can significantly improve the quality of the translation.
[0056] Specifically, considering that streaming translation needs to consider the output time, three connection identifiers are designed to minimize the output of the model: Connection_representation = {"[wait]", "[add]", "[revise]"}. In data processing, the meanings of the three connection identifiers are as follows: i and xx_stream_text i , traverse backwards from the first chunk, assuming that this data i Continuous streaming input, then remember "current input" as chunk m , "previous original text" is chunk1+…+chunk m-1 , "previous translation" is translated_Instance_data m-1 , now compare translated_Instance_data m (i.e. current translation) and "previous translation", if the two are equal, set the corresponding flag at this moment to "[wait]", and the "current translation" at this time is empty; if translated_Instance_data m It is just added after the "previous translation", and the corresponding flag is set to "[add]". The "current translation" at this time is the newly added part; otherwise, the corresponding flag is set to "[revise]". In particular, this requires finding the first different character position of the two strings, recording it as the "starting position", and recording translated_Instance_data m The final string from the "starting position" to the end of the string is the "current translation".
[0057] Specifically, through the identification rules, each original text (i.e., source language data) is processed into m stream data, where each stream data contains the following information: the previous original text, the previous translation, the current input, the current translation, the connection marker, and the starting position. For example, in the task of translating English into Chinese, the data sample is as follows:
[0058] {'Previous text': 'And if you play the answer machine,', 'Previous translation': 'If you play the answer machine,', 'Current input': ″can you take down everyone's messages?″, 'Current translation': 'Can you take down everyone's messages? ', 'Connection identifier': '[add]', 'Start position': 'null'}.
[0059] Specifically, according to the identification rules, the dataset is batch-processed into training data. The prompt for the training data is designed as follows: You are an expert in ##source-target-language## translation. Your task is to fully understand the "previous original text" and "previous translation" and translate the "current input" in strict accordance with the JSON format, outputting three pieces of information: "current translation," "connection marker," and "starting position." The "previous original text" is ##previous original text##, the "previous translation" is ##previous translation##, and the "current input" is ##current input##. The output "current translation" is the result of translating the "current input." During translation, the semantic information of the "previous original text" should be considered, and the translation should be completed by appending to the "previous translation" as much as possible. If direct appending is not possible, the "previous translation" can be considered as is or modified. The "connection marker" indicates how the "current translation" connects with the "previous translation." "[wait]": The current input lacks sufficient information for translation. In this case, the "starting position" will output "null" and the "current translation" will output "null". "[add]": The current input has sufficient information for translation, and the concatenation of the "previous translation" and the "current input" can be completed by continuing the previous translation, making the concatenation of the "previous source text" and the "current input" grammatically and contextually coherent. In this case, the "starting position" will output "null" and the "current translation" will be the continued translation. "[revise]": The current input has sufficient information for translation, but cannot be completed by continuing the previous translation. In this case, the "starting position" indicates the character in the "previous translation" that needs to be modified (starting from 0), and the "current translation" is the modified translation. Note that the content enclosed by ## needs to be dynamically changed according to the actual scenario. Accordingly, if a piece of original text is segmented into m segments, m pieces of data will be generated for training.
[0060] According to other exemplary embodiments of the present application, based on the above-mentioned training data, the decoder of the first language model is adjusted to obtain a target translation model, including: dividing the above-mentioned training data into a training set and a test set, and using the above-mentioned training set to adjust the above-mentioned decoder of the above-mentioned first language model to obtain the above-mentioned target translation model; using the above-mentioned target translation model, the above-mentioned streaming data in the above-mentioned test set is translated to generate a test translation, and using the bilingual evaluation index as the evaluation index, the above-mentioned test translation is compared with the reference translation to obtain a comparison result, and the above-mentioned reference translation is the above-mentioned target streaming data corresponding to the above-mentioned streaming data in the above-mentioned test set; if the above-mentioned comparison result does not meet expectations, the above-mentioned target translation model is optimized. In this embodiment, the process of adjusting the decoder using the training set is essentially to guide the model on how to more accurately understand and generate the target language, while the evaluation of the test set ensures that the performance of the model meets the requirements of practical applications. The use of bilingual evaluation indicators provides a means of quantitatively evaluating model performance, so that developers can intuitively understand key indicators such as the coherence and accuracy of the model translation, which facilitates subsequent performance optimization.
[0061] In some alternative embodiments of the present application, the decoder of the first language model is adjusted using the training set, including utilizing knowledge distillation to adjust the decoder using the training set. In this embodiment, knowledge distillation can generate a smaller and faster decoder model, allowing the model to quickly respond and generate translations for each stream of text input, while significantly reducing computational complexity and memory consumption.
[0062] Specifically, the training and test sets are divided into a 9:1 ratio. Each data entry in the training set is formatted like this: Instance_train = [prompt, bot_ans], where prompt is the original text and bot_ans is the response from the first language model. Each data entry in the test set is formatted like this: Instance_test = [prompt, true_ans], where prompt is the same as in the training set, and true_ans corresponds to bot_ans, serving as the gold label for model evaluation and comparison with the actual model inference results.
[0063] Specifically, the training set is used to fine-tune the first language model (such as qwen-7b or qwen35b) to obtain the fine-tuned target translation model. The target translation model is then evaluated using the test set, using BLEU (Bilingual Evaluation Understudy) as the evaluation metric. If the BLEU meets the expected performance, the target translation model is used as the final prediction model. Otherwise, the training process is optimized and retrained until the performance reaches the expected performance.
[0064] Specifically, the trained target translation model is used for deployment reasoning. The detailed steps are as follows: design an interface document. The required input parameters are "current input", "previous original text" and "previous translation", and the required output parameters are "current translation", "connection identifier" and "starting position". The prompt template (i.e., prompt word template) is set inside the interface. The input parameters and prompt word template are combined and input into the trained target translation model for reasoning: cur_target_translation, revise_start_index, connection_identification =
[0065] sft_llm[historica1_source_text, historical_target_translation, cur_source_text].
[0066] Specifically, it is important to note that because large model outputs are random and uncontrollable, they may fail due to model performance issues, such as starting position out of bounds or missing fields. To address this issue and ensure service availability, a fallback service is configured. Here, nllb-200-distiled-600m is selected as the fallback service. This model not only supports translation between multiple languages but also is a small-size distilled version, which shortens inference time.
[0067] Specifically, the target translation model usually needs to be combined with the foreground page display, and the screen display needs to be controlled according to the connection identifier. The screen display logic is: add: the screen displays historical_target_translation+cur_target_translation, indicating that the previous translation is appended; wait: the screen displays historical_target_translation, indicating that the current input is insufficient for translation and needs to wait for more context; revise: the screen displays historical_target_translation[:start]+cur_targettranslation, indicating that the correction and appending of the previous translation are completed at the same time.
[0068] In summary, this application uses a large language model to construct a dynamic streaming dataset, and generates training data adapted to different scenarios by combining granularity control with prompt engineering; it breaks through the mechanical waiting mode of the traditional wait-k strategy and pioneers the "Wait-Revise-Add" three-state decision mechanism: Wait: maintain the existing translation and wait for subsequent input, Revise: dynamically revise the generated translation based on the new input, and Add: directly expand the unmodified translation content. It breaks through the limitations of traditional parallel corpus and generates a dynamic streaming training set of tens of millions in scale, covering most of the input mutations in real scenarios; the dynamic correction mechanism improves the BLEU value of the translation, and combines the advantages of the large model while minimizing the control of the model output, taking into account the problem of long time consumption of the large model, and performs particularly well in long-distance dependency scenarios (such as language pairs with large differences in word order). The model supports flexible deployment and can be adapted to the downstream of most cascade systems in real-time translation.
[0069] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the streaming text translation method of the present application will be described in detail below with reference to specific embodiments.
[0070] This embodiment relates to a specific streaming text translation method, including the following steps:
[0071] Step S1: Collect source language data in business scenarios;
[0072] Step S2: segmenting the source language data according to the streaming granularity to generate streaming data, wherein the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity;
[0073] Step S3: translating the streaming data to obtain target streaming data, where the streaming data and the target streaming data constitute a data set;
[0074] Step S4: Reconstructing the data set based on the connection markers to obtain training data. The connection markers are used to indicate how the current translation connects with the previous translation. The connection markers include at least one of the following: a waiting marker, an adding marker, and a correcting marker. The waiting marker indicates that the previous translation is maintained and waiting for subsequent input. The adding marker indicates that the current translation is added after the previous translation. The correcting marker indicates that the previous translation is corrected based on the current input. The current input indicates the original text that needs to be translated. The current translation indicates the translation corresponding to the current input. The previous translation indicates the translation corresponding to the previous original text. The previous original text indicates the context above the current input.
[0075] Step S5: Divide the training data into a training set and a test set, and use the training set to adjust the decoder of the first language model to obtain a target translation model; use the bilingual evaluation index as an evaluation indicator and use the test set to evaluate the target translation model; if the evaluation does not meet expectations, optimize the target translation model;
[0076] Step S6: Obtain target source language data, and use the optimized target translation model to translate the target source language data to obtain a target translation text.
[0077] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0078] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program. When the program is executed, the device where the computer-readable storage medium is located is controlled to execute the streaming text translation method.
[0079] Specifically, the streaming text translation method includes:
[0080] Step S201: acquiring source language data in a business scenario, and segmenting the source language data to generate streaming data;
[0081] Step S202: translating the streaming data to obtain target streaming data, wherein the streaming data and the target streaming data constitute a data set;
[0082] Step S203: Reconstructing the dataset to obtain training data based on the connection markers, wherein the connection markers are used to indicate how the current translation connects with the previous translation. The connection markers include at least one of the following: a waiting marker, an adding marker, and a correcting marker. The waiting marker indicates that the previous translation is maintained pending subsequent input. The adding marker indicates that the current translation is added after the previous translation. The correcting marker indicates that the previous translation is corrected based on the current input. The current input indicates the original text to be translated. The current translation indicates the translation corresponding to the current input. The previous translation indicates the translation corresponding to the previous original text. The previous original text indicates the context preceding the current input.
[0083] Step S204: adjusting the decoder of the first language model based on the training data to obtain a target translation model, where the first language model is a large language model;
[0084] Step S205 : acquiring target source language data, and translating the target source language data using the target translation model to obtain a target translation text.
[0085] Optionally, segmenting the source language data includes segmenting the source language data according to streaming granularity, where the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity, and the free granularity representation determines the segmentation points based on the intrinsic semantic structure of the source language data and the coherence of the context.
[0086] Optionally, the source language data is segmented according to the streaming granularity, including: when the streaming granularity includes the word granularity, the source language data is input into a word segmenter so that the word segmenter segments the source language data; when the streaming granularity includes the short sentence granularity, the source language data is segmented using a preset set of punctuation marks; when the streaming granularity includes the free granularity, the source language data is input into a second largest language model based on a prompt project so that the second largest language model segments the source language data, the second largest language model being a large language model, and the prompt project is used to guide the second largest language model to understand and process the source language data.
[0087] Optionally, the source language data is segmented to generate streaming data, including: segmenting the source language data to obtain a plurality of initial streaming data as [chunk1, chunk2, ..., chunk m ], where chunk m Indicates the mth initial streaming data; integrate multiple initial streaming data, and re-save the initial streaming data based on the prefix appending method, and obtain the above streaming data as d i =[chunk1, chunk1+chunk2, chunk1+chunk2+chunk3,..., text i ], where d i Represents the above streaming data, text i Indicates the above source language data.
[0088] Optionally, based on the connection identifier, the above-mentioned data set is reconstructed, including: according to the identification rule, the above-mentioned data set is reconstructed so that the above-mentioned training data contains the following information: the above-mentioned previous original text, the above-mentioned previous translation, the above-mentioned current input, the above-mentioned current translation, the above-mentioned connection identifier and the starting position, wherein the above-mentioned identification rule is: when the above-mentioned previous translation is the same as the current translation, the above-mentioned connection identifier corresponding to the above-mentioned previous translation and the above-mentioned current translation is determined to be the above-mentioned waiting identifier, and the above-mentioned current translation is determined to be empty, the above-mentioned current translation represents the translation corresponding to the current original text, and the above-mentioned current original text represents the text obtained by combining the above-mentioned previous original text with the above-mentioned current input; in the above-mentioned current translation, a new translation text is added only after the above-mentioned previous translation, without changing the above-mentioned In the case of the original content of the previous translation, the corresponding connection marker between the previous translation and the current translation is determined to be the added marker, and the current translation is determined to be the new translation text; in the case of differences between the current translation and the previous translation, and the original content of the previous translation is changed, the corresponding connection marker between the previous translation and the current translation is determined to be the revised marker, and the first different character position between the first character string and the second character string is determined to be the starting position, and the character string corresponding to the starting position to the end position of the second character string in the second character string is determined to be the current translation, the first character string is all the characters in the previous translation, and the second character string is all the characters in the current translation.
[0089] Optionally, based on the above-mentioned training data, the decoder of the first large language model is adjusted to obtain the target translation model, including: dividing the above-mentioned training data into a training set and a test set, and using the above-mentioned training set to adjust the above-mentioned decoder of the above-mentioned first large language model to obtain the above-mentioned target translation model; using the above-mentioned target translation model, the above-mentioned streaming data in the above-mentioned test set is translated to generate a test translation, and using a bilingual evaluation index as an evaluation index, the above-mentioned test translation is compared with a reference translation to obtain a comparison result, and the above-mentioned reference translation is the above-mentioned target streaming data corresponding to the above-mentioned streaming data in the above-mentioned test set; if the above-mentioned comparison result does not meet expectations, the above-mentioned target translation model is optimized.
[0090] Optionally, adjusting the decoder of the first language model using the training set includes: utilizing knowledge distillation technology to adjust the decoder using the training set.
[0091] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement at least the following method steps: Step S201, obtaining source language data in a business scenario, and segmenting the source language data to generate streaming data; Step S202, translating the streaming data to obtain target streaming data, wherein the streaming data and the target streaming data constitute a data set; Step S203, reconstructing the data set based on a connection identifier to obtain training data, wherein the connection identifier is used to indicate the way in which the current translation is connected to the previous translation, and the connection identifier includes at least one of the following: a waiting identifier, an adding identifier, and a correcting identifier, wherein the waiting identifier indicates the maintenance of the previous translation. The translation waits for subsequent input, the above-mentioned addition mark represents adding the above-mentioned current translation after the above-mentioned previous translation, the above-mentioned correction mark represents correcting the above-mentioned previous translation based on the current input, the above-mentioned current input represents the original text currently to be translated, the above-mentioned current translation represents the translation corresponding to the above-mentioned current input, the above-mentioned previous translation represents the translation corresponding to the previous original text, and the above-mentioned previous original text represents the above-mentioned current input; step S204, according to the above-mentioned training data, the decoder of the first large language model is adjusted to obtain a target translation model, and the above-mentioned first large language model is a large language model; step S205, obtain target source language data, and use the above-mentioned target translation model to translate the above-mentioned target source language data to obtain a target translated text.
[0092] Optionally, segmenting the source language data includes segmenting the source language data according to streaming granularity, where the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity, and the free granularity representation determines the segmentation points based on the intrinsic semantic structure of the source language data and the coherence of the context.
[0093] Optionally, the source language data is segmented according to the streaming granularity, including: when the streaming granularity includes the word granularity, the source language data is input into a word segmenter so that the word segmenter segments the source language data; when the streaming granularity includes the short sentence granularity, the source language data is segmented using a preset set of punctuation marks; when the streaming granularity includes the free granularity, the source language data is input into a second largest language model based on a prompt project so that the second largest language model segments the source language data, the second largest language model being a large language model, and the prompt project is used to guide the second largest language model to understand and process the source language data.
[0094] Optionally, the source language data is segmented to generate streaming data, including: segmenting the source language data to obtain a plurality of initial streaming data as [chunk1, chunk2, ..., chunk m ], where chunk m Indicates the mth initial streaming data; integrate multiple initial streaming data, and re-save the initial streaming data based on the prefix appending method, and obtain the above streaming data as d i =[chunk1, chunk1+chunk2, chunk1+chunk2+chunk3,..., text i ], where d i Represents the above streaming data, text i Indicates the above source language data.
[0095] Optionally, based on the connection identifier, the above-mentioned data set is reconstructed, including: according to the identification rule, the above-mentioned data set is reconstructed so that the above-mentioned training data contains the following information: the above-mentioned previous original text, the above-mentioned previous translation, the above-mentioned current input, the above-mentioned current translation, the above-mentioned connection identifier and the starting position, wherein the above-mentioned identification rule is: when the above-mentioned previous translation is the same as the current translation, the above-mentioned connection identifier corresponding to the above-mentioned previous translation and the above-mentioned current translation is determined to be the above-mentioned waiting identifier, and the above-mentioned current translation is determined to be empty, the above-mentioned current translation represents the translation corresponding to the current original text, and the above-mentioned current original text represents the text obtained by combining the above-mentioned previous original text with the above-mentioned current input; in the above-mentioned current translation, a new translation text is added only after the above-mentioned previous translation, without changing the above-mentioned In the case of the original content of the previous translation, the corresponding connection marker between the previous translation and the current translation is determined to be the added marker, and the current translation is determined to be the new translation text; in the case of differences between the current translation and the previous translation, and the original content of the previous translation is changed, the corresponding connection marker between the previous translation and the current translation is determined to be the revised marker, and the first different character position between the first character string and the second character string is determined to be the starting position, and the character string corresponding to the starting position to the end position of the second character string in the second character string is determined to be the current translation, the first character string is all the characters in the previous translation, and the second character string is all the characters in the current translation.
[0096] Optionally, based on the above-mentioned training data, the decoder of the first large language model is adjusted to obtain the target translation model, including: dividing the above-mentioned training data into a training set and a test set, and using the above-mentioned training set to adjust the above-mentioned decoder of the above-mentioned first large language model to obtain the above-mentioned target translation model; using the above-mentioned target translation model, the above-mentioned streaming data in the above-mentioned test set is translated to generate a test translation, and using a bilingual evaluation index as an evaluation index, the above-mentioned test translation is compared with a reference translation to obtain a comparison result, and the above-mentioned reference translation is the above-mentioned target streaming data corresponding to the above-mentioned streaming data in the above-mentioned test set; if the above-mentioned comparison result does not meet expectations, the above-mentioned target translation model is optimized.
[0097] Optionally, adjusting the decoder of the first language model using the training set includes: utilizing knowledge distillation technology to adjust the decoder using the training set.
[0098] An embodiment of the present application also provides an electronic device, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include a method for executing any one of the above-mentioned streaming text translation methods.
[0099] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, can be centralized on a single computing device, or can be distributed across a network of multiple computing devices. They can be implemented using program code executable by the computing device, and thus, can be stored in a storage device and executed by the computing device. In some cases, the steps shown or described herein can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0100] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0101] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0102] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0103] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0104] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0105] Memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0106] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0107] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, commodity, or apparatus that includes the element.
[0108] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0109] In the streaming text translation method of the present application, the source language data is first segmented to generate streaming data, and then the streaming data is translated to obtain target streaming data. Then, based on the connection identifier, the data set composed of the streaming data and the target streaming data is reconstructed to obtain training data. According to the training data, the decoder of the first language model is adjusted to obtain the target translation model. Finally, the target source language data is translated using the target translation model to obtain the target translated text, wherein the connection identifier includes at least one of the following: a waiting identifier, an adding identifier, and a correcting identifier. The waiting identifier indicates that the previous translation is maintained and waits for subsequent input. The adding identifier indicates that the current translation is added after the previous translation. The correcting identifier indicates that the previous translation is corrected based on the current input. Compared with the existing technology in which the decoding strategy of streaming translation is centered around wait-k, the decoding is relatively fixed and lacks flexibility, resulting in low translation quality, this application reconstructs the data set based on the connection identifier to obtain training data, and adjusts the decoder of the first language model based on the training data. By using three connection identifiers, namely the wait identifier, the add identifier and the correction identifier, the first language model can intelligently determine the translation generation strategy based on the context information in the real-time translation process, avoiding the mechanical nature of fixed waiting or fixed appending, and increasing the flexibility and intelligence of the decoding strategy; in addition, the introduction of the correction identifier allows the model to dynamically correct the generated translation based on the new streaming input, which solves the problems of structural rigidity and semantic deviation that may occur in the translation under the traditional wait-k strategy, thereby significantly improving the translation quality.
[0110] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A streaming text translation method, characterized in that: include: Acquire source language data in a business scenario, segment the source language data, and generate streaming data; Translating the streaming data to obtain target streaming data, wherein the streaming data and the target streaming data constitute a data set; Reconstructing the data set based on a connection identifier to obtain training data, wherein the connection identifier is used to indicate a connection method between the current translation and the previous translation, and the connection identifier includes at least one of the following: a waiting identifier, an adding identifier, and a correcting identifier, wherein the waiting identifier indicates that the previous translation is maintained to wait for subsequent input, the adding identifier indicates that the current translation is added after the previous translation, and the correcting identifier indicates that the previous translation is corrected based on the current input, wherein the current input indicates the original text currently to be translated, the current translation indicates the translation corresponding to the current input, the previous translation indicates the translation corresponding to the previous original text, and the previous original text indicates the context above the current input; Adjusting a decoder of a first language model according to the training data to obtain a target translation model, wherein the first language model is a large language model; Target source language data is acquired, and the target translation model is used to translate the target source language data to obtain a target translation text.
2. The streaming text translation method according to claim 1, characterized in that: Segmenting the source language data includes: The source language data is segmented according to a streaming granularity, where the streaming granularity includes at least one of the following: word granularity, short sentence granularity, and free granularity. The free granularity represents segmentation points determined according to the intrinsic semantic structure of the source language data and the coherence of the context.
3. The streaming text translation method according to claim 2, characterized in that: The source language data is segmented according to the streaming granularity, including: In a case where the streaming granularity includes the word granularity, inputting the source language data into a word segmenter so that the word segmenter segments the source language data; When the streaming granularity includes the short sentence granularity, segmenting the source language data using a preset set of punctuation marks; When the streaming granularity includes the free granularity, based on a prompting project, the source language data is input into a second large language model so that the second large language model segments the source language data. The second large language model is a large language model, and the prompting project is used to guide the second large language model to understand and process the source language data.
4. The streaming text translation method according to claim 1, wherein: Segmenting the source language data to generate streaming data includes: The source language data is segmented to obtain a plurality of initial streaming data as [chunk1, chunk2, ..., chunk m ], where chunk m represents the mth initial streaming data; The multiple initial streaming data are integrated and the initial streaming data are saved again based on the method of continuously appending prefixes to obtain the streaming data d i =[chunk1,chunk1+chunk2,chunk1+chunk2+chunk3,…,text i ], where d i Represents the streaming data, text i Indicates the source language data.
5. The streaming text translation method according to claim 1, wherein: Reconstructing the data set based on the connection identifier includes: According to the identification rules, the data set is reconstructed so that the training data contains the following information: the previous original text, the previous translation, the current input, the current translation, the connection identifier and the starting position, The identification rules are: In the case where the previous translation is identical to the current translation, determining that the corresponding connection identifier between the previous translation and the current translation is the waiting identifier, and determining that the current translation is empty, the current translation represents the translation corresponding to the current original text, and the current original text represents the text obtained by combining the previous original text with the current input; In a case where the current translation only adds a new translation text after the previous translation without changing the original content of the previous translation, determining the corresponding connection mark between the previous translation and the current translation as the addition mark, and determining the current translation as the new translation text; In the case where there are differences between the current translation and the previous translation, and the original content of the previous translation is changed, the connection identifier corresponding to the previous translation and the current translation is determined to be the correction identifier, the first different character position between the first character string and the second character string is determined to be the starting position, and the character string corresponding to the starting position to the end position of the second character string in the second character string is determined to be the current translation, the first character string being all the characters in the previous translation, and the second character string being all the characters in the current translation.
6. The streaming text translation method according to claim 1, characterized in that: Adjusting the decoder of the first language model based on the training data to obtain a target translation model includes: Dividing the training data into a training set and a test set, and using the training set to adjust the decoder of the first large language model to obtain the target translation model; translating the streaming data in the test set using the target translation model to generate a test translation, and comparing the test translation with a reference translation using a bilingual evaluation index as an evaluation index to obtain a comparison result, where the reference translation is the target streaming data corresponding to the streaming data in the test set; When the comparison result does not meet expectations, the target translation model is optimized.
7. The streaming text translation method according to claim 6, characterized in that: Adjusting the decoder of the first language model using the training set includes: The decoder is tuned using the training set using knowledge distillation techniques.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the streaming text translation method according to any one of claims 1 to 7.
9. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the streaming text translation method according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include instructions for executing the streaming text translation method according to any one of claims 1 to 7.