Update longformer.md#37622
Merged
stevhliu merged 6 commits intohuggingface:mainfrom Apr 21, 2025
Merged
Conversation
Contributor
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
stevhliu
reviewed
Apr 18, 2025
| </hfoptions | ||
|
|
||
| For more information please also refer to [`~LongformerModel.forward`] method. | ||
| Quantization reduces the memory burden of large models by representing the weights in a lower precision. Refer to the [Quantization](../quantization/overview) overview for more available quantization backends. |
Member
There was a problem hiding this comment.
I don't think we need a Quantization example here since the model isn't that big
| - [Question answering task guide](../tasks/question_answering) | ||
| - [Masked language modeling task guide](../tasks/masked_language_modeling) | ||
| - [Multiple choice task guide](../tasks/multiple_choice) | ||
| - If you're using Transformers < 4.37.0.dev, set `trust_remote_code=True` in [~AutoModel.from_pretrained]. Otherwise, make sure you update Transformers to the latest stable version. |
Member
There was a problem hiding this comment.
Not necessary to include this note. Instead, add the below
- Longformer is based on RoBERTa and doesn't have
token_type_ids. You don't need to indicate which token belongs to which segment. You only need to separate the segments with the separation token</s>ortokenizer.sep_token. - You can set which tokens can attend locally and which tokens attend globally with the
global_attention_maskat inference (see this example for more details). A value of0means a token attends locally and a value of1means a token attends globally. - [
LongformerForMaskedLM] is trained like [RobertaForMaskedLM] and should be used as shown below.input_ids = tokenizer.encode("This is a sentence from [MASK] training data", return_tensors="pt") mlm_labels = tokenizer.encode("This is a sentence from the training data", return_tensors="pt") loss = model(input_ids, labels=input_ids, masked_lm_labels=mlm_labels)[0]
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
zucchini-nlp
pushed a commit
to zucchini-nlp/transformers
that referenced
this pull request
May 14, 2025
* Update longformer.md * Update longformer.md * Update docs/source/en/model_doc/longformer.md Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> * Update docs/source/en/model_doc/longformer.md Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com> * Update longformer.md --------- Co-authored-by: Steven Liu <59462357+stevhliu@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactored Longformer docs
Added examples for pipeline, Automodel and cli
Added quantization
Did not add a Attention visualizer, from what I researched it doesn't support it, if it is not the case I am happy to add it !
Added a note concerning versions < 4.37.0.dev