| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# Copyright (c) 2016-present, Facebook, Inc. |
| 4 |
# All rights reserved. |
| 5 |
# |
| 6 |
# This source code is licensed under the MIT license found in the |
| 7 |
# LICENSE file in the root directory of this source tree. |
| 8 |
# |
| 9 |
|
| 10 |
# This script applies quantization to the models from Table 1 in: |
| 11 |
# Bag of Tricks for Efficient Text Classification, arXiv 1607.01759, 2016 |
| 12 |
|
| 13 |
set -e |
| 14 |
|
| 15 |
DATASET=( |
| 16 |
ag_news |
| 17 |
sogou_news |
| 18 |
dbpedia |
| 19 |
yelp_review_polarity |
| 20 |
yelp_review_full |
| 21 |
yahoo_answers |
| 22 |
amazon_review_full |
| 23 |
amazon_review_polarity |
| 24 |
) |
| 25 |
|
| 26 |
# These learning rates were chosen by validation on a subset of the training set. |
| 27 |
LR=( 0.25 0.5 0.5 0.1 0.1 0.1 0.05 0.05 ) |
| 28 |
|
| 29 |
RESULTDIR=result |
| 30 |
DATADIR=data |
| 31 |
|
| 32 |
echo 'Warning! Make sure you run the classification-results.sh script before this one' |
| 33 |
echo 'Otherwise you can expect the commands in this script to fail' |
| 34 |
|
| 35 |
for i in {0..7} |
| 36 |
do |
| 37 |
echo "Working on dataset ${DATASET[i]}" |
| 38 |
../../fasttext quantize -input "${DATADIR}/${DATASET[i]}.train" \ |
| 39 |
-output "${RESULTDIR}/${DATASET[i]}" -lr "${LR[i]}" \ |
| 40 |
-thread 4 -qnorm -retrain -epoch 5 -cutoff 100000 > /dev/null |
| 41 |
../../fasttext test "${RESULTDIR}/${DATASET[i]}.ftz" \ |
| 42 |
"${DATADIR}/${DATASET[i]}.test" |
| 43 |
done |