Giter Site home page Giter Site logo

zikaiguo / fastnlp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fastnlp/fastnlp

0.0 0.0 0.0 17.92 MB

fastNLP: A Modularized and Extensible NLP Framework. Currently still in incubation.

License: Apache License 2.0

Python 97.97% Jupyter Notebook 1.99% Shell 0.05%

fastnlp's Introduction

fastNLP

Build Status codecov Pypi Hex.pm Documentation Status

fastNLP 是一款轻量级的 NLP 处理套件。你既可以使用它快速地完成一个序列标注(NER、POS-Tagging等)、中文分词、文本分类Matching指代消解摘要等任务; 也可以使用它构建许多复杂的网络模型,进行科研。它具有如下的特性:

  • 统一的Tabular式数据容器,让数据预处理过程简洁明了。内置多种数据集的DataSet Loader,省去预处理代码;
  • 多种训练、测试组件,例如训练器Trainer;测试器Tester;以及各种评测metrics等等;
  • 各种方便的NLP工具,例如预处理embedding加载(包括ELMo和BERT); 中间数据cache等;
  • 详尽的中文文档教程以供查阅;
  • 提供诸多高级模块,例如Variational LSTM, Transformer, CRF等;
  • 在序列标注、中文分词、文本分类、Matching、指代消解、摘要等任务上封装了各种模型可供直接使用,详细内容见 reproduction 部分;
  • 便捷且具有扩展性的训练器; 提供多种内置callback函数,方便实验记录、异常捕获等。

安装指南

fastNLP 依赖以下包:

  • numpy>=1.14.2
  • torch>=1.0.0
  • tqdm>=4.28.1
  • nltk>=3.4.1
  • requests
  • spacy

其中torch的安装可能与操作系统及 CUDA 的版本相关,请参见 PyTorch 官网 。 在依赖包安装完成后,您可以在命令行执行如下指令完成安装

pip install fastNLP
python -m spacy download en

目前使用pip安装fastNLP的版本是0.4.1,有较多功能仍未更新,最新内容以master分支为准。 fastNLP0.5.0版本将在近期推出,请密切关注。

fastNLP教程

内置组件

大部分用于的 NLP 任务神经网络都可以看做由词嵌入(embeddings)和两种模块:编码器(encoder)、解码器(decoder)组成。

以文本分类任务为例,下图展示了一个BiLSTM+Attention实现文本分类器的模型流程图:

fastNLP 在 embeddings 模块中内置了几种不同的embedding:静态embedding(GloVe、word2vec)、上下文相关embedding (ELMo、BERT)、字符embedding(基于CNN或者LSTM的CharEmbedding)

与此同时,fastNLP 在 modules 模块中内置了两种模块的诸多组件,可以帮助用户快速搭建自己所需的网络。 两种模块的功能和常见组件如下:

类型 功能 例子
encoder 将输入编码为具有具有表示能力的向量 embedding, RNN, CNN, transformer
decoder 将具有某种表示意义的向量解码为需要的输出形式 MLP, CRF

项目结构

fastNLP的大致工作流程如上图所示,而项目结构如下:

fastNLP 开源的自然语言处理库
fastNLP.core 实现了核心功能,包括数据处理组件、训练器、测试器等
fastNLP.models 实现了一些完整的神经网络模型
fastNLP.modules 实现了用于搭建神经网络模型的诸多组件
fastNLP.embeddings 实现了将序列index转为向量序列的功能,包括读取预训练embedding等
fastNLP.io 实现了读写功能,包括数据读入,模型读写等

In memory of @FengZiYjun. May his soul rest in peace. We will miss you very very much!

fastnlp's People

Contributors

2017alan avatar augc000 avatar chenkaiyu1997 avatar dqwang122 avatar fengziyjun avatar fftyyy avatar h00jiang avatar hazelnutsgz avatar henryl7 avatar keezen avatar kunyaa avatar lyhuang18 avatar ohlionel avatar srwyg avatar violetyao avatar willqvq avatar wlhgtc avatar xiaoxiong-liu avatar xpqiu avatar xuyige avatar yhcc avatar zide05 avatar zikaiguo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.