RougeL
classkeras_nlp.metrics.RougeL(use_stemmer=False, name="rouge-l", **kwargs)
ROUGE-L metric.
This class implements the ROUGE-L variant of the ROUGE metric. The ROUGE-L metric is traditionally used for evaluating summarisation systems. Succinctly put, ROUGE-L is a score based on the length of the longest common subsequence present in the reference text and the hypothesis text.
Note on input shapes:
For y_true
and y_pred
, this class supports scalar values and batch
inputs of shapes ()
, (batch_size,)
and (batch_size, 1)
.
Arguments
False
."float32"
.References
Examples
>>> rouge_l = keras_nlp.metrics.RougeL()
>>> y_true = "the tiny little cat was found under the big funny bed"
>>> y_pred = "the cat was under the bed"
>>> rouge_l(y_true, y_pred)["f1_score"]
<tf.Tensor: shape=(), dtype=float32, numpy=0.7058824>
>>> rouge_l = keras_nlp.metrics.RougeL()
>>> y_true = [
... "the tiny little cat was found under the big funny bed",
... "i really love contributing to KerasNLP",
... ]
>>> y_pred = [
... "the cat was under the bed",
... "i love contributing to KerasNLP",
... ]
>>> rouge_l(y_true, y_pred)["f1_score"]
<tf.Tensor: shape=(), dtype=float32, numpy=0.80748665>
>>> rouge_l = keras_nlp.metrics.RougeL()
>>> y_true = [
... ["the tiny little cat was found under the big funny bed"],
... ["i really love contributing to KerasNLP"],
... ]
>>> y_pred = [
... ["the cat was under the bed"],
... ["i love contributing to KerasNLP"],
... ]
>>> rouge_l(y_true, y_pred)["f1_score"]
<tf.Tensor: shape=(), dtype=float32, numpy=0.80748665>