【问题标题】:HuggingFace API and ReactJS For SummaryHuggingFace API 和 ReactJS 总结
【发布时间】:2022-01-14 20:27:27
【问题描述】:

我正在尝试调用大型 bert 模型以执行摘要任务,但响应始终是相同的通用“CNN.com 将在每周旅行快照库中展示 iReporter 照片。请提交您的最佳照片下周美国的照片。下周三访问 CNN.com/Travel 以获取新的快照画廊。请与 CNN iReport 分享您在美国的最佳照片。这与我从维基百科的测试输入无关。我尝试使用“https://api-inference.huggingface.co/docs/node/html/detailed_pa​​rameters.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))

【问题讨论】:

    标签: reactjs nlp huggingface-transformers


    【解决方案1】:
    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();
    

    看来我没有正确传递脚本数据。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2022-06-30
    • 2014-05-13
    • 2021-03-09
    • 2016-12-09
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    相关资源
    最近更新 更多