[CLS 03 · 视觉与语言:任务、训练与接口](/course/notebooks/680da245145447dd88983aabd136fd24.html) # 四条件的规则预期 · 实现代码 [独立阅读](/course/notebook-blocks/88deeaae5acf42cc94771c90b0e19b8a.html) 主线阅读与优先实验 caption历史、VQA、CLIP候选、关系控制、GLIP/LLaVA与生成桥梁 展开完整实现代码 ``` # 独立 CPU 规则对照;输出 A/B 来自明确规则,不是 CLIP。 conditions=[('1','red','blue','left'),('2','blue','red','left'), ('3','red','blue','right'),('4','blue','red','right')] answer_of={'red':'A','blue':'B'} rows=[] for cid,left,right,holder_side in conditions: holder_color=left if holder_side=='left' else right relation=answer_of[holder_color] shortcut=answer_of[left] rows.append((cid,relation,shortcut)) print('条件',cid,'持球者规则',relation,'左侧规则',shortcut,'一致?',relation==shortcut) assert rows==[('1','A','A'),('2','B','B'),('3','B','A'),('4','A','B')] ```