Shitao Xiao
Shitao Xiao
没有太理解这个问题。自带的负样本对数据,写入到neg里即可。
> 这种是不是得改loss函数了🙏 @staoxiao 改loss会好一些,使用二分类损失,这样就不需要同时拥有正样本和负样本。 要保留负样本,用大模型生成一个假的正样本A,应该要比直接复制A作为正样本要好。
You can try to reduce the `learning_rate` and `num_train_epochs `
训练目标是交叉熵,将正样本排在负样本前面即可,并没有严格约束要增加正样本的相似度。 另外,模型合并是可选选项,可以尝试不做。
from FlagEmbedding import BGEM3FlagModel 应该不会花费15s,您可能指的是模型加载时间`mode=FlagModel('')`,直接只加载一次模型,不要每次推理都加载。
可以设置self_distill_start_step=0看看效果。self_distill_start_step指的是从多少step开始使用蒸馏loss,如果训练step数据没有6000步,可能导致根本没有使用蒸馏。
请问token耗时指的是哪块时间?
@Tian14267 , 这块涉及到tokenizer和数据从cpu转到gpu,可能是数据转移花费了较多时间。 但理论上使用fp16和fp32这块时间应该是一致的,可以多测几次取平均值。 tokenizer这块有很大的提速空间,可以使用dataloader进行多线程处理,参考https://github.com/FlagOpen/FlagEmbedding/blob/master/FlagEmbedding/flag_reranker.py#L16 也可以使用一些加速推理库,如https://github.com/huggingface/text-embeddings-inference
We recommand to directly fine-tuning bge on downstream task. If you want to do continue pre-training, you can use this script https://github.com/FlagOpen/FlagEmbedding/tree/master/examples/pretrain.
不需要保持负样本的数量一致,如果负样本数量不足,程序会自动重复采样。 因此,train_group_size设置成什么值,程序都能跑,可以设置成负样本的平均数量,避免样本过多重复导致模型过拟合。