繁体   English   中英

将Rasa NLU模型与python API而不是HTTP服务器一起使用

[英]Using Rasa NLU model with python API instead of HTTP server

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

是的,这在nlu.rasa.com上的文档(特别是本节)中进行了说明

从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")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM