
Tev1とJevをn8nで比較してみる。メールの「対応すべき」をDecision Modelに判断させてみる
Jev を緩やかに検証し始めていたら、ollama でも tev1 が提供されたり、Amazon も Jev clone 出したりと市場沸騰中だなというか、高速かつトークンどうやって減らそうかなという時代に入ってきましたね。
ゆくゆくは全てロジック回帰するんじゃないかと思いつつも、LLM が強い分野は勿論存在するので、緩やかにイロイロ試してみてはいます。
分かりやすいユースケースとして、届いたメールにすぐに判断すべきかどうか、があります。
せっかくなので、n8n で Tev1 と Jev の結果を比較しながら、返信すべきメールが届いたら OmniFocus へ登録するものを準備してみました。

まず手始めに Gmail だけでスタートです。他のメールも入れてみようかどうかはこれからの話です。
そこから二つ、Tev1(家庭内のLocal Ollama) と Jev の両方へ HTTP Request した結果をマージして、Tev1 でも優位な結果が出るなら Tev1 を採用し、層でもなければ Jev の結果を元にして判断するようにしました。
後でログをみれば、どちらの結果も比較ができるので面白いだろうなと思います。
Tev1/Jev への Request Body はこのようになっています。Tev1へ送る時の Json ですね。Jev の場合は model を "jev-latest" にすれば使えます。
{
"model": "tev1:4b",
"state": {{ JSON.stringify({
"from": $json.from || "",
"subject": $json.subject || "",
"body": ($json.text || "").slice(0, 4000),
"received_at": $json.date || ""
}) }},
"questions": {
"is_bulk_or_automated": {
"type": "noul",
"instructions": "Is this email a bulk or automated message rather than a message written to the recipient individually? Judge from `from`, `subject`, and `body`.",
"criteria": {
"true": "A newsletter, marketing or promotional email, product announcement, or automated notification such as a receipt, invoice, shipping update, security alert, password reset, SaaS or social-media digest, or a system-generated calendar message; or any message sent from a no-reply address.",
"false": "A message that a specific person wrote to the recipient, including replies in an ongoing thread and messages addressed to a small group of named people."
}
},
"requests_action": {
"type": "noul",
"instructions": "Does the sender ask the recipient to do something? Judge from `subject` and `body`. The text may be in Japanese or English.",
"criteria": {
"true": "The sender explicitly asks the recipient to reply, answer a question, approve or reject something, review a document, confirm, schedule or attend a meeting, or make a decision.",
"false": "The message only informs, thanks, acknowledges, or shares information for reference (FYI), or the only suggested action is a generic link such as 'read more', 'view online', or 'unsubscribe'."
}
},
"deadline": {
"type": "choice",
"instructions": "By when does the sender expect the recipient to respond or act? Judge from `subject` and `body`. If a date is given, compare it with `received_at`.",
"criteria": {
"within_1_day": "A deadline of today or tomorrow is stated or clearly implied, or urgent wording is used such as 'urgent', 'ASAP', 'immediately', 'by end of day', '至急', '大至急', '本日中', '明日まで'.",
"within_1_week": "A deadline within the next seven days is stated or clearly implied, such as 'by Friday', 'this week', 'before next week's meeting', '今週中', '来週の会議までに'.",
"none_or_later": "No deadline is stated or implied, the deadline is more than one week away, the sender says there is no rush ('whenever you have time', 'no rush', 'お手すきの際に'), or the email does not ask for any action."
}
}
}
}使い方としては、次の判断軸です。
"is_bulk_or_automated" が 0.5 以上ならどうでも良いメールです。
"request_action" が 0.7 以上なら対応すべきメールです。"deadline" で優先度を把握する方法もとれますね。
その判断軸で if ノードを入れた結果がこちらです。

[
{
"model": "tev1:4b",
"answers": {
"is_bulk_or_automated": {
"type": "noul",
"noul": 0.99921667266671
},
"requests_action": {
"type": "noul",
"noul": 0.0667609683113029
},
"deadline": {
"type": "choice",
"choice": "none_or_later",
"probabilities": {
"within_1_day": 0.00418065516632515,
"within_1_week": 0.018402902152984516,
"none_or_later": 0.9774164426806904
},
"confidence": 0.8919096430605247
}
},
"usage": {
"input_tokens": 4824,
"output_tokens": 4
},
"_source": "input1"
}
]今回のケースでは Tev1 の "confidence" が 0.8 以上なので、ある程度の信頼度があるかなと判断して、Tev1 の結果を採用しています。
Tev1 と Jev のどちらを採用するかは、Tev1 と Jev の結果をマージした後、 "code" ノードで次のように判断しています。
// $input.all() には tev1 と jev の両方の結果が入っています
const tev1 = $input.all()[0]?.json;
const jev = $input.all()[1]?.json;
// 例: tev1 に有効な回答があればそちらを優先、なければ jev を採用
if (tev1 && tev1.answers.deadline.confidence > 0.8) {
return [{ json: tev1 }];
} else {
return [{ json: jev }];
}複数の結果から、何をどのように採用するかはコードを書くしかなく、n8n って思った以上にコードから離れられないのだよな、と悲しみに暮れる日々です。