DeepakKumarMSL commited on
Commit
c7f2b64
Β·
verified Β·
1 Parent(s): 5cf8f26

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -0
README.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # English to Hindi Translation (Quantized Model)
2
+
3
+ This repository contains a **quantized English-to-Hindi translation model** fine-tuned on the [`Aarif1430/english-to-hindi`](https://huggingface.co/datasets/Aarif1430/english-to-hindi) dataset and optimized using **dynamic quantization** for efficient CPU inference.
4
+
5
+ ## πŸ”§ Model Details
6
+
7
+ - **Base model**: [`Helsinki-NLP/opus-mt-en-hi`](https://huggingface.co/Helsinki-NLP/opus-mt-en-hi)
8
+ - **Training platform**: Kaggle (CUDA GPU)
9
+ - **Fine-tuned**: On English-Hindi pairs from the Hugging Face dataset
10
+ - **Quantization**: PyTorch Dynamic Quantization (`torch.quantization.quantize_dynamic`)
11
+ - **Tokenizer**: Saved alongside the model
12
+
13
+ ## πŸ“ Folder Structure
14
+
15
+ quantized_model/
16
+ β”œβ”€β”€ config.json
17
+ β”œβ”€β”€ pytorch_model.bin
18
+ β”œβ”€β”€ tokenizer_config.json
19
+ β”œβ”€β”€ tokenizer.json
20
+ β”œβ”€β”€ vocab.json / merges.txt
21
+
22
+
23
+ ---
24
+
25
+ ## πŸš€ Usage
26
+
27
+ ### πŸ”Ή 1. Load Quantized Model for Inference
28
+
29
+ ```python
30
+ import torch
31
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
32
+
33
+ # Load tokenizer
34
+ tokenizer = AutoTokenizer.from_pretrained("./quantized_model")
35
+
36
+ # Load quantized model
37
+ model = AutoModelForSeq2SeqLM.from_pretrained("./quantized_model")
38
+ model.eval()
39
+
40
+ # Run translation
41
+ translator = pipeline("translation_en_to_hi", model=model, tokenizer=tokenizer, device=-1)
42
+
43
+ text = "How are you?"
44
+ print("Hindi:", translator(text)[0]['translation_text'])
45
+ ```
46
+
47
+ ## Model Training Summary
48
+
49
+ - Loaded dataset: Aarif1430/english-to-hindi
50
+
51
+ - Mapped translation data: {"en": ..., "hi": ...} before training
52
+
53
+ - Training: 3 epochs using GPU
54
+
55
+ - Disabled: wandb logging
56
+
57
+ - Skipped: Evaluation phase
58
+
59
+ - Saved: Trained + Quantized model and tokenizer
60
+
61
+ - Quantization: torch.quantization.Quantize_dynamic is used for efficient CPU inference
62
+