File size: 1,691 Bytes
9ef89a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
langs=(en_de en_es en_fr en_it en_nl en_pt en_ru en_zh en_ko de_en es_en fr_en it_en nl_en pt_en ru_en zh_en ko_en)
# Read the file name from the command line

for lang in "${langs[@]}"; do
    echo $lang
    in_dir=/mnt/data/shared/multilingual_llm/experiments_megatron/continue_pretraining_tinyllama_all_20B/DumpHFDataset_baseline/Dataset.${lang}
    in_file=/mnt/data/shared/multilingual_llm/experiments_megatron/continue_pretraining_tinyllama_all_20B/DumpHFDataset_baseline/Dataset.${lang}/dataset.json
    out_dir_big=/mnt/data/shared/multilingual_llm/experiments_megatron/continue_pretraining_tinyllama_all_20B/DumpHFDataset/Dataset.${lang}/
    out_dir_small=/mnt/data/shared/multilingual_llm/experiments_megatron/continue_pretraining_tinyllama_all_20B/DumpHFDataset_annealing/Dataset.${lang}/
    mkdir -p $out_dir_big
    mkdir -p $out_dir_small

    # Calculate the total number of lines in the file
    total_lines=$(wc -l < "$in_file")

    # Calculate the line number for 87.5% of the file
    split_line=$(awk -v lines=$total_lines 'BEGIN {print int(lines * 0.875)}')
    echo calced split_line at $split_line

    # Split the file into two at the calculated line number
    awk -v split_lines=$split_line -v out_dir_big="$out_dir_big" -v out_dir_small="$out_dir_small" 'NR<=split_lines {print > (out_dir_big "/dataset.json")} NR>split_lines {print > (out_dir_small "/dataset.json")}' $in_file

    cp $in_dir/ducttape_exit_code.txt $in_dir/ducttape_stderr.txt $in_dir/ducttape_stdout.txt $in_dir/ducttape_task.sh $out_dir_big
    cp $in_dir/ducttape_exit_code.txt $in_dir/ducttape_stderr.txt $in_dir/ducttape_stdout.txt $in_dir/ducttape_task.sh $out_dir_small
done