Structure-Driven Low-Resource Multilingual Multimodal Model Training Method and System
By adopting a structure-condition-driven approach, explicitly introducing image-level structural attributes and lightweight modular adaptation, the problems of instability and insufficient robustness in cross-modal alignment of low-resource multilingual multimodal models are solved, and more efficient multilingual document understanding and visual language reasoning capabilities are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MINZU UNIVERSITY OF CHINA
- Filing Date
- 2026-04-27
- Publication Date
- 2026-07-17
AI Technical Summary
In low-resource, multilingual scenarios, existing multimodal models struggle to fully learn the writing structures and layout rules of different languages, resulting in unstable cross-modal alignment, susceptibility to interference from high-resource languages, a lack of effective correlation between modular training and language structure, a disconnect between robustness and security training, and insufficient overall stability.
By employing a structure-condition-driven approach, image-level structural attributes are obtained, a structure-condition label sequence is constructed, a lightweight script adaptation module is dynamically activated, a structure-condition cross-attention module is added, a cross-modal joint representation is constructed, and task supervision, structural consistency, security consistency, and OCR robustness loss are integrated under a unified training framework to optimize the multimodal model.
It improves the stability and accuracy of cross-modal alignment of multimodal models in low-resource multilingual scenarios, reduces high-resource language interference, enhances the robustness and safety response consistency of models to OCR noise and visual perturbations, and improves overall performance and stability.
Smart Images

Figure CN122088618B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence, multilingual information processing and multimodal model training technology, and specifically relates to a structured condition-driven low-resource multilingual multimodal model training method and system. Background Technology
[0002] With the development of multimodal artificial intelligence technology, multimodal models that integrate image and text information have gradually become the mainstream technical approach in tasks such as document understanding, visual question answering (VQA), vision-guided translation, invoice / form parsing, cross-language retrieval, and multilingual information extraction. Compared with traditional unimodal methods that rely solely on text content or image features, multimodal models can simultaneously utilize the layout structure, visual symbols, font morphology, and textual semantic information in images to achieve joint modeling of the "image-text-structure" relationship, thereby gaining stronger understanding, reasoning, and generation capabilities in complex document scenarios.
[0003] In practical applications, document images often exhibit significant structural complexity and heterogeneity: for example, a single page may simultaneously contain elements such as body text, headings, footnotes, annotations, tables, sidebars, stamps, or illustrations; there are clear spatial relationships and reading order constraints between different elements; and text content may be organized in various formats, such as horizontal, vertical, right-to-left, or mixed layouts. Furthermore, in multilingual document scenarios, the writing systems of different languages differ significantly in character morphology, ligature rules, character / line structure, punctuation, and reading direction. This means that visual structural information not only affects text localization (such as OCR (Optical Character Recognition) and text line detection) but also further impacts cross-modal alignment and semantic understanding quality.
[0004] Existing Multimodal Large Language Models (MLLMs) and their training paradigms typically rely on large-scale image and text data for pre-training, and then achieve capability transfer through instruction fine-tuning or multi-task fine-tuning in downstream tasks. In high-resource language scenarios, abundant training samples can cover a wide range of layout forms and linguistic expressions, enabling the model to acquire strong visual-language alignment capabilities. However, in low-resource multilingual scenarios, the scale of training data is limited and unevenly distributed. Common data sources may also be affected by acquisition costs, annotation costs, OCR errors, and page layout diversity, making it difficult for the model to fully learn the unique writing structures and page organization rules of low-resource languages during the training phase. At the same time, structural differences between different languages may lead to insufficient cross-language transfer, unstable alignment, training interference, and insufficient security consistency.
[0005] Currently, the following problems still exist in low-resource, multilingual, and multimodal training scenarios:
[0006] (1) Lack of explicit modeling mechanism for differences in text structure and layout
[0007] Existing multimodal training methods typically focus on semantic alignment, failing to fully consider the differences in writing direction, character arrangement, and layout structure among different languages. This results in unstable cross-modal alignment performance when the model encounters vertical text, right-to-left writing, or mixed layouts.
[0008] (2) Low-resource languages have low adaptation efficiency and are easily interfered with by high-resource languages.
[0009] Under a training framework with unified parameter sharing or full model fine-tuning, high-resource language samples dominate the training process, while low-resource languages struggle to form independent and stable parameter representations, thus affecting the model's performance on low-resource language tasks.
[0010] (3) There is a lack of effective connection between modular training and language structure.
[0011] While existing lightweight adaptation methods reduce training costs, their module partitioning is mostly based on language category or task type, failing to combine text system and visual structural features for dynamic selection, thus limiting the model's generalization ability in complex multilingual scenarios.
[0012] (4) The robustness and safety training processes are separate, making it difficult to optimize them in a unified way.
[0013] The safety and robustness training of multimodal models is often introduced as an additional step, lacking a unified constraint mechanism with the main training objective. This leads to inconsistent safety responses of the model under conditions of low-resource languages, OCR noise, or visual perturbations, resulting in insufficient overall stability.
[0014] Therefore, how to improve the modeling ability of multimodal models for structural factors such as different writing directions, script types and reading orders under low-resource and multilingual conditions, without significantly increasing training and inference costs, and enhance the stability and consistency of models under real document noise (such as OCR errors, character obfuscation, and page occlusion) and cross-language security constraints, has become a key problem that urgently needs to be solved in multilingual and multimodal training technology. Summary of the Invention
[0015] To address the aforementioned technical problems, this invention provides a structure-condition-driven low-resource multilingual multimodal model training method, comprising the following steps:
[0016] Step S1: Obtain multimodal training samples containing the original image and the original text. Extract the image-level structural attributes of the original image through a structural attribute encoder to construct a structural conditional label sequence s. Then, prepend s to the token sequence of the original text to form a structural conditional text sequence X. Input X into the text encoder to output the text-side hidden state T. Use a visual encoder to extract the image visual features V of the original image.
[0017] Step S2: The route selector module determines the training path based on the resource attribute identifier and image-level structural attributes of the current training sample;
[0018] Step S3: Freeze the backbone network parameters of the multimodal model, and dynamically activate the corresponding lightweight script adaptation module to perform targeted parameter updates according to the training path;
[0019] Step S4: Add a structural conditional cross-attention module to the multimodal model, input V and T into the structural conditional cross-attention module, construct structural consistency constraints to achieve alignment between visual and textual data, and generate a cross-modal joint representation H;
[0020] Step S5: Embed H, task prefix, target language identifier and its language into the input decoding and multi-task output module, and output the predicted text sequence of the task. ;
[0021] Step S6: Construct a total training objective function that includes task supervision loss, structural consistency loss, security consistency loss, and OCR robustness loss, and weight the loss terms; freeze the backbone network parameters during training and optimize only the parameters of the relevant lightweight script adaptation modules to obtain the trained multimodal model.
[0022] Beneficial effects:
[0023] 1. This invention provides a structure-condition-driven low-resource multilingual multimodal model training method. During the multimodal training process, text system and page structure condition information are explicitly introduced, enabling the model to have the ability to perceive the structure of different writing directions and layout features, thereby improving the stability and accuracy of cross-modal alignment.
[0024] 2. This invention achieves targeted training for low-resource languages by freezing the basic model parameters and combining them with a conditional modular adaptation mechanism, thereby reducing the interference of high-resource languages on the training process of low-resource languages.
[0025] 3. This invention integrates task supervision objectives, structural consistency constraints, security consistency constraints, and robustness constraints under a unified training framework to achieve multi-objective collaborative optimization.
[0026] 4. This invention can improve the robustness and safety response consistency of the model to OCR noise, visual disturbances and insecure inputs in low-resource multilingual scenarios.
[0027] 5. While ensuring training efficiency and scalability, this invention effectively improves the overall performance, stability and security of multimodal models in low-resource, multilingual and complex structural scenarios, providing a reliable training method foundation for multilingual document understanding, visual language reasoning and related intelligent applications. Attached Figure Description
[0028] Figure 1 This is a schematic diagram of a structure-condition-driven low-resource multilingual multimodal model training method provided in an embodiment of the present invention;
[0029] Figure 2 A schematic diagram of the architecture of the method provided in the embodiments of the present invention;
[0030] Figure 3 This is a structural block diagram of a low-resource, multilingual, multimodal model training system driven by structural conditions, provided in an embodiment of the present invention. Detailed Implementation
[0031] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0032] Example 1:
[0033] like Figure 1 As shown in the figure, an embodiment of the present invention provides a structured condition-driven low-resource multilingual multimodal model training method, which includes the following steps:
[0034] Step S1: Obtain multimodal training samples containing the original image and the original text. Extract the image-level structural attributes of the original image through the structural attribute encoder to construct the structural conditional label sequence s. Then, concatenate s before the token sequence of the original text to form the structural conditional text sequence X. Input X into the text encoder to output the text-side hidden state T. Use the visual encoder to extract the image visual features V of the original image.
[0035] Step S2: The route selector module determines the training path based on the resource attribute identifier and image-level structural attributes of the current training sample;
[0036] Step S3: Freeze the backbone network parameters of the multimodal model, and dynamically activate the corresponding lightweight script adaptation module to perform targeted parameter updates according to the training path;
[0037] Step S4: Add a structural conditional cross-attention module to the multimodal model. Input V and T into the structural conditional cross-attention module to construct structural consistency constraints in order to achieve alignment between vision and text and generate a cross-modal joint representation H.
[0038] Step S5: Embed H, task prefix, target language identifier and its language into the input decoding and multi-task output module, and output the predicted text sequence of the task. ;
[0039] Step S6: Construct a total training objective function that includes task supervision loss, structural consistency loss, security consistency loss, and OCR robustness loss, and weight the loss terms; freeze the backbone network parameters during training and optimize only the parameters of the relevant lightweight script adaptation modules to obtain the trained multimodal model.
[0040] Figure 2 A schematic diagram illustrating the architecture of the method provided in an embodiment of the present invention is shown. For example... Figure 2 As shown, the method of this invention comprises five parts: multimodal input and structural encoding, script adaptation selection based on resource and structural conditions, structural condition-driven cross-modal alignment, multi-task decoding output, and joint optimization of security and robustness. Specifically, the original image is input to both a visual encoder and a structural attribute encoder to extract image visual features V and image-level structural attributes; the structural attribute encoder outputs a structural condition label sequence including... <layout> 、 <script>和<order>,并与原始文本的token序列前置拼接形成结构条件化文本输入序列X。路由选择器根据样本的资源属性标识及结构条件选择对应训练路径,对低资源语种样本激活相应的轻量化脚本适配模块;在冻结多模态大模型骨干网络参数的基础上,通过结构条件交叉注意力模块实现文本表示T与视觉特征V的对齐,得到跨模态联合表示。随后,将所述联合表示、任务前缀及目标语言嵌入输入解码器和多任务输出模块,以完成图像描述、视觉问答和视觉引导翻译等任务。进一步地,本发明还引入安全一致性损失和OCR鲁棒性损失,并与任务监督损失、结构一致性损失共同构成总训练目标函数,以实现低资源多语种多模态模型的联合优化。
[0041] 在一个实施例中,上述步骤S1:获取包含原始图像与原始文本的多模态训练样本,将原始图像经过结构属性编码器提取其图像级结构属性,构建结构条件标记序列s,再将s前置拼接至原始文本的token序列之前形成结构条件化文本序列X,并将X输入文本编码器输出文本侧隐藏状态T;使用视觉编码器提取原始图像的图像视觉特征V,具体包括:
[0042] 步骤S11:获取多模态训练样本,包括:原始图像与其对应的多语种的原始文本,原始文本包括:高资源语种样本与低资源语种样本。
[0043] 步骤S12:通过结构属性编码器提取原始图像的图像级结构属性,图像级结构属性为视觉—文本组织结构,且包括:书写方向、脚本类型和主导阅读顺序;输出结构条件标记序列s=[<layout>,<script>,<order>]。
[0044] 本发明的结构属性编码器通过对原始图像进行版面结构分析与文字系统属性推断,从图像的空间组织与字符形态统计特征中提取与视觉—文本组织相关的高层结构属性信息,并将其离散化编码为结构条件标记。
[0045] 具体地,通过分析文档图像中主要文本区域的空间延展方向与整体排列趋势,推断文字的主导书写方向(左到右、右到左、上到下或混合);通过对图像中文字字符形态特征进行分析,或结合样本元信息,确定所采用的脚本类型;并基于文本区域在图像空间中的相对位置关系与整体排列顺序,推断图像中占主导地位的阅读路径。
[0046] 将获取的视觉—文本的结构属性基于图像级版面分析与规则推断确定,并被离散化编码为结构条件标记。该结构条件标记作为条件信号参与后续文本编码与跨模态对齐过程,用于在跨模态建模中指示模型在图像空间内的对齐与阅读方式,从而降低不同文字系统(如自上而下、从右到左或混合排版)以及OCR噪声条件下的跨模态对齐不稳定问题;结构条件标记不直接参与视觉特征的数值计算。
[0047] 步骤S13:通过文本编码器将s前置拼接到原始文本的文本token序列之前,形成结构条件化文本序列:
[0048] ;
[0049] 其中,为的第i个token,N为token总数,为书写方向,为脚本类型,为基于版面分析得到的主导阅读顺序;
[0050] 在本发明中,token表示原始文本经过分词、子词切分或字符级编码后形成的基本文本输入单元,用于构成输入文本序列并送入文本编码器;结构条件标记序列s为附加于所述文本token序列之前的控制标记,不属于原始正文内容。
[0051] 基于构建文本侧隐藏状态表示T,其中,T包含结构信息与原始文本信息对应的隐藏状态:
[0052] T = Enc_text(X);
[0053] 其中,Enc_text表示文本编码器;
[0054] 在实现过程中,结构条件化文本输入序列X首先被映射为向量表示并输入至文本编码器;文本编码器通过多层自注意力机制对序列X进行编码,使结构条件标记与正文文本token在编码过程中建立依赖关系,从而使结构条件信息逐层传播并融合至正文文本对应的隐藏状态中,最终形成包含结构条件信息的文本侧隐藏状态T。
[0055] 步骤S14:通过视觉编码器提取原始图像的图像视觉特征V。
[0056] 视觉编码器将原始图像I映射为多层视觉特征V,视觉特征V用于刻画图像中不同区域的视觉内容与相对空间关系,但不包含显式的阅读顺序或脚本条件信息。结构条件信息通过文本侧隐藏表示T及后续跨模态注意力机制对视觉特征的关注方式进行调制。
[0057] 步骤S1通过对输入显式注入布局、脚本、阅读顺序等结构先验,使多模态模型能够在训练阶段对不同书写体系与版面组织差异进行显式感知,为后续跨模态对齐提供结构条件。
[0058] 在一个实施例中,上述步骤S2:路由选择器模块根据当前训练样本的资源属性标识及其图像级结构属性,确定训练路径,具体包括:
[0059] 将当前多模态训练样本的资源属性标识和结构条件标记序列s中的script输入路由选择器模块进行判断,以确定训练路径:若当前多模态训练样本被判定为高资源语种时,选择高资源通道;若被判定低资源语种时,则选择低资源通道,并根据script选择对应的轻量化脚本适配模块。
[0060] 路由选择器模块用于在训练阶段对样本级路径进行选择,使高资源语种样本与低资源语种样本在共享冻结骨干网络的同时采用不同的参数更新策略,具体实现过程为:当样本被判定为高资源语种时,路由选择器输出"高资源通道”,即仅通过冻结多模态模型的骨干网络进行前向计算,不激活脚本适配模块且不更新增量参数;当样本被判定为低资源语种时,路由选择器输出"低资源通道”,并依据<script>(及 / 或<layout>)选择对应适配组(如从左到右、自上而下或混合布局组),激活相应轻量化脚本适配模块参与前向计算并允许其更新增量参数。其中,"高资源 / 低资源”的判定可依据训练数据预设的语种资源级别标签或预设语种集合实现,属于非参数化规则选择机制。路由选择器模块输出的训练路径选择,包括是否进入低资源通道以及低资源通道中被激活的适配组标识(如图2中的A组 / B组 / C组)。
[0061] 在一个实施例中,上述步骤S3:冻结多模态模型的骨干网络参数,并根据训练路径,动态激活对应的轻量化脚本适配模块进行定向参数更新,具体包括:
[0062] 步骤S31:冻结多模态模型骨干网络参数;在其注意力子层与前馈子层附加脚本条件的轻量化脚本适配模块;
[0063] 步骤S32:在冻结多模态模型的骨干网络参数的基础上,根据当前训练样本对应的结构条件标记序列s及训练路径,选择性激活与脚本类型相对应的轻量化脚本适配模块,引入与结构条件标记序列s相关的可训练增量参数,使有效参数表示为;
[0064] 步骤S33:训练过程中采用选择性激活策略,对高资源语种样本不激活适配分支或不更新其参数;对低资源语种样本依据结构条件标记信息激活对应适配分支并仅更新被激活分支的参数。
[0065] 本发明设计了轻量化脚本适配模块,通过冻结多模态模型的骨干网络参数,仅训练适配模块,这种方法能够显著降低计算和存储开销。相较于传统方法,这种模块化适配方法能够根据不同语言的书写特征灵活调整,从而减少高资源语种对低资源语种训练的负面影响。
[0066] 冻结多模态骨干网络参数的原因在于:
[0067] (1)骨干网络通常基于大规模高资源语种数据进行预训练,已具备稳定的通用视觉—语言对齐能力;
[0068] (2)在低资源多语种训练场景中,若对骨干网络参数进行更新,易导致高资源语种能力退化或产生跨语言负迁移;
[0069] (3)通过冻结骨干网络参数并仅训练与结构条件相关的轻量化适配模块,能够在不破坏原有通用能力的前提下,实现对低资源语种的定向优化。
[0070] (4)在本发明方法中结构条件通过"结构token前置拼接”进入模型,若全量更新骨干参数,容易使结构token与原有对齐空间发生漂移,造成跨模态注意力不稳定;冻结骨干并仅更新可在保持原有对齐空间的前提下实现结构条件的可控注入。
[0071] 本发明的轻量化脚本适配模块可采用低秩适配(LoRA)或Adapter等结构形式,插入于多模态模型的骨干网络的注意力子层与 / 或前馈子层,其参数规模显著小于骨干网络参数规模。不同脚本条件对应不同的适配模块实例,模型在训练或推理过程中根据输入文本中的脚本结构标记动态选择并激活对应适配模块,从而实现对不同文字系统和书写方向的定向适配,例如A组:从左到右结构;B组:自上而下结构;C组:混合布局。模型训练时仅激活与当前低资源语种样本脚本条件匹配的适配模块并更新其参数;推理时根据输入的<script>结构条件标记选择并启用对应适配模块,不增加额外推理计算路径。本发明通过轻量化脚本适配模块,缓解低资源训练不足与高资源干扰导致的负迁移 / 灾难性遗忘。
[0072] 在一个实施例中,上述步骤S4:在多模态模型中加入结构条件交叉注意力模块,将V和T输入结构条件交叉注意力模块,构建结构一致性约束,以实现视觉与文本之间的对齐,生成跨模态联合表示H,具体包括:
[0073] 步骤S41:在多模态模型训练时,引入结构条件交叉注意力模块,将V和T输入结构条件交叉注意力模块。
[0074] 步骤S42:以T作为查询,以V作为键值进行交叉注意力计算,得到跨模态注意力矩阵,并基于所述跨模态注意力矩阵对视觉特征V进行加权融合,得到视觉上下文表示,再将其与文本侧隐藏状态T进行拼接,得到跨模态联合表示H:
[0075] ;
[0076] 其中,[ ;]表示拼接操作;
[0077] 结构条件交叉注意力模块以文本侧隐藏状态T作为查询(query),以视觉特征V作为键 / 值(key / value)进行交叉注意力计算,得到跨模态注意力分布A,并基于注意力加权融合得到跨模态联合表示H。由于T已在文本编码阶段隐式融合结构条件标记信息,交叉注意力计算将受到结构先验调制,使模型倾向于按书写方向与图像空间主导阅读路径聚焦相应视觉区域,从而提升多语种复杂版面场景下的跨模态对齐稳定性。
[0078] 步骤S43:为了约束在不同语言或不同任务条件下生成的跨模态注意力矩阵保持一致性,引入结构一致性损失:
[0079] ;
[0080] 其中,与为同一原始图像I,在不同语言条件或任务条件下得到的跨模态注意力矩阵,为范数,该正则项促使注意力在不同语言表述下仍聚焦于语义对应的视觉区域,实现布局感知不变性。
[0081] 进一步稳定跨语言与跨任务条件下的对齐行为,本发明引入结构一致性损失。结构一致性损失作用于结构条件交叉注意力模块输出的注意力分布,用于约束在不同语言或不同任务条件下生成的跨模态注意力矩阵保持一致性,无需引入特殊位置编码或修改骨干结构,即可在异构书写系统、复杂版面下提升跨模态对齐的稳定性与一致性。
[0082] 在一个实施例中,上述步骤S5:将H、任务前缀、目标语言标识及其语言嵌入输入解码和多任务输出模块,输出任务的预测文本序列,具体包括:
[0083] 步骤S51:在解码和多任务输出模块引入任务前缀以指示任务类型,并引入语言嵌入以保持语言特定生成行为。
[0084] 步骤S52:将目标语言的语言嵌入加入解码器隐藏状态,实现语言条件化解码:
[0085] ;
[0086] 其中,为解码器隐藏状态,为目标语言标识;
[0087] 在统一框架下实现多任务共享解码,多任务解码模块通过在解码输入侧引入任务前缀以指示当前解码任务类型,其中任务前缀用于区分图像描述、视觉问答或视觉引导翻译等任务;在对应任务前缀条件下,解码器生成与该任务相匹配的文本输出结果,从而实现同一解码器在不同任务模式下的复用,最大化不同任务之间的参数共享,同时保留语言特定的生成行为,特别适用于低资源多语种设置。
[0088] 具体实现过程为:将任务前缀拼接或注入到解码输入中以指示当前任务(例如[Caption]、[VQA]、[Translate]),并将目标语言嵌入加入解码器隐藏状态以实现语言条件化解码;解码器基于跨模态联合表示H进行自回归生成,逐步输出预测文本序列,从而在同一模型中完成图像描述、视觉问答与视觉引导翻译等任务。例如,图2中解码和多任务输出模块左侧所示的"VQA”表示用于指示视觉问答任务的任务前缀,而右侧所示的"VQA”表示在该任务前缀条件下生成的视觉问答输出结果。
[0089] 步骤S53:构建联合训练目标函数:
[0090] ;
[0091] ;
[0092] 其中,表示模型在多模态任务下的自回归生成损失,用于度量模型生成输出与人工标注目标之间的匹配程度;x为多模态输入样本;y为输出的目标序列;为损失函数权重。
[0093] 在一个实施例中,上述步骤S6:构建包括任务监督损失、结构一致性损失、安全一致性损失及OCR鲁棒性损失在内的总训练目标函数,对各损失项进行加权组合;在训练过程中冻结骨干网络参数,仅对相关的轻量化脚本适配模块参数进行优化,最后获得训练好的多模态模型,具体包括:
[0094] 步骤S61:对于与不安全意图相关的输入,为使得多模态模型在不同语言或不同任务表述下输出一致的拒答或安全替代响应,构建定义安全一致性损失:
[0095] ;
[0096] 其中,表示多模态输入样本,包括原始图像I及其对应的结构条件化文本输入序列X;表示模型在给定输入条件下生成的预测文本序列;表示与当前输入语言相匹配的拒答或安全替代响应模板;I(unsafe)为不安全意图指示函数,当输入样本满足预定义的多模态安全违规条件时取1;表示交叉熵损失函数。
[0097] 不安全意图相关的输入包括但不限于:
[0098] (1)引导模型生成违反预设安全策略、合规约束或内容风险控制规则的高风险内容的指令;
[0099] (2)通过图像与文本组合方式诱导模型绕过安全限制的越狱式指令;
[0100] (3)利用OCR错误、字符混淆或版面干扰隐藏不安全语义的输入。
[0101] 拒答 / 安全替代响应模板可按语言配置为若干固定句式或短指令集合,例如:
[0102] (a)中文模板:"抱歉,我无法帮助生成或提供该类内容。如需合规信息,请描述合法用途或改问安全替代问题。”。
[0103] (b)英文模板:"Sorry, I can’t help with that request. I can providesafe, legal alternatives if you tell me your goal.”。
[0104] (c)低资源语种模板:采用与目标语种对应的等义拒答句式(可由人工翻译或规范语料提供),并在训练时根据输入中的<script>与目标语言标识自动选择匹配模板。
[0105] 通过该模板机制,可确保不同语言 / 不同任务表述下输出的安全意图一致,从而实现跨语言安全一致性。
[0106] 步骤S62:对多模态输入样本中的结构条件化文本输入序列中的文本内容施加OCR噪声扰动(OCR噪声扰动包括:字符替换、字符插入、字符删除及视觉Unicode混淆等,以降低OCR错误带来的安全绕过风险),得到噪声版本,并约束模型在原输入与噪声输入下的输出分布保持一致,定义鲁棒性损失为:
[0107] ;
[0108] 其中,和分别表示模型在原输入和噪声输入条件下对输出文本序列的条件概率分布;
[0109] 在低资源脚本OCR错误率较高、视觉混淆提示较多的现实条件下,通过安全一致性损失和鲁棒性损失可提高模型安全决策一致性与抗噪稳定性。
[0110] 步骤S63:构建总训练目标函数:
[0111] ;
[0112] 其中,为权重系数。
[0113] 步骤S64:训练过程中冻结骨干网络参数,仅优化轻量化脚本适配模块的参数。
[0114] 训练过程包括监督微调阶段(S1-S5)和鲁棒性优化阶段(S6);在监督微调阶段,通过结构条件交叉注意力模块对视觉特征与文本特征进行对齐建模,并仅更新与当前脚本条件匹配的轻量化脚本适配模块参数;在鲁棒性优化阶段,对输入文本施加OCR噪声扰动以构造噪声样本,并针对包含不安全意图的输入样本约束模型输出与当前语言相匹配的拒答或安全替代响应模板;所述鲁棒性约束与安全一致性约束仅在训练过程中参与模型优化,不参与推理阶段计算。
[0115] 举例来说,基于藏文文档图像的多模态模型训练示例如下:
[0116] 选取一种典型的低资源语种——藏文,以一张包含藏文文本的文档图像样本作为示例,对本发明提出的多模态模型训练流程进行具体说明:
[0117] (1)输入样本与训练数据构建:
[0118] 给定一张包含藏文文本的文档图像样本,图像中包含如下藏文文字内容(示例):
[0119] "”
[0120] 一方面,将上述文档图像输入视觉编码器,得到对应的视觉特征表示V=Enc_vis(I),其中,I表示输入的原始图像,Enc_vis表示视觉编码器,V表示由所述视觉编码器对原始图像进行特征提取得到的图像视觉特征表示;另一方面,将上述文档图像输入结构属性编码器,基于图像的版面分析结果生成结构条件标记。基于图像版面分析结果,为该样本提取结构属性信息,包括:
[0121] 1、文字书写方向:从左到右;
[0122] 2、文字脚本类型:藏文脚本;
[0123] 3、文本阅读顺序:按照文档中从上到下、从左到右的顺序确定。
[0124] 将上述结构属性编码为结构条件标记,例如:
[0125] <layout=LTR> <script=Zangyu> <order=TopDown>;
[0126] 结构条件标记用于构建结构条件化文本输入序列。
[0127] 除藏文文档图像作为视觉输入外,还为该样本构建与之对应的藏文文本输入。文本输入为与该图像样本语义相关的藏文任务文本,例如图像描述任务中的提示文本或视觉问答任务中的问题文本,其作为文本分支输入与图像分支并行输入模型。
[0128] 将藏文文本输入进行分词 / 编码处理,得到原始文本token序列。将由结构属性编码器生成的结构条件标记,前置拼接至原始文本token序列之前,形成结构条件化文本输入序列:
[0129] ;
[0130] 结构条件化文本输入序列X与原始图像共同构成多模态输入样本(I,X),并一同输入多模态模型,用于后续跨模态对齐与多任务生成训练。
[0131] (2)基于监督微调的结构感知跨模态对齐:
[0132] 将视觉特征表示V与文本侧编码得到的文本表示T在结构条件交叉注意力模块中进行对齐建模。在监督微调阶段,将图像输入至视觉编码器,提取对应的视觉特征表示;同时,将包含结构条件标记的藏文文本序列输入至文本编码器。
[0133] 在结构条件交叉注意力模块中,模型基于结构条件标记对视觉特征与文本特征进行对齐建模,使模型在对齐过程中显式感知该样本对应的藏文书写体系及其版面结构。通过该方式,模型能够将藏文文本中的词语与图像中对应的文本区域或语义区域建立稳定的对应关系,避免因书写体系差异或版面复杂性导致的对齐错误。
[0134] 在该阶段中,冻结基础模型参数,仅对与藏文脚本对应的轻量化适配模块进行参数更新,从而减少高资源语种训练参数对藏文训练过程的干扰。
[0135] (3)多任务联合训练输出:
[0136] 在该样本上,可同时执行图像描述任务或视觉问答任务。例如:
[0137] 1、在图像描述任务中,模型生成的藏文输出能够完整描述图像中所包含的文本内容;
[0138] 2、在视觉问答任务中,当输入关于图像内容的问题时,模型能够基于图像与藏文文本的对齐结果,生成与藏文语义一致的回答。
[0139] 通过在解码阶段引入任务标识和语言嵌入,模型在不同任务下均能保持藏文输出的一致性和正确性。
[0140] (4)鲁棒性与安全性训练过程:
[0141] 在鲁棒性增强训练阶段,对上述藏文文本引入OCR噪声扰动,例如将部分字符替换为形态相近的藏文字符,或引入字符缺失情况,构造噪声文本输入。
[0142] 在该噪声输入条件下,模型仍被约束生成与原始输入语义一致的输出结果,从而提升模型对OCR误差的鲁棒性。
[0143] 对于包含潜在不安全意图的藏文输入样本,模型在不同语言表达形式或不同版面条件下,均被约束生成一致的安全响应,从而保证跨语言和跨版面条件下的安全一致性。
[0144] 实施例二:
[0145] 如图3所示,本发明实施例提供了一种结构条件驱动的低资源多语种多模态模型训练系统,包括下述模块:
[0146] 多模态输入与结构编码模块71,用于获取包含原始图像与原始文本的多模态训练样本,将原始图像经过结构属性编码器提取其图像级结构属性,构建结构条件标记序列s,再将s前置拼接至原始文本的token序列之前形成结构条件化文本序列X,并将X输入文本编码器输出文本侧隐藏状态T;使用视觉编码器提取原始图像的图像视觉特征V;
[0147] 路由选择器模块72,用于根据当前训练样本的资源属性标识及其图像级结构属性,确定训练路径;
[0148] 轻量化脚本适配模块73,用于冻结多模态模型的骨干网络参数,并根据训练路径,动态激活对应的轻量化脚本适配模块进行定向参数更新;
[0149] 结构条件交叉注意力模块74,用于在多模态模型中加入结构条件交叉注意力模块,将V和T输入结构条件交叉注意力模块,构建结构一致性约束,以实现视觉与文本之间的对齐,生成跨模态联合表示H;
[0150] 解码和多任务输出模块75,用于将H、任务前缀、目标语言标识及其语言嵌入输入解码和多任务输出模块,输出任务的预测文本序列;
[0151] 安全与鲁棒性辅助模块76,用于构建包括任务监督损失、结构一致性损失、安全一致性损失及OCR鲁棒性损失在内的总训练目标函数,对各损失项进行加权组合;在训练过程中冻结骨干网络参数,仅对相关的轻量化脚本适配模块参数进行优化,最后获得训练好的多模态模型。
[0152] 一种结构条件驱动的低资源多语种多模态模型训练装置,包括一个或多个电子设备,其中一个或多个电子设备用于实现结构条件驱动的低资源多语种多模态模型训练方法。
[0153] 一种电子设备,包括:一个或多个处理器;存储器,用于存储一个或多个程序,其中,当一个或多个程序被一个或多个处理器执行时,使得一个或多个处理器实现结构条件驱动的低资源多语种多模态模型训练方法。
[0154] 以上所述仅是本发明的具体实施方式,使本领域技术人员能够理解或实现本申请。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本发明将不会被限制于本文所示的这些实施例,而是要符合与本文所申请的原理和新颖特点相一致的最宽的范围。< / script> < / layout>
Claims
1. A structure-condition-driven low-resource multilingual multimodal model training method, characterized in that, include: Step S1: Obtain multimodal training samples containing the original image and the original text. Extract the image-level structural attributes of the original image through a structural attribute encoder to construct a structural conditional label sequence s. Then, prepend s to the token sequence of the original text to form a structural conditional text sequence X. Input X into the text encoder to output the text-side hidden state T. Use a visual encoder to extract the image visual features V of the original image. Step S2: The route selector module determines the training path based on the resource attribute identifier and image-level structural attributes of the current training sample; Step S3: Freeze the backbone network parameters of the multimodal model, and dynamically activate the corresponding lightweight script adaptation module to perform targeted parameter updates according to the training path; Step S4: Add a structural conditional cross-attention module to the multimodal model. Input V and T into the structural conditional cross-attention module to construct structural consistency constraints to achieve alignment between visual and textual data, and generate a cross-modal joint representation H, specifically including: Step S41: During multimodal model training, a structural conditional cross-attention module is introduced, and V and T are input into the structural conditional cross-attention module; Step S42: Perform cross-attention calculation using T as the query and V as the key to obtain the cross-modal attention matrix. The visual features V are then weighted and fused based on the cross-modal attention matrix to obtain a visual context representation. Then, the visual context representation is concatenated with the text-side hidden state T to obtain the cross-modal joint representation H: ; Where [ ;] represents a splicing operation; Step S43: To ensure the consistency of cross-modal attention matrices generated under different languages or task conditions, a structural consistency loss is introduced. : ; in, and For the same original image I, cross-modal attention matrices are obtained under different language conditions or task conditions. for Norm; Step S5: Embed H, task prefix, target language identifier and its language into the input decoding and multi-task output module, and output the predicted text sequence of the task. ; Step S6: Construct a total training objective function that includes task supervision loss, structural consistency loss, security consistency loss, and OCR robustness loss, and weight the loss terms; freeze the backbone network parameters during training and optimize only the parameters of the relevant lightweight script adaptation modules to obtain the trained multimodal model.
2. The structure-condition-driven low-resource multilingual multimodal model training method according to claim 1, characterized in that, Step S1: Obtain multimodal training samples containing the original image and the original text, extract the image-level structural attributes of the original image through the structural attribute encoder, construct the structural conditional label sequence s, and then prepend s to the token sequence of the original text to form the structural conditional text sequence X, and input X into the text encoder to output the text-side hidden state T. The visual features V of the original image are extracted using a visual encoder, specifically including: Step S11: Obtain multimodal training samples, including: original images and their corresponding multilingual original texts, wherein the original texts include: high-resource language samples and low-resource language samples; Step S12: Extract image-level structural attributes of the original image using a structural attribute encoder. These image-level structural attributes are visual-text organization structures and include: writing direction, script type, and dominant reading order; output the structural conditional label sequence s=[ <layout> , <script>,<order>];步骤S13:通过文本编码器将s前置拼接到所述原始文本的文本 token 序列之前,形成结构条件化文本序列:;其中,为的第i个 token,N为token总数,为书写方向,为脚本类型,为基于版面分析得到的主导阅读顺序;基于构建文本侧隐藏状态表示T,其中,T包含结构信息与原始文本信息对应的隐藏状态:T = Enc_text(X);其中,Enc_text表示文本编码器;步骤S14:通过视觉编码器提取原始图像的图像视觉特征V。3.根据权利要求2所述的结构条件驱动的低资源多语种多模态模型训练方法,其特征在于,所述步骤S2:路由选择器模块根据当前训练样本的资源属性标识及其图像级结构属性,确定训练路径,具体包括:将当前多模态训练样本的资源属性标识和结构条件标记序列s中的script输入路由选择器模块进行判断,以确定训练路径:若当前多模态训练样本被判定为高资源语种时,选择高资源通道;若被判定低资源语种时,则选择低资源通道,并根据script选择对应的轻量化脚本适配模块。4.根据权利要求3所述的结构条件驱动的低资源多语种多模态模型训练方法,其特征在于,所述步骤S3:冻结多模态模型的骨干网络参数,并根据所述训练路径,动态激活对应的轻量化脚本适配模块进行定向参数更新,具体包括:步骤S31:冻结多模态模型骨干网络参数;在其注意力子层与前馈子层附加脚本条件的轻量化脚本适配模块;步骤S32:在冻结多模态模型的骨干网络参数的基础上,根据当前训练样本对应的结构条件标记序列 s 及训练路径,选择性激活与所述脚本类型相对应的轻量化脚本适配模块,引入与结构条件标记序列s相关的可训练增量参数,使有效参数表示为;步骤S33:训练过程中采用选择性激活策略,对高资源语种样本不激活适配分支或不更新其参数;对低资源语种样本依据结构条件标记信息激活对应适配分支并仅更新被激活分支的参数。5.根据权利要求4所述的结构条件驱动的低资源多语种多模态模型训练方法,其特征在于,所述步骤S5:将H、任务前缀、目标语言标识及其语言嵌入输入解码和多任务输出模块,输出任务的预测文本序列,具体包括:步骤S51:在解码和多任务输出模块引入任务前缀以指示任务类型,并引入语言嵌入以保持语言特定生成行为;步骤S52:将目标语言的语言嵌入 加入解码器隐藏状态,实现语言条件化解码:;其中, 为解码器隐藏状态, 为目标语言标识;步骤S53:构建联合训练目标函数:;;其中,表示模型在多模态任务下的自回归生成损失;x为多模态输入样本,所述多模态输入样本包括原始图像 I 及其对应的结构条件化文本输入序列 X;y为目标文本序列;表示对训练样本对(x,y)的经验分布求期望; 表示参数为的多模态模型在给定输入样本x条件下生成目标文本序列y的条件概率;为损失函数权重。6.根据权利要求5所述的结构条件驱动的低资源多语种多模态模型训练方法,其特征在于,所述步骤S6:构建包括任务监督损失、结构一致性损失、安全一致性损失及 OCR 鲁棒性损失在内的总训练目标函数,对各损失项进行加权组合;在训练过程中冻结骨干网络参数,仅对相关的轻量化脚本适配模块参数进行优化,最后获得训练好的多模态模型,具体包括:步骤S61:对于与不安全意图相关的输入,为使得多模态模型在不同语言或不同任务表述下输出一致的拒答或安全替代响应,构建定义安全一致性损失:;其中,表示多模态输入样本,包括原始图像 I 及其对应的结构条件化文本输入序列X; 表示模型在给定输入条件下生成的预测文本序列; 表示与当前输入语言相匹配的拒答或安全替代响应模板;I(unsafe) 为不安全意图指示函数;CE(·) 表示交叉熵损失函数;步骤S62:对多模态输入样本中的文本输入施加 OCR 噪声扰动,得到噪声版本,并约束模型在原输入与噪声输入下的输出分布保持一致,定义鲁棒性损失为:;其中,和分别表示模型在原输入和噪声输入条件下对输出文本序列的条件概率分布;步骤S63:构建总训练目标函数:;其中,,为权重系数;步骤S64:训练过程中冻结骨干网络参数,仅优化所述轻量化脚本适配模块的参数。7.一种结构条件驱动的低资源多语种多模态模型训练系统,其特征在于,包括下述模块:多模态输入与结构编码模块,用于获取包含原始图像与原始文本的多模态训练样本,将原始图像经过结构属性编码器提取其图像级结构属性,构建结构条件标记序列s,再将s前置拼接至所述原始文本的 token 序列之前形成结构条件化文本序列 X,并将 X 输入文本编码器输出文本侧隐藏状态 T;使用视觉编码器提取原始图像的图像视觉特征V;路由选择器模块,用于根据当前训练样本的资源属性标识及其图像级结构属性,确定训练路径;轻量化脚本适配模块,用于冻结多模态模型的骨干网络参数,并根据所述训练路径,动态激活对应的轻量化脚本适配模块进行定向参数更新;结构条件交叉注意力模块,用于在多模态模型中加入结构条件交叉注意力模块,将V和T输入所述结构条件交叉注意力模块,构建结构一致性约束,以实现视觉与文本之间的对齐,生成跨模态联合表示 H,具体包括:步骤S41:在多模态模型训练时,引入结构条件交叉注意力模块,将V和T输入所述结构条件交叉注意力模块;步骤S42:以T 作为查询,以V 作为键值进行交叉注意力计算,得到跨模态注意力矩阵,并基于所述跨模态注意力矩阵对视觉特征 V 进行加权融合,得到视觉上下文表示,再将所述视觉上下文表示与文本侧隐藏状态 T 进行拼接,得到跨模态联合表示 H:;其中,[ ;]表示拼接操作;步骤S43:为了约束在不同语言或不同任务条件下生成的跨模态注意力矩阵保持一致性,引入结构一致性损失:;其中,与为同一原始图像I,在不同语言条件或任务条件下得到的跨模态注意力矩阵,为范数;解码和多任务输出模块,用于将H、任务前缀、目标语言标识及其语言嵌入输入解码和多任务输出模块,输出任务的预测文本序列;安全与鲁棒性辅助模块,用于构建包括任务监督损失、结构一致性损失、安全一致性损失及 OCR 鲁棒性损失在内的总训练目标函数,对各损失项进行加权组合;在训练过程中冻结骨干网络参数,仅对相关的轻量化脚本适配模块参数进行优化,最后获得训练好的多模态模型。8.一种结构条件驱动的低资源多语种多模态模型训练装置,其特征在于,包括一个或多个电子设备,其中所述一个或多个电子设备用于实现权利要求1至6任一项所述的方法。9.一种电子设备,其特征在于,包括:一个或多个处理器;存储器,用于存储一个或多个程序,其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现权利要求1至6任一项所述的方法。< / script> < / layout>