Instructions to use Short-Answer-Feedback/bart-score-finetuned-saf-communication-networks with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Short-Answer-Feedback/bart-score-finetuned-saf-communication-networks with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Short-Answer-Feedback/bart-score-finetuned-saf-communication-networks") model = AutoModelForSeq2SeqLM.from_pretrained("Short-Answer-Feedback/bart-score-finetuned-saf-communication-networks") - Notebooks
- Google Colab
- Kaggle
| MAX_INPUT_LENGTH = 256 | |
| MAX_TARGET_LENGTH = 128 | |
| def preprocess_function(examples): | |
| """ | |
| Preprocess entries of the given dataset (should be used with a `map` function) | |
| Params: | |
| examples (Dataset): dataset to be preprocessed | |
| Returns: | |
| model_inputs (BatchEncoding): tokenized dataset entries | |
| """ | |
| inputs, targets = [], [] | |
| for i in range(len(examples['question'])): | |
| inputs.append(f"Answer: {examples['provided_answer'][i]} Reference: {examples['reference_answer'][i]} Question: {examples['question'][i]}") | |
| targets.append(f"{examples['score'][i]} Feedback: {examples['answer_feedback'][i]}") | |
| # apply tokenization to inputs and labels | |
| model_inputs = tokenizer(inputs, max_length=MAX_INPUT_LENGTH, padding='max_length', truncation=True) | |
| labels = tokenizer(text_target=targets, max_length=MAX_TARGET_LENGTH, padding='max_length', truncation=True) | |
| model_inputs['labels'] = labels['input_ids'] | |
| return model_inputs | |