Document translation method, device and equipment
By using a large language model in the document translation system to translate the elements to be translated in the document and splicing them with the preset template, the problem of low translation efficiency and accuracy of existing Chinese documents is solved, and efficient and accurate document translation is achieved.
Patent Information
- Application Number
- CN202411920889.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-24
AI Technical Summary
In the prior art, the document translation process relies on manual translation and simple machine translation, resulting in the inability to guarantee the translation accuracy, time-consuming and high cost.
A document translation method is adopted to determine the document type by receiving translation requests, extract the elements to be translated, use a large language model to translate, and splice the element translation with the preset translation template to generate the final document translation.
It improves the efficiency and accuracy of document translation, avoids the need to translate all content in the document, and replaces manual translation and simple machine translation.
Smart Images

Figure CN119849517A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text translation, and in particular to a document translation method, device and equipment. Background Art
[0002] With the development of the times, people have an increasing demand for the translation of documents such as identity cards, graduation certificates, and notarizations. In the existing technology, the translation process for documents usually involves manual translation first, followed by manual review, which results in the inability to guarantee translation accuracy, long translation time, and high costs. With the rapid development of artificial intelligence technology, traditional manual translation and simple machine translation can no longer meet users' needs for efficient and accurate document translation.
[0003] In view of this, there is a need to provide an efficient and accurate document translation solution. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a document translation method, device and equipment to provide an efficient and highly accurate document translation solution.
[0005] In order to solve the above technical problems, the present specification provides a document translation method, including:
[0006] receiving a document translation request for requesting translation of a document to be translated;
[0007] In response to the document translation request, determining the document type of the document to be translated;
[0008] Determine the translation template according to the document type;
[0009] Extracting elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template;
[0010] Using a large language model to translate the elements to be translated to obtain element translations;
[0011] The element translation is concatenated with the translation template to obtain a document translation of the document to be translated.
[0012] The embodiment of this specification also provides a document translation device, including:
[0013] A request receiving module, used for receiving a document translation request for requesting translation of a document to be translated;
[0014] A document type determination module, configured to determine the document type of the document to be translated in response to the document translation request;
[0015] A translation template determination module, used to determine a translation template according to the document type;
[0016] An element extraction module is used to extract elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template;
[0017] An element translation module, used to translate the element to be translated using a large language model to obtain an element translation;
[0018] The translation splicing module is used to splice the element translation with the translation template to obtain the document translation of the document to be translated.
[0019] The embodiment of this specification also provides a document translation device, including:
[0020] at least one processor; and,
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0023] receiving a document translation request for requesting translation of a document to be translated;
[0024] In response to the document translation request, determining the document type of the document to be translated;
[0025] Determine the translation template according to the document type;
[0026] Extracting elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template;
[0027] Using a large language model to translate the elements to be translated to obtain element translations;
[0028] The element translation is concatenated with the translation template to obtain a document translation of the document to be translated.
[0029] At least one embodiment provided in this specification can achieve the following beneficial effects:
[0030] In the embodiment of the present specification, after receiving a document translation request for translating a document to be translated, the document translation platform can determine the document type of the document to be translated based on the request, and then obtain the translation template of the document type on the one hand, and extract the elements to be translated in the document of the document type and use the large language model to translate to obtain the element translation corresponding to the element to be translated, and then splice the element translation with the translation template to obtain the document translation. Thus, by setting the fixed content in the document as a template and translating the variable content in the document using the large language model, the translation of all the content in the document is avoided, and manual translation and simple machine translation can be replaced, which is not only conducive to improving the translation efficiency of the document, but also conducive to improving the accuracy of the document translation. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0032] Figure 1 A schematic diagram of an application scenario of a document translation method provided in an embodiment of this specification;
[0033] Figure 2 A flowchart of a document translation method provided in an embodiment of this specification;
[0034] Figure 3 A schematic diagram of an embodiment of translating a graduation certificate provided in an embodiment of this specification;
[0035] Figure 4 A schematic diagram of an embodiment of translating a notarial certificate provided in an embodiment of this specification;
[0036] Figure 5 An overall flow chart of a document translation method provided in an embodiment of this specification;
[0037] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a document translation device;
[0038] Figure 7 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a document translation device. DETAILED DESCRIPTION
[0039] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0040] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0041] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0042] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0043] In the prior art, one way to translate documents such as identity cards, graduation certificates, and notarizations is to first translate manually, and then manually proofread. This method consumes a lot of human resources, takes a long time to translate, and has a high translation cost. Another method is to extract all the content in the document, and then use simple machine translation to translate the extracted content. However, simple machine translation has low translation accuracy and is prone to translation errors.
[0044] In order to solve the defects in the prior art, this solution provides the following embodiments.
[0045] Figure 1 A schematic diagram of an application scenario of a document translation method provided in an embodiment of this specification.
[0046] like Figure 1 As shown, the user can upload the document to be translated to the document translation platform server 102 at the document translation platform client 101, and initiate a document translation request. For example, the document translation platform client 101 can upload the document to be translated by calling the first interface of the document translation platform server 102 for uploading the document to be translated, and initiate a document translation request by calling the second interface of the document translation platform server 102 for initiating a document translation request. In actual application, uploading the document to be translated and initiating a document translation request can be performed at the same time; or, the document to be translated can be uploaded first, and the document translation request can be sent after a period of time after the upload of the document to be translated is completed.
[0047] After the document translation platform server 102 receives a document translation request for requesting the translation of a document to be translated, it can generate a translation task for translating the document to be translated in response to the document translation request. In actual application, for example, the translation task can be generated immediately after each document translation request is received. Afterwards, the translation task can be executed on the document translation platform server 102. Optionally, each generated document translation task can be executed immediately; or optionally, considering that the execution process of the document translation task is a relatively time-consuming task, in order to improve the overall utilization efficiency of computing resources, after generating one or several document translation tasks, the execution operation of the document translation task can be triggered periodically. Furthermore, the process of executing the document translation task may include: determining the document type of the document to be translated, and determining a translation template according to the document type; after the document translation platform server 102 determines the translation template, it can extract the to-be-translated elements corresponding to the document type from the document to be translated, and use a large language model to translate the to-be-translated elements to obtain element translations; thereafter, the document translation platform server 102 can splice the element translations with the translation template to obtain the document translation of the document to be translated. After the document translation platform server 102 determines the document translation of the document to be translated, it can further feed back the determined document translation of the document to be translated to the document translation platform client 101. After receiving the document translation fed back by the document translation platform server 102, the document translation platform client 101 can display the document translation to the user.
[0048] The document translation platform server 102 includes but is not limited to any device, equipment, platform, server cluster, etc. with computing and processing capabilities. The document translation platform client 101 and the document translation platform server 102 can transmit data via a local area network connection, a wide area network connection, an Internet connection, or other types of data network connections, or transmit data via other methods, which are not specifically limited.
[0049] In addition, despite Figure 1 In at least some of the embodiments of the specification shown, the document translation method provided in the embodiment of the specification can be executed by the document translation platform server 102, but in other optional embodiments, when the operating resources of the document translation platform client 101 can meet the deployment and operating conditions of the document translation method system, the document translation platform client 101 can also have similar functions as the document translation platform server 102, thereby executing the document translation method provided in the embodiment of the specification. In addition, in other optional embodiments, the document translation method provided in the embodiment of the specification can also be jointly executed by the document translation platform client 101 and the document translation platform server 102. Next, taking the document translation platform server 102 executing the document translation method provided in the embodiment of the specification as an example, the implementation process of the document translation method is described.
[0050] Figure 1 In the method, after receiving a document translation request for translating a document to be translated, the document translation platform can determine the document type of the document to be translated based on the request, and then obtain the translation template of the document type on the one hand, and extract the elements to be translated in the document of the document type and use the large language model to translate to obtain the element translation corresponding to the element to be translated, and then splice the element translation with the translation template to obtain the document translation. Therefore, by setting the fixed content in the document as a template and using the large language model to translate the variable content in the document, the translation of all the content in the document is avoided, which can replace manual translation and simple machine translation, which is not only conducive to improving the translation efficiency of the document, but also conducive to improving the accuracy of the document translation.
[0051] Figure 2 The flowchart of a document translation method provided in the embodiment of this specification is shown in FIG. From the hardware perspective, the execution subject of the process may be a server. From the program perspective, the execution subject of the process may be an application installed on the server. Figure 2 As shown, the process may include the following steps:
[0052] Step 202: receiving a document translation request for requesting translation of a document to be translated.
[0053] In the embodiments of this specification, documents, also known as "files", refer to the general term for various official documents, contracts, agreements, letters, receipts, certificates and other materials formed and used by people in social interactions. In document identification, it refers to all kinds of materials that record and provide content and information related to the facts of the case in the form of text, language, graphics and symbols. Files can be divided into written files, printed files and electronic files according to the production method; they can be divided into ordinary files and special files according to the production technology; they can be divided into real files, tampered files, defaced files, etc. according to their nature; they can be divided into originals and copies according to their status.
[0054] Specifically, the documents to be translated may include but are not limited to: birth certificates, ID cards, graduation certificates, degree certificates, transcripts, marriage certificates, divorce certificates, driver's licenses, scholarship certificates, competition award certificates, teacher qualification certificates, driver's licenses, house lease contracts, notarial certificates, etc. Among them, notarial certificates refer to judicial certificates with special legal effect made by the notary office based on the application of the parties, in accordance with facts and laws, and in accordance with legal procedures. It is a type of judicial document. A notarial certificate is a legal document made by a notary office and issued to the parties for use.
[0055] In actual applications, when a user needs to translate a document or documents, he can log in to the client of the document translation platform, upload the document to be translated to the server of the document translation platform through the client, and initiate a document translation request. After receiving the document translation request for requesting the translation of the document to be translated, the server of the document translation platform can respond to the document translation request, generate a translation task for translating the document to be translated, and then execute the translation task.
[0056] In actual applications, the document translation request may also include the target language for the document translation set by the user. Among them, the target language for the document translation may be the language of the translated document content that the user wants to obtain. For example: the content of the document to be translated uploaded by the user is in Chinese, and the user wants to translate it into English. Then, when the user initiates a document translation request to the server of the document translation platform through the client of the document translation platform, the user may specify to translate the document into English. Correspondingly, the document translation request sent by the client of the document translation platform to the server of the document translation platform may include indication information such as "the target language for the document translation is English", so that the server of the document translation platform can translate the document to be translated into the document of the target language that the user wants to obtain based on these indication information.
[0057] Step 204: In response to the document translation request, determine the document type of the document to be translated.
[0058] In the embodiments of this specification, the document type can reflect the business type of the document. The document type can include but is not limited to: birth certificate, ID card, graduation certificate, degree certificate, transcript, marriage certificate, divorce certificate, driver's license, scholarship certificate, competition award certificate, teacher qualification certificate, driver's license, house lease contract, notarization, etc. In practical applications, in order to improve translation accuracy, the classification of document types can be more detailed, for example: notarization for degree certificate and notarization for marriage certificate can correspond to different document types respectively.
[0059] In actual application, the document translation request may carry the document to be translated, so that after receiving the document translation request, the server of the document translation platform may determine the document type of the document to be translated based on the document content of the document to be translated in the document translation request. Since the subsequent embodiments in the embodiments of this specification will explain in detail the method for determining the document type of the document to be translated, it will not be repeated here.
[0060] Step 206: Determine a translation template according to the document type.
[0061] In the embodiments of this specification, different document types may correspond to different translation templates. For example, a document of the document type "identity card" corresponds to the "identity card" translation template; and a document of the document type "marriage certificate" corresponds to the "marriage certificate" translation template.
[0062] In practical applications, a mapping relationship can be preset between the document type and the translation template. When the document type of the document is determined, the translation template corresponding to the document type can be determined based on the mapping relationship. Specifically, a mapping relationship table reflecting the mapping relationship between the document type and the translation template can be formulated, and the mapping relationship table can be stored at the server of the document translation platform, so that the server of the document translation platform can retrieve the mapping relationship table during the document translation process and determine the corresponding translation template based on the document type.
[0063] Specifically, for graduation certificates and degree certificates, considering that there may be differences between graduation certificates and degree certificates of different colleges and universities, corresponding graduation certificate and degree certificate translation templates can be formulated based on the graduation certificate and degree certificate samples of each college and university. Of course, for colleges and universities with a high degree of similarity in graduation certificates and degree certificates, the same graduation certificate and degree certificate translation template can also be used, thereby improving the efficiency of producing graduation certificate and degree certificate translation templates, and there is no specific limitation on this. For example: when it is determined that the document type of the document to be translated is "Tsinghua University Graduation Certificate", the corresponding translation template of Tsinghua University Graduation Certificate is retrieved.
[0064] Step 208: extracting elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template.
[0065] In the embodiments of the present specification, there can be a one-to-one correspondence between the document type of the document to be translated, the translation template, and the elements to be translated. That is, one document type can correspond to one translation template and a group of elements to be translated. In the translation template, the fixed fields in the document to be translated are directly translated, that is, the translation template contains the translation of the fixed fields in the document to be translated. Therefore, when translating the content in the document to be translated, there is no need to translate the existing content in the translation template. Only the non-fixed fields in the document to be translated need to be translated, thereby reducing the content to be translated, improving translation efficiency, and shortening the translation time.
[0066] In the embodiments of the present specification, the elements to be translated extracted from the document to be translated may be non-fixed fields in the document to be translated, and these non-fixed fields are contents not included in the translation template, that is, contents outside the translation template. As an example, an ID card is used as an example. The element types in the document of the ID card type may include "name", "address", "validity period of the certificate", etc. The fields such as "name", "address", "validity period of the certificate" corresponding to these element types have been translated in the translation template of the ID card, and the elements to be translated corresponding to these element types may include, for example, "Zhang San", "male", "Han nationality", "xxxx, Haidian District, Beijing", "xxxx.xx.xx-xxxx.xx.xx", etc. These elements to be translated are the contents that need to be further translated using the translation tool.
[0067] In practical applications, the method of extracting the elements to be translated corresponding to the document type from the document to be translated may include but is not limited to the following two methods: Method 1: Pre-train an element extraction model using a document sample marked with elements to be translated, and input the document to be translated into the element extraction model. The element extraction model can extract the elements to be translated in the document to be translated and output the extraction result. Method 2: Extract the elements to be translated based on rules. The element extraction rules may vary depending on the document type, that is, different element extraction rules may be set for different document types. There may be various element extraction rules. For example, the element itself may be directly identified. For example, the certificate number of a graduation certificate has a specific structure, and the certificate number of a graduation certificate may be identified based on this structure. For another example, the element may be identified based on the associated information with the element. For example, the element behind the word "name" is the name element. The method of extracting elements to be translated based on rules in method 2 is relatively simple, but because it is difficult to cover all situations, the accuracy is relatively low. Therefore, different element extraction methods can be used for different types of documents. For example, for documents of the "identity card" type, given that the structure of this type of document is simple and fixed and the structure of the element content is predictable, the rule-based method of method 2 can be used to extract the elements to be translated, which can save computing resources and improve extraction efficiency; for documents of the "notarization" type, given that the structure of this type of document is flexible and changeable and the element content is also diverse, the method of method 1 based on the element extraction model to extract the elements to be translated can be used to improve the accuracy of element extraction.
[0068] Step 210: Use a large language model to translate the elements to be translated to obtain element translations.
[0069] In the embodiments of this specification, a large language model (LLM) may refer to a deep learning model trained with a large amount of text data, which can generate natural language text or understand the meaning of language text. The large language model can handle a variety of natural language tasks, such as text classification, text translation, question and answer, dialogue, etc. The large language model is trained by processing and analyzing massive amounts of text data, which may include books, websites, news articles, etc. During the training process, the model learns how to understand and generate language.
[0070] In the embodiments of this specification, the large language model may be a pre-trained large language model with language translation capabilities. In practical applications, the large language model may be a model for translating document elements obtained by performing enhanced training or fine-tuning training on a pre-trained basic large language model using document samples. Among them, a document sample used for enhanced training or fine-tuning training may include a first language version and a second language version of a document, so that the large language model after enhanced training or fine-tuning training can have the ability to translate a document from the first language to the second language, or, to translate a document from the second language to the first language.
[0071] In practical applications, different large language models can be trained for different language translation tasks, for example, one large language model can be trained for Chinese to English or English to Chinese, and another large language model can be trained for Chinese to Japanese or Japanese to Chinese. Alternatively, a large language model can be trained using samples of multiple languages so that the large language model has the ability to translate between multiple languages, and there is no specific limitation on this.
[0072] Step 212: concatenate the element translation with the translation template to obtain the document translation of the document to be translated.
[0073] In the embodiments of the present specification, a placeholder corresponding to the element translation may be reserved in the translation template, so that the element translation can be directly inserted into the corresponding placeholder (or, replace the corresponding placeholder) to complete the splicing between the element translation and the translation template. For example: a document translation of a graduation certificate is performed, and the Chinese document is translated into an English document. Before the translation, the "college name" column is "Tsinghua University", then the translation template contains "College name:", and a placeholder is left after "College name:", "Tsinghua University" is used as the element to be translated, and the translated element translation is "Tsinghua University", then "Tsinghua University" is inserted into the placeholder after "College name:" (or, replace the placeholder after "College name:") to complete the splicing. In practical applications, the splicing model can also be used to splice the element translation with the translation template, or other methods can be used to splice the element translation with the translation template, and no specific limitation is made to this.
[0074] Figure 2In the method, after receiving a document translation request for translating a document to be translated, the document translation platform can determine the document type of the document to be translated based on the request, and then obtain the translation template of the document type on the one hand, and extract the elements to be translated in the document of the document type and use the large language model to translate to obtain the element translation corresponding to the element to be translated, and then splice the element translation with the translation template to obtain the document translation. Therefore, by setting the fixed content in the document as a template and using the large language model to translate the variable content in the document, the translation of all the content in the document is avoided, which can replace manual translation and simple machine translation, which is not only conducive to improving the translation efficiency of the document, but also conducive to improving the accuracy of the document translation.
[0075] based on Figure 2 The method in this specification also provides some specific implementation plans of the method, which are described below.
[0076] Optional, Figure 2 In the method, in step 204, in response to the document translation request, determining the document type of the document to be translated may specifically include:
[0077] In response to the document translation request, reading the document content of the document to be translated;
[0078] The document type of the document to be translated is determined according to the content of the document.
[0079] In actual applications, the document to be translated can be carried in the document translation request, so that after the server of the document translation platform receives the document translation request, it can read the document content of the document to be translated, and determine the document type of the document to be translated based on the document content. Specifically, the document type of the document to be translated can be determined based on the keyword information in the document content. For example, if the document content of a document to be translated contains the keyword information "graduation certificate", it can be determined that the document type of the document to be translated is a graduation certificate. The document classification model can also be used to determine the document type of the document to be translated. Since the subsequent embodiments in the embodiments of this specification will explain in detail the method of determining the document type of the document to be translated, it will not be repeated here.
[0080] Correspondingly, in response to the document translation request, reading the document content of the document to be translated may specifically include:
[0081] Determine the file format of the document to be translated; the file format includes image format, WORD document format or PDF document format;
[0082] The document content of the document to be translated is read using a content reading rule corresponding to the file format.
[0083] In an embodiment of the present specification, the file format of the document to be translated can be determined based on the file suffix of the document to be translated. Specifically, for different file formats, a corresponding file suffix list can be provided. By comparing the file suffix of the document to be translated with the list, the file format of the document to be translated can be determined.
[0084] In the embodiments of this specification, the file suffixes of the picture format may include but are not limited to: jpg, jpeg, jpe, png, tif, gif, bmp, pcx, tga, exif, fpx, svg, psd, cdr, pcd, dxf, ufo, eps, ai, raw, WMF, webp, avif, apng, etc. In practical applications, the document to be translated may adopt any of the above picture formats. The file suffixes of the WORD document format may include but are not limited to: doc, docx, dot, dotx, etc. The file suffixes of the PDF document format may include but are not limited to: pdf, etc.
[0085] In actual applications, different content reading rules can be set for different file formats. For example, the content reading rules for documents in picture format and those for documents in WORD document format can be different. Of course, the content reading rules corresponding to different file formats may also be the same, and there is no specific limitation on this.
[0086] Optionally, the adopting of a content reading rule corresponding to the file format to read the document content of the document to be translated may specifically include:
[0087] If the file format is a picture format, a multimodal large model is used to perform OCR recognition to obtain the document content of the document to be translated.
[0088] In the embodiments of this specification, multimodal large models (MLMs) refer to deep learning models that can process and generate different types of data (such as text, images, audio and video). Multimodal large models can fuse multiple modal data such as text, images, audio, video, and perform comprehensive understanding and reasoning. Multimodal large models can not only understand the information of a single modality, but also fuse information across multiple modalities, enabling them to more comprehensively understand and generate diverse content. Multimodal large models have the ability to process text and pictures at the same time. Using multimodal large models to perform OCR recognition, the multimodal large model's processing ability for pictures is applied, specifically, the ability of the multimodal large model to extract text content from pictures is utilized.
[0089] In the embodiments of this specification, Optical Character Recognition (OCR) refers to the process in which an electronic device (such as a scanner or digital camera) examines characters printed on paper, determines their shapes by detecting dark and light patterns, and then translates the shapes into computer text using character recognition methods. The basic principle of OCR technology is to convert text information in visual sources such as paper documents and pictures into computer editable and searchable text data by scanning or taking pictures. OCR technology uses image processing and pattern recognition technology to identify and extract text content by scanning documents and analyzing the fonts, formats and characters in the image.
[0090] In practical applications, if the file format of the document to be translated is in picture format, the content of the document to be translated can be obtained through OCR recognition. Optionally, the content of the document to be translated can be read through traditional OCR recognition methods, or a multimodal large model can be used to perform OCR recognition to obtain the content of the document to be translated. When applying a multimodal large model to perform OCR recognition for pictures, it can also combine information from other modalities (such as text descriptions, context images, etc.) to further improve the accuracy and completeness of recognition. For example, when processing pictures containing characters, the model can use contextual information to more accurately identify characters. In addition, after applying a multimodal large model to perform OCR recognition for pictures and obtaining the recognition results, the multimodal large model can also perform intelligent proofreading on the recognition results based on its own language capabilities to make the recognition results more accurate.
[0091] Optionally, the adopting of a content reading rule corresponding to the file format to read the document content of the document to be translated may specifically include:
[0092] If the file format is a WORD document format, the first library function for reading WORD document content is used to read the document content of the document to be translated.
[0093] In the embodiment of this specification, the first library function is a function that has the function of reading the content of a WORD document, and may include but is not limited to: a specific function in the Apache POI library, where Apache POI is an open source Java library designed specifically for processing Office documents (such as Word, Excel, etc.).
[0094] In actual application, using the first library function to read the document content of the document to be translated can include the following stages: 1. Preparation stage: In the preparation stage, make sure that the Apache POI library has been installed and correctly configured in the computer system. 2. Document loading stage: In the document loading stage, the classes and methods provided by the Apache POI library can be used to load the Word document to be processed into memory. 3. Text extraction stage: After the document is successfully loaded, all the text content in the Word document can be extracted by traversing all the paragraphs (XWPFParagraph objects) contained in the XWPFDocument object and using the getText method of each paragraph object. The extracted text content can be saved in a string variable for subsequent processing or analysis.
[0095] In actual applications, if the document to be translated in WORD format also contains pictures, a multimodal large model or other means can be used to perform OCR recognition on the picture to obtain the recognized text result. For the remaining text in the document to be translated, the first library function can be directly used to read it.
[0096] Optionally, the adopting of a content reading rule corresponding to the file format to read the document content of the document to be translated may specifically include:
[0097] If the file format is a PDF document format, a second library function for reading PDF document content is used to read the document content of the document to be translated.
[0098] In the embodiment of this specification, the second library function is a function that has the function of reading the content of a PDF document, and may include but is not limited to: a specific function in the iText library. The iText library is a powerful PDF processing library that supports multiple operations such as creation, modification, and extraction of text content of PDF documents.
[0099] In actual application, using the second library function to read the document content of the document to be translated can include the following stages: 1. Preparation stage: In the preparation stage, make sure that the iText library has been installed and correctly configured in the computer system. 2. Document loading stage: In the document loading stage, you can use the relevant classes in the iText library (such as PdfReader) to load the PDF document and load the PDF document to be processed into memory. This stage usually involves creating a PdfReader object and reading the content of the PDF file through the object. 3. Text extraction stage: After the document is successfully loaded, traverse the pages and page contents of the PDF document (for example, using the getNumberOfPages method and getPage method of the PdfDocument object), and use the getTextFromPage method of the PdfTextExtractor class to extract the text content from each page. The extracted text content can be stored in a string variable for subsequent processing or analysis.
[0100] In the embodiments of this specification, the content in the PDF document may be directly readable by the second library function, or it may be a PDF document in the form of an image. For a PDF document in the form of an image, the second library function may read an empty character as a result. For a PDF document in the form of an image, or an image in a PDF document, a traditional OCR recognition method may be used to read the document content, or a multimodal large model may be used to perform OCR recognition to obtain the document content of the document to be translated.
[0101] Based on this, if the file format is a PDF document format, the second library function for reading PDF document content is used to read the document content of the document to be translated, which may specifically include:
[0102] If the file format is a PDF document format, a second library function for reading PDF document content is used to read the content of the document to be translated, and a reading result of the second library function is obtained;
[0103] Determine the proportion of null characters in the result read by the second library function;
[0104] Determine whether the blank character ratio is less than a preset blank character ratio threshold, and obtain a blank character determination result;
[0105] If the empty character judgment result indicates that the proportion of empty characters is less than a preset empty character ratio threshold, the second library function reading result is determined as the document content of the document to be translated.
[0106] Correspondingly, after determining whether the proportion of the blank characters is less than a preset blank character proportion threshold and obtaining the blank character determination result, the method further includes:
[0107] If the empty character judgment result indicates that the proportion of empty characters is greater than or equal to a preset empty character ratio threshold, a multimodal large model is used to perform OCR recognition to obtain the document content of the document to be translated.
[0108] In the embodiment of this specification, the preset empty character ratio threshold can reflect the proportion of empty characters in the PDF file under normal circumstances, which is an empirical parameter. Of course, the empty character ratio threshold can also be set and adjusted according to actual needs, and no specific limitation is made to this.
[0109] In an embodiment of the present specification, if the proportion of empty characters in the reading result of the second library function is less than a preset empty character ratio threshold, it can be said that the PDF document is a document that can be directly read by the second library function, so that in this case the reading result of the second library function can be directly determined as the document content of the document to be translated.
[0110] In the embodiment of this specification, for a PDF document in the form of a picture, the result of the second library function reading is an empty character. Therefore, when the proportion of empty characters in the result of the second library function reading is greater than or equal to the preset empty character ratio threshold, it can be indicated that the PDF document is a PDF document in the form of a picture that cannot be directly read by the second library function. For a PDF document in the form of a picture, a multimodal large model can be used to perform OCR recognition to obtain the document content of the document to be translated. Since the content of performing OCR recognition using a multimodal large model has been described in detail in the aforementioned embodiment, it will not be repeated here.
[0111] In actual applications, if the file format of the document to be translated is in PDF document format and contains multiple pages, in order to improve processing efficiency and translation efficiency, the multiple pages can be split into multiple pages, and then each page can be processed separately.
[0112] Based on this, if the file format is a PDF document format, the second library function for reading PDF document content is used to read the document content of the document to be translated, which may specifically include:
[0113] If the file format is a PDF document format, a splitting operation is performed on the document to be translated that contains two or more pages to obtain sub-documents;
[0114] For each sub-document, determine whether the content of the document to be translated is readable.
[0115] In actual applications, considering the complexity of PDF processing and the limited amount of files that OCR recognition can process each time, in order to improve processing efficiency, multi-page PDFs can be split before recognition processing. The sub-documents obtained after splitting a multi-page PDF are usually single pages of documents, that is, they are obtained by splitting by page. Of course, in addition to splitting by page number, other splitting methods can be used according to actual needs. For example, it can also be split according to the division of content, etc., and there is no specific limitation on this. For documents to be translated in single-page PDF document format, they can be processed directly without splitting.
[0116] In the embodiments of this specification, the threshold value of the ratio of empty characters corresponding to each sub-document can reflect the ratio of empty characters in a PDF page under normal circumstances, which is an empirical parameter. Of course, the threshold value of the ratio of empty characters in a PDF page can also be set and adjusted according to actual needs, and there is no specific limitation on this.
[0117] In an embodiment of the present specification, after a splitting operation is performed on the document to be translated comprising two or more pages to obtain multiple sub-documents, some of the sub-documents may be readable documents. For these readable documents, the second library function can be used to directly read the document contents from these sub-documents; while some of the sub-documents may not be directly readable by the second library function, that is, unreadable documents. For these sub-documents, OCR recognition can be adopted.
[0118] In actual applications, a document to be translated containing two or more pages is split into multiple sub-documents. Each sub-document can be processed in parallel to determine whether the content in each sub-document is readable, which can greatly improve the processing speed and efficiency and save processing time. Moreover, processing each sub-document is equivalent to refining the entire document to be translated, which is also conducive to improving the accuracy of translation processing.
[0119] In practical applications, it is also possible to pre-train a document classification model using document content samples marked with document type labels, and then use the document classification model to determine the document type of the document to be translated.
[0120] Based on this, determining the document type of the document to be translated according to the document content may specifically include:
[0121] The document content is input into a document classification model to obtain the document type of the document to be translated determined by the document classification model; the document classification model is trained based on document content samples marked with document type labels.
[0122] In the embodiments of this specification, the document content samples may be samples in the form of text, and each sample is marked with a document type label, so that after the initial document classification model is trained using the document content samples marked with the document type label, a trained document classification model with document classification capabilities can be obtained. In practical applications, the document classification model may include but is not limited to the following types: clustering model, neural network model, logistic regression model, decision tree model, random forest model, naive Bayes model, etc.
[0123] In actual applications, the document type of the document to be translated can also be determined based on one or several keywords in the document content of the document to be translated. For example, if the document content of the document to be translated contains the keyword "graduation certificate", the document type of the document to be translated is determined to be a graduation certificate; another example is if the document content of the document to be translated contains the keyword "notarization", the document type of the document to be translated is determined to be a notarization. Another example is if the document content of the document to be translated contains both the keywords "notarization" and "graduation certificate", the document type of the document to be translated can be determined to be a notarization for a graduation certificate. Determining the document type of the document to be translated based on the keywords in the document content of the document to be translated is more efficient than using a document classification model to determine the document type of the document to be translated, and does not require calculation, can save computing resources, and is also conducive to improving the speed of determining the document type.
[0124] In practical applications, the document classification model is used to determine the document type of the document to be translated. Compared with directly determining the document type of the document to be translated based on the keywords in the document content, the document type can be determined more accurately. For example, for a document, if it contains the words "marriage certificate", the document may be a document of the "marriage certificate" type, or it may be a document of the "notarization related to the marriage certificate" type. If the type is determined by setting keywords, errors may occur. If errors are to be prevented, more complex judgment rules need to be set. Using the document classification model can directly obtain more accurate recognition results.
[0125] In actual applications, the document type of the document to be translated can be determined based on the keywords in the document content, or the document type of the document to be translated can be determined using a document classification model. It is also possible to first roughly classify the document type of the document to be translated based on the keywords in the document content, and then use the document classification model to finely classify the document type of the document to be translated. There is no specific limitation on this.
[0126] In the embodiment of this specification, the purpose of classifying documents is to make documents of different document types correspond to different translation templates. Therefore, in actual application, documents that can apply the same translation template can be classified into the same document type.
[0127] For example, for documents with a national unified format such as identity cards, marriage certificates, and divorce certificates, a translation template can be set for each. Therefore, the classification model needs to identify all identity card documents as the same type (i.e., identity card type), and so on. Of course, if the application scenario requires identification of identity cards from different countries, and the formats of identity cards from different countries are not unified, then in the embodiments of this specification, corresponding translation templates need to be set for identity cards from different countries. In this case, the document classification model needs to have the ability to identify identity cards from different countries as different types.
[0128] For another example, for documents such as graduation certificates and birth certificates that vary depending on the region or institution where the documents are issued, different translation templates can be set according to the format of the graduation certificates and birth certificates. For example, for graduation certificates, multiple templates such as horizontal and vertical versions can be set. Furthermore, in the horizontal version, multiple translation templates can be further divided according to the difference in content format.
[0129] For another example, for a document such as a notarial certificate which varies depending on the notarial matter and the institution that issues the notarial certificate, different translation templates may be provided according to the institution that issues the notarial certificate and / or different translation templates may be provided according to the notarial matter.
[0130] In actual applications, the more detailed the translation templates corresponding to the documents are divided, the more accurate the final translation result of the document to be translated will be, and the format of the final translation of the document to be translated will be closer to the format of the document to be translated. However, the more detailed the translation templates corresponding to the documents are divided, the greater the workload of making the translation templates. Therefore, the translation templates can be divided according to actual needs, taking into account both accuracy and workload.
[0131] In practical applications, the multimodal large language model can be pre-trained using document samples marked with document type labels, and then the pre-trained multimodal large language model can be used to determine the document type of the document to be translated.
[0132] Based on this, Figure 2 In the method, in step 204, in response to the document translation request, determining the document type of the document to be translated may specifically include:
[0133] In response to the document translation request, the document to be translated is input into a pre-trained multimodal large language model to obtain the document type of the document to be translated determined by the multimodal large language model; the multimodal large language model is trained based on document samples marked with document type labels.
[0134] In the embodiments of this specification, multimodal large language models (MLLMs) are a class of artificial intelligence models that can process and understand multiple types of data (such as text, images, audio, etc.). Unlike traditional unimodal language models, multimodal models combine different types of information to better capture complex contexts and semantic relationships. Multimodal large language models are extended from large language models (LLMs) and have the ability to receive and reason about multimodal information. Among them, modality is the way things experience and happen, and people live in a world composed of multiple modal information, including visual information, auditory information, text information, olfactory information, etc. Multimodal large language models can jointly analyze different types of data, such as images, videos, sounds, and texts, which enables it to have a more comprehensive understanding of rich information.
[0135] In the embodiments of the present specification, the document samples marked with document type labels used for pre-training the multimodal large language model can be documents in any file format, including but not limited to: picture format, word document format, and pdf document format, etc.
[0136] In the embodiments of the present specification, after training the multimodal large language model with document samples marked with document type labels, the multimodal large language model can be enabled to have the ability to classify documents. Since the document samples used for pre-training the multimodal large language model can be documents in any file format, the documents can be directly used as training samples without extracting the content of the document and then using the content of the document as training samples. Correspondingly, when using the multimodal large language model to classify documents, it is sufficient to input the document without first extracting the content of the document and then inputting the content of the document into the model. Therefore, using a multimodal large language model to classify documents is more convenient and more efficient than using a document classification model to classify documents.
[0137] Optional, Figure 2 In the method, in step 210, before translating the elements to be translated using a large language model and obtaining the element translation, the following may also be included:
[0138] Determining a translation library corresponding to the document type; the translation library includes standard translations of candidate elements;
[0139] Correspondingly, the use of a large language model to translate the elements to be translated to obtain element translations may specifically include:
[0140] The element to be translated and the translation library are input into a large language model, and an element translation for the element to be translated output by the large language model with reference to the translation library is obtained.
[0141] In the embodiment of this specification, the purpose of setting the translation library corresponding to the document type is that when a word in the translation library appears in a document of the document type, the standard translation pre-stored in the translation library can be directly used for translation. In practical application, some content that needs to be fixedly translated can be set in the translation library. For example, for entity names such as university names, institution names, and company names and the fixed translations corresponding to these entity names, they can be set in the translation library. When a large language model is used to translate the translation elements, the translation can be based on the accurate translation in the translation library, thereby reducing the situation where translation errors occur when using a large language model for translation. For another example, for some abbreviated contents that are not easy to translate based on literal meanings, such as the font size of a notarial certificate: the English translation corresponding to "XM LJZI" is to avoid large language models from translating these abbreviated contents that are not easy to translate based on literal meanings, and these contents and corresponding translations can also be set in the translation library.
[0142] In actual applications, different translation libraries can be set for different types of documents. This is because, even for the same alternative elements, the corresponding translations may require different translation content in different types of documents. For example, the word "World Bank" is usually translated as "World Bank" in most documents; however, in certain specific contexts, in order to emphasize its nature as an international bank for reconstruction and development, it may also be translated as "International Bank for Reconstruction and Development". Therefore, in actual applications, in order to adapt to the translation styles of different types of documents, different translation libraries can be set for different types. Of course, one translation library can also be set for multiple types of documents, and there is no specific limitation on this.
[0143] Exemplarily, taking a document of the document type "graduation certificate" as an example, this type of document usually contains element types such as "school name", "president", and "certificate number", among which the alternative element corresponding to the "school name" element type is the entity name. Therefore, the standard translation corresponding to the common (or easily mistranslated) entity name corresponding to the "school name" element can be set in the translation library. Specifically, for example, the standard translation of "Tsinghua University" can be set as "Tsinghua University" in the translation library; for another example, the standard translation of "Peking University" can be set as "Peking University" in the translation library.
[0144] Correspondingly, the step of inputting the to-be-translated element and the translation library into the large language model to obtain the element translation for the to-be-translated element output by the large language model with reference to the translation library may specifically include:
[0145] Based on the elements to be translated and the translation library, generating prompt information for inputting into the large language model; the prompt information is used to instruct the large language model to translate the elements to be translated based on the content of the translation library;
[0146] The prompt information is input into the large language model to obtain the element translation for the element to be translated output by the large language model with reference to the translation library.
[0147] In the embodiments of the present specification, the determination of the translation library corresponding to the document type may be to determine the library identification information or storage location information of the translation library corresponding to the document type. Accordingly, the generation of prompt information for input into the large language model based on the elements to be translated and the translation library may be based on the elements to be translated and the library identification information or storage location information used to represent the translation library, to generate prompt information for input into the large language model. In this case, there is no need to directly provide the specific content in the translation library to the large speech model, and the library identification information or storage location information of the translation library is provided to the large speech model, and the large language model can obtain the specific content in the translation library based on the library identification information or storage location information of the translation library.
[0148] In actual applications, when the elements to be translated are consistent with the candidate elements in the translation library, for example, the elements to be translated include "Tsinghua University", and the candidate elements in the translation library include "Tsinghua University" and the standard translation corresponding to the candidate element "Tsinghua University" is "Tsinghua University", then when the large speech model translates the elements to be translated, it can refer to the content in the translation library and determine the element translation of the element to be translated "Tsinghua University" as "Tsinghua University" instead of directly translating it as "Qinghua University". It can be seen that when the large language model translates with reference to the translation library, the accuracy of the element translation can be effectively improved, and the consistency of the element translation can also be ensured.
[0149] In actual applications, the translation library can not only set up alternative elements and their corresponding standard translations, but also further record the target element type corresponding to the alternative element, wherein the target element type of the alternative element is included in the element type contained in the document of the document type. The advantage of this setting is that when the same element to be translated appears in multiple places in a document, if the element to be translated appears in different positions, the required translation format is different, for example, when it is the first element type, the full name translation is used, and when it is the second element type, the abbreviated translation is used. According to the specific element type corresponding to the element to be translated, a more refined translation can be adopted according to actual business needs to improve the accuracy of the translation.
[0150] Optional, Figure 2 In the method, in step 212, the element translation is spliced with the translation template to obtain the document translation of the document to be translated, which may specifically include:
[0151] The element translations of the elements to be translated are used to replace the corresponding placeholders in the translation template to obtain the document translation of the document to be translated.
[0152] In the embodiments of the present specification, a placeholder corresponding to the element translation may be reserved in the translation template, so that the element translation of the element to be translated can replace the corresponding placeholder in the translation template to complete the splicing between the element translation and the translation template, and obtain the document translation of the document to be translated. For example: a document translation of a graduation certificate is performed, and the Chinese document is translated into an English document. Before the translation, the "College Name" column is "Peking University", then the translation template contains "College name:", and a placeholder is reserved after "College name:", "Peking University" is the element to be translated, and the translated element translation is "Peking University", then "Peking University" replaces the placeholder after "College name:", completes the splicing, and obtains "College name: Peking University".
[0153] In practical applications, a splicing model can also be used to splice the element translation and the translation template, or other methods can be used to splice the element translation and the translation template, without specific limitation. In the embodiments of this specification, by introducing the translation template, since the translation template contains the translation of part of the content, there is no need to translate the existing part of the content in the translation template, thereby reducing the amount of translation, improving translation efficiency, and minimizing translation errors. In addition, by introducing the translation template, the format of the document translation of the document to be translated can be guaranteed to be consistent with the format of the document to be translated.
[0154] Optional, Figure 2 In the method, the translation template is consistent with the page format of the document to be translated.
[0155] Among them, the page format can specifically reflect the layout of the content in the page. More specifically, it can reflect the relative positions of different contents in the page. For example, for a graduation certificate, if the document to be translated is in horizontal format and the graduate's photo is in the upper right corner, then the translation template is in horizontal format and the graduate's photo is in the upper right corner. What is given here is only an example. In actual application, all fixed content that appears in the translation template and its corresponding content in the document to be translated can be in the same position on the page. In this way, it can be ensured that the translated document has a consistent page format with the document to be translated.
[0156] In actual applications, some elements that require standardized translation can have their standard translations set in the translation library, such as the name of a notary agency, the name of a university, etc. If the business volume of a candidate element that requires standardized translation is large, the candidate element can be used as the dimension for dividing the document type, a new document type can be divided, and the translation content of the candidate element can be set in the translation template. For example, a notarial certificate contains content such as "Lujiang Notary Office, Xiamen, Fujian Province, People's Republic of China" and "Xia Lu Certificate". The corresponding translations of these contents can be set directly in the translation template or in the translation library, and there is no specific limitation on this.
[0157] Figure 3 This is a schematic diagram of an embodiment of the present specification for translating a graduation certificate. Figure 3 As shown, the document type of the document to be translated is a graduation certificate, and the document to be translated is in Chinese and needs to be translated into English. The "Zhang San", "Male", "Civil Engineering", "Tsinghua University", "100xxxxxxxxxxx" and specific years, months, dates, etc. in the graduation certificate are elements to be translated. After using the large language model to translate these elements to be translated, the corresponding element translations are obtained. For example, the element translation corresponding to "Zhang San" is "Zhang San"; the element translation corresponding to "Male" is "male"; the element translation corresponding to "Civil Engineering" is "Civil Engineering", which are not listed here one by one. In the document translation obtained after translating the document to be translated, the content in the dotted box is the element translation corresponding to the elements to be translated in the dotted box in the graduation certificate. The content in the dotted box in the translation template is empty characters or placeholders. By Figure 3 It can also be seen that the page format of the document translation is consistent with that of the document to be translated, and the translation template is consistent with the format of the document translation. Therefore, the page format of the translation template is also consistent with that of the document to be translated. The consistency of the page formats of the three is conducive to improving the accuracy of the translation, facilitating the proofreader to proofread, and improving user satisfaction.
[0158] Figure 4 This is a schematic diagram of an embodiment of the present specification for translating a notarial certificate. Figure 4As shown, the document type of the document to be translated is a notarial certificate, and the document to be translated is in Chinese and needs to be translated into English. The "Yang xx", "female", "130xxxxxxxxxxxxxxx", "XX Middle School", "1xx" and specific years, months, dates, etc. in the notarial certificate are elements to be translated. After these elements to be translated are translated using a large language model, the corresponding element translations are obtained. For example, the element translation corresponding to "Yang xx" is "Yang xx"; the element translation corresponding to "female" is "female"; the element translation corresponding to "XX Middle School" is "XX Middle School", which are not listed one by one here. In the document translation obtained after translating the document to be translated, the content in the dotted box is the element translation corresponding to the elements to be translated in the dotted box in the graduation certificate. The content in the dotted box in the translation template is empty characters or placeholders. By Figure 4 It can also be seen that the page format of the document translation is consistent with that of the document to be translated, and the translation template is consistent with the format of the document translation. Therefore, the page format of the translation template is also consistent with that of the document to be translated. The consistency of the page formats of the three is conducive to improving the accuracy of the translation, facilitating the proofreader to proofread, and improving user satisfaction.
[0159] Optional, Figure 2 In the method, in step 212, after the element translation is spliced with the translation template to obtain the document translation of the document to be translated, the method may further include:
[0160] The document translation is fed back to the requesting device that sends the document translation request.
[0161] In an embodiment of the present specification, the requesting device that sends the document translation request can be a client of the document translation platform. The user can upload the document to be translated to the document translation platform server through the client of the document translation platform and initiate a document translation request. After the server of the document translation platform receives the document translation request for requesting the translation of the document to be translated, it can respond to the document translation request, generate a translation task for translating the document to be translated, and then execute the translation task to translate the document to be translated. After the translation is completed, the document translation of the document to be translated is obtained, and then the document translation of the document to be translated is fed back to the requesting device (client of the document translation platform) that sends the document translation request. In actual applications, the data transmission between the client of the document translation platform and the server of the document translation platform can be based on wired network communications such as Ethernet and optical fiber communications, or can be based on wireless network communications such as WIFI and mobile networks, and there is no specific limitation on this.
[0162] In actual applications, using a large language model to translate documents cannot guarantee that the translation results are completely accurate. Therefore, in order to improve the accuracy of the document translation feedback to users, a large language model is used to translate the document. After obtaining the document translation, the document translation can also be manually reviewed and corrected.
[0163] Based on this, Figure 2 In the method, in step 212, after the element translation is spliced with the translation template to obtain the document translation of the document to be translated, the method may further include:
[0164] Obtaining manual correction operations for the translation of the document;
[0165] Modifying the document translation in response to the manual correction operation to obtain a document correction translation;
[0166] The corrected translation of the document is fed back to the requesting device that sent the document translation request.
[0167] In the embodiments of this specification, a large language model is used to translate the document to be translated. After obtaining the document translation, the document translation proofreader can review the document translation. If translation errors are found in the document translation, manual correction operations can be performed on the document translation. Among them, manual correction operations can include but are not limited to: deleting characters, adding characters, replacing characters, etc. In actual applications, for each manual correction operation, a corresponding manual correction operation record can be generated and stored for later inspection.
[0168] In actual applications, after the document translation is modified in response to a manual correction operation and the corrected translation is obtained, the corrected translation can be stored at the server of the document translation platform or in other data storage spaces to retain a backup of the corrected translation.
[0169] Optionally, after modifying the document translation in response to the manual correction operation to obtain the document corrected translation, the method may further include:
[0170] In response to the manual correction operation, determining the corrected element targeted by the manual correction operation and the element-corrected translation corresponding to the corrected element;
[0171] The corrected element and the element-corrected translation corresponding to the corrected element are updated in the translation library.
[0172] In the embodiment of the present specification, the corrected elements targeted by the manual correction operation are elements that are incorrectly translated by the large language model, and these corrected elements are also elements that are not included in the original translation library. Therefore, after the corrected elements and the element correction translations corresponding to the corrected elements are updated to the translation library, the large language model will translate the corrected elements based on the reference to the updated translation library, and the translation result obtained is the element correction translation corresponding to the corrected elements, which is an accurate translation result, thereby further improving the accuracy and efficiency of translation.
[0173] In order to verify the beneficial effects of the present application, the inventor used the document translation method in the present application to conduct translation tests on eight types of documents, namely, birth certificates, identity cards, graduation certificates, degree certificates, transcripts, marriage certificates, divorce certificates, and driver's licenses. The test results are shown in Table 1.
[0174] Table 1:
[0175]
[0176] In Table 1, the element accuracy rate may refer to the accuracy rate of extracting the elements to be translated corresponding to the document type from the document to be translated, that is, the accuracy rate of element extraction; the translation accuracy rate may refer to the accuracy rate of the element translation obtained by translating the elements to be translated using a large language model, that is, the accuracy rate of element translation. The comprehensive accuracy rate may be the product of the element accuracy rate and the translation accuracy rate, which may comprehensively reflect the final translation accuracy rate. In practical applications, considering that the template is a fixed content and does not need to be translated, the comprehensive accuracy rate described in Table 1 may reflect the accuracy rate of translating the document based on the document translation method of the embodiment of the present application. It can be seen from the results in Table 1 that the document translation method in the present application may ensure that the comprehensive accuracy rate of document translation reaches more than 85%.
[0177] Figure 5 The following is an overall flow chart of a document translation method provided in the embodiment of this specification. Figure 5 As shown, the document translation method may specifically include the following steps:
[0178] Step 502: Receive a document translation request from a requesting party.
[0179] Step 504: Determine the file format of the document to be translated.
[0180] Step 506: Using the content reading rules corresponding to the file format, read the document content of the document to be translated.
[0181] Step 508: Input the document content into the document classification model to obtain the document type of the document to be translated determined by the document classification model.
[0182] Step 510: extracting elements to be translated corresponding to the document type from the document to be translated.
[0183] Step 512: Determine a translation template based on the document type.
[0184] Step 514: Determine the translation library corresponding to the document type.
[0185] Step 516: Based on the elements to be translated and the translation library, generate prompt information for input into the large language model.
[0186] Step 518: Input the prompt information into the large language model to obtain the element translation for the element to be translated output by the large language model reference translation library.
[0187] Step 520: The element translations of the elements to be translated are used to replace the corresponding placeholders in the translation template to obtain the document translation of the document to be translated.
[0188] Step 522: Obtain manual correction operations for the document translation, and modify the document translation based on the manual correction operations to obtain a corrected document translation.
[0189] Step 524: Feedback the document correction translation to the requesting device.
[0190] Step 526: Determine the corrected element targeted by the manual correction operation and the element-corrected translation corresponding to the corrected element; and update the corrected element and the element-corrected translation corresponding to the corrected element to the translation library.
[0191] Among them, in step 506, if the file format is a picture format, a multimodal large model is used to perform OCR recognition to obtain the document content of the document to be translated; if the file format is a WORD document format, a first library function for reading WORD document content is used to read the document content of the document to be translated; if the file format is a PDF document format, a second library function for reading PDF document content is used to read the document content of the document to be translated.
[0192] Figure 5In the method, after receiving a document translation request for translating a document to be translated, the document translation platform can determine the document type of the document to be translated based on the request, and then obtain the translation template of the document type on the one hand, and extract the elements to be translated in the document of the document type and use the large language model to translate to obtain the element translation corresponding to the element to be translated, and then splice the element translation with the translation template to obtain the document translation. Therefore, by setting the fixed content in the document as a template and using the large language model to translate the variable content in the document, the translation of all the content in the document is avoided, which can replace manual translation and simple machine translation, which is not only conducive to improving the translation efficiency of the document, but also conducive to improving the accuracy of the document translation.
[0193] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0194] Figure 6 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a document translation device. Figure 6 As shown, the device may include:
[0195] The request receiving module 602 is used to receive a document translation request for requesting translation of a document to be translated.
[0196] The document type determination module 604 is used to determine the document type of the document to be translated in response to the document translation request.
[0197] The translation template determination module 606 is used to determine the translation template according to the document type.
[0198] The element extraction module 608 is used to extract elements to be translated corresponding to the document type from the document to be translated. The elements to be translated are the contents of the document to be translated other than the translation template.
[0199] The element translation module 610 is used to translate the element to be translated using a large language model to obtain an element translation.
[0200] The translation splicing module 612 is used to splice the element translation with the translation template to obtain the document translation of the document to be translated.
[0201] based on Figure 6 The present specification also provides some specific implementation schemes of the device, which are described below.
[0202] Optionally, the document type determination module 604 may specifically include:
[0203] The document content reading submodule is used to read the document content of the document to be translated in response to the document translation request.
[0204] The document type determination submodule is used to determine the document type of the document to be translated according to the content of the document.
[0205] Optionally, the document content reading submodule may specifically include:
[0206] The file format determination unit is used to determine the file format of the document to be translated; the file format includes a picture format, a WORD document format or a PDF document format.
[0207] The document content reading unit is used to read the document content of the document to be translated by adopting a content reading rule corresponding to the file format.
[0208] Optionally, the document content reading unit may specifically include:
[0209] The first reading subunit is used to perform OCR recognition using a multimodal large model to obtain the document content of the document to be translated if the file format is a picture format.
[0210] Optionally, the document content reading unit may specifically include:
[0211] The second reading subunit is used to read the document content of the document to be translated by using a first library function for reading WORD document content if the file format is a WORD document format.
[0212] Optionally, the document content reading unit may specifically include:
[0213] The third reading subunit is used to read the document content of the document to be translated by using a second library function for reading PDF document content if the file format is a PDF document format.
[0214] Optionally, the third reading subunit is configured as:
[0215] If the file format is a PDF document format, a second library function for reading PDF document content is used to read the content of the document to be translated, and a reading result of the second library function is obtained;
[0216] Determine the proportion of null characters in the result read by the second library function;
[0217] Determine whether the blank character ratio is less than a preset blank character ratio threshold, and obtain a blank character determination result;
[0218] If the empty character judgment result indicates that the proportion of empty characters is less than a preset empty character ratio threshold, the second library function reading result is determined as the document content of the document to be translated.
[0219] Optionally, the third reading subunit is further configured as follows:
[0220] If the empty character judgment result indicates that the proportion of empty characters is greater than or equal to a preset empty character ratio threshold, a multimodal large model is used to perform OCR recognition to obtain the document content of the document to be translated.
[0221] Optionally, the third reading subunit is configured as:
[0222] If the file format is a PDF document format, a splitting operation is performed on the document to be translated that contains two or more pages to obtain sub-documents;
[0223] For each sub-document, determine whether the content of the document to be translated is readable.
[0224] Optionally, the document type determination submodule may specifically include:
[0225] The document type determination unit is used to input the document content into a document classification model to obtain the document type of the document to be translated determined by the document classification model; the document classification model is trained based on document content samples marked with document type labels.
[0226] Optionally, the document type determination module 604 may specifically include:
[0227] The document type determination submodule is used to respond to the document translation request, input the document to be translated into a pre-trained multimodal large language model, and obtain the document type of the document to be translated determined by the multimodal large language model; the multimodal large language model is trained based on document samples marked with document type labels.
[0228] Optionally, the device may further include:
[0229] The translation library determination module is used to determine the translation library corresponding to the document type; the translation library contains standard translations of candidate elements.
[0230] Correspondingly, the element translation module 610 specifically includes:
[0231] The element translation submodule is used to input the element to be translated and the translation library into the large language model, and obtain the element translation for the element to be translated output by the large language model with reference to the translation library.
[0232] Optionally, the element translation submodule may specifically include:
[0233] A prompt information generating unit is used to generate prompt information for input into a large language model based on the element to be translated and the translation library; the prompt information is used to instruct the large language model to translate the element to be translated based on the content of the translation library.
[0234] The element translation obtaining unit is used to input the prompt information into the large language model to obtain the element translation for the element to be translated output by the large language model with reference to the translation library.
[0235] Optionally, the translation splicing module 612 may specifically include:
[0236] The translation splicing submodule is used to replace the corresponding placeholders in the translation template with the element translations of each element to be translated, so as to obtain the document translation of the document to be translated.
[0237] Optionally, in the device, the translation template is consistent with the page format of the document to be translated.
[0238] Optionally, the device further comprises:
[0239] The result feedback module is used to feed back the document translation to the requesting device that sent the document translation request.
[0240] Optionally, the device further comprises:
[0241] The correction operation acquisition module is used to acquire manual correction operations for the document translation.
[0242] The corrected translation acquisition module is used to modify the document translation in response to the manual correction operation to obtain a corrected translation of the document.
[0243] The correction translation feedback module is used to feed back the correction translation of the document to the requesting device that sends the document translation request.
[0244] Optionally, the device further comprises:
[0245] The corrected element determination module is used to determine, in response to the manual correction operation, the corrected element targeted by the manual correction operation and the element correction translation corresponding to the corrected element.
[0246] The corrected element updating module is used to update the corrected element and the element-corrected translation corresponding to the corrected element to the translation library.
[0247] It is understood that the above modules refer to computer programs or program segments for executing one or more specific functions. In addition, the distinction between the above modules does not mean that the actual program codes must also be separated.
[0248] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0249] Figure 7 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a document translation device. Figure 7 As shown, the device 700 may include:
[0250] at least one processor 710; and,
[0251] A memory 730 in communication with the at least one processor; wherein,
[0252] The memory 730 stores instructions 720 that can be executed by the at least one processor 710. The instructions are executed by the at least one processor 710 to enable the at least one processor 710 to:
[0253] receiving a document translation request for requesting translation of a document to be translated;
[0254] In response to the document translation request, determining the document type of the document to be translated;
[0255] Determine the translation template according to the document type;
[0256] Extracting elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template;
[0257] Using a large language model to translate the elements to be translated to obtain element translations;
[0258] The element translation is concatenated with the translation template to obtain a document translation of the document to be translated.
[0259] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 7 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0260] The above is a description of a specific embodiment of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0261] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0262] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0263] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0264] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0265] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0266] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks 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 processes in the flowchart and / or block diagram. 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.
[0267] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate 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 A function specified in one or more boxes.
[0268] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0269] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0270] The memory may include non-permanent storage 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. The memory is an example of a computer-readable medium.
[0271] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape 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 temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0272] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0273] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0274] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.
Claims
1. A document translation method, comprising: receiving a document translation request for requesting translation of a document to be translated; In response to the document translation request, determining the document type of the document to be translated; Determine the translation template according to the document type; Extracting elements to be translated corresponding to the document type from the document to be translated; The elements to be translated are the contents of the document to be translated other than the translation template; Using a large language model to translate the elements to be translated to obtain element translations; The element translation is concatenated with the translation template to obtain a document translation of the document to be translated.
2. The method according to claim 1, wherein in response to the document translation request, determining the document type of the document to be translated specifically comprises: In response to the document translation request, reading the document content of the document to be translated; The document type of the document to be translated is determined according to the content of the document.
3. The method according to claim 2, wherein in response to the document translation request, reading the document content of the document to be translated specifically comprises: Determine the file format of the document to be translated; The file format includes picture format, WORD document format or PDF document format; The document content of the document to be translated is read using a content reading rule corresponding to the file format.
4. The method according to claim 3, wherein the step of reading the content of the document to be translated by using a content reading rule corresponding to the file format comprises: If the file format is a picture format, a multimodal large model is used to perform OCR recognition to obtain the document content of the document to be translated; If the file format is a WORD document format, the first library function for reading WORD document content is used to read the document content of the document to be translated; If the file format is a PDF document format, a second library function for reading PDF document content is used to read the document content of the document to be translated.
5. The method according to claim 3, wherein the step of reading the content of the document to be translated by using a content reading rule corresponding to the file format comprises: If the file format is a PDF document format, a splitting operation is performed on the document to be translated that contains two or more pages to obtain sub-documents; For each sub-document, determine whether the content of the document to be translated is readable.
6. The method according to claim 2, wherein determining the document type of the document to be translated based on the content of the document specifically comprises: Inputting the document content into a document classification model to obtain the document type of the document to be translated determined by the document classification model; The document classification model is trained based on document content samples marked with document type labels.
7. The method according to claim 1, wherein in response to the document translation request, determining the document type of the document to be translated specifically comprises: In response to the document translation request, input the document to be translated into a pre-trained multimodal large language model to obtain a document type of the document to be translated determined by the multimodal large language model; The multimodal large language model is trained based on document samples marked with document type labels.
8. The method according to claim 1, before translating the elements to be translated using a large language model to obtain element translations, further comprising: Determining a translation library corresponding to the document type; The translation library contains standard translations of candidate elements; The adopting of a large language model to translate the elements to be translated to obtain element translations specifically includes: The element to be translated and the translation library are input into a large language model, and an element translation for the element to be translated output by the large language model with reference to the translation library is obtained.
9. The method according to claim 8, wherein the step of inputting the element to be translated and the translation library into a large language model to obtain an element translation of the element to be translated output by the large language model with reference to the translation library comprises: Based on the elements to be translated and the translation library, generating prompt information for input into a large language model; The prompt information is used to instruct the large language model to translate the element to be translated based on the content of the translation library; The prompt information is input into the large language model to obtain the element translation for the element to be translated output by the large language model with reference to the translation library.
10. The method according to claim 1, wherein the step of combining the element translation with the translation template to obtain the document translation of the document to be translated comprises: The element translations of the elements to be translated are used to replace the corresponding placeholders in the translation template to obtain the document translation of the document to be translated.
11. The method of claim 1, wherein: The translation template is consistent with the page format of the document to be translated.
12. The method according to claim 1, after splicing the element translation with the translation template to obtain the document translation of the document to be translated, further comprises: Obtaining manual correction operations for the translation of the document; Modifying the document translation in response to the manual correction operation to obtain a document correction translation; The corrected translation of the document is fed back to the requesting device that sent the document translation request.
13. The method according to claim 12, wherein after the document translation is modified in response to the manual correction operation to obtain the document corrected translation, the method further comprises: In response to the manual correction operation, determining the corrected element targeted by the manual correction operation and the element-corrected translation corresponding to the corrected element; The corrected element and the element-corrected translation corresponding to the corrected element are updated in the translation library.
14. A document translation device, comprising: A request receiving module, used for receiving a document translation request for requesting translation of a document to be translated; A document type determination module, configured to determine the document type of the document to be translated in response to the document translation request; A translation template determination module, used to determine a translation template according to the document type; An element extraction module, used to extract elements to be translated corresponding to the document type from the document to be translated; The elements to be translated are the contents of the document to be translated other than the translation template; An element translation module, used to translate the element to be translated using a large language model to obtain an element translation; The translation splicing module is used to splice the element translation with the translation template to obtain the document translation of the document to be translated.
15. A document translation device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: receiving a document translation request for requesting translation of a document to be translated; In response to the document translation request, determining the document type of the document to be translated; Determine the translation template according to the document type; Extracting elements to be translated corresponding to the document type from the document to be translated; the elements to be translated are the contents of the document to be translated other than the translation template; Using a large language model to translate the elements to be translated to obtain element translations; The element translation is concatenated with the translation template to obtain a document translation of the document to be translated.
Citation Information
Patent Citations
Multi-language translation method and system based on templates
CN106708809A
Text translation method and device and equipment
CN107391500A
Document translation method and device and electronic equipment
CN113297856A
Text processing method and device, storage medium and electronic equipment
CN116956116A
Generative picture translation method and system, electronic equipment and storage medium
CN117953109A