vw が機能を抽出する方法について混乱しています。文字 ngram を機能として使用したいテキスト分類の問題を考えてみましょう。私の質問を説明する最も単純なケースでは、入力文字列は「aa」で、1 グラムの機能のみを使用します。したがって、この例は、次のように、カウントが 2 の単一の機能「a」で構成されている必要があります。
$ echo "1 |X a:2" | vw --noconstant --invert_hash f && grep '^X^' f
Num weight bits = 18
learning rate = 0.5
initial_t = 0
power_t = 0.5
using no cache
Reading datafile =
num sources = 1
average since example example current current current
loss last counter weight label predict features
1.000000 1.000000 1 1.0 1.0000 0.0000 1
finished run
number of examples per pass = 1
passes used = 1
weighted example sum = 1
weighted label sum = 1
average loss = 1
best constant = 1
total feature number = 1
X^a:108118:0.196698
ただし、文字列「aa」を vw に渡すと (文字間にスペースが入ります)、vw は次の 2 つの機能を報告します。
$ echo "1 |X a a" | vw --noconstant --invert_hash f && grep '^X^' f
Num weight bits = 18
learning rate = 0.5
initial_t = 0
power_t = 0.5
using no cache
Reading datafile =
num sources = 1
average since example example current current current
loss last counter weight label predict features
1.000000 1.000000 1 1.0 1.0000 0.0000 2
finished run
number of examples per pass = 1
passes used = 1
weighted example sum = 1
weighted label sum = 1
average loss = 1
best constant = 1
total feature number = 2
X^a:108118:0.375311
実際のモデルには 1 つの機能しか含まれていませんが (予想どおり)、その重み (0.375311) は最初のモデル (0.196698) とは異なります。
より高次の n グラムを使用して実際のデータセットでトレーニングを行う場合、使用する入力形式によって、平均損失に大きな違いが見られます。私は parser.cc のソース コードを調べましたが、もう少し時間があれば何が起こっているのか理解できるでしょう。しかし、誰かが上記の 2 つのケースの不一致 (バグですか?) を説明したり、ソースの関連部分を教えてくれたりしたら、助けていただければ幸いです。