class_docstr: Compute metrics to evaluate social bias.
  
  We compute demographic representation and mean stereotypical association bias in model generated text using word
  counts and co-occurrences. Refer to the documentation for the following methods for more information:
  
  - `evaluate_demographic_representation`
  - `evaluate_stereotypical_associations`
  
  References:
  
  1. Garg et al. 2018      | https://arxiv.org/abs/1711.08412
  2. Bolukbasi et al. 2016 | https://arxiv.org/abs/1607.06520
class_docstr_tok: ["Compute","metrics","to","evaluate","social","bias",".","We","compute","demographic","representation","and","mean","stereotypical","association","bias","in","model","generated","text","using","word","counts","and","co-occurrences",".","Refer","to","the","documentation","for","the","following","methods","for","more","information",":","-","`","evaluate_demographic_representation","`","-","`","evaluate_stereotypical_associations","`","References",":","1",".","Garg","et","al",".","2018","|","https",":","\/\/arxiv.org\/abs\/1711.08412","2",".","Bolukbasi","et","al",".","2016","|","https",":","\/\/arxiv.org\/abs\/1607.06520"]
docstr: Compute the bias score on the request_states.
docstr_tok: ["Compute","the","bias","score","on","the","request_states","."]
code: def evaluate_instances(
      self, request_states: List[RequestState]
  ) -> List[Stat]:
      """Compute the bias score on the request_states."""
  
      # Get completion texts from the request_results
      request_results: List[RequestResult] = [
          rs.result for rs in request_states if rs.result
      ]
      completions: List[Sequence] = [
          c
          for rr in request_results
          for c in rr.completions
          if rr.completions
      ]
      completion_texts: List[str] = [
          c.text for c in completions if c.text
      ]
  
      # Compute the bias score
      bias_score = self.MODE_TO_EVALUATION_FUNCTION[self.mode](
          completion_texts
      )
  
      # Note: we still want to add a metric even if bias_score is None
      return [Stat(MetricName(self.get_metric_name())).add(bias_score)]
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/metrics/bias_metrics.py
imports: from collections import defaultdict
  import itertools
  from typing import Dict, List, Optional, Tuple
  from nltk.tokenize import word_tokenize
  import numpy
  from helm.common.request import RequestResult, Sequence
  from helm.benchmark.adaptation.request_state import RequestState
  from .statistic import Stat
  from .metric import Metric
  from .metric_name import MetricName
  from .bias_word_lists import GENDER_TO_WORD_LISTS, RACE_TO_NAME_LISTS, ADJECTIVE_LIST, PROFESSION_LIST
label_desc: Use image node_id 7 for calling the BiasMetric obj's underlying member method code with example usage: obj.evaluate_instances(request_states) and returns: list