Instructions to use NotXia/longformer-bio-ext-summ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NotXia/longformer-bio-ext-summ with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "summarization" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("summarization", model="NotXia/longformer-bio-ext-summ", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("NotXia/longformer-bio-ext-summ", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
metadata
license: apache-2.0
datasets:
- allenai/mslr2022
language:
- en
pipeline_tag: summarization
Longformer for biomedical extractive summarization
Description
Work done for my Bachelor's thesis.
Longformer fine-tuned on MS^2 for extractive summarization.
The model architecture is similar to BERTSum.
Training code is available at biomed-ext-summ.
Usage
summarizer = pipeline("summarization",
model = "NotXia/longformer-bio-ext-summ",
tokenizer = AutoTokenizer.from_pretrained("NotXia/longformer-bio-ext-summ"),
trust_remote_code = True,
device = 0
)
sentences = ["sent1.", "sent2.", "sent3?"]
summarizer({"sentences": sentences}, strategy="count", strategy_args=2)
>>> (['sent1.', 'sent2.'], [0, 1])
Strategies
Strategies to summarize the document:
length: summary with a maximum length (strategy_argsis the maximum length).count: summary with the given number of sentences (strategy_argsis the number of sentences).ratio: summary proportional to the length of the document (strategy_argsis the ratio [0, 1]).threshold: summary only with sentences with a score higher than a given value (strategy_argsis the minimum score).