Skip to content

This project develops an English to Hindi translator using NMT with attention mechanisms in Keras. It aims for accuracy in translating English to grammatically correct Hindi, leveraging IIT Bombay's dataset, RMSprop optimizer, and rigorous evaluation.

Notifications You must be signed in to change notification settings

Kuntal-Yash/English_To_Hindi_Translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

English_To_Hindi_Translator.

This project develops an English to Hindi translator using NMT with attention mechanisms in Keras. It aims for accuracy in translating English to grammatically correct Hindi, leveraging IIT Bombay's dataset, RMSprop optimizer, and rigorous evaluation.

ABSTRACT:

In an increasingly interconnected world, effective communication across linguistic boundaries is essential. The demand for translation services, particularly between widely spoken languages like English and Hindi, continues to rise. This project addresses this need by focusing on the development of an English to Hindi translator leveraging advanced neural machine translation (NMT) techniques. The significance of English and Hindi as languages of global and regional importance respectively underscores the importance of effective translation systems between them. English serves as a lingua franca in various domains such as business, technology, and academia, while Hindi is one of the most spoken languages in India, with a rich cultural and literary heritage. The primary objective of this project is to create a sophisticated and accurate translation system capable of seamlessly converting English text into grammatically correct and contextually relevant Hindi sentences. Achieving this goal requires the utilization of state-of-the-art NMT methodologies, which have demonstrated superior performance in capturing complex linguistic patterns and nuances. The development of the translator involves a multi-step process encompassing data acquisition, preprocessing, model architecture design, training, and evaluation. The dataset used for training is sourced from a diverse range of texts to ensure the model's exposure to varied linguistic contexts and styles. By embarking on this project, we aim to contribute to the advancement of cross-linguistic communication and understanding, enabling individuals and organizations to overcome language barriers and engage more effectively in a globalized world. The resulting English to Hindi translator represents not only a technological achievement but also a means to foster cultural exchange, promote inclusivity, and facilitate access to information and resources across linguistic divides.

INTRODUCTION:

This project focuses on the development of an English to Hindi translator using neural machine translation (NMT) techniques. The translator is built using a sequence-to-sequence model with attention mechanisms, implemented using the Keras library. The primary objective is to create a robust and accurate system capable of translating English sentences into grammatically correct and contextually relevant Hindi sentences. The methodology involves several key steps, including data preprocessing, model development, training, and evaluation. A dataset consisting of parallel English-Hindi sentence pairs is utilized, sourced primarily from IIT Bombay. The dataset undergoes extensive cleaning and preprocessing, including removing duplicates, punctuation, and digits. The NMT model architecture is constructed using LSTM layers with attention mechanisms, allowing the model to effectively capture the semantic and syntactic information present in the input sentences. The model is trained using the RMSprop optimizer and categorical cross-entropy loss function, aiming to minimize the discrepancy between the predicted and actual probability distributions over the target vocabulary. During the training process, the model's performance is monitored using both training and validation data. The training dynamics, including the convergence of the loss values, are visualized using line plots generated with Matplotlib. Overall, this project represents a significant step towards bridging the language barrier between English and Hindi, facilitating seamless communication and understanding across linguistic boundaries.

METHODOLOGY:

● Data Acquisition: ○ The dataset used for training the English to Hindi translator is sourced primarily from the "Hindi_English_Truncated_Corpus.csv" file. ○ The dataset contains parallel English-Hindi sentence pairs, with a focus on data from IIT Bombay to ensure a diverse range of linguistic contexts and styles. ● Data Preprocessing: ○ Duplicate entries are removed from the dataset to ensure data quality. ○ Punctuation and digits are stripped from the text to standardize and simplify the input data. ○ Special characters and symbols specific to the Hindi script are handled appropriately to ensure proper tokenization and processing. ● Model Development: ○ The translator model is built using a sequence-to-sequence architecture with Long Short-Term Memory (LSTM) networks. ○ The model incorporates attention mechanisms to enable the model to focus on relevant parts of the input sequence during translation. ○ Embedding layers are employed to represent input words in a continuous vector space, facilitating semantic understanding. ● Training: ○ The model is trained using the RMSprop optimizer, an adaptive learning rate optimization algorithm. ○ Categorical cross-entropy loss function is utilized to measure the discrepancy between predicted and actual probability distributions over the target vocabulary. ○ Training is conducted iteratively over multiple epochs, with batched data fed into the model using a custom data generator. ● Evaluation: ○ The model's performance is evaluated using both training and validation datasets. ○ Metrics such as loss values and validation accuracy are monitored to assess the model's convergence and generalization capabilities. ○ Human evaluation may also be conducted to assess the quality and fluency of the translated sentences.

● Loss Function: ○ Loss Function: Categorical Cross-Entropy ○ Categorical cross-entropy is a widely used loss function in neural network models, particularly in classification tasks where the output is a categorical distribution. In the context of sequence-to-sequence models like the one used in machine translation, categorical cross-entropy measures the discrepancy between the predicted probability distribution over the target vocabulary and the actual distribution. ○ Optimizer: The RMSprop optimizer is chosen for updating the model's parameters during training. RMSprop is an adaptive learning rate optimization algorithm that helps in mitigating the vanishing gradient problem. ○ Loss: The loss function is specified as 'categorical_crossentropy'. This choice of loss function is suitable for multi-class classification tasks where each sample belongs to one and only one class. In the context of machine translation, each target word is treated as a separate class, and the model aims to predict the probability distribution over the entire target vocabulary for each word in the sequence. During training, the model minimizes the categorical cross-entropy loss by adjusting its parameters (weights and biases) through backpropagation and gradient descent. The loss is calculated based on the predicted probability distribution over the target vocabulary and the one-hot encoded representation of the actual target words. By minimizing the categorical cross-entropy loss, the model learns to generate more accurate probability distributions over the target vocabulary, leading to improved translations. Additionally, monitoring the loss value during training helps in assessing the convergence and performance of the model.

Dataset Used: Hindi_English_Truncated_Corpus ● English To Hindi is a cleaned csv file of IIT Bombay translation dataset. Original dataset can be found at https://www.cfilt.iitb.ac.in/iitb_parallel/ The English and Hindi txt files are original IIT Bombay data. ● Hindi English Truncated Corpus is available at https://www.clarin.eu/resource-families/parallel-corpora ● Link for dataset: https://www.kaggle.com/datasets/umasrikakollu72/hindi-english-trunc ated-corpus Total Computation Time: ● The total computation time for the provided code snippet was measured from the initiation of the script to its completion. ● The computation involved various tasks, including installation of required packages, dataset downloading and extraction, model building, training, and evaluation. ● Time-consuming tasks such as model training and evaluation, dataset loading, and image processing contribute significantly to the overall computation time. ● The total computation time is calculated as the difference between the start time and end time, utilizing the time.time() function to capture precise timestamps. ● In this specific implementation, the total computation time was determined to be approximately 97 minutes

IMPLEMENTATION STEPS:

  1. Start 2. Data a. b.
  2. Data a. b. c. d. Acquisition: Acquirethedataset,primarilysourcedfromthe "Hindi_English_Truncated_Corpus.csv" file. Verify the integrity of the dataset and ensure it contains parallel English-Hindi sentence pairs. Preprocessing: Cleanthedatasetbyremovingduplicateentries. Normalize the text by stripping punctuation and digits. HandlespecialcharactersandsymbolsspecifictotheHindiscript. Prepare the dataset for model training.
  3. Model Development: a. Designthearchitectureoftheneuralmachinetranslation(NMT) model. b. Specify the sequence-to-sequence model with LSTM layers and attention mechanisms. c. Incorporateembeddinglayersforrepresentinginputwordsina continuous vector space. d. Define the optimizer (RMSprop) and loss function (categorical cross-entropy).
  4. Training: a. Initializethemodelparameters. b. Split the dataset into training and validation sets. c. Implementbatchtrainingusingacustomdatagenerator. d. Iterate over multiple epochs, updating the model parameters based on the computed gradients. e. Monitorthetrainingprocessforconvergenceandadjust hyperparameters as needed.
  5. Evaluation: a. Assessthemodel'sperformanceusingvalidationdata. b. Calculate metrics such as loss values and validation accuracy. c. Visualizetrainingandvalidationlossoverepochsusinglineplots. d. Optionally, conduct human evaluation to assess translation quality and fluency.
  6. Save Model: a. Savethetrainedmodelweightsandarchitectureforfutureuse.

CONCLUSION:

In conclusion, the development of an English to Hindi translator using neural machine translation techniques represents a significant step towards bridging the language barrier between these two languages. Leveraging the "Hindi_English_Truncated_Corpus" dataset, which is a cleaned CSV file derived from the IIT Bombay translation dataset, this project has demonstrated the feasibility and effectiveness of employing advanced NMT methodologies to facilitate cross-linguistic communication. The methodology employed in this project involved meticulous data preprocessing to ensure the quality and integrity of the dataset. Duplicate entries were removed, and text normalization techniques were applied to standardize the input data. Special attention was given to handling linguistic characteristics specific to the Hindi script, ensuring accurate tokenization and preprocessing. The model developed for the translator utilized a sequence-to-sequence architecture with LSTM layers and attention mechanisms. This architecture enables the model to capture complex linguistic patterns and nuances present in English sentences and produce contextually relevant translations in Hindi. Training the model involved iterative optimization using the RMSprop optimizer and categorical cross-entropy loss function. The training process was conducted over multiple epochs, with careful monitoring of training and validation loss values to assess model convergence and generalization capabilities. Evaluation of the trained model revealed promising results in terms of translation accuracy and fluency. The model demonstrated the ability to accurately translate English sentences into grammatically correct and contextually relevant Hindi sentences, thereby fulfilling the primary objective of the project. Moving forward, further refinements and optimizations can be explored to enhance the translator's performance, such as fine-tuning on additional datasets and experimenting with different model architectures. Additionally, the translator represents a valuable tool for various applications, including cross-cultural communication, language learning, and content localization, contributing to greater accessibility and inclusivity in a globalized world.

About

This project develops an English to Hindi translator using NMT with attention mechanisms in Keras. It aims for accuracy in translating English to grammatically correct Hindi, leveraging IIT Bombay's dataset, RMSprop optimizer, and rigorous evaluation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published