CoolFace
Modelpublic

Giyaseddin/distilbert-base-uncased-finetuned-short-answer-assessment

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
1likes25downloads
Model Card

DistilBERT base uncased model for Short Question Answer Assessment

Model description

DistilBERT is a transformers model, smaller and faster than BERT, which was pretrained on the same corpus in a self-supervised fashion, using the BERT base model as a teacher. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts using the BERT base model.

This is a classification model that solves Short Question Answer Assessment task, finetuned pretrained DistilBERT model on Question Answer Assessment dataset

Intended uses & limitations

This can only be used for the kind of questions and answers provided by that are similar to the ones in the dataset of Banjade et al..

How to use

You can use this model directly with a :

python
>>> from transformers import pipeline
>>> classifier = pipeline("text-classification", model="Giyaseddin/distilbert-base-uncased-finetuned-short-answer-assessment", return_all_scores=True)
>>> context = "To rescue a child who has fallen down a well, rescue workers fasten him to a rope, the other end of which is then reeled in by a machine. The rope pulls the child straight upward at steady speed."
>>> question = "How does the amount of tension in the rope compare to the downward force of gravity acting on the child?"
>>> ref_answer = "Since the child is being raised straight upward at a constant speed, the net force on the child is zero and all the forces balance. That means that the tension in the rope balances the downward force of gravity."
>>> student_answer = "The tension force is higher than the force of gravity."
>>> 
>>> body = " [SEP] ".join([context, question, ref_answer, student_answer])
>>> raw_results = classifier([body])
>>> raw_results
[[{'label': 'LABEL_0', 'score': 0.0004029414849355817},
  {'label': 'LABEL_1', 'score': 0.0005476847873069346},
  {'label': 'LABEL_2', 'score': 0.998059093952179},
  {'label': 'LABEL_3', 'score': 0.0009902542224153876}]]
>>> _LABELS_ID2NAME = {0: "correct", 1: "correct_but_incomplete", 2: "contradictory", 3: "incorrect"}
>>> results = []
>>> for result in raw_results:
    	for score in result:
        	results.append([
            	{_LABELS_ID2NAME[int(score["label"][-1:])]: "%.2f" % score["score"]}
        	])

>>> results
[[{'correct': '0.00'}],
 [{'correct_but_incomplete': '0.00'}],
 [{'contradictory': '1.00'}],
 [{'incorrect': '0.00'}]]

Limitations and bias

Even if the training data used for this model could be characterized as fairly neutral, this model can have biased predictions. It also inherits some of the bias of its teacher model.

This bias will also affect all fine-tuned versions of this model.

Also one of the limiations of this model is the length, longer sequences would lead to wrong predictions, due to the pre-processing phase (after concatentating the input sequences, the important student answer might be pruned!)

Pre-training data

DistilBERT pretrained on the same data as BERT, which is BookCorpus, a dataset consisting of 11,038 unpublished books and English Wikipedia (excluding lists, tables and headers).

Fine-tuning data

The annotated dataset consists of 900 students’ short constructed answers and their correctness in the given context. Four qualitative levels of correctness are defined, correct, correct-but-incomplete, contradictory and Incorrect.

Training procedure

Preprocessing

In the preprocessing phase, the following parts are concatenated: question context, question, referenceanswer, and studentanswer using the separator [SEP]. This makes the full text as:

[CLS] Context Sentence [SEP] Question Sentence [SEP] Reference Answer Sentence [SEP] Student Answer Sentence [CLS]

The data are splitted according to the following ratio:

  • —Training set 80%.
  • —Test set 20%.

Lables are mapped as: {0: "correct", 1: "correct_but_incomplete", 2: "contradictory", 3: "incorrect"}

Fine-tuning

The model was finetuned on GeForce GTX 960M for 20 minuts. The parameters are:

ParameterValue
Learning rate5e-5
Weight decay0.01
Training batch size8
Epochs4

Here is the scores during the training:

EpochTraining LossValidation LossAccuracyF1PrecisionRecall
1No log0.6657650.7553300.7435740.7812100.755330
20.9321000.3621240.8903550.8898750.8914070.890355
30.3649000.2262250.9421320.9418020.9424580.942132
30.1769000.1936600.9543150.9541750.9549850.954315

Evaluation results

When fine-tuned on downstream task of Question Answer Assessment, 4 class classification, this model achieved the following results: (scores are rounded to 2 floating points)

precisionrecallf1-scoresupport
correct0.9380.9890.963366
correctbutincomplete0.9750.9220.948257
contradictory0.9460.9380.942113
incorrect0.9630.9440.953249
accuracy--0.954985
macro avg0.9560.9480.952985
weighted avg0.9550.9540.954985

Confusion matrix:

Actual \ Predicted_correct__correct_but_incomplete__contradictory__incorrect_
correct362400
correctbutincomplete1323707
contradictory411062
incorrect716235

The AUC score is: 'micro'= 0.9695 and 'macro': 0.9659