使用 Rasa NLU 模型 python API 而不是 HTTP 服务器
Using Rasa NLU model with python API instead of HTTP server
有没有办法在没有 HTTP 服务器的情况下使用 https://nlu.rasa.com 模型?我想将其用作 python library/module。
是的,这在 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")
有没有办法在没有 HTTP 服务器的情况下使用 https://nlu.rasa.com 模型?我想将其用作 python library/module。
是的,这在 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")