DeepakKumarMSL commited on
Commit
6acce8a
Β·
verified Β·
1 Parent(s): 5a75830

Create README.md

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