myZagar / train_with_fasttext_classifier.sh
ye-nlp's picture
added shell scripts etc.
0d84e21
#!/bin/bash
# Define the base directory, input data, and the Python script
BASE_DIR="$HOME/exp/myNLP/lang_detect"
PYTHON_SCRIPT="$BASE_DIR/demo_usage.py"
INPUT_DATA="$BASE_DIR/data/all_languages.fasttext"
FASTTEXT_DIR="$BASE_DIR/profile/fasttext_class"
# Create the directory for FastText models if it doesn't exist
mkdir -p "$FASTTEXT_DIR"
# Loop over the desired n-grams (3 to 7)
for ngram in {3..7}; do
# Define the output model filename
model_output="${FASTTEXT_DIR}/${ngram}gram.model.bin"
# Training the model
time python3 "$PYTHON_SCRIPT" --mode train --input "$INPUT_DATA" \
--output "$model_output" --epoch 25 --lr 1.0 --wordNgrams $ngram \
--approach fasttext_class
echo "FastText model with ${ngram}-gram saved to $model_output"
done
echo "Training completed for all n-grams."