lilt / alignment-scripts Goto Github PK
View Code? Open in Web Editor NEWScripts to preprocess training and test data and to run fast_align and giza
License: MIT License
Scripts to preprocess training and test data and to run fast_align and giza
License: MIT License
Thank you for your great work "Adding Interpretable Attention to Neural Translation Models Improves Word Alignment", In this article, the alignment layer output is a target word, so how to get alignments results? the alignments results is generated by attention weights A?
Hi,
I have read your paper "End-to-End Neural Word Alignment Outperforms GIZA++" and "Adding Interpretable Attention to Neural Translation Models Improves Word Alignment". The methods mentioned in your work are very interesting and the experiment results are very good.
Now I am carrying out research in machine translation task, and my work needs good soft alignment results, so I want to implement “alignment layer” and “alignment optimization” to obtain soft alignments for each sentence pair.
Since I can't find the open source code, I need to confirm with you the following questions, or if it is convenient for you to provide open source code?
background
I have some details need to ask for your help since I am in trouble with reproducing the method (Add+SGD) results in the article "Adding Interpretable Attention to Neural Translation Models Improves Word Alignment".
my anlysis
I have reproduce the method (Rand + SGD) mentioned in this article, so I thought is my errors was caused by forward pass Initialization.
article discription
the article mentioned that: "Therefore, we run a forward pass of the complete Transformer network, extract the attention weights of the alignment layer and start the optimization process with these weights."
my understanding
my understanding is the forward pass model includes the alignment layer and the transformer structure. and I restore all parameters of the forward pass model which has trained.but I got the alignment results is 50% which is lower than your article.
Hi,
does this code only work on the languages specified? What about other languages like Chinese/Mandarin?
FYI, there are non-breaking space characters in some of the Ro-En and En-Fr training files, which causes the nonbreaking whitespace character to be interpreted as a vocabulary word. For instance, we see this in train/roen.lc.plustest.src.vcb:
41390 doliu 10
41391 38
41392 sogor 1
One offending file, for instance, is train/Romanian-English/training/Newspapers/2002.10.02.english.98880.0977.e:
"status seeking phenomenon in politics"
I fixed this problem by sending the training sentences through sed 's/\xC2\xA0/ /g' (source: https://rmoff.net/2019/01/21/replacing-utf8-non-breaking-space-with-bash/sed-on-the-mac/)
This should perhaps be added to your preprocessing pipeline, since I think the chances of the source published in 2003 being changed are low :)
Hi
Thank you for your work, I follow the usage instructions but I can't using it correctly. because I'm luck the corresponding data set. I have try to understand your code but I found that those dataset has some unfamiliar suffix. Those suffix hinder me to find correct data with data preprocessing.
Thank you for your kindness assistance.
Running scripts/create_fast_align_corpus.sh $FILE1 $FILE2 $OUT
results in:
sed: -e expression #1, char 9: unterminated `s' command
sed (GNU sed) 4.4
Distributor ID: Debian
Description: Debian GNU/Linux 9.13 (stretch)
Release: 9.13
As the script set spm_train --add_dummy_prefix 1, the resulting subword file begins with '▁'.
This makes the word alignment, which is converted from subword, all start from 1.
The issus do not affect the result of word fastalign, but completely break the fastalign using BPE tokenization.
Here show my result before the fix:
test.deen.bpe.word.grow-diagonal-final.talp: 64.4% (39.8%/32.0%/8127)
test.deen.bpe.word.grow-diagonal.talp: 63.8% (41.7%/31.7%/7647)
test.deen.bpe.word.intersection.talp: 65.7% (41.2%/29.2%/7127)
test.deen.bpe.word.reverse.talp: 65.9% (34.8%/33.4%/9700)
test.deen.bpe.word.talp: 65.7% (34.5%/34.2%/10009)
test.deen.bpe.word.union.talp: 65.9% (30.9%/38.4%/12582)
test.deen.grow-diagonal-final.talp: 27.7% (80.7%/65.5%/7964)
test.deen.grow-diagonal.talp: 27.0% (84.6%/64.1%/7418)
test.deen.intersection.talp: 28.0% (87.1%/61.3%/6863)
test.deen.reverse.talp: 32.0% (69.7%/66.4%/9414)
test.deen.talp: 28.4% (71.3%/71.8%/9932)
test.deen.union.talp: 31.8% (61.4%/77.0%/12483)
Here show my result (bpe part) after the fix (by -1 for all idx in converted talp file):
test.deen.bpe.word.talp.grow-diagonal-final.talp: 25.9% (81.7%/67.6%/8127)
test.deen.bpe.word.talp.grow-diagonal.talp: 25.2% (85.2%/66.5%/7647)
test.deen.bpe.word.talp.intersection.talp: 26.2% (87.3%/63.8%/7127)
test.deen.bpe.word.talp.union.talp: 31.1% (61.8%/78.1%/12582)
test.deen.bpe.word.reverse.talp.new: 30.4% (70.2%/68.9%/9700)
Reference from results/fastalign in the repo:
test.deen.bpe.word.grow-diagonal-final.talp: 27.0% (79.8%/67.2%/8270)
test.deen.bpe.word.grow-diagonal.talp: 26.4% (83.2%/65.9%/7755)
test.deen.bpe.word.intersection.talp: 27.2% (85.9%/63.1%/7171)
test.deen.bpe.word.reverse.talp: 30.9% (68.7%/69.4%/9985)
test.deen.bpe.word.talp: 29.8% (69.4%/71.1%/10099)
test.deen.bpe.word.union.talp: 32.7% (59.7%/77.4%/12913)
test.deen.grow-diagonal-final.talp: 27.7% (80.6%/65.5%/7964)
test.deen.grow-diagonal.talp: 27.0% (84.5%/64.1%/7421)
test.deen.intersection.talp: 28.0% (87.1%/61.3%/6863)
test.deen.reverse.talp: 32.0% (69.7%/66.4%/9421)
test.deen.talp: 28.5% (71.3%/71.8%/9930)
test.deen.union.talp: 31.8% (61.4%/77.0%/12488)
Am trying to run the alignment-scripts and am experiencing slight issues when running preprocessing. I was confused as to what this instruction meant, if anyone could give an example it might be helpful:
Export install locations for dependencies: export {MOSES_DIR,FASTALIGN_DIR,MGIZA_DIR}=/foo/bar
When running the code I get these issues:
./preprocess/train.sh: line 16: roen.src: No such file or directory
+ ../scripts/lowercase.py
+ for ln_pair in '"roen"' '"enfr"' '"deen"'
+ for suffix in '"src"' '"tgt"'
./preprocess/train.sh: line 16: roen.tgt: No such file or directory
+ ../scripts/lowercase.py
+ for suffix in '"src"' '"tgt"'
+ ../scripts/lowercase.py
+ wait
+ ../scripts/lowercase.py
./preprocess/train.sh: line 16: deen.src: No such file or directory
./preprocess/train.sh: line 16: deen.tgt: No such file or directory
+ cd -
/home/dl1051/alignment-scripts
+ for ln_pair in '"roen"' '"enfr"' '"deen"'
+ for suffix in '"src"' '"tgt"'
+ cat train/roen.lc.src test/roen.lc.src
cat: train/roen.lc.src: No such file or directory
might this have anything to do with the above instruction?
Thank you for sharing. I would like to use my own dataset to run eegiza. What should I do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.