lancopku / label-words-are-anchors

Repository for Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learning
MIT License
144 stars 12 forks source link

请问predictor_classes.py程序中的问题 #13

Open xsc1234 opened 8 months ago

xsc1234 commented 8 months ago

您好,请问能详细介绍下predictor_classes.py,Predictor这个类中get_pos函数的具体作用吗?为什么在获取索引的时候要乘以100000呢?

leanwang326 commented 8 months ago

其实就是,比如我想在input_id 里(不妨假设它是个List[int])匹配一个长度为二的List[int] [a,b] (比如要找label,但只匹配label本身的话万一句子里也有多次出现,可能会出问题,所以再匹配下前面的':')

所以我去匹配了下x{i-1}*100000+x{i}和a*100000+b(取100000单纯是为了大于词表大小) 就单纯是为了匹配下子序列,来获取索引