hezar.metrics.rouge module¶
- class hezar.metrics.rouge.ROUGE(config: ROUGEConfig, **kwargs)[source]¶
- Bases: - Metric- ROUGE metric for evaluating text summarization using rouge_score. - Parameters:
- config (ROUGEConfig) – Metric configuration object. 
- **kwargs – Extra configuration parameters passed as kwargs to update the config. 
 
 - compute(predictions=None, targets=None, use_aggregator=None, n_decimals=None, output_keys=None, **kwargs)[source]¶
- Computes the ROUGE scores for the given predictions against targets. - Parameters:
- predictions – Predicted summaries. 
- targets – Ground truth summaries. 
- use_aggregator (bool) – Flag to enable score aggregation for multiple references. 
- n_decimals (int) – Number of decimals for the final score. 
- output_keys (tuple) – Filter the output keys. 
 
- Returns:
- A dictionary of the metric results, with keys specified by output_keys. 
- Return type:
- dict 
 
 
- class hezar.metrics.rouge.ROUGEConfig(objective: str = 'maximize', output_keys: tuple = ('rouge1', 'rouge2', 'rougeL', 'rougeLsum'), n_decimals: int = 4, use_stemmer: bool = False, use_aggregator: bool = True, multi_ref: bool = True)[source]¶
- Bases: - MetricConfig- Configuration class for ROUGE metric. - Parameters:
- name (MetricType) – The type of metric, ROUGE in this case. 
- use_stemmer (bool) – Flag to enable stemming when computing ROUGE. 
- use_aggregator (bool) – Flag to enable score aggregation for multiple references. 
- multi_ref (bool) – Flag to indicate if multiple references are present. 
- output_keys (tuple) – Keys to filter the metric results for output. 
 
 - multi_ref: bool = True¶
 - name: str = 'rouge'¶
 - objective: str = 'maximize'¶
 - output_keys: tuple = ('rouge1', 'rouge2', 'rougeL', 'rougeLsum')¶
 - use_aggregator: bool = True¶
 - use_stemmer: bool = False¶