Skip to content
Back to skills

Rougescore

ASecurity

Compute the ROUGEScore metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute ROUGEScore, or asks how to score with ROUGEScore.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 11, 2026
documentationpython

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add qhjqhj00/research-skills-pool --skill rougescore --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Rougescore?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Rougescore
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qhjqhj00-rougescore/badge)](https://www.skillsdirectory.com/skills/qhjqhj00-rougescore)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: rougescore
description: Compute the ROUGEScore metric — provided by torchmetrics. Use when the user has predictions and ground-truth and needs to compute ROUGEScore, or asks how to score with ROUGEScore.
metadata:
  skill_kind: metric
  source_lib: torchmetrics
  import_path: torchmetrics.text.ROUGEScore
  source: library_introspection
---

# rougescore

> Metric `ROUGEScore` from `torchmetrics` (torchmetrics.text.ROUGEScore)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with ROUGEScore, or
mentions `torchmetrics.text.ROUGEScore` directly, or wants the standard torchmetrics implementation.

## Reference signature

```python
from torchmetrics.text import ROUGEScore

# ROUGEScore(use_stemmer: bool = False, normalizer: Optional[Callable[[str], str]] = None, tokenizer: Optional[Callable[[str], collections.abc.Sequence[str]]] = None, accumulate: Literal['avg', 'best'] = 'best', rouge_keys: Union[str, tuple[str, ...]] = ('rouge1', 'rouge2', 'rougeL', 'rougeLsum'), **kwargs: Any) -> None
```

## Library docstring

```
`Calculate Rouge Score`_, used for automatic summarization.

This implementation should imitate the behaviour of the ``rouge-score`` package `Python ROUGE Implementation`

As input to ``forward`` and ``update`` the metric accepts the following input:

- ``preds`` (:class:`~Sequence`): An iterable of predicted sentences or a single predicted sentence
- ``target`` (:class:`~Sequence`): An iterable of target sentences
  or an iterable of interables of target sentences
  or a single target sentence

As output of ``forward`` and ``compute`` the metric returns the following output:

- ``rouge`` (:class:`~Dict`): A dictionary of tensor rouge scores for each input str rouge key

Args:
    use_stemmer: Use Porter stemmer to strip word suffixes to improve matching.
    normalizer: A user's own normalizer function.
        If this is ``None``, replacing any non-alpha-numeric characters with spaces is default.
        This function must take a ``str`` and return a ``str``.
    tokenizer:
        A user's own tokenizer function. If this is ``None``, splitting by spaces is default
        This function must take a ``str`` and return ``Sequence[str]``
    accumulate:
        Useful in case of multi-reference rouge score.

        - ``avg`` takes the avg of all references with respect to predictions
        - ``best`` takes the best fmeasure score obtained between prediction and multiple corresponding references.

    rouge_keys: A list of rouge types to calculate.
        Keys that are allowed are ``rougeL``, ``rougeLsum``, and ``rouge1`` through ``rouge9``.
    kwargs: Additional keyword arguments, see :ref:`Metric kwargs` for more info.

Example:
    >>> from torchmetrics.text.rouge import ROUGEScore
    >>> preds = "My name is John"
    >>> target = "Is your name John"
    >>> rouge = ROUGEScore()
    >>> from pprint import pprint
    >>> pprint(rouge(preds, target))
    {'rouge1_fmeasure': tensor(0.7500),
     'rouge1_precision': tensor(0.7500),
     'rouge1_recall': tensor(0.7500),
     'rouge2_fmeasure': tensor(0.),
     'rouge2_precision': tensor(0.),
     'rouge2_recall': tensor(0.),
     'rougeL_fmeasure': tensor(0.5000),
     'rougeL_precision': tensor(0.5000),
     
```

## Quick recipe

```python
import torchmetrics.text as _m
score = _m.ROUGEScore(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.