File size: 3,566 Bytes
0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e 0dc983f b04921e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# RoBERTa Fine-Tuned Model for Question Answering
This repository hosts a fine-tuned version of the RoBERTa model optimized for question-answering tasks using the [SQuAD](w) dataset. The model is designed to efficiently perform question answering while maintaining high accuracy.
## Model Details
- **Model Architecture**: RoBERTa
- **Task**: Question Answering
- **Dataset**: [SQuAD](w) (Stanford Question Answering Dataset)
- **Quantization**: FP16
- **Fine-tuning Framework**: Hugging Face Transformers
## π Usage
### Installation
```bash
pip install transformers torch
```
### Loading the Model
```python
from transformers import RobertaTokenizer, RobertaForQuestionAnswering
import torch
device = "cuda" if torch.cuda.is_available() else "cpu"
model_name = "AventIQ-AI/roberta-chatbot"
model = RobertaForQuestionAnswering.from_pretrained(model_name).to(device)
tokenizer = RobertaTokenizer.from_pretrained(model_name)
```
### Chatbot Inference
```python
from transformers import pipeline
# Load QA pipeline
qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer, device=0)
# Test sample question
# Updated context and question for a flight prediction example
# Updated context and question for flight prediction example
context = "Flight AI101 departs from New York at 10:00 AM and arrives in San Francisco at 1:30 PM. The flight duration is 5 hours and 30 minutes."
question = "What is the duration of Flight AI101?"
# Get answer
result = qa_pipeline(question=question, context=context)
print(result)
```
π Evaluation Results
After fine-tuning the RoBERTa-base model for question answering, we evaluated the model's performance on the validation set from the SQuAD dataset. The following results were obtained:
Metric Score Meaning
F1 Score 89.5 Measures the balance between precision and recall for answer extraction.
Exact Match 82.4 Percentage of questions where the predicted answer matches the ground truth exactly.
Fine-Tuning Details
Dataset
The SQuAD dataset, containing over 100,000 question-answer pairs based on Wikipedia articles, was used for fine-tuning the model.
Training
Number of epochs: 3
Batch size: 8
Evaluation strategy: steps
Quantization
Post-training quantization was applied using PyTorch's built-in quantization framework to reduce the model size and improve inference efficiency.
Repository Structure
```
.
βββ model/ # Contains the quantized model files
βββ tokenizer_config/ # Tokenizer configuration and vocabulary files
βββ model.safetensors/ # Quantized Model
βββ README.md # Model documentation
```
## β‘ Quantization Details
Post-training quantization was applied using PyTorch's built-in quantization framework. The model was quantized to Float16 (FP16) to reduce model size and improve inference efficiency while balancing accuracy.
## π Repository Structure
```
.
βββ model/ # Contains the quantized model files
βββ tokenizer_config/ # Tokenizer configuration and vocabulary files
βββ model.safetensors/ # Quantized Model
βββ README.md # Model documentation
```
## β οΈ Limitations
- The model may struggle with highly ambiguous sentences.
- Quantization may lead to slight degradation in accuracy compared to full-precision models.
- Performance may vary across different writing styles and sentence structures.
## π€ Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request if you have suggestions or improvements.
|