• This repository has been archived on 24/Jan/2024
  • Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    Python
  • Created about 5 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Fast, Flexible, Extensible and Easy-to-use NLP Large-scale Pretraining and Multi-task Learning Framework.

PaddlePALM

English | 简体中文

PaddlePALM (PArallel Learning from Multi-tasks) is a fast, flexible, extensible and easy-to-use NLP large-scale pretraining and multi-task learning framework. PaddlePALM is a high level framework aiming at fastly developing high-performance NLP models.

With PaddlePALM, it is easy to achieve effecient exploration of robust learning of NLP models with multiple auxilary tasks. For example, based on PaddlePALM, the produced robust MRC model, D-Net, has achieved the 1st place in EMNLP2019 MRQA track.

Sample

MRQA2019 Leaderboard

Beyond the research scope, PaddlePALM has been applied on Baidu Search Engine to seek for more accurate user query understanding and answer mining, which implies the high reliability and performance of PaddlePALM.

Features:

  • Easy-to-use: with PALM, 8 steps to achieve a typical NLP task. Moreover, all basic components (e.g., the model backbone, dataset reader, task output head, optimizer...) have been decoupled, which allows the replacement of any component to other candidates with quite minor changes of your code.
  • Built-in Popular NLP Backbones and Pre-trained models: multiple state-of-the-art general purpose model architectures and pretrained models (e.g., BERT,ERNIE,RoBERTa,...) are built-in.
  • Easy to play Multi-task Learning: only one API is needed for jointly training of several tasks with parameters reusement.
  • Support train/eval with Multi-GPUs: automatically recognize and adapt to multiple gpus mode to accelerate training and inference.
  • Pre-training friendly: self-supervised tasks (e.g., mask language model) are built-in to facilitate pre-training. Easy to train from scratch.
  • Easy to Customize: support customized development of any component (e.g, backbone, task head, reader and optimizer) with reusement of pre-defined ones, which gives developers high flexibility and effeciency to adapt for diverse NLP scenes.

You can easily re-produce following competitive results with minor codes, which covers most of NLP tasks such as classification, matching, sequence labeling, reading comprehension, dialogue understanding and so on. More details can be found in examples.

Dataset
chnsenticorp Quora Question Pairs matching MSRA-NER
(SIGHAN2006)
CMRC2018

Metric

accuracy
f1-score
accuracy
f1-score
f1-score
em
f1-score
test
test
test
dev
ERNIE Base 95.8 95.8 86.2 82.2 99.2 64.3 85.2

Overview

Sample

Architecture Diagram

PaddlePALM is a well-designed high-level NLP framework. You can efficiently achieve supervised learning, unsupervised/self-supervised learning, multi-task learning and transfer learning with minor codes based on PaddlePALM. There are three layers in PaddlePALM architecture, i.e., component layer, trainer layer and high-level trainer layer from bottom to top.

In component layer, PaddlePALM supplies 6 decoupled components to achieve a NLP task. Each component contains rich pre-defined classes and a Base class. Pre-defined classes are aiming at typical NLP tasks, and the base class is to help users develop a new Class (based on pre-defined ones or from the base).

The trainer layer is to establish a computation graph with selected components and do training and predicting. The training strategy, model saving and loading, evaluation and predicting procedures are described in this layer. Noted a trainer can only process one task.

The high-level trainer layer is for complicated learning and inference strategy, e.g., multi-task learning. You can add auxilary tasks to train robust NLP models (improve test set and out-of-domain performance of a model), or jointly training multiple related tasks to gain more performance for each task.

module illustration
paddlepalm an open source NLP pretraining and multitask learning framework, built on paddlepaddle.
paddlepalm.reader a collection of elastic task-specific dataset readers.
paddlepalm.backbone a collection of classic NLP representation models, e.g., BERT, ERNIE, RoBERTa.
paddlepalm.head a collection of task-specific output layers.
paddlepalm.lr_sched a collection of learning rate schedualers.
paddlepalm.optimizer a collection of optimizers.
paddlepalm.downloader a download module for pretrained models with configure and vocab files.
paddlepalm.Trainer the core unit to start a single task training/predicting session. A trainer is to build computation graph, manage training and evaluation process, achieve model/checkpoint saving and pretrain_model/checkpoint loading.
paddlepalm.MultiHeadTrainer the core unit to start a multi-task training/predicting session. A MultiHeadTrainer is built based on several Trainers. Beyond the inheritance of Trainer, it additionally achieves model backbone reuse across tasks, trainer sampling for multi-task learning, and multi-head inference for effective evaluation and prediction.

Installation

PaddlePALM support both python2 and python3, linux and windows, CPU and GPU. The preferred way to install PaddlePALM is via pip. Just run following commands in your shell.

pip install paddlepalm

Installing via source

git clone https://github.com/PaddlePaddle/PALM.git
cd PALM && python setup.py install

Library Dependencies

  • Python >= 2.7
  • cuda >= 9.0
  • cudnn >= 7.0
  • PaddlePaddle >= 1.7.0 (Please refer to this to install)

Downloading pretrain models

We incorporate many pretrained models to initialize model backbone parameters. Training big NLP model, e.g., 12-layer transformers, with pretrained models is practically much more effective than that with randomly initialized parameters. To see all the available pretrained models and download, run following code in python interpreter (input command python in shell):

>>> from paddlepalm import downloader
>>> downloader.ls('pretrain')
Available pretrain items:
  => RoBERTa-zh-base
  => RoBERTa-zh-large
  => ERNIE-v2-en-base
  => ERNIE-v2-en-large
  => XLNet-cased-base
  => XLNet-cased-large
  => ERNIE-v1-zh-base
  => ERNIE-v1-zh-base-max-len-512
  => BERT-en-uncased-large-whole-word-masking
  => BERT-en-cased-large-whole-word-masking
  => BERT-en-uncased-base
  => BERT-en-uncased-large
  => BERT-en-cased-base
  => BERT-en-cased-large
  => BERT-multilingual-uncased-base
  => BERT-multilingual-cased-base
  => BERT-zh-base

>>> downloader.download('pretrain', 'BERT-en-uncased-base', './pretrain_models')
...

Usage

Quick Start

8 steps to start a typical NLP training task.

  1. use paddlepalm.reader to create a reader for dataset loading and input features generation, then call reader.load_data method to load your training data.
  2. use paddlepalm.backbone to create a model backbone to extract text features (e.g., contextual word embedding, sentence embedding).
  3. register your reader with your backbone through reader.register_with method. After this step, your reader is able to yield input features used by backbone.
  4. use paddlepalm.head to create a task output head. This head can provide task loss for training and predicting results for model inference.
  5. create a task trainer with paddlepalm.Trainer, then build forward graph with backbone and task head (created in step 2 and 4) through trainer.build_forward.
  6. use paddlepalm.optimizer (and paddlepalm.lr_sched if is necessary) to create a optimizer, then build backward through trainer.build_backward.
  7. fit prepared reader and data (achieved in step 1) to trainer with trainer.fit_reader method.
  8. load pretrain model with trainer.load_pretrain, or load checkpoint with trainer.load_ckpt or nothing to do for training from scratch, then do training with trainer.train.

For more implementation details, see following demos:

Multi-task Learning

To run with multi-task learning mode:

  1. repeatedly create components (i.e., reader, backbone and head) for each task followed with step 1~5 above.
  2. create empty trainers (each trainer is corresponded to one task) and pass them to create a MultiHeadTrainer.
  3. build multi-task forward graph with multi_head_trainer.build_forward method.
  4. use paddlepalm.optimizer (and paddlepalm.lr_sched if is necessary) to create a optimizer, then build backward through multi_head_trainer.build_backward.
  5. fit all prepared readers and data to multi_head_trainer with multi_head_trainer.fit_readers method.
  6. load pretrain model with multi_head_trainer.load_pretrain, or load checkpoint with multi_head_trainer.load_ckpt or nothing to do for training from scratch, then do training with multi_head_trainer.train.

The save/load and predict operations of a multi_head_trainer is the same as a trainer.

For more implementation details with multi_head_trainer, see

Save models

To save models/checkpoints and logs during training, just call trainer.set_saver method. More implementation details see this.

Evaluation/Inference

To do predict/evaluation after a training stage, just create another three reader, backbone and head instance with phase='predict' (repeat step 1~4 above). Then do predicting with predict method in trainer (no need to create another trainer). More implementation details see this.

If you want to do evaluation during training process, use trainer.train_one_step() instead of trainer.train(). The trainer.train_one_step(batch) achieves to train only one step, thus you can insert evaluation code into any point of training process. The argument batch can be fetched from trainer.get_one_batch.

PaddlePALM also supports multi-head inference, please reference examples/multi-task/joint_predict.py.

Play with Multiple GPUs

If there exists multiple GPUs in your environment, you can control the number and index of these GPUs through the environment variable CUDA_VISIBLE_DEVICES. For example, if 4 GPUs in your enviroment, indexed with 0,1,2,3, you can run with GPU2 only with following commands

CUDA_VISIBLE_DEVICES=2 python run.py

Multiple GPUs should be seperated with ,. For example, running with GPU2 and GPU3, following commands is refered:

CUDA_VISIBLE_DEVICES=2,3 python run.py

On multi-gpu mode, PaddlePALM will automatically split each batch onto the available cards. For example, if the batch_size is set 64, and there are 4 cards visible for PaddlePALM, then the batch_size in each card is actually 64/4=16. Therefore, when running with multiple cards, you need to ensure that the set batch_size can be divided by the number of cards.

License

This tutorial is contributed by PaddlePaddle and licensed under the Apache-2.0 license.

More Repositories

1

PaddleOCR

Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
Python
43,170
star
2

Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
C++
22,193
star
3

PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.
Python
12,744
star
4

PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
Python
12,704
star
5

PaddleNLP

👑 Easy-to-use and powerful NLP and LLM library with 🤗 Awesome model zoo, supporting wide-range of NLP tasks from research to industrial applications, including 🗂Text Classification, 🔍 Neural Search, ❓ Question Answering, ℹ️ Information Extraction, 📄 Document Intelligence, 💌 Sentiment Analysis etc.
Python
11,953
star
6

PaddleSpeech

Easy-to-use Speech Toolkit including Self-Supervised Learning model, SOTA/Streaming ASR with punctuation, Streaming TTS with text frontend, Speaker Verification System, End-to-End Speech Translation and Keyword Spotting. Won NAACL2022 Best Demo Award.
Python
11,053
star
7

PaddleSeg

Easy-to-use image segmentation library with awesome pre-trained model zoo, supporting wide-range of practical tasks in Semantic Segmentation, Interactive Segmentation, Panoptic Segmentation, Image Matting, 3D Segmentation, etc.
Python
8,601
star
8

PaddleGAN

PaddlePaddle GAN library, including lots of interesting applications like First-Order motion transfer, Wav2Lip, picture repair, image editing, photo2cartoon, image style transfer, GPEN, and so on.
Python
7,858
star
9

Paddle-Lite

PaddlePaddle High Performance Deep Learning Inference Engine for Mobile and Edge (飞桨高性能深度学习端侧推理引擎)
C++
6,953
star
10

models

Officially maintained, supported by PaddlePaddle, including CV, NLP, Speech, Rec, TS, big models and so on.
Python
6,897
star
11

ERNIE

Official implementations for various pre-training models of ERNIE-family, covering topics of Language Understanding & Generation, Multimodal Understanding & Generation, and beyond.
Python
6,300
star
12

PaddleClas

A treasure chest for visual classification and recognition powered by PaddlePaddle
Python
5,418
star
13

PaddleX

All-in-One Development Tool based on PaddlePaddle(飞桨低代码全流程开发工具)
Python
4,781
star
14

VisualDL

Deep Learning Visualization Toolkit(『飞桨』深度学习可视化工具 )
HTML
4,773
star
15

PaddleRec

Recommendation Algorithm大规模推荐算法库,包含推荐系统经典及最新算法LR、Wide&Deep、DSSM、TDM、MIND、Word2Vec、Bert4Rec、DeepWalk、SSR、AITM,DSIN,SIGN,IPREC、GRU4Rec、Youtube_dnn、NCF、GNN、FM、FFM、DeepFM、DCN、DIN、DIEN、DLRM、MMOE、PLE、ESMM、ESCMM, MAML、xDeepFM、DeepFEFM、NFM、AFM、RALM、DMR、GateNet、NAML、DIFM、Deep Crossing、PNN、BST、AutoInt、FGCNN、FLEN、Fibinet、ListWise、DeepRec、ENSFM,TiSAS,AutoFIS等,包含经典推荐系统数据集criteo 、movielens等
Python
4,273
star
16

PARL

A high-performance distributed training framework for Reinforcement Learning
Python
3,261
star
17

awesome-DeepLearning

深度学习入门课、资深课、特色课、学术案例、产业实践案例、深度学习知识百科及面试题库The course, case and knowledge of Deep Learning and AI
Jupyter Notebook
3,001
star
18

FastDeploy

⚡️An Easy-to-use and Fast Deep Learning Model Deployment Toolkit for ☁️Cloud 📱Mobile and 📹Edge. Including Image, Video, Text and Audio 20+ main stream scenarios and 150+ SOTA models with end-to-end optimization, multi-platform and multi-framework support.
C++
2,952
star
19

book

Deep Learning 101 with PaddlePaddle (『飞桨』深度学习框架入门教程)
Jupyter Notebook
2,735
star
20

Research

novel deep learning research works with PaddlePaddle
Python
1,715
star
21

PGL

Paddle Graph Learning (PGL) is an efficient and flexible graph learning framework based on PaddlePaddle
Python
1,572
star
22

PaddleSlim

PaddleSlim is an open-source library for deep model compression and architecture search.
Python
1,557
star
23

PaddleVideo

Awesome video understanding toolkits based on PaddlePaddle. It supports video data annotation tools, lightweight RGB and skeleton based action recognition model, practical applications for video tagging and sport action detection.
Python
1,512
star
24

PaddleHelix

Bio-Computing Platform Featuring Large-Scale Representation Learning and Multi-Task Deep Learning “螺旋桨”生物计算工具集
Python
1,007
star
25

Paddle.js

Paddle.js is a web project for Baidu PaddlePaddle, which is an open source deep learning framework running in the browser. Paddle.js can either load a pre-trained model, or transforming a model from paddle-hub with model transforming tools provided by Paddle.js. It could run in every browser with WebGL/WebGPU/WebAssembly supported. It could also run in Baidu Smartprogram and WX miniprogram.
JavaScript
980
star
26

Serving

A flexible, high-performance carrier for machine learning models(『飞桨』服务化部署框架)
C++
894
star
27

RocketQA

🚀 RocketQA, dense retrieval for information retrieval and question answering, including both Chinese and English state-of-the-art models.
Python
763
star
28

X2Paddle

Deep learning model converter for PaddlePaddle. (『飞桨』深度学习模型转换工具)
Python
727
star
29

Paddle2ONNX

ONNX Model Exporter for PaddlePaddle
Python
723
star
30

Paddle-Lite-Demo

lib, demo, model, data
C++
675
star
31

Knover

Large-scale open domain KNOwledge grounded conVERsation system based on PaddlePaddle
Python
674
star
32

Parakeet

PAddle PARAllel text-to-speech toolKIT (supporting Tacotron2, Transformer TTS, FastSpeech2/FastPitch, SpeedySpeech, WaveFlow and Parallel WaveGAN)
Python
600
star
33

FlyCV

FlyCV is a high-performance library for processing computer visual tasks.
C++
577
star
34

Paddle3D

A 3D computer vision development toolkit based on PaddlePaddle. It supports point-cloud object detection, segmentation, and monocular 3D object detection models.
Python
565
star
35

Quantum

Jupyter Notebook
564
star
36

PaddleYOLO

🚀🚀🚀 YOLO series of PaddlePaddle implementation, PP-YOLOE+, RT-DETR, YOLOv5, YOLOv6, YOLOv7, YOLOv8, YOLOv10, YOLOX, YOLOv5u, YOLOv7u, YOLOv6Lite, RTMDet and so on. 🚀🚀🚀
Python
551
star
37

Anakin

High performance Cross-platform Inference-engine, you could run Anakin on x86-cpu,arm, nv-gpu, amd-gpu,bitmain and cambricon devices.
C++
531
star
38

VIMER

视觉预训练基础模型仓库
Python
494
star
39

PaddleTS

Awesome Easy-to-Use Deep Time Series Modeling based on PaddlePaddle, including comprehensive functionality modules like TSDataset, Analysis, Transform, Models, AutoTS, and Ensemble, etc., supporting versatile tasks like time series forecasting, representation learning, and anomaly detection, etc., featured with quick tracking of SOTA deep models.
Python
481
star
40

PaddleFL

Federated Deep Learning in PaddlePaddle
Python
480
star
41

PaddleFleetX

飞桨大模型开发套件,提供大语言模型、跨模态大模型、生物计算大模型等领域的全流程开发工具链。
Python
436
star
42

ERNIE-SDK

ERNIE Bot Agent is a Large Language Model (LLM) Agent Framework, powered by the advanced capabilities of ERNIE Bot and the platform resources of Baidu AI Studio.
Jupyter Notebook
341
star
43

PaddleSpatial

PaddleSpatial is an open-source spatial-temporal computing tool based on PaddlePaddle.
GLSL
331
star
44

PaddleRS

Awesome Remote Sensing Toolkit based on PaddlePaddle.
Python
330
star
45

PaddleMIX

Paddle Multimodal Integration and eXploration, supporting mainstream multi-modal tasks, including end-to-end large-scale multi-modal pretrain models and diffusion model toolbox. Equipped with high performance and flexibility.
Python
308
star
46

PaddleCloud

PaddlePaddle Docker images and K8s operators for PaddleOCR/Detection developers to use on public/private cloud.
Go
284
star
47

MetaGym

Collection of Reinforcement Learning / Meta Reinforcement Learning Environments.
Python
276
star
48

PASSL

PASSL包含 SimCLR,MoCo v1/v2,BYOL,CLIP,PixPro,simsiam, SwAV, BEiT,MAE 等图像自监督算法以及 Vision Transformer,DEiT,Swin Transformer,CvT,T2T-ViT,MLP-Mixer,XCiT,ConvNeXt,PVTv2 等基础视觉算法
Python
273
star
49

PaddleScience

PaddleScience is SDK and library for developing AI-driven scientific computing applications based on PaddlePaddle.
Python
259
star
50

InterpretDL

InterpretDL: Interpretation of Deep Learning Models,基于『飞桨』的模型可解释性算法库。
Python
241
star
51

docs

Documentations for PaddlePaddle
Python
240
star
52

Paddle-Inference-Demo

C++
235
star
53

PaddleRobotics

PaddleRobotics is an open-source algorithm library for robots based on Paddle, including open-source parts such as human-robot interaction, complex motion control, environment perception, SLAM positioning, and navigation.
Python
215
star
54

TrustAI

飞桨可信AI
Python
182
star
55

ElasticCTR

ElasticCTR,即飞桨弹性计算推荐系统,是基于Kubernetes的企业级推荐系统开源解决方案。该方案融合了百度业务场景下持续打磨的高精度CTR模型、飞桨开源框架的大规模分布式训练能力、工业级稀疏参数弹性调度服务,帮助用户在Kubernetes环境中一键完成推荐系统部署,具备高性能、工业级部署、端到端体验的特点,并且作为开源套件,满足二次深度开发的需求。
Python
176
star
56

AutoDL

Python
158
star
57

PLSC

Paddle Large Scale Classification Tools,supports ArcFace, CosFace, PartialFC, Data Parallel + Model Parallel. Model includes ResNet, ViT, Swin, DeiT, CaiT, FaceViT, MoCo, MAE, ConvMAE, CAE.
Python
148
star
58

CINN

Compiler Infrastructure for Neural Networks
C++
142
star
59

LiteKit

Off-The-Shelf AI Development Kit for APP Developers based on Paddle Lite (『飞桨』移动端开箱即用AI套件, 包含Java & Objective C接口支持)
Objective-C
134
star
60

PaddleFlow

Go
113
star
61

PaddleSports

Python
101
star
62

PaddleDTX

Paddle with Decentralized Trust based on Xuperchain
Go
89
star
63

PaConvert

PaddlePaddle Code Convert Toolkit. 『飞桨』深度学习代码转换工具
Python
87
star
64

XWorld

A C++/Python simulator package for reinforcement learning
C++
85
star
65

community

PaddlePaddle Developer Community
Jupyter Notebook
83
star
66

PaddleSleeve

PaddleSleeve
Python
76
star
67

benchmark

Python
76
star
68

hapi

hapi is a High-level API that supports both static and dynamic execution modes
Jupyter Notebook
76
star
69

Mobile

Embedded and Mobile Deployment
Python
71
star
70

PaddleCustomDevice

PaddlePaddle custom device implementaion. (『飞桨』自定义硬件接入实现)
Python
68
star
71

PaddleDepth

Python
63
star
72

PaddlePaddle.org

PaddlePaddle.org is the repository for the website of the PaddlePaddle open source project.
CSS
48
star
73

PaDiff

Paddle Automatically Diff Precision Toolkits.
Python
46
star
74

EasyData

Python
46
star
75

PaddleTest

PaddlePaddle TestSuite
Python
44
star
76

epep

Easy & Effective Application Framework for PaddlePaddle
Python
34
star
77

paddle-ce-latest-kpis

Paddle Continuous Evaluation, keep updating.
Python
26
star
78

VisionTools

Python
21
star
79

PaddleCraft

Take neural networks as APIs for human-like AI.
Python
20
star
80

Contrib

contribution works with PaddlePaddle from the third party developers
Python
20
star
81

PaddleTransfer

飞桨迁移学习算法库
Python
19
star
82

continuous_evaluation

Macro Continuous Evaluation Platform for Paddle.
Python
19
star
83

recordio

An implementation of the RecordIO file format.
Go
19
star
84

Perf

SOTA benchmark
Python
17
star
85

Paddle-bot

Python
17
star
86

examples

Python
17
star
87

continuous_integration

Python
16
star
88

PaddleSOT

A Bytecode level Implementation of Symbolic OpCode Translator For PaddlePaddle
Python
15
star
89

tape

C++
14
star
90

paddle_upgrade_tool

upgrade paddle-1.x to paddle-2.0
Python
12
star
91

PaddleAPEX

PaddleAPEX:Paddle Accuracy and Performance EXpansion pack
Python
7
star
92

talks

Shell
6
star
93

CLA

5
star
94

any

Legacy Repo only for PaddlePaddle with version <= 1.3
C++
5
star