Skip to main content

Install Train and Test Moses Machine Translation Toolkit

Following are few easy steps with my experience with installing moses toolkit

I am doing it for ubuntu 64 bit (linux) system you can make an analogy for other installations.

1) Download the binary moses from here http://www.statmt.org/moses/?n=Moses.Packages In my case I used this - http://www.statmt.org/~jie/linux/moses-2.1-1/moses_2.1-1_amd64.deb


2) Install that with following command in the relevant directory
 sudo dpkg -i http://www.statmt.org/~jie/linux/moses-2.1-1/moses_2.1-1_amd64.deb

This install moses and all other relevant tools like GIZA and Language Modeler (IRSTLM) in "/opt" directory. You can copy that to wherever you want or leave it as it is there.

3)  Now goto /moses folder in /opt and move all contents of /giza++-v1.0.7 to a new folder /tools in /moses. You can avoid this, but then need to make some changes in training script below, so don't avoid it for the sake of introduction.

4) Creating Language Model: Your environment is set up. Now create a language model using target language corpus using following shell script. You are in your workdirectory say - YF

/opt/moses/irstlm-5.70.04/bin/add-start-end.sh \
   < YF/monolingualFilepath.hin \
   > LMV1.fl

export IRSTLM=/opt/moses/irstlm-5.70.04; 

/opt/moses/irstlm-5.70.04/bin/build-lm.sh \
   -i LMV1.fl                  \
   -t ./tmp  -p -s improved-kneser-ney -o LMV2.fl

/opt/moses/irstlm-5.70.04/bin/compile-lm  \
   --text=yes \
   LMV2.fl.gz \
   MYLM.lm

/opt/moses/bin/build_binary \
   MYLM.lm \
   MyLm.lm.bin.hi

I you don't want to worry much about what is happening, name your monolingual input data file for LM creation as - monolingualFilepath.hin and put in the directory where this script will be run i.e. YF. And if you understand what's it. Please go ahead and do as as you want the files to be named.

5) The above step creates new files move all new files to a new folder and name it /lm. Your language model is ready of which you will be using the MyLM.lm.bin.hin version.

Check you built binarized LM for Hindi i.e. MyLM.lm.bin.hin with:

echo "यह हिंदी वाक्य है  क्या ?" | /opt/moses/bin/query MyLm.lm.bin.hi 

It gives some numbers per word and that means you are done with LM creation.

6) Training the English to Hindi SMT system: Keep your bi-lingual training corpus in a folder called /corpus inside /YF and name files traincorpus.hin and traincorpus.eng. And then run the following script to train a English to Hindi translation system.

/opt/moses/scripts/training/train-model.perl \
    -cores 4 \
    -root-dir /YF \
    -corpus YF/corpus/traincorpus -f eng -e hin \
    -alignment grow-diag-final-and \
    -reordering msd-bidirectional-fe \
    -lm 0:3:YF/lm/MyLm.lm.bin.hi:8 \
    -external-bin-dir /opt/moses/tools >& YF/trainingLog.out


 7) It will take some time depending on the training data size. Once it creates the moses.ini, we can say that the training is done. Now you can try the trained system by executing following command -

/opt/moses/bin/moses -f YF/model/moses.ini 

It will ask for the English sentence and will output the Hindi. 
And we are DONE!










Comments

Popular posts from this blog

Navigating the JOBS in the times of AI

One of last staturdays I spoke to first-year students on the opening day of their year. Eighteen, most of them. Some had come for computer science, some for the humanities, some for management or commerce or the pure sciences. Bright, a little restless, and all of them carrying the same question without quite saying it: now that AI has shown up, what happens to my career? I want to write down what I told them, because I don't think it's a question only eighteen-year-olds are asking. Why do jobs even exist? Strip everything away and a job is just a problem somebody is paid to solve. People need food, health, a roof, education, safety, someone to talk to. Those needs don't go anywhere, and every one of them is somebody's work. What's easy to miss is that the needs stay put while the way we meet them gets rewritten every couple of generations. Farming gave us a food surplus. The steam engine gave us factories. Electricity, mass production. Computers, the information...

आपण महाराष्ट्राच्या संस्कृतीचे अजूनही खरंच पाईक आहोत कि भरकटलोत ?

महाराष्ट्र दिनाच्या सगळ्यांना शुभेच्छा. तसं ज्याला आज आपण महाराष्ट्र म्हणतो, त्याचा हा आधुनिक जन्म दिवस. महाराष्ट्र कधी पासून अस्तित्वात असेल? म्हणजे इथली संस्कृती, आपण जे वागतो, जगतो, बोलतो, राहतो वगैरे वगैरे. कधी पासून हे सगळं असं असावं? याचं उत्तर आपल्या सारख्या सामान्यांपेक्षा हा ज्या कोणत्या विषयाचा विषय असेल त्या विषयाच्या निष्णातांना जास्त चांगलं माहित असेल. तरी, आपला एक सामान्य माणूस म्हणून या भूमीवर अधिकार आहे आणि त्याच अधिकाराने आपण आपला एक अंदाज लावू शकतो. म्हणजे ज्ञानेश्वर-नामदेव इथे आपल्याला या मराठी राज्याची - महाराष्ट्राची - सुरुवात झाली असावी, असा अंदाज लावता येईल.म्हणजे आजच्या आपल्या मराठी म्हणता येईल अशा संस्कृतीची सुरवात तिथून झाली असं आपण समजू शकतो. किंवा मला जे मांडायचं त्या साठी ते सोयीचं आहे म्हणून समजा हवं तर! पण मीच कशाला वारकरी साहित्यातच संत बहिणाबाईंनी लिहून ठेवलयं - संतकृपा झाली । इमारत फळा आली ॥ १ ॥ ज्ञानदेवें रचिला पाया । उभारिलें देवालया ॥ २ ॥ नामा तयाचा किंकर । तेणें रचिलें तें आवार ॥ ३ ॥ जनार्दन एकनाथ । खांब दिधला भागवत ॥ ४ ॥ तुका झालासे कळस । भजन करा ...