开源技术 * IBM 微讲堂:Kubeflow 系列(观看回放 | 下载讲义) 了解详情

审查文本生成器

概述

审查文本生成器(Review Text Generator)可生成与 Yelp® 评论数据集中的文本类似的英语文本。此模型由一个具有 2 个 LSTM 层的递归神经网络组成,这个模型已根据 Yelp® 评论数据进行了训练。此模型的输入是一段文本(用来为生成模型提供种子),而输出是一段生成的文本。此模型基于 IBM Code Pattern:使用 Keras 和 Tensorflow 训练深度学习语言模型

模型元数据

领域 应用 行业 框架 训练数据 输入数据格式
文本/NLP 语言建模 普通 Keras Kaggle Yelp 评论数据集 文本

参考资料

许可

组件 许可 链接
模型 GitHub 代码库 Apache 2.0 许可
模型权重 Apache 2.0 许可
测试资产 自定义 资产 README 文件

此模型的可用部署选项

可以使用以下机制来部署此模型:

  • 通过 Dockerhub 进行部署:

    docker run -it -p 5000:5000 codait/max-review-text-generator
    
  • 在 Red Hat OpenShift 上部署:

    遵循本教程中有关 OpenShift Web 控制台或 OpenShift Container Platform CLI 的操作说明,并指定 codait/max-review-text-generator 作为镜像名称。

  • 在 Kubernetes 上部署:

    kubectl apply -f https://raw.githubusercontent.com/IBM/MAX-Review-Text-Generator/master/max-review-text-generator.yaml
    

    可以在此处找到有关如何将此 MAX 模型部署到 IBM Cloud 上的生产环境的更详细的教程。

  • 本地:遵循 GitHub 上的模型 README 文件中的操作说明

用法示例

在部署模型后,可以在命令行中测试该模型。例如:

curl -X POST --header 'Content-Type: application/json' -d '{"seed_text": "heart be still i loved this place. way better than i expected. i had the spicy noodles and they were delicious, flavor great and quality was on point. for desert the sticky rice with mango, i dream about it now. highly recommend if you are in the mood for "}' 'http://localhost:5000/model/predict'

您应该会看到与下面类似的 JSON 响应。但需注意,由于字符生成步骤使用的是随机采样,因此您应该会在响应中的 generated_text 字段中看到不同的结果。

{
  "status": "ok",
  "prediction": {
    "seed_text": "heart be still i loved this place. way better than i expected. i had the spicy noodles and they were delicious, flavor great and quality was on point. for desert the sticky rice with mango, i dream about it now. highly recommend if you are in the mood for ",
    "generated_text": "made to make the coffee is friendly food in breads is delicy dep much to spice good, we went and bee",
    "full_text": "heart be still i loved this place. way better than i expected. i had the spicy noodles and they were delicious, flavor great and quality was on point. for desert the sticky rice with mango, i dream about it now. highly recommend if you are in the mood for made to make the coffee is friendly food in breads is delicy dep much to spice good, we went and bee"
  }
}

资源与贡献

如果您有兴趣为 Model Asset Exchange 项目做出贡献或有任何疑问,遵循此处的操作说明。

本文翻译自:Review Text Generator(2018-09-21)