【问题标题】:Using Rasa NLU model with python API instead of HTTP server使用带有 python API 的 Rasa NLU 模型而不是 HTTP 服务器
【发布时间】:2018-06-25 09:10:38
【问题描述】:

有没有办法在没有 HTTP 服务器的情况下使用 https://nlu.rasa.com 模型?我想将它用作 python 库/模块。

【问题讨论】:

  • 我认为您可以使用此处的excerpt 来做到这一点。
  • 是的,在我发布问题后立即找到该页面
  • 但在大多数情况下,您需要一个 REST API 来获取有效负载或对其进行训练。

标签: python rasa-nlu


【解决方案1】:

是的,这在 nlu.rasa.com 的文档中有记录,特别是 this section

从 0.12.3 版开始:

培训

from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Trainer
from rasa_nlu import config

training_data = load_data('data/examples/rasa/demo-rasa.json')
trainer = Trainer(config.load("sample_configs/config_spacy.yml"))
trainer.train(training_data)
model_directory = trainer.persist('./projects/default/')  # Returns the directory the model is stored in

解析

from rasa_nlu.model import Metadata, Interpreter

# where `model_directory points to the folder the model is persisted in
interpreter = Interpreter.load(model_directory)

interpreter.parse(u"The text I want to understand")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    • 2020-11-06
    相关资源
    最近更新 更多