John-Machado commited on
Commit
44dcbcf
verified
1 Parent(s): ed22a5b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -0
README.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - rajpurkar/squad
5
+ language:
6
+ - en
7
+ base_model:
8
+ - distilbert/distilbert-base-uncased
9
+ pipeline_tag: question-answering
10
+ library_name: transformers
11
+ tags:
12
+ - extractive-qa
13
+ - span-prediction
14
+ ---
15
+
16
+ # DistilBERT Fine-Tuned on SQuAD for Extractive QA
17
+
18
+ ## Model Description
19
+
20
+ DistilBERT base uncased fine-tuned on a 5,000-sample subset of [SQuAD](https://huggingface.co/datasets/rajpurkar/squad) for extractive question answering.
21
+
22
+ ## Training Details
23
+
24
+ - **Base model:** distilbert-base-uncased
25
+ - **Dataset:** SQuAD (5,000 samples, 80/20 train/test split)
26
+ - **Epochs:** 3
27
+ - **Learning rate:** 2e-5
28
+ - **Batch size:** 16
29
+ - **Training loss:** 2.303
30
+ - **Device:** Apple Silicon (MPS)
31
+
32
+ ## Usage
33
+
34
+ ```python
35
+ from transformers import AutoTokenizer, AutoModelForQuestionAnswering
36
+ import torch
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained("John-Machado/distilbert-squad-qa")
39
+ model = AutoModelForQuestionAnswering.from_pretrained("John-Machado/distilbert-squad-qa")
40
+
41
+ question = "How many official league titles has Juventus won?"
42
+ context = "The club has won 36 official league titles, 14 Coppa Italia titles and nine Supercoppa Italiana titles."
43
+
44
+ inputs = tokenizer(question, context, return_tensors="pt")
45
+ with torch.no_grad():
46
+ outputs = model(**inputs)
47
+
48
+ start = outputs.start_logits.argmax()
49
+ end = outputs.end_logits.argmax()
50
+ answer = tokenizer.decode(inputs.input_ids[0, start : end + 1])
51
+ print(answer) # "36"
52
+ ```
53
+
54
+ ## Limitations
55
+ - Trained on only 5,000 SQuAD samples (out of 87,599) as a learning exercise
56
+ - Answers must exist as a verbatim substring in the context
57
+ - Cannot synthesize answers across multiple passages