This repository hosts a fine-tuned version of the T5-Base model optimized for question-answering tasks using the [SQuAD] dataset. The model is designed to efficiently perform question answering while maintaining high accuracy.
1defanswer_question(question, context):2 input_text =f"question: {question} context: {context}"3 inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding="max_length", max_length=512)45# Move input tensors to the same device as the model6 inputs ={key: value.to(device)for key, value in inputs.items()}78# Generate answer9with torch.no_grad():10 output = model.generate(**inputs, max_length=150)1112# Decode and return answer13return tokenizer.decode(output[0], skip_special_tokens=True)1415# Test Case16question ="What is overfitting in machine learning?"17context = "Overfitting occurs when a model learns the training data too well, capturing noise instead of actual patterns.18predicted_answer = answer_question(question, context)19print(f"Predicted Answer: {predicted_answer}")20
⚡ 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.