HuggingFace API 和 ReactJS 总结
HuggingFace API and ReactJS For Summary
我正在尝试调用 large-bert 模型来执行摘要任务,但响应始终是相同的通用“CNN.com 将在每周旅行快照图库中展示 iReporter 照片。请提交下周 U.S 的最佳照片。下周三访问 CNN。com/Travel 以获取新的快照画廊。请与 CNN iReport 分享您对美国的最佳照片。”这与我从维基百科的测试输入无关。我尝试根据“https://api-inference.huggingface.co/docs/node/html/detailed_parameters.html#summarization-task”对我的代码进行建模,这对 nodeJS 更具体,但我认为应该非常相似。
我想知道是否有解释。我是否遗漏了某些输入或传递了错误的数据?
以下是尝试的代码
const response = await fetch(
"https://api-inference.huggingface.co/models/facebook/bart-large-cnn",
{
headers: { Authorization: `Bearer ${API_TOKEN}` },
method: "POST",
data: {
"inputs": JSON.stringify(script),
"parameters": {"do_sample": false},
},
}
);
const result = await response.json();
setSummation(JSON.stringify(result[0].summary_text))
const response = await fetch(
"https://api-inference.huggingface.co/models/facebook/bart-large-cnn",
{
headers: { Authorization: `Bearer ${API_TOKEN}` },
method: "POST",
body: JSON.stringify(script),
}
);
const result = await response.json();
看来我没有正确传递脚本数据。
我正在尝试调用 large-bert 模型来执行摘要任务,但响应始终是相同的通用“CNN.com 将在每周旅行快照图库中展示 iReporter 照片。请提交下周 U.S 的最佳照片。下周三访问 CNN。com/Travel 以获取新的快照画廊。请与 CNN iReport 分享您对美国的最佳照片。”这与我从维基百科的测试输入无关。我尝试根据“https://api-inference.huggingface.co/docs/node/html/detailed_parameters.html#summarization-task”对我的代码进行建模,这对 nodeJS 更具体,但我认为应该非常相似。
我想知道是否有解释。我是否遗漏了某些输入或传递了错误的数据?
以下是尝试的代码
const response = await fetch(
"https://api-inference.huggingface.co/models/facebook/bart-large-cnn",
{
headers: { Authorization: `Bearer ${API_TOKEN}` },
method: "POST",
data: {
"inputs": JSON.stringify(script),
"parameters": {"do_sample": false},
},
}
);
const result = await response.json();
setSummation(JSON.stringify(result[0].summary_text))
const response = await fetch(
"https://api-inference.huggingface.co/models/facebook/bart-large-cnn",
{
headers: { Authorization: `Bearer ${API_TOKEN}` },
method: "POST",
body: JSON.stringify(script),
}
);
const result = await response.json();
看来我没有正确传递脚本数据。