Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# π Language Translation Model
|
2 |
+
|
3 |
+
This repository hosts a fine-tuned **T5-small-based** model optimized for **language translation**. The model translates text between multiple languages, including English, Spanish, German, French, and Hindi.
|
4 |
+
|
5 |
+
## π Model Details
|
6 |
+
|
7 |
+
- **Model Architecture**: T5-small
|
8 |
+
- **Task**: Language Translation
|
9 |
+
- **Dataset**: Custom multilingual dataset
|
10 |
+
- **Fine-tuning Framework**: Hugging Face Transformers
|
11 |
+
- **Quantization**: Dynamic (int8) for efficiency
|
12 |
+
|
13 |
+
## π Usage
|
14 |
+
|
15 |
+
### Installation
|
16 |
+
|
17 |
+
```bash
|
18 |
+
pip install transformers torch datasets
|
19 |
+
```
|
20 |
+
|
21 |
+
### Loading the Model
|
22 |
+
|
23 |
+
```python
|
24 |
+
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
25 |
+
import torch
|
26 |
+
|
27 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
28 |
+
|
29 |
+
model_name = AventIQ-AI/t5-language-translation
|
30 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name).to(device)
|
31 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
32 |
+
```
|
33 |
+
|
34 |
+
### Perform Translation
|
35 |
+
|
36 |
+
```python
|
37 |
+
|
38 |
+
def translate_text(model, tokenizer, input_text, target_language):
|
39 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
40 |
+
formatted_text = f"translate English to {target_language}: {input_text}"
|
41 |
+
input_ids = tokenizer(formatted_text, return_tensors="pt").input_ids.to(device)
|
42 |
+
|
43 |
+
with torch.no_grad():
|
44 |
+
output_ids = model.generate(input_ids, max_length=50)
|
45 |
+
|
46 |
+
return tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
47 |
+
|
48 |
+
# πΉ **Test Translation**
|
49 |
+
input_text = "Hello, how are you?"
|
50 |
+
target_language = "French" # Options: "Spanish", "German".
|
51 |
+
translated_text = translate_text(model, tokenizer, input_text, target_language)
|
52 |
+
|
53 |
+
print(f"Original: {input_text}")
|
54 |
+
print(f"Translated: {translated_text}")
|
55 |
+
```
|
56 |
+
|
57 |
+
## π Evaluation Results
|
58 |
+
|
59 |
+
After fine-tuning, the model was evaluated on a multilingual dataset, achieving the following performance:
|
60 |
+
|
61 |
+
| Metric | Score | Meaning |
|
62 |
+
| ------------------- | ----- | ----------------------------------- |
|
63 |
+
| **BLEU Score** | 38.5 | Measures translation accuracy |
|
64 |
+
| **Inference Speed** | Fast | Optimized for real-time translation |
|
65 |
+
|
66 |
+
## π§ Fine-Tuning Details
|
67 |
+
|
68 |
+
### Dataset
|
69 |
+
|
70 |
+
The model was trained using a **multilingual dataset** containing sentence pairs from multiple language sources.
|
71 |
+
|
72 |
+
### Training Configuration
|
73 |
+
|
74 |
+
- **Number of epochs**: 3
|
75 |
+
- **Batch size**: 8
|
76 |
+
- **Optimizer**: AdamW
|
77 |
+
- **Learning rate**: 2e-5
|
78 |
+
- **Evaluation strategy**: Epoch-based
|
79 |
+
|
80 |
+
### Quantization
|
81 |
+
|
82 |
+
The model was quantized using **fp16 quantization**, reducing latency and memory usage while maintaining accuracy.
|
83 |
+
|
84 |
+
## π Repository Structure
|
85 |
+
|
86 |
+
```bash
|
87 |
+
.
|
88 |
+
βββ model/
|
89 |
+
βββ tokenizer_config/
|
90 |
+
βββ quantized_model/
|
91 |
+
βββ README.md
|
92 |
+
```
|
93 |
+
|
94 |
+
## β οΈ Limitations
|
95 |
+
|
96 |
+
- The model may struggle with **very complex sentences**.
|
97 |
+
- **Low-resource languages** may have slightly lower accuracy.
|
98 |
+
- **Contextual understanding** is limited to sentence-level translation.
|
99 |
+
|