gpt4 book ai didi

javascript - 如何在毒性分类器中添加更多单词

转载 作者:行者123 更新时间:2023-11-29 22:49:34 26 4
gpt4 key购买 nike

有没有办法我可以添加更多的单词毒性分类器 ?

这就是我目前使用的只是一个基本的脚本来自github页面中给出的示例

// The minimum prediction confidence.
const threshold = 0.9;

// Load the model. Users optionally pass in a threshold and an array of
// labels to include.
toxicity.load(threshold).then(model => {
const sentences = ['you suck'];

model.classify(sentences).then(predictions => {
// `predictions` is an array of objects, one for each prediction head,
// that contains the raw probabilities for each input along with the
// final prediction in `match` (either `true` or `false`).
// If neither prediction exceeds the threshold, `match` is `null`.

console.log(predictions);
/*
prints:
{
"label": "identity_attack",
"results": [{
"probabilities": [0.9659664034843445, 0.03403361141681671],
"match": false
}]
},
{
"label": "insult",
"results": [{
"probabilities": [0.08124706149101257, 0.9187529683113098],
"match": true
}]
},
...
*/
});
});

https://github.com/tensorflow/tfjs-models/tree/master/toxicity

最佳答案

您可以在预测的数组句子中添加更多单词:

const sentences = ['you suck', 'add whatever you want'];

但是,您不能更改模型的标签。您只能在模型训练期间这样做。在移植到 js 之前,使用 python 训练了毒性模型。所以你只能通过重新训练python模型来改变标签。

关于javascript - 如何在毒性分类器中添加更多单词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57723593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com