MonicaDasari commited on
Commit
e049ea2
·
verified ·
1 Parent(s): 9da7fa1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +82 -54
README.md CHANGED
@@ -1,73 +1,101 @@
1
- # **BLEU Score Comparison for English-to-Japanese Translations**
2
 
3
  ## **Overview**
4
- This project demonstrates the calculation and visualization of BLEU scores for English-to-Japanese translations. The BLEU scores evaluate the performance of two different models: an **LSTM-based model** and a **Seq2Seq model**, based on their ability to translate input sentences into Japanese.
 
 
5
 
6
- ## **Models Evaluated**
7
- 1. **LSTM-based Model**:
8
- - A simpler model that predicts translations based on a sequential structure.
9
- - Tends to perform moderately well but lacks sophistication in handling complex language patterns.
10
 
11
- 2. **Seq2Seq Model**:
12
- - A more advanced model designed for sequence-to-sequence tasks.
13
- - Expected to perform better due to its ability to learn complex patterns and context.
14
 
15
- ## **Key Features**
16
- - Calculates BLEU scores using the **SacreBLEU** library.
17
- - Visualizes BLEU scores as a bar chart for easy comparison.
18
- - Saves the BLEU scores to a CSV file for further analysis.
19
 
20
- ## **Implementation**
21
- ### **Steps in the Code**:
22
- 1. **Dataset Preparation**:
23
- - The dataset contains English sentences and their corresponding Japanese translations (used as references).
24
- - Predictions from both LSTM and Seq2Seq models are compared against these references.
 
 
 
 
25
 
26
- 2. **BLEU Score Calculation**:
27
- - BLEU scores are computed using SacreBLEU to quantify the overlap between the model predictions and the ground truth references.
28
 
29
- 3. **Visualization**:
30
- - BLEU scores are visualized using a bar chart to provide an intuitive comparison of model performance.
31
 
32
- 4. **Saving Results**:
33
- - The BLEU scores for both models are saved to a CSV file named `bleu_scores_english_to_japanese.csv`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  ## **Files**
36
- - `main.py`: The primary Python script containing the code for BLEU score calculation, visualization, and saving results.
37
- - `bleu_scores.csv`: Output file containing the BLEU scores for both models.
38
 
39
- ## **Requirements**
40
- ### **Dependencies**:
 
 
 
 
 
41
  - Python 3.x
42
- - Libraries:
43
- - `sacrebleu`
44
- - `matplotlib`
45
- - `csv`
46
 
47
- To install the required dependencies, run:
48
  ```bash
49
  pip install sacrebleu matplotlib
50
  ```
51
 
52
- ## **Usage**
53
- 1. Clone this repository and navigate to the project directory.
54
- 2. Run the script:
55
- ```bash
56
- python main.py
57
- ```
58
- 3. View the BLEU scores printed in the console and the generated bar chart.
59
- 4. Check the `bleu_scores_english.csv` file for the saved results.
60
-
61
- ## **Results**
62
- - The BLEU scores for both models are displayed in the console and visualized in the bar chart.
63
- - Example output:
64
- ```
65
- BLEU Score Comparison (English-to-Japanese):
66
- LSTM Model BLEU Score: 45.32
67
- Seq2Seq Model BLEU Score: 70.25
68
- BLEU scores have been saved to bleu_scores.csv
69
- ```
70
-
71
- ## **Acknowledgments**
72
- This project uses the SacreBLEU library for BLEU score calculation and Matplotlib for visualization.
73
 
 
1
+ # **BLEU and chrF Score Evaluation for English-to-Japanese Translations**
2
 
3
  ## **Overview**
4
+ This project evaluates the performance of two translation models:
5
+ 1. **LSTM-based Model**
6
+ 2. **Seq2Seq Model**
7
 
8
+ The evaluation is based on two standard metrics:
9
+ - **BLEU Score**: Measures n-gram precision with a penalty for shorter translations.
10
+ - **chrF Score**: Measures character-level n-gram precision and recall with a focus on fluency.
 
11
 
12
+ The dataset contains translations from **English to Japanese**, where both the reference (ground truth) and predicted translations are evaluated.
 
 
13
 
14
+ ---
 
 
 
15
 
16
+ ## **Project Structure**
17
+ - **Code**: Contains Python scripts for computing BLEU and chrF scores using the `sacrebleu` library.
18
+ - **Input Data**:
19
+ - Reference translations (ground truth in Japanese).
20
+ - Predictions generated by LSTM and Seq2Seq models.
21
+ - **Output**:
22
+ - BLEU and chrF scores for each model.
23
+ - Visualizations of the comparison as bar charts.
24
+ - Results saved to `.csv` files.
25
 
26
+ ---
 
27
 
28
+ ## **Evaluation Steps**
 
29
 
30
+ ### **1. BLEU Score Evaluation**
31
+ The **BLEU** metric evaluates n-gram matches between model predictions and reference translations. Higher scores indicate better translation quality.
32
+
33
+ **Process**:
34
+ 1. Compute BLEU scores using `sacrebleu.corpus_bleu`.
35
+ 2. Compare scores for LSTM and Seq2Seq models.
36
+ 3. Save results to `bleu_scores.csv`.
37
+ 4. Visualize the results with a bar chart.
38
+
39
+ **Example BLEU Results**:
40
+ | Model | BLEU Score |
41
+ |---------|------------|
42
+ | LSTM | 60.45 |
43
+ | Seq2Seq | 85.78 |
44
+
45
+ ---
46
+
47
+ ### **2. chrF Score Evaluation**
48
+ The **chrF** metric evaluates character-level n-gram precision and recall, making it more sensitive to fluency and grammatical correctness.
49
+
50
+ **Process**:
51
+ 1. Compute chrF scores using `sacrebleu.corpus_chrf`.
52
+ 2. Compare scores for LSTM and Seq2Seq models.
53
+ 3. Save results to `chrf_scores_updated.csv`.
54
+ 4. Visualize the results with a bar chart.
55
+
56
+ **Example chrF Results**:
57
+ | Model | chrF Score |
58
+ |---------|------------|
59
+ | LSTM | 72.36 |
60
+ | Seq2Seq | 93.12 |
61
+
62
+ ---
63
 
64
  ## **Files**
 
 
65
 
66
+ - **`bleu_scores.csv`**: Contains BLEU scores for LSTM and Seq2Seq models.
67
+ - **`chrf_scores_updated.csv`**: Contains chrF scores for LSTM and Seq2Seq models.
68
+ - **Python Script**: Computes BLEU and chrF scores, generates visualizations, and saves results.
69
+
70
+ ---
71
+
72
+ ## **Dependencies**
73
  - Python 3.x
74
+ - `sacrebleu`: Library for computing BLEU and chrF scores.
75
+ - `matplotlib`: For plotting visualizations.
76
+ - `csv`: To save results as `.csv` files.
 
77
 
78
+ Install dependencies using:
79
  ```bash
80
  pip install sacrebleu matplotlib
81
  ```
82
 
83
+ ---
84
+
85
+ ## **How to Run**
86
+ 1. Results will be saved as `.csv` files, and bar charts will be displayed.
87
+
88
+ ---
89
+
90
+ ## **Visualization**
91
+ Both BLEU and chrF results are displayed as bar charts for easy comparison:
92
+ - **X-axis**: Models (LSTM, Seq2Seq).
93
+ - **Y-axis**: Scores (BLEU or chrF).
94
+ - Each chart highlights the comparative performance of the models.
95
+
96
+ ---
97
+
98
+ ## **Conclusion**
99
+ - **Seq2Seq Model**: Achieves higher BLEU and chrF scores, demonstrating better translation accuracy and fluency.
100
+ - **LSTM Model**: Performs adequately but lags behind Seq2Seq in both metrics.
 
 
 
101