@@ -15,12 +15,12 @@ fastNLP 是一款轻量级的 NLP 处理套件。你既可以使用它快速地 | |||||
内置组件 | 内置组件 | ||||
------------ | ------------ | ||||
大部分用于的 NLP 任务神经网络都可以看做由编码(encoder)、聚合(aggregator)、解码(decoder)三中模块组成。 | |||||
大部分用于的 NLP 任务神经网络都可以看做由编码(encoder)、聚合(aggregator)、解码(decoder)三种模块组成。 | |||||
.. image:: figures/text_classification.png | .. image:: figures/text_classification.png | ||||
fastNLP 在 :mod:`~fastNLP.modules` 模块中内置了三个模块的诸多组件,可以帮助用户快速搭建自己所需的网络。 | |||||
三个模块的功能和常见组件如下: | |||||
fastNLP 在 :mod:`~fastNLP.modules` 模块中内置了三种模块的诸多组件,可以帮助用户快速搭建自己所需的网络。 | |||||
三种模块的功能和常见组件如下: | |||||
+-----------------------+-----------------------+-----------------------+ | +-----------------------+-----------------------+-----------------------+ | ||||
| module type | functionality | example | | | module type | functionality | example | | ||||
@@ -1,6 +1,10 @@ | |||||
""" | """ | ||||
使用 fastNLP 实现的一系列常见模型,具体有: | |||||
TODO 详细介绍的表格,与主页相对应 | |||||
fastNLP 在 :mod:`~fastNLP.models` 模块中内置了如 :class:`~fastNLP.models.CNNText` 、 | |||||
:class:`~fastNLP.models.SeqLabeling` 等完整的模型,以供用户直接使用。 | |||||
.. todo:: | |||||
这些模型的介绍(与主页一致) | |||||
""" | """ | ||||
__all__ = ["CNNText", "SeqLabeling", "ESIM", "STSeqLabel", "AdvSeqLabel", "STNLICls", "STSeqCls"] | __all__ = ["CNNText", "SeqLabeling", "ESIM", "STSeqLabel", "AdvSeqLabel", "STNLICls", "STSeqCls"] | ||||
@@ -1,10 +1,25 @@ | |||||
""" | """ | ||||
modules 模块是 fastNLP 的重要组成部分,它实现了神经网络构建中常见的组件, | |||||
具体包括 TODO | |||||
大部分用于的 NLP 任务神经网络都可以看做由编码 :mod:`~fastNLP.modules.encoder` 、 | |||||
聚合 :mod:`~fastNLP.modules.aggregator` 、解码 :mod:`~fastNLP.modules.decoder` 三种模块组成。 | |||||
可以和 PyTorch 结合使用?TODO | |||||
.. image:: figures/text_classification.png | |||||
TODO __all__ 里面多暴露一些 | |||||
:mod:`~fastNLP.modules` 中实现了 fastNLP 提供的诸多模块组件,可以帮助用户快速搭建自己所需的网络。 | |||||
三种模块的功能和常见组件如下: | |||||
+-----------------------+-----------------------+-----------------------+ | |||||
| module type | functionality | example | | |||||
+=======================+=======================+=======================+ | |||||
| encoder | 将输入编码为具有具 | embedding, RNN, CNN, | | |||||
| | 有表示能力的向量 | transformer | | |||||
+-----------------------+-----------------------+-----------------------+ | |||||
| aggregator | 从多个向量中聚合信息 | self-attention, | | |||||
| | | max-pooling | | |||||
+-----------------------+-----------------------+-----------------------+ | |||||
| decoder | 将具有某种表示意义的 | MLP, CRF | | |||||
| | 向量解码为需要的输出 | | | |||||
| | 形式 | | | |||||
+-----------------------+-----------------------+-----------------------+ | |||||
""" | """ | ||||
from . import aggregator | from . import aggregator | ||||
@@ -16,3 +31,20 @@ from .dropout import TimestepDropout | |||||
from .encoder import * | from .encoder import * | ||||
from .utils import get_embeddings | from .utils import get_embeddings | ||||
__all__ = [ | |||||
"LSTM", | |||||
"Embedding", | |||||
"ConvMaxpool", | |||||
"BertModel", | |||||
"MaxPool", | |||||
"MaxPoolWithMask", | |||||
"AvgPool", | |||||
"MultiHeadAttention", | |||||
"BiAttention", | |||||
"MLP", | |||||
"ConditionalRandomField", | |||||
"viterbi_decode", | |||||
"allowed_transitions", | |||||
] |
@@ -1,7 +1,14 @@ | |||||
__all__ = ["MaxPool", "MaxPoolWithMask", "AvgPool", "MultiHeadAttention", "BiAttention"] | |||||
from .pooling import MaxPool | from .pooling import MaxPool | ||||
from .pooling import MaxPoolWithMask | from .pooling import MaxPoolWithMask | ||||
from .pooling import AvgPool | from .pooling import AvgPool | ||||
from .pooling import MeanPoolWithMask | from .pooling import MeanPoolWithMask | ||||
from .attention import MultiHeadAttention, BiAttention | from .attention import MultiHeadAttention, BiAttention | ||||
__all__ = [ | |||||
"MaxPool", | |||||
"MaxPoolWithMask", | |||||
"AvgPool", | |||||
"MultiHeadAttention", | |||||
"BiAttention" | |||||
] |
@@ -1,5 +1,11 @@ | |||||
__all__ = ["MLP", "ConditionalRandomField", "viterbi_decode", "allowed_transitions"] | |||||
from .CRF import ConditionalRandomField | from .CRF import ConditionalRandomField | ||||
from .MLP import MLP | from .MLP import MLP | ||||
from .utils import viterbi_decode | from .utils import viterbi_decode | ||||
from .CRF import allowed_transitions | from .CRF import allowed_transitions | ||||
__all__ = [ | |||||
"MLP", | |||||
"ConditionalRandomField", | |||||
"viterbi_decode", | |||||
"allowed_transitions" | |||||
] |
@@ -3,7 +3,9 @@ from .embedding import Embedding | |||||
from .lstm import LSTM | from .lstm import LSTM | ||||
from .bert import BertModel | from .bert import BertModel | ||||
__all__ = ["LSTM", | |||||
"Embedding", | |||||
"ConvMaxpool", | |||||
"BertModel"] | |||||
__all__ = [ | |||||
"LSTM", | |||||
"Embedding", | |||||
"ConvMaxpool", | |||||
"BertModel" | |||||
] |