src/baselines/unifiedqa.py
def prep_example_piqa(example, index):
  """ Prepare PIQA example for scoring preds from the T5 notebook """
  match = re.match(r'^(.+) \\n \(A\) (.+) \(B\) (.+)$', example['input'])

  instance = {}
  instance['sol1'] = match[2].strip().lower()
  instance['sol2'] = match[3].strip().lower()

  example['target'] = example['target'].strip().lower()

  instance['example_idx'] = index
  instance['target'] = example['target']
  instance['target_idx'] = (instance['sol1'], instance['sol2'],
                            example['target']).index(example['target'])

  if instance['target_idx'] > 1:
    logging.warning('failed to parse solution index.')

  return instance
 Prepare PIQA example for scoring preds from the T5 notebook 
Prepare PIQA example for scoring preds from the T5 notebook
Prepare PIQA example for scoring preds from the T5 notebook
def prep_example_piqa(example, index):
  match = re.match(r'^(.+) \\n \(A\) (.+) \(B\) (.+)$', example['input'])
  instance = {}
  instance['sol1'] = match[2].strip().lower()
  instance['sol2'] = match[3].strip().lower()
  example['target'] = example['target'].strip().lower()
  instance['example_idx'] = index
  instance['target'] = example['target']
  instance['target_idx'] = (instance['sol1'], instance['sol2'],
                            example['target']).index(example['target'])
  if instance['target_idx'] > 1:
    logging.warning('failed to parse solution index.')
  return instance
def prep_example_piqa ( example , index ) : match = re . match ( r'^(.+) \\n \(A\) (.+) \(B\) (.+)$' , example [ 'input' ] ) instance = { } instance [ 'sol1' ] = match [ 2 ] . strip ( ) . lower ( ) instance [ 'sol2' ] = match [ 3 ] . strip ( ) . lower ( ) example [ 'target' ] = example [ 'target' ] . strip ( ) . lower ( ) instance [ 'example_idx' ] = index instance [ 'target' ] = example [ 'target' ] instance [ 'target_idx' ] = ( instance [ 'sol1' ] , instance [ 'sol2' ] , example [ 'target' ] ) . index ( example [ 'target' ] ) if instance [ 'target_idx' ] > 1 : logging . warning ( 'failed to parse solution index.' ) return instance
Prepare PIQA example for scoring preds from the T5 notebook
Prepare PIQA example for scoring preds from the T5 notebook
""" Prepare PIQA example for scoring preds from the T5 notebook """
example
index