tfm.nlp.ops.get_sentence_order_labels
Stay organized with collections
Save and categorize content based on your preferences.
Extract segments and labels for sentence order prediction (SOP) task.
tfm.nlp.ops.get_sentence_order_labels(
sentences,
random_threshold=0.5,
random_next_threshold=0.5,
random_fn=tf.random.uniform
)
Extracts the segment and labels for the sentence order prediction task
defined in "ALBERT: A Lite BERT for Self-Supervised Learning of Language
Representations" (https://arxiv.org/pdf/1909.11942.pdf)
Args |
sentences
|
a RaggedTensor of shape [batch, (num_sentences)] with string
dtype.
|
random_threshold
|
(optional) A float threshold between 0 and 1, used to
determine whether to extract a random, out-of-batch sentence or a
suceeding sentence. Higher value favors succeeding sentence.
|
random_next_threshold
|
(optional) A float threshold between 0 and 1, used to
determine whether to extract either a random, out-of-batch, or succeeding
sentence or a preceeding sentence. Higher value favors preceeding
sentences.
|
random_fn
|
(optional) An op used to generate random float values.
|
Returns |
a tuple of (preceeding_or_random_next, is_suceeding_or_random) where:
preceeding_or_random_next: a RaggedTensor of strings with the same shape
as sentences and contains either a preceeding, suceeding, or random
out-of-batch sentence respective to its counterpart in sentences and
dependent on its label in is_preceeding_or_random_next .
is_suceeding_or_random: a RaggedTensor of bool values with the
same shape as sentences and is True if it's corresponding sentence in
preceeding_or_random_next is a random or suceeding sentence, False
otherwise.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-02-02 UTC.
[null,null,["Last updated 2024-02-02 UTC."],[],[],null,["# tfm.nlp.ops.get_sentence_order_labels\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.15.0/official/nlp/modeling/ops/segment_extractor.py#L75-L161) |\n\nExtract segments and labels for sentence order prediction (SOP) task. \n\n tfm.nlp.ops.get_sentence_order_labels(\n sentences,\n random_threshold=0.5,\n random_next_threshold=0.5,\n random_fn=tf.random.uniform\n )\n\nExtracts the segment and labels for the sentence order prediction task\ndefined in \"ALBERT: A Lite BERT for Self-Supervised Learning of Language\nRepresentations\" (\u003chttps://arxiv.org/pdf/1909.11942.pdf\u003e)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `sentences` | a `RaggedTensor` of shape \\[batch, (num_sentences)\\] with string dtype. |\n| `random_threshold` | (optional) A float threshold between 0 and 1, used to determine whether to extract a random, out-of-batch sentence or a suceeding sentence. Higher value favors succeeding sentence. |\n| `random_next_threshold` | (optional) A float threshold between 0 and 1, used to determine whether to extract either a random, out-of-batch, or succeeding sentence or a preceeding sentence. Higher value favors preceeding sentences. |\n| `random_fn` | (optional) An op used to generate random float values. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| a tuple of (preceeding_or_random_next, is_suceeding_or_random) where: preceeding_or_random_next: a `RaggedTensor` of strings with the same shape as `sentences` and contains either a preceeding, suceeding, or random out-of-batch sentence respective to its counterpart in `sentences` and dependent on its label in `is_preceeding_or_random_next`. is_suceeding_or_random: a `RaggedTensor` of bool values with the same shape as `sentences` and is True if it's corresponding sentence in `preceeding_or_random_next` is a random or suceeding sentence, False otherwise. ||\n\n\u003cbr /\u003e"]]