Run this model with HF Jobs
Run primer-ai/bart-squad2 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/primer-ai/bart-squad2. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/primer-ai/bart-squad2 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use primer-ai/bart-squad2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use primer-ai/bart-squad2 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "question-answering" 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("question-answering", model="primer-ai/bart-squad2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForQuestionAnswering tokenizer = AutoTokenizer.from_pretrained("primer-ai/bart-squad2") model = AutoModelForQuestionAnswering.from_pretrained("primer-ai/bart-squad2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Migrate model card from transformers-repo
Browse filesRead announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/Primer/bart-squad2/README.md
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263---language: "en"---
# BART-Squad2
## Model description
BART for extractive (span-based) question answering, trained on Squad 2.0.
F1 score of 87.4.
## Intended uses & limitations
Unfortunately, the Huggingface auto-inference API won't run this model, so if you're attempting to try it through the input box above and it complains, don't be discouraged!
#### How to use
Here's a quick way to get question answering running locally:
```pythonfrom transformers import AutoTokenizer, AutoModelForQuestionAnswering
tokenizer = AutoTokenizer.from_pretrained("Primer/bart-squad2")model = AutoModelForQuestionAnswering.from_pretrained("Primer/bart-squad2")model.to('cuda'); model.eval()
def answer(question, text): seq = '<s>' + question + ' </s> </s> ' + text + ' </s>' tokens = tokenizer.encode_plus(seq, return_tensors='pt', padding='max_length', max_length=1024) input_ids = tokens['input_ids'].to('cuda') attention_mask = tokens['attention_mask'].to('cuda') start, end, _ = model(input_ids, attention_mask=attention_mask) start_idx = int(start.argmax().int()) end_idx = int(end.argmax().int()) print(tokenizer.decode(input_ids[0, start_idx:end_idx]).strip()) # ^^ it will be an empty string if the model decided "unanswerable"
>>> question = "Where does Tom live?">>> context = "Tom is an engineer in San Francisco.">>> answer(question, context)San Francisco```
(Just drop the `.to('cuda')` stuff if running on CPU).
#### Limitations and bias
Unknown, no further evaluation has been performed. In a technical sense one big limitation is that it's 1.6G 馃槵
## Training procedure
`run_squad.py` with:
|param|value||---|---||batch size|8||max_seq_length|1024||learning rate|1e-5||epochs|2|
Modified to freeze shared parameters and encoder embeddings.
README.mdAdded+63