Page 273 - 《软件学报》2025年第5期
P. 273
琚江舟 等: 多粒度单元格对比的文本和表格数值问答模型 2173
generate Program: subtract (229.59, 100), divide (#0, 100)
Decoder
Exec answer: 1.295 9
Question & textual Tabular embedding
embedding … … … SemContrast RowContrast
Contrastive
…
… … … learning
… … … … push push pull push
pull
… … … push
push
push
Encoder
ColContrast
ValContrast
[CLS] What was the percentage cumulative total shareholder
Question return on Masco common stock for the five year period ended
2013? [SEP] push push push push
… push
Textual The graph assumes investments of $ 100 on December 31, 2008 push
data in our common stock and in each of the three indices [SEP] pull
pull
…
The Masco of 2009 is $128.21.[SEP]
…
Tabular
The Masco of 2013 is $229.59. [SEP]
data …
The S&P industrials index of 2012 is $120.19.[SEP] Row. embedding Col. embedding Val. embedding Sep. embedding
The S&P industrials index of 2013 is $151.89.[SEP]
图 4 基于多粒度单元格语义对比的生成器框架
3.2 粗粒度单元格语义对比
为了使生成器可以区分支撑单元格句子和干扰单元格句子, 本文提出了一种粗粒度单元格语义对比学习方
法. 此方法拉远支撑单元格句子整体语义表示 S _support 和干扰单元格句子整体语义表示 S _distrub 之间的距离.
因为支撑单元格和干扰单元格由问题确定, 所以不同于直接拉近 S _support 之间的距离, 拉远 S _support 和
S _distrub 的距离. 这里本文以问题 Q 作为锚点, 以 S _support 作为正例, 以 S _distrub 作为负例. 然后拉近问题 Q
表示与 S _support 之间的距离, 拉远问题 Q 表示与 S _distrub 之间的距离, 进而实现区分支撑和干扰单元格句子.
因为单元格句子整体语义也反映单元格整体语义, 所以本文称粗粒度对比方法为粗粒度单元格语义对比. 这里本
文使用 InfoNCE [24] 损失函数达成上述目的.
锚点表示: 本文以问题经过分词器后子词的平均表示作为问题的表示; 或者类似于 Caciularu 等人 [4] 的做法,
本文用 Q 后的特殊单词 [SEP] 表示作为问题的表示.
正例表示: 本文将支撑单元格句子的所有子词的平均表示或者支撑单元格句子紧随的 [SEP] 作为单元格句子
整体语义表示, 随机采样固定数量 K1 的支撑单元格句子整体语义表示作为正例表示.
负例表示: 本文用干扰单元格所有子词的平均表示或者干扰单元格句子紧随的 [SEP] 表示作为干扰单元格句
子整体语义表示, 随机采样固定数量 K2 的干扰单元格句子整体语义表示作为负例表示.
损失计算: 本文使用 InfoNCE 损失拉近问题表示和 S _support 之间的距离, 同时拉远问题表示与 S _distrub 之
间的距离. 具体见公式 (4):
∑ e sim(u † ,q)/τ
L cg = − log ∑ (4)
sim(u,q)/τ
† e
u † ∈U cg u∈(U ′ ∨u † )
cg
τ
其中, U † 为正例表示的集合, U ′ 是负例表示的结合, τ 是温度系数, 越小, 代表模型更加关注如何将锚点和更
cg cg
困难负例区分开, sim(·,·) 是相似度函数, 其计算过程见公式 (5):
⊺
˜ u ˜q
sim(u,q) = (5)
∥ ˜u ∥∥ ˜q ∥
其中, ∥ · ∥ 表示求 ℓ 2 范数. 为了避免问答任务的学习目标和对比学习冲突, 和其他工作一样 [4] , 本文通过映射函数
c u 映射到一个辅助空间进行对比学习. 公式 (6) 反映了这个
f 1 和 f 2 , 将来自于 H 的原始锚点表示 q 和正负例表示