Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
**π§ Q&AMODEL-SQUAD**
|
2 |
+
|
3 |
+
A roberta-base-squad2 extractive Question Answering model fine-tuned on the SQuAD v2.0 dataset to predict precise answers from context passages, including handling unanswerable questions.
|
4 |
+
|
5 |
+
---
|
6 |
+
|
7 |
+
β¨ **Model Highlights**
|
8 |
+
|
9 |
+
- π Based on roberta-base-squad2
|
10 |
+
- π Fine-tuned on SQuAD v2.0 (or your custom QA dataset)
|
11 |
+
- β‘ Supports extractive question answering finds precise answers from context passages
|
12 |
+
- πΎ Suitable for real-time inference with minimal latency on both CPU and GPU
|
13 |
+
-π οΈ Easily integrable into web apps, enterprise tools, and virtual assistants
|
14 |
+
-π Handles unanswerable questions gracefully with no-answer detection (if trained on SQuAD v2)
|
15 |
+
|
16 |
+
---
|
17 |
+
|
18 |
+
π§ Intended Uses
|
19 |
+
|
20 |
+
- β
Customer support bots that extract answers from product manuals or FAQs
|
21 |
+
- β
Educational tools that answer student queries based on textbooks or syllabus
|
22 |
+
- β
Legal, financial, or technical document analysis
|
23 |
+
- β
Search engines with context-aware question answering
|
24 |
+
- β
Chatbots that require contextual comprehension for precise responses
|
25 |
+
|
26 |
+
---
|
27 |
+
|
28 |
+
- π« Limitations
|
29 |
+
|
30 |
+
- βTrained primarily on formal text performance may degrade on informal or slang-heavy input
|
31 |
+
- βDoes not support multi-hop questions requiring reasoning across multiple paragraphs
|
32 |
+
- β May struggle with ambiguous questions or context with multiple possible answers
|
33 |
+
- β Not designed for very long documents (performance may drop for inputs >512 tokens)
|
34 |
+
|
35 |
+
---
|
36 |
+
|
37 |
+
ποΈββοΈ Training Details
|
38 |
+
|
39 |
+
| Field | Value |
|
40 |
+
| -------------- | ------------------------------ |
|
41 |
+
| **Base Model** | `roberta-base-squad2` |
|
42 |
+
| **Dataset** | SQuAD v2.0 |
|
43 |
+
| **Framework** | PyTorch with Transformers |
|
44 |
+
| **Epochs** | 3 |
|
45 |
+
| **Batch Size** | 16 |
|
46 |
+
| **Optimizer** | AdamW |
|
47 |
+
| **Loss** | CrossEntropyLoss (token-level) |
|
48 |
+
| **Device** | Trained on CUDA-enabled GPU |
|
49 |
+
|
50 |
+
---
|
51 |
+
|
52 |
+
π Evaluation Metrics
|
53 |
+
|
54 |
+
| Metric | Score |
|
55 |
+
| ----------------------------------------------- | ----- |
|
56 |
+
| Accuracy | 0.80 |
|
57 |
+
| F1-Score | 0.78 |
|
58 |
+
| Precision | 0.79 |
|
59 |
+
| Recall | 0.78 |
|
60 |
+
|
61 |
+
---
|
62 |
+
|
63 |
+
π Usage
|
64 |
+
```python
|
65 |
+
from transformers import BertTokenizerFast, BertForTokenClassification
|
66 |
+
from transformers import pipeline
|
67 |
+
import torch
|
68 |
+
|
69 |
+
model_name = "AventIQ-AI/QA-Squad-Model"
|
70 |
+
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
|
71 |
+
model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)
|
72 |
+
model.eval()
|
73 |
+
|
74 |
+
|
75 |
+
|
76 |
+
#Inference
|
77 |
+
|
78 |
+
|
79 |
+
qa_pipeline = pipeline("question-answering", model="./qa_model", tokenizer="./qa_model")
|
80 |
+
|
81 |
+
# Provide a context and a question
|
82 |
+
context = """
|
83 |
+
The Amazon rainforest, also known as Amazonia, is a moist broadleaf tropical rainforest in the Amazon biome
|
84 |
+
that covers most of the Amazon basin of South America. This region includes territory belonging to nine nations.
|
85 |
+
"""
|
86 |
+
question = "What is the Amazon rainforest also known as?"
|
87 |
+
|
88 |
+
# Run inference
|
89 |
+
result = qa_pipeline(question=question, context=context)
|
90 |
+
|
91 |
+
# Print the result
|
92 |
+
print(f"Question: {question}")
|
93 |
+
print(f"Answer: {result['answer']}")
|
94 |
+
print(f"Score: {result['score']:.4f}")
|
95 |
+
```
|
96 |
+
---
|
97 |
+
|
98 |
+
- π§© Quantization
|
99 |
+
- Post-training static quantization applied using PyTorch to reduce model size and accelerate inference on edge devices.
|
100 |
+
|
101 |
+
----
|
102 |
+
|
103 |
+
π Repository Structure
|
104 |
+
```
|
105 |
+
.
|
106 |
+
βββ model/ # Quantized model files
|
107 |
+
βββ tokenizer_config/ # Tokenizer and vocab files
|
108 |
+
βββ model.safensors/ # Fine-tuned model in safetensors format
|
109 |
+
βββ README.md # Model card
|
110 |
+
|
111 |
+
```
|
112 |
+
---
|
113 |
+
π€ Contributing
|
114 |
+
|
115 |
+
Open to improvements and feedback! Feel free to submit a pull request or open an issue if you find any bugs or want to enhance the model.
|
116 |
+
|
117 |
+
|