From 972298e0c91d0360f0f9efe3685e0f28f78f5bca Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 6 Nov 2017 14:42:24 +0100 Subject: [PATCH] Update Pipe component docs and training API --- website/api/language.jade | 4 +-- website/api/pipe.jade | 55 ++++++++++++++++++++++++++++++++++----- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/website/api/language.jade b/website/api/language.jade index 1bc9b601f..1ea129295 100644 --- a/website/api/language.jade +++ b/website/api/language.jade @@ -200,8 +200,8 @@ p +cell Config parameters. +row("foot") - +cell yields - +cell tuple + +cell returns + +cell callable +cell An optimizer. +h(2, "use_params") Language.use_params diff --git a/website/api/pipe.jade b/website/api/pipe.jade index c2afbde12..7770d7bad 100644 --- a/website/api/pipe.jade +++ b/website/api/pipe.jade @@ -262,13 +262,13 @@ p +tag method p - | Initialize the pipe for training, using data exampes if available. If no - | model has been initialized yet, the model is added. + | Initialise the pipe for training, using data exampes if available. If no + | model has been initialised yet, the model is added. +aside-code("Example"). #{VARNAME} = #{CLASSNAME}(nlp.vocab) nlp.pipeline.append(#{VARNAME}) - #{VARNAME}.begin_training(pipeline=nlp.pipeline) + optimizer = #{VARNAME}.begin_training(pipeline=nlp.pipeline) +table(["Name", "Type", "Description"]) +row @@ -285,6 +285,36 @@ p | Optional list of #[+api("pipe") #[code Pipe]] components that | this component is part of. + +row + +cell #[code sgd] + +cell callable + +cell + | An optional optimizer. Should take two arguments #[code weights] + | and #[code gradient], and an optional ID. Will be created via + | #[+api(CLASSNAME.toLowerCase() + "#create_optimizer") #[code create_optimizer]] + | if not set. + + +row("foot") + +cell returns + +cell callable + +cell An optimizer. + ++h(2, "create_optimizer") #{CLASSNAME}.create_optimizer + +tag method + +p + | Create an optmizer for the pipeline component. + ++aside-code("Example"). + #{VARNAME} = #{CLASSNAME}(nlp.vocab) + optimizer = #{VARNAME}.create_optimizer() + ++table(["Name", "Type", "Description"]) + +row("foot") + +cell returns + +cell callable + +cell The optimizer. + +h(2, "use_params") #{CLASSNAME}.use_params +tag method +tag contextmanager @@ -309,9 +339,14 @@ p Modify the pipe's model, to use the given parameter values. p Add a new label to the pipe. -+aside-code("Example"). - #{VARNAME} = #{CLASSNAME}(nlp.vocab) - #{VARNAME}.add_label('MY_LABEL') +if CLASSNAME == "Tagger" + +aside-code("Example"). + #{VARNAME} = #{CLASSNAME}(nlp.vocab) + #{VARNAME}.add_label('MY_LABEL', {POS: 'NOUN'}) +else + +aside-code("Example"). + #{VARNAME} = #{CLASSNAME}(nlp.vocab) + #{VARNAME}.add_label('MY_LABEL') +table(["Name", "Type", "Description"]) +row @@ -319,6 +354,14 @@ p Add a new label to the pipe. +cell unicode +cell The label to add. + if CLASSNAME == "Tagger" + +row + +cell #[code values] + +cell dict + +cell + | Optional values to map to the label, e.g. a tag map + | dictionary. + +h(2, "to_disk") #{CLASSNAME}.to_disk +tag method