srikanth1579 commited on
Commit
42b4c73
·
verified ·
1 Parent(s): ab8cd43

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +116 -0
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - is
4
+ ---
5
+ README
6
+
7
+ Overview
8
+
9
+ This project implements a language translation model using GPT-2, capable of translating between Icelandic and English. The pipeline includes data preprocessing, model training, evaluation, and an interactive user interface for translations.
10
+
11
+ Features
12
+
13
+ Text Preprocessing: Tokenization and padding for uniform input size.
14
+
15
+ Model Training: Training a GPT-2 model on paired Icelandic-English sentences.
16
+
17
+ Evaluation: Perplexity-based validation of model performance.
18
+
19
+ Interactive Interface: An easy-to-use widget for real-time translations.
20
+
21
+ Installation
22
+
23
+ Prerequisites
24
+
25
+ Ensure you have the following installed:
26
+
27
+ Python (>= 3.8)
28
+
29
+ PyTorch
30
+
31
+ Transformers library by Hugging Face
32
+
33
+ ipywidgets (for the translation interface)
34
+
35
+ Steps
36
+
37
+ Clone the repository:
38
+
39
+ git clone <repository_url>
40
+ cd <repository_name>
41
+
42
+ Install the required libraries:
43
+
44
+ pip install -r requirements.txt
45
+
46
+ Ensure GPU availability for faster training (optional but recommended).
47
+
48
+ Usage
49
+
50
+ Training the Model
51
+
52
+ Prepare your dataset with English-Icelandic sentence pairs.
53
+
54
+ Run the script to preprocess the data and train the model:
55
+
56
+ python train_model.py
57
+
58
+ The trained model and tokenizer will be saved in the ./trained_gpt2 directory.
59
+
60
+ Evaluating the Model
61
+
62
+ Evaluate the trained model using validation data:
63
+
64
+ python evaluate_model.py
65
+
66
+ The script computes perplexity to measure model performance.
67
+
68
+ Running the Interactive Interface
69
+
70
+ Launch a Jupyter Notebook or Jupyter Lab.
71
+
72
+ Open the file interactive_translation.ipynb.
73
+
74
+ Enter a sentence in English or Icelandic, and view the translation in real-time.
75
+
76
+ File Structure
77
+
78
+ train_model.py: Contains code for data preprocessing, model training, and saving.
79
+
80
+ evaluate_model.py: Evaluates model performance using perplexity.
81
+
82
+ interactive_translation.ipynb: Interactive interface for testing translations.
83
+
84
+ requirements.txt: List of required Python packages.
85
+
86
+ trained_gpt2/: Directory to save trained model and tokenizer.
87
+
88
+ Key Parameters
89
+
90
+ Max Length: Maximum token length for inputs (default: 128).
91
+
92
+ Learning Rate: .
93
+
94
+ Batch Size: 4 (both training and validation).
95
+
96
+ Epochs: 10.
97
+
98
+ Beam Search: Used for generating translations, with a beam size of 5.
99
+
100
+ Future Improvements
101
+
102
+ Expand dataset to include additional language pairs.
103
+
104
+ Optimize the model for faster inference.
105
+
106
+ Integrate the application into a web-based interface.
107
+
108
+ Acknowledgements
109
+
110
+ Hugging Face for providing the GPT-2 model and libraries.
111
+
112
+ PyTorch for enabling seamless implementation and training.
113
+
114
+ License
115
+
116
+ This project is licensed under the MIT License. See the LICENSE file for details.