Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add missing files to run cc_net with a given config #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ dmypy.json

# temporary files
data_prep/data
*.csv
*.sav
data_prep/src/cc/log.txt
data_prep/src/cc/inference_output.json
Expand Down
23 changes: 13 additions & 10 deletions data_prep/cc/cc_net/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Makefile to install CC-Net and train the LMs.
# `make` or `make help` to get some help.


# Arguments:
lang?=en
process?=8
Expand Down Expand Up @@ -58,6 +59,7 @@ dl_lm:
lm: data/lm_sp/$(lang).sp.model data/lm_sp/$(lang).arpa.bin
# Computes a 5-gram LM for the given language -> make lang=it lm
# Restricted to the first NDOC_FOR_LM documents
mkdir -p data/lm_sp

sp: data/lm_sp/$(lang).sp.model
# Train a sentence piece model on Wikipedia -> make lang=it sp
Expand Down Expand Up @@ -111,20 +113,21 @@ data/lm_sp/%.sp.model: data/cirrus/txt/%.opening.txt
echo "Trained SentencePiece model with `wc -l $(basename $@).vocab` pieces"

data/cirrus/sp/%.opening.txt: data/cirrus/gz/%.json.gz data/lm_sp/%.sp.model
mkdir -p data/cirrus/sp
$(SPM_ENCODE) \
--model=$(word 2,$^) \
--output_format=piece \
< <(python get_wiki_cirrus.py opening --file $< --n_docs $(NDOC_FOR_LM)) \
< <(python cc_net/get_wiki_cirrus.py opening --file $< --n_docs $(NDOC_FOR_LM)) \
> $@

data/cirrus/txt/%.opening.txt: data/cirrus/gz/%.json.gz
python get_wiki_cirrus.py opening \
python cc_net/get_wiki_cirrus.py opening \
--n_docs $(NDOC_FOR_LM) \
--file $< --output $@

data/cirrus/gz/%.json.gz:
mkdir $(@D)
python get_wiki_cirrus.py dl --lang $(call get_lang,$(@F)) --output_dir $(@D)
mkdir -p $(@D)
python cc_net/get_wiki_cirrus.py dl --lang $(call get_lang,$(@F)) --output_dir $(@D)

clean:
# Remove intemediary files, dataset, third_party sources
Expand Down Expand Up @@ -155,11 +158,8 @@ bin/lmplz: third_party/kenlm
third_party/sentencepiece:
# Download sentencepiece sources: https://github.com/google/sentencepiece
mkdir -p $(@D)
wget -c -O $(@D)/sentencepiece.zip https://github.com/google/sentencepiece/archive/v0.1.83.zip
unzip -o -d $(@D) $(@D)/sentencepiece.zip
rm $(@D)/sentencepiece.zip
# remove the version id from the folder name
mv $(@D)/sentencepiece-* $@
git clone https://github.com/google/sentencepiece.git $(@D)/sentencepiece


bin/spm_train: third_party/sentencepiece
# Compiles sentencepiece binaries
Expand All @@ -172,7 +172,10 @@ bin/spm_train: third_party/sentencepiece
# $ cd $</build
# $ sudo make install
# $ sudo ldconfig -v

# if using MAC OS
# ifeq ($(shell uname -s),Darwin)
# sudo update_dyld_shared_cache

test:
python -m cc_net mine --config test
mkdir -p test_data/mini
Expand Down
Loading