Instructions to use ccdv/lsg-bart-base-4096-booksum with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ccdv/lsg-bart-base-4096-booksum 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="ccdv/lsg-bart-base-4096-booksum", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("ccdv/lsg-bart-base-4096-booksum", trust_remote_code=True) model = AutoModelForSeq2SeqLM.from_pretrained("ccdv/lsg-bart-base-4096-booksum", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Sample code is not functional
RuntimeError: The expanded size of the tensor (64) must match the existing size (2) at non-singleton dimension 0. Target sizes: [64]. Tensor sizes: [2]
RuntimeError: The expanded size of the tensor (64) must match the existing size (2) at non-singleton dimension 0. Target sizes: [64]. Tensor sizes: [2]
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
tokenizer = AutoTokenizer.from_pretrained("ccdv/lsg-bart-base-4096-booksum", trust_remote_code=True)
model = AutoModelForSeq2SeqLM.from_pretrained("ccdv/lsg-bart-base-4096-booksum", trust_remote_code=True)
text = "Replace by what you want."*512
pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer)
generated_text = pipe(
text,
truncation=True,
max_length=256,
no_repeat_ngram_size=7,
num_beams=2,
early_stopping=True
)
Works fine on colab (transformers 4.38.2)
Ah I wasn't actually using the sample code exactly, as I had added device="mps" to pipe = pipeline("text2text-generation", model=model, tokenizer=tokenizer, device="mps") on MacOS.
Unsure if the above is a model error or user error, as I'm new to transformers and still learning, but can confirm the above works with no device given.
Didn't test on mac