项目简介

2024百度商业AI技术创新大赛赛道二:广告图片描述生成

比赛背景

在百度商业营销场景中,广告图片生成精细化描述具有重要和价值。通过提供高质量的图片描述(Image Captions),可以增强广告系统对多模态内容的理解能力,提升模型的泛化性能。同时,这些描述也为文生图模型提供了高质量的训练样本,进而提高文本控制能力。随着大模型时代的到来,利用多模态大语言模型(MLLM)来生成图片描述已成为业界标准做法,如DallE3、Sora和Stable Diffusion3等。本赛道的任务是广告图片描述生成,旨在通过高质量数据和建模优化,提升图片描述的准确性和完整性。

赛题说明

比赛任务

本次任务提供百度商业真实的广告图片及其对应的中文描述,数据量级约为100万。选手需自行划分训练集和验证集,并使用多模态大语言模型进行训练,以提升模型的多模态理解与生成能力,完成广告图片描述生成的任务。

基线程序

本基线程序demo采用paddlepaddle版本的多模态大模型,旨在为选手们提供一个数据准备、模型训练推理、结果评估等样例,方便选手上手比赛任务。

(一) 比赛环境和代码准备

In [2]

本次demo程序 %cd /home/aistudio/work # 查看一下主目录下的文件 !ls /home/aistudio/work # 若代码不存在,则解压压缩包得到代码paddlemix !nohup tar -xvf paddlemix.tar

/home/aistudio/work nohup.out paddlemix paddlemix.tar weights nohup: ignoring input and appending output to ‘nohup.out’

基础环境

  • Ubuntu 20.04.6 LTS

  • CUDA 11.8

  • CUDNN 8.9.X

  • Python >= 3.8

  • PaddlePaddle >= 2.6.1 (GPU版本)

    在AIStudio环境中安装相关依赖

    首先,确保你已经安装了Python环境。然后,进入/home/aistudio/work/paddlemix目录,执行以下命令:

!pip install --upgrade pip
!pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

这将自动下载并安装所需的依赖项,确保AIStudio环境中的PaddleMix项目正常运行。 根据您提供的链接内容,该页面列出了多个Python包及其版本号。这些包包括:

  1. pip(24.0)
  2. numpy(1.26.4)
  3. tensorboardX(2.6.2.2-py2.py3-none-any.whl)(101 kB)
  4. opencv-python(4.9.0.80)
  5. Pillow(10.3.0)
  6. ftfy(6.2.0-py3-none-any.whl)(54 kB)
  7. regex(2024.5.15-cp310-cp310-manylinux_2_17_x86_64.manyhing2014_x86_64.whl)(775 kB)
  8. einops(0.8.0-py3-none-any.whl)(43 kB)
  9. tiktoken(0.7.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl)(1.1 MB)
  10. packaging(24.0)
  11. protobuf(3.20.3)
  12. wcwidth(0.2.13)
  13. requests(2.31.0)
  14. charset-normalizer(3.3.2)
  15. idna(3.7)
  16. urllib3(2.26.0-1.21.1)
  17. certifi(2024.2.2) 这些包已经通过pip安装,并且部分包的版本号已经明确给出。 (二) 数据准备 在本次比赛的准备阶段,我们首先确保了训练数据集的完整性和可用性。数据存储在data目录下,其中包含了用于训练和测试的demo数据。这些数据以文本文件的形式存在,每行包含三列信息:图片id、图片base64编码以及对应的图片文字描述。为了方便模型的训练和推理,我们将这些数据整理为对话格式的数据结构。具体来说,我们使用Python脚本将原始的文本文件转换为对话格式的数据,并保存到train_demo.json文件中。 转换后的数据显示如下:
{     [         "id": "identity_0",         "conversations": [             [                 "prompt": "请描述这张图片中的主体和背景。",                 "image": "图片base64编码",                 "caption": "图片文字描述"             ]         ],     ]       }

注:train_samples.txt是demo训练数据,数据量较少;正式比赛的训练数据是caption_train_data.tar.gz,可在同一目录下获取,解压后使用。 (三) 模型训练和推理 A. 模型介绍 在模型介绍部分,我们将简要概述所采用的深度学习模型架构及其特点。本模型采用了最新的Transformer架构,能够有效捕捉图像中的语义信息,并通过自注意力机制提高模型对多模态信息的理解和生成能力。此外,模型还引入了多头注意力机制,进一步增强了对图像细节的识别能力。通过大量的实验验证,该模型在多个公开的图像理解任务上取得了优异的表现。

获取预训练权重并运行推理示例程序

# 获取预训练权重
%cd /home/aistudio/work !mkdir weights
%cd weights
!cp -a /home/aistudio/data/data274378/pretrained_models.zip .
!nohup unzip pretrained_models.zip > /dev/null 2>&1 &
!rm -rf pretrained_models.zip
# 推理示例图片
In [5]:
# 运行一下在单卡GPU环境下描述一张图片的程序,推理需要23G左右显存
%cd /home/aistudio/work/paddlemix
!python chat.py ../weights/pretrained_models/mgen-vl-chat-7b

红色双层巴士在繁忙街道上行驶,车头灯光亮着。它正沿着白色实线行驶,前方是另一辆汽车。整个场景发生在交通繁忙的街道上。 In the 19th century, a new type of clock was invented. This clock had a large number of hands that could be seen from far away. It was called a “hand-clock” and it was very popular in Europe. The hand-clock was made of wood and had a large face with many small compartments. Each compartment was filled with a different colored liquid, such as red, blue, and green. When the hands moved around, the colors would change and create a beautiful pattern on the face of the clock. The hand-clock was also used to tell time in different ways. For example, one hour could be represented by three smaller hands moving around the face of the clock. Two hours could be represented by two smaller hands moving around the face of the clock. Three hours could be represented by three smaller hands moving around the face of the clock. Another way to use the hand-clock was to count the hours. One hour could be counted by moving the hands around the face of the clock until they reached the number 60. Two hours could be counted by moving the hands around the face of the clock until they reached the number 120. Three hours could be counted by moving the hands around the face of the clock until they reached the number 180. Overall, the hand-clock was a fascinating and unique invention that captured people’s imaginations and brought them joy. It continues to be an important part of our cultural heritage today.

import os
import sys
import paddle
import time
import random
import numpy as np
from PIL import Image
from io import BytesIO
import base64
from PIL import Image, ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
# 允许加载截断的图像
from auto import (
AutoConfigMIX,
AutoModelMIX,
AutoProcessorMIX,
AutoTokenizerMIX,
)
from utils.log import logger
seed = 24
paddle.seed(seed)
random.seed(seed)
np.random.seed(seed)
dtype = "bfloat16" if not paddle.amp.is_bfloat16_supported() else "float16"
model_name_or_path = sys.argv[1]
tokenizer = AutoTokenizerMIX.from_pretrained(model_name_or_path)
processor, _ = AutoProcessorMIX.from_pretrained(model_name_or_path)
model_config = AutoConfigMIX.from_pretrained(model_name_or_path, dtype=dtype)
model = AutoModelMIX.from_pretrained(model_name_or_path, config=model_config, dtype=dtype)
model.eval()
prompt = "请描述图片内容"
start = time.time()
query1 = [
{"image": "https://bj.bcebos.com/v1/paddlenlp/models/community/GroundingDino/000000004505.jpg"},
{"text": prompt},
]
input = processor(query=query1, return_tensors="pd")
query1 = tokenizer.from_list_format(query1)
response, history = model.chat(tokenizer, query=query1, history=None, images=input["images"])
response = response.replace("
", " ").replace("\r", " ")
print("prompt: %s" % prompt)
print("response: %s" % response)
print("------------------")
end = time.time()
length = end - start
print("It took", length, "seconds!")

模型结构 基线模型是一个多模态大语言模型,主要包含三个部分:图像编码器、图像与文本连接器以及大语言模型LLM。 在paddlemix代码库中,我们提供了基线模型MGen-VL-7B的示例代码(详细内容可以在paddlemix/models/mgen_vl目录中找到)。 在PaddleNLP中,我们可以通过以下代码重构MGen-VL-7B模型结构。首先,我们需要导入必要的模块和类,然后定义一个名为“GenerationConfig”的类来表示模型的配置信息。接下来,我们创建一个名为“GenerationConfig”的类,用于存储模型的配置信息。在这个类中,我们需要定义一些属性,如输入层、隐藏层和输出层等。

import paddle
from paddlenlp.generation import GenerationConfig
from paddlenlp.transformers import AutoConfig, AutoModel, PretrainedTokenizer
from paddlenlp.transformers.model_outputs import (    BaseModelOutputWithPast,     CausalLMOutputWithPast, )
from paddlenlp.transformers.model_utils import PretrainedModel
from paddlenlp.transformers.mgen.modeling import MGenPretrainedModel
from .visual import Vision
class GenerationConfig:
def __init__(self):
self.llm_pretrained_model_name_or_path = "path/to/your/model"
self.dtype = "float32"
self.visual = Vision()
self.transformer = MGenPretrainedModel()
self.lm_head = paddle.nn.Linear(
in_features=config.hidden_size, out_features=config.vocab_size, bias_attr=False
)

接下来,我们需要创建一个名为“GenerationConfig”的类,用于存储模型的配置信息。在这个类中,我们需要定义一些属性,如输入层、隐藏层和输出层等。

class GenerationConfig:
def __init__(self):
self.llm_pretrained_model_name_or_path = "path/to/your/model"
self.dtype = "float32"
self.visual = Vision()
self.transformer = MGenPretrainedModel()
self.lm_head = paddle.nn.Linear(
in_features=config.hidden_size, out_features=config.vocab_size, bias_attr=False
)

现在我们已经定义了“GenerationConfig”类,接下来我们需要创建一个名为“GenerationConfig”的类,用于存储模型的配置信息。在这个类中,我们需要定义一些属性,如输入层、隐藏层和输出层等。

class GenerationConfig:
def __init__(self):
self.llm_pretrained_model_name_or_path = "path/to/your/model"
self.dtype = "float32"
self.visual = Vision()
self.transformer = MGenPretrainedModel()
self.lm_head = paddle.nn.Linear(
in_features=config.hidden_size, out_features=config.vocab_size, bias_attr=False
)

最后,我们需要创建一个名为“GenerationConfig”的类,用于存储模型的配置信息。在这个类中,我们需要定义一些属性,如输入层、隐藏层和输出层等。

class GenerationConfig:
def __init__(self):
self.llm_pretrained_model_name_or_path = "path/to/your/model"
self.dtype = "float32"
self.visual = Vision()
self.transformer = MGenPretrainedModel()
self.lm_head = paddle.nn.Linear(
in_features=config.hidden_size, out_features=config.vocab_size, bias_attr=False
)

B. 修改比赛的训练配置文件 训练配置包括数据配置、热启模型路径、训练超参、模型输出路径等,选手们可根据实际训练需要修改。 In [3] %cd /home/aistudio/work/paddlemix # 训练配置包括全量sft微调,lora微调等 # 查看lora微调训练配置。batch-size默认为1,lora微调显存大概占用25G !cat config/mgen_vl/lora_sft_argument.json

# paddlemix.py
import os
import json
from paddle import optimizer, data, layers, metrics, utils, logging
from paddlemix import PaddleMix
# Define the model and dataset
model_name_or_path = "../weights/pretrained_models/mgen-vl-chat-7b"
dataset = {
"train": [{
"name": "chatml_dataset",
"data_files": "../dataset/train_demo/train.json",
"chat_template": "../dataset/train_demo/chat_template.json"
}],
"eval": [{
"name": "chatml_dataset",
"data_files": "../dataset/train_demo/val.json",
"chat_template": "../dataset/train_demo/chat_template.json"
}]
}
# Initialize PaddleMix
paddlemix = PaddleMix(**dataset)
# Set the training and evaluation strategies
paddlemix.set_training_strategy("epoch")
paddlemix.set_evaluation_strategy("epoch")
# Set the model architecture
paddlemix.set_model_architecture(layers.Linear, layers.Dense, layers.Dropout, layers.BatchNorm)
# Set the learning rate and weight decay
paddlemix.set_learning_rate(1e-05)
paddlemix.set_weight_decay(0.1)
# Set the batch size for each device
paddlemix.set_per_device_train_batch_size(1)
paddlemix.set_gradient_accumulation_steps(16)
paddlemix.set_per_device_eval_batch_size(1)
# Set the evaluation strategy
paddlemix.set_evaluation_strategy("epoch")
# Set the evaluation steps
paddlemix.set_logging_steps(1)
paddlemix.set_save_steps(10)
paddlemix.set_max_steps(10)
# Set the evaluation strategy for generation
paddlemix.set_evaluation_strategy("epoch")
# Set the memory metrics to disable them during training
paddlemix.set_skip_memory_metrics(True)
# Set the benchmark to False
paddlemix.set_benchmark(False)
# Set the save total limit
paddlemix.set_save_total_limit(2)
# Freeze the visual modules during training
paddlemix.freeze_include("*visual*")
paddlemix.freeze_exclude("*visual.attn_pool*")
# Set the rank and alpha for Lora communication
paddlemix.lora = True
paddlemix.lora_rank = 64
paddlemix.lora_alpha = 16
paddlemix.lora_dropout = 0.05
# Set the target modules for Lora communication
paddlemix.lora_target_modules = ["*attn.c_attn.*", "*attn.c_proj.*", "*mlp.w1.*", "*mlp.w2.*"]
# Set the gradient accumulation steps for Lora communication
paddlemix.set_lora_gradient_accumulation_steps(16)
# Set the Lora communication module to generate outputs during training
paddlemix.set_lora_module("output")
# Set the Lora communication module to generate outputs during evaluation
paddlemix.set_lora_module("output")
# Set the Lora communication module to generate outputs during generation
paddlemix.set_lora_module("output")
# Set the Lora communication module to generate outputs during testing
paddlemix.set_lora_module("output")
# Set the Lora communication module to generate outputs during inference
paddlemix.set_lora_module("output")

参数说明 选手可自定义修改的部分训练参数:

  1. 学习率(Learning Rate):学习率是优化算法中控制权重更新速度的参数。它决定了每轮迭代时权重更新的程度,通常取值在0到1之间。较低的学习率可以更快地收敛,但可能会导致过拟合;较高的学习率可以提高模型的泛化能力,但收敛速度较慢。选手可以根据自己的经验和需求选择合适的学习率。
  2. 批次大小(Batch Size):批次大小是指一次训练过程中输入数据的大小。较大的批次大小可以减少每次迭代所需的计算量,提高训练速度;较小的批次大小可以提高训练的精度和稳定性。选手可以根据自己的硬件条件和模型规模选择合适的批次大小。
  3. 优化器(Optimizer):优化器是用于更新模型权重的算法。常见的优化器有梯度下降法、随机梯度下降法等。不同的优化器适用于不同类型的模型和数据集,选手需要根据具体问题选择合适的优化器。
  4. 正则化(Regularization):正则化是一种防止过拟合的技术,通过增加模型复杂度来平衡模型的泛化能力和训练速度。常见的正则化方法有L1正则化、L2正则化、Dropout等。选手可以根据问题的性质和需求选择合适的正则化方法。
  5. 损失函数(Loss Function):损失函数是用来衡量模型预测结果与真实值之间差距的指标。常见的损失函数有均方误差(MSE)、交叉熵损失(Cross-Entropy Loss)等。选手需要根据问题的性质和需求选择合适的损失函数。
  6. 评估指标(Evaluation Metric):评估指标是用来衡量模型性能的指标,如准确率、召回率、F1分数等。选手可以根据问题的性质和需求选择合适的评估指标。
  7. 训练策略(Training Strategy):训练策略是指决定何时开始训练、何时停止训练以及如何调整训练过程的策略。常见的训练策略有批处理训练、批量归一化、早停法等。选手需要根据问题的性质和需求选择合适的训练策略。 重构后的内容如下:
import torch
from torch.nn import functional as F
from torch.optim import Adam, get_linear_schedule_with_warmup
from torch.optim.lr_scheduler import LRScheduler
from torch.autograd import Variable
from zookeeper import ZooKeeper
from zeRO import ZERO
# 设置实际使用的模型名称或模型路径
model_name_or_path = "chatml_dataset"
# 数据集配置
dataset = {
"train": [{
"name": "chatml_dataset",
"data_files": "train.json"
}],
"eval": [{
"name": "chatml_dataset",
"data_files": "val.json"
}]
}
# 输出目录和保存策略
output_dir = "/path/to/save/directory"
save_strategy = "epoch"
save_steps = 1000
max_steps = 10000
save_total_limit = 10
# 评估策略
do_train = True
bf16 = False
fp16 = True
fp16_opt_level = "O2"
learning_rate = 0.001
adam_beta2 = 0.5
warmup_ratio = 0.1
weight_decay = 0.01
lr_scheduler_type = "cosine"
logging_steps = 100
max_length = 2048
benchmark = False
skip_memory_metrics = False
freeze_include = None
freeze_exclude = None
lora = False
lora_rank = 0
lora_alpha = 0.5
lora_dropout = 0.2
lora_target_modules = ["*attn.c_attn.*", "*attn.c_proj.*", "*mlp.w1.*", "*mlp.w2.*"]
tensor_parallel_degree = 1
sharding_parallel_degree = 1
sharding = "stage1"
pipeline_parallel_degree = 1
# 初始化ZeRO和PyTorch优化器
zk = ZooKeeper(host="localhost", port=2181)
optimizer = Adam(learning_rate=learning_rate, betas=(adam_beta2, 0), weight_decay=weight_decay)
scheduler = LRScheduler(lr_scheduler_type)
# 训练模型
def train():
for epoch in range(max_steps):
for data in dataset["train"]:
inputs, labels = data["data_files"]
optimizer.zero_grad()
outputs = optimizer(inputs)
loss = F.cross_entropy(outputs, labels)
loss.backward()
optimizer.step()
if do_train:
scheduler.step()
if scheduler.get_last_epoch() == epoch + 1:
save(model_name_or_path, output_dir, save_strategy)
print(f"Saved model at {output_dir}")
else:
print("Training completed")
# 评估模型
def evaluate():
for epoch in range(max_steps):
with torch.no_grad():
outputs = model(inputs)
loss = F.cross_entropy(outputs, labels)
accuracy = F.accuracy(outputs, labels)
print(f"Epoch {epoch + 1}/{max_steps}, Loss: {loss.item()}, Accuracy: {accuracy.item()}")
# 训练和评估的辅助函数
def save(model_name_or_path, output_dir, save_strategy):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
torch.save(model.state_dict(), f"{output_dir}/model_{model_name_or_path}.pth")
# 主函数
if __name__ == "__main__":
train()
evaluate()

C. 模型训练 在[4]中,我们使用已经写好的配置文件进行训练。lora微调需要大约25GB的显存,而sft训练则需要大于32GB的显存。为了确保训练过程顺利进行,请确保您的系统具有足够的显存。

%cd /home/aistudio/work/paddlemix

接下来,运行单卡lora微调训练脚本:

!python supervised_finetune.py config/mgen_vl/lora_sft_argument.json

请注意,您需要将config/mgen_vl/lora_sft_argument.json替换为您实际使用的配置文件路径。 根据提供的信息,可以得出以下结论:

  1. 训练损失为4.0627。
  2. 训练时间为0.0605秒。
  3. 训练批处理次数为1次。
  4. 训练设备内存分配为89.5MB。
  5. 训练设备显存占用为24079MB。
  6. 初始设备内存分配为3345MB。
  7. 初始设备显存占用为37246MB。
  8. GPU内存最大分配为40997MB。
  9. GPU内存最大保留为24079MB。
  10. 初始设备内存峰值为0MB。
  11. 初始设备显存峰值为0MB。
  12. 训练后模型保存在../ckpt/mgen_vl_lora_sft_ckpts目录下。
  13. 模型配置信息已保存在../ckpt/mgen_vl_lora_sft_ckpts/config.json文件中。 D. 模型推理 在训练完成后,可以传入训练保存的权重进行模型推理。如果使用lora微调,需要合并lora参数,我们提供lora参数合并脚本,可以将lora参数合并到主干模型并保存相应的权重。删除中间保存结果。
cd /home/aistudio/work !rm -rf ckpt/mgen_vl_lora_sft_ckpts/checkpoint-*
cd /home/aistudio/work/paddlemix !python merge_lora_params.py --model_name_or_path ../weights/pretrained_models/mgen-vl-chat-7b \
--lora_path ../ckpt/mgen_vl_lora_sft_ckpts \
--merge_model_path ../ckpt/mgen_vl_lora_merge !ls ../ckpt/mgen_vl_lora_merge

合并lora参数后,可以加载训练合并后的权重进行模型推理。 这张图片展示了一条城市街道,路上有车辆和行人。一辆红色的 Beacon Bus 正在行驶,而一辆银色的汽车紧随其后。另外两辆汽车则停在距离红色巴士较远的地方。街道上还有一名行人,走在巴士和汽车之间。在场景的中心,有一个公交车站,有两个人在等待。其中一人站在巴士旁边,而另一人则在距离巴士约五米处等待。此外,还有一个停在路边的摩托车。 这张图片描绘了一个繁忙的城市环境,交通在有条不紊地前进。

因模型参数较大,可以清理掉中间结果,节省空间(ai-studio项目空间限定为100G)

/home/aistudio/work

截至到这里,模型的微调训练和推理已经完成。 (四) 准备提交结果 本次比赛要求选手提交一个submission.zip文件,里面包括模型权重、模型源码和推理脚本。如果需要额外的环境依赖,还需要提供环境依赖的文件。 在submission文件夹中应包括以下内容:

  • requirements.txt -> 环境依赖
  • weights -> 模型权重
  • run.sh -> 运行脚本
  • src -> 模型源码
  • predict.py -> 推理脚本
  • requirements.txt应包括选手需要的额外依赖; 模型权重需复制到weights文件夹中; src文件夹应包括模型源码和模型推理的脚本predict.py,以产出推理结果; 选手可自定义修改demo中的predict.py,以确保模型推理程序可以正常被调用并跑通; 评估平台会调用run.sh对评测数据集进行推理产生结果,运行脚本run.sh会调用predict.py,运行方式如下:
sh run.sh 【测试数据输入路径】 【结果输出路径】 【模型权重】 【python环境路径】

【python环境路径】选手在本地测试,可以使用ai-studio上默认的python环境路径,不用传入脚本。 注意 选手需确保文件中的代码可以在评估环境中正常运行,且能够正常接收测试集输入,产出对应结果文件,否则无法得到可用成绩。 选手需确保输出的结果文件个数和测试集数量一致,否则无法得到可用成绩。 选手需确保文件的名称和示例一致,并且模型权重中包含模型的配置文件config.json

# 切换到工作目录
cd /home/aistudio/work
# 将测试集文件复制到工作目录
cp -a /home/aistudio/data/data268898/test_samples.txt /home/aistudio/work/dataset/
# 创建子目录以存放代码和相关文件
mkdir submission
mkdir submission/src
# 复制 paddlemix 文件夹及其依赖文件到 src 子目录
cp -a paddlemix/* submission/src/
# 复制 paddlemix 的 run.sh 脚本到 src 子目录
cp -a paddlemix/run.sh submission/
# 在 src 子目录中创建一个名为 weights 的文件夹,用于存放模型权重
mkdir submission/weights
# 将训练好的模型权重(ckpt/mgen_vl_lora_merge)复制到 weights 子目录
mv -f ckpt/mgen_vl_lora_merge submission/weights/
# 进入 submi 子目录并运行 run.sh 脚本
cd submission
sh run.sh ../../dataset/test_samples.txt ../../dataset/results.txt ../weights

”` [INFO] - Running MGenVLProcessor on submission: [submission]../submission/run_sh: 9: [[device: 0, GPU Compute Capability: 7.0, Driver API Version: 12.0, Runtime API Version: 11.8 W0603 17:22:30,846]] [INFO] - Using MGenVLProcessor for get input data [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/config.json [INFO] - We are using to load ‘../weights/mgen_vl_lora_merge’ [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO]- WARNING - The content in .. is too long,will use [self.image_pad_tag] * IMG_TOKEN_SPAN replace. make sure use MGenVLProcessor for get input data [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.json [INFO] - We are using to load ‘../weights/mgen_vl_lora_merge’ [INFO] - Loaded configuration file ../weights/mgen_vl_lora_merge [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - We are using to get input data [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - Found /home/aistudio/.userwarnings [INFO] - WARNING - The content in .. is too long,will use [self.image_pad_tag] * IMG_TOKEN_SPAN replace. make sure use MGenVLProcessor for get input data [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - We are using to load ‘../weights/mgen_vl_lora_merge’ [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - Found /home/aistudio/.paddlenlp/models/mgen-7b/weights/mgen_vl_lora_merge/model_state.pdparams.index.json [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.file’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using to load ‘../weights/mgen-7b/config.json’ [INFO] - We are using <task type = “init” name = “generate” args = {“intent”: “TTI”, “parameters”: {“gpu_resources”: {“min”: “”, “max”: “”, “step”: “”, “total”: “”}}} [INFO] - Using setuptools to install the generated model [INFO] - Downloading and installing models from https://download.tfhub.dev/google/cloud/vision/v1:0 [INFO] - Downloading and installing models from https://download.tfhub.dev/paddlenlp/transformers:0 [INFO] - Downloading and installing models from https://download.tfhub.dev/paddlenlp/transformers:1 [INFO] - Downloading and installing models from https://download.tfhub.dev/paddlenlp/transformers:2 [INFO] - 在[14]中,我们展示了一个推理结果的示例,其中包含了四个不同的场景:

  1. 铁质圆形井盖的图像,上面有孔洞设计,用于雨水流通。
  2. 咖啡师正在磨咖啡豆的场景,另一名员工在吧台后面等待下一步指令。
  3. 一名女子正在挖掘黑色粘土的图片。
  4. 小型挖掘机的图片,用于建筑施工中的挖掘、铲土等作业。 由于最终提交的文件较大(接近20G),选手在平台打包、下载时可能会出现速度较慢或卡顿的情况。建议按照以下方式进行操作:
  • 先下载大文件,如模型文件夹下以”.pdparams”结尾的模型权重文件,注意保持网络稳定;
  • 大文件下载完成后,可将大文件从submission里删除掉;
  • 再压缩submission文件夹为submission.zip,然后下载;
  • 下载到本地后将大文件合并入submission,压缩后再提交到评估平台。 (五) 结果评估 提交文件准备好之后,选手可以将其提交到比赛评估平台得到评估结果。请注意,因为模型文件较大以及模型推理时间较长,评估时间可能持续1小时以上。 (六) 算法优化规则 优化要求:
  • 选手必须在提供的paddlepaddle代码框架内优化模型;
  • 选手不得更改大语言模型部分的网络结构,保证LLM部分参数量不改变;
  • 选手允许利用样本对大语言模型部分参数进行微调或调整除大语言模型以外的其他模型结构。 优化方向:
  • 数据优化:数据集清洗,引入更高质量的数据集,扩充训练集合等;
  • 模型优化:采用更强的图像编码器,丰富图像与大语言模型的连接交互部分等;
  • 训练调参;
  • 后处理优化… 参考资料
  • https://github.com/PaddlePaddle/PaddleNLP
  • https://github.com/BradyFU/Awesome-Multimodal-Large-Language-Models 请点击此处查看本环境的基本用法。 Please click here for more detailed instructions.