File size: 6,415 Bytes
1e1092f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
LSTM and Seq-to-Seq Language Translator
This project implements language translation using two approaches:

LSTM-based Translator: A model that translates between English and Hebrew using a basic encoder-decoder architecture.
Seq-to-Seq Translator: A sequence-to-sequence model without attention for bidirectional translation between English and Hebrew.
Both models are trained on a parallel dataset of 1000 sentence pairs and evaluated using BLEU and CHRF scores.
Model Architectures
1. LSTM-Based Translator
The LSTM model is built with the following components:

Encoder: Embedding and LSTM layers to encode English input sequences into latent representations.
Decoder: Embedding and LSTM layers initialized with the encoder's states, generating Hebrew translations token-by-token.
Dense Layer: A fully connected output layer with a softmax activation to predict the next word in the sequence.
2. Seq-to-Seq Translator
The Seq-to-Seq model uses:

Encoder: Similar to the LSTM-based translator, this encodes the input sequence into context vectors.
Decoder: Predicts the target sequence without attention, relying entirely on the encoded context.

LSTM and Seq-to-Seq Language Translator
This project implements language translation using two approaches:

LSTM-based Translator: A model that translates between English and Hebrew using a basic encoder-decoder architecture.
Seq-to-Seq Translator: A sequence-to-sequence model without attention for bidirectional translation between English and Hebrew.
Both models are trained on a parallel dataset of 1000 sentence pairs and evaluated using BLEU and CHRF scores.

Model Architectures
1. LSTM-Based Translator
The LSTM model is built with the following components:

Encoder: Embedding and LSTM layers to encode English input sequences into latent representations.
Decoder: Embedding and LSTM layers initialized with the encoder's states, generating Hebrew translations token-by-token.
Dense Layer: A fully connected output layer with a softmax activation to predict the next word in the sequence.
2. Seq-to-Seq Translator
The Seq-to-Seq model uses:

Encoder: Similar to the LSTM-based translator, this encodes the input sequence into context vectors.
Decoder: Predicts the target sequence without attention, relying entirely on the encoded context.
Dataset
The models are trained on a custom parallel dataset containing 1000 English-Hebrew sentence pairs, formatted as JSON with fields english and hebrew. The Hebrew text includes <start> and <end> tokens for better decoding.

Preprocessing:

Tokenization: Text is tokenized using Keras' Tokenizer.
Padding: Sequences are padded to a fixed length for training.
Vocabulary Sizes:
English: 1000 pairs
Hebrew: 1000 pairs

Training Details
Training Parameters:
Optimizer: Adam
Loss Function: Sparse Categorical Crossentropy
Batch Size: 32
Epochs: 20
Validation Split: 20%
Checkpoints:
Models are saved at their best-performing stages based on validation loss using Keras' ModelCheckpoint.

Training Metrics:
Both models track:

Training Loss
Validation Loss

Evaluation Metrics
1. BLEU Score:
The BLEU metric evaluates the quality of translations by comparing them to reference translations. Higher BLEU scores indicate better translations.

LSTM Model BLEU: [BLEU Score for LSTM]
Seq-to-Seq Model BLEU: [BLEU Score for Seq-to-Seq]
2. CHRF Score:
The CHRF metric evaluates translations using character-level F-scores. Higher CHRF scores indicate better translations.

LSTM Model CHRF: [CHRF Score for LSTM]
Seq-to-Seq Model CHRF: [CHRF Score for Seq-to-Seq]


LSTM and Seq-to-Seq Language Translator
This project implements language translation using two approaches:

LSTM-based Translator: A model that translates between English and Hebrew using a basic encoder-decoder architecture.
Seq-to-Seq Translator: A sequence-to-sequence model without attention for bidirectional translation between English and Hebrew.
Both models are trained on a parallel dataset of 1000 sentence pairs and evaluated using BLEU and CHRF scores.

Model Architectures
1. LSTM-Based Translator
The LSTM model is built with the following components:

Encoder: Embedding and LSTM layers to encode English input sequences into latent representations.
Decoder: Embedding and LSTM layers initialized with the encoder's states, generating Hebrew translations token-by-token.
Dense Layer: A fully connected output layer with a softmax activation to predict the next word in the sequence.
2. Seq-to-Seq Translator
The Seq-to-Seq model uses:

Encoder: Similar to the LSTM-based translator, this encodes the input sequence into context vectors.
Decoder: Predicts the target sequence without attention, relying entirely on the encoded context.
Dataset
The models are trained on a custom parallel dataset containing 1000 English-Hebrew sentence pairs, formatted as JSON with fields english and hebrew. The Hebrew text includes <start> and <end> tokens for better decoding.

Preprocessing:

Tokenization: Text is tokenized using Keras' Tokenizer.
Padding: Sequences are padded to a fixed length for training.
Vocabulary Sizes:
English: [English Vocabulary Size]
Hebrew: [Hebrew Vocabulary Size]
Training Details
Training Parameters:
Optimizer: Adam
Loss Function: Sparse Categorical Crossentropy
Batch Size: 32
Epochs: 20
Validation Split: 20%
Checkpoints:
Models are saved at their best-performing stages based on validation loss using Keras' ModelCheckpoint.

Training Metrics:
Both models track:

Training Loss
Validation Loss
Evaluation Metrics
1. BLEU Score:
The BLEU metric evaluates the quality of translations by comparing them to reference translations. Higher BLEU scores indicate better translations.

LSTM Model BLEU: [BLEU Score for LSTM]
Seq-to-Seq Model BLEU: [BLEU Score for Seq-to-Seq]
2. CHRF Score:
The CHRF metric evaluates translations using character-level F-scores. Higher CHRF scores indicate better translations.

LSTM Model CHRF: [CHRF Score for LSTM]
Seq-to-Seq Model CHRF: [CHRF Score for Seq-to-Seq]
Results
Training Loss Comparison: The Seq-to-Seq model achieved slightly better convergence compared to the LSTM model due to its structured architecture.
Translation Quality: The BLEU and CHRF scores indicate that both models provide reasonable translations, with the Seq-to-Seq model performing better on longer sentences.

Acknowledgments
Dataset: [Custom Parallel Dataset]
Evaluation Tools: PyTorch BLEU, SacreBLEU CHRF.