Paddlenlp

Easy-to-use and powerful LLM and SLM library with awesome model zoo.

Last verified:

Visit Paddlenlp

What is Paddlenlp?

PaddleNLP is the natural language processing development library of PaddlePaddle, designed to enhance modeling efficiency in the text domain for PaddlePaddle developers. It features user-friendly text domain APIs, multi-scenario application examples, and high-performance distributed training capabilities.

Key features include Taskflow with industry-grade preset task capabilities, comprehensive text domain APIs (Dataset API for Chinese dataset loading, Data API for efficient preprocessing, Embedding API with 60+ pretrained word vectors, and Transformer API with 100+ pretrained models). It supports NLP application examples from academic to industry levels, covering fundamental NLP technologies, NLP system applications, and extended applications. The library also provides high-performance distributed training based on PaddlePaddle's automatic mixed precision optimization and 4D hybrid parallel strategies for large-scale pretrained model training.

PaddleNLP is designed for PaddlePaddle developers, NLP researchers, and industry practitioners who need to build NLP applications from research to production. It supports a wide range of NLP tasks including Neural Search, Question Answering, Information Extraction, Sentiment Analysis, text classification, sequence labeling, reading comprehension, and semantic matching. The library is particularly useful for those working with Chinese NLP tasks and large language model (LLM) development, offering efficient training, lossless compression, and high-performance inference on multiple hardware platforms.

Paddlenlp pricing

Pricing model: Freemium

PaddleNLP is completely free and open-source. It can be installed via pip (pip install --upgrade --pre paddlenlp), from source code by cloning the GitHub repository, or using Docker images. There are no paid tiers, subscription fees, or commercial licensing costs. The library, model zoo, datasets, and all features are freely available to all users.

Paddlenlp pros

  • User-friendly Taskflow with industry-grade preset task capabilities
  • Comprehensive Dataset API supporting rich Chinese dataset loading
  • Flexible and efficient Data API for data preprocessing
  • 60+ pretrained word vectors via Embedding API
  • 100+ pretrained models available through Transformer API
  • High-performance distributed training with 4D hybrid parallel strategies
  • Automatic mixed precision optimization from PaddlePaddle core framework
  • Multi-scenario application examples from academic to industry levels
  • Easy rapid fine-tuning with just a few lines of code
  • Support for large language model full fine-tuning and pretraining
  • Built-in support for both dynamic and static graph modes
  • Docker image support for isolated environment deployment
  • Simple pip installation with automatic latest version installation
  • Extensive FAQ documentation with practical troubleshooting guides
  • Model distillation and compression support including DynaBERT, TinyBERT, MiniLM

Paddlenlp cons

  • Primarily focused on PaddlePaddle framework, limiting flexibility for other frameworks
  • Heavy emphasis on Chinese datasets and Chinese NLP tasks
  • Some advanced features require understanding of PaddlePaddle internals
  • GPU version cannot run on CPU-only machines without special configuration
  • Dynamic to static graph conversion adds complexity for deployment
  • Learning curve for users unfamiliar with PaddlePaddle ecosystem
  • Some documentation available primarily in Chinese
  • Requires specific CUDA versions for GPU training (cuda11.8 or cuda12.3)
  • Model saving/loading requires specific interface usage (save_pretrained/from_pretrained)
  • Memory/GPU memory issues common with large batch sizes requiring adjustment

Frequently asked questions about Paddlenlp

How to load your own local dataset to use PaddleNLP's features?

By using PaddleNLP's load_dataset, MapDataset, and IterDataset, you can easily customize your own dataset. Create a dataset from a local file by providing a reading function based on the format of the local dataset and passing it into load_dataset(). You can also create datasets from paddle.io.Dataset/IterableDataset or other Python objects like List objects.

What methods can improve model performance when training samples are limited?

Increasing training samples is most direct. Additionally, perform warm start based on open-source models and fine-tune with a small dataset. Contrastive Learning can also yield good results for classification and matching scenarios.

How can model performance be improved to enhance QPS?

For server-side deployment, use the high-performance prediction engine. For GPU prediction of Transformer models, use PaddleNLP's fast prediction feature. From a model strategy perspective, use model miniaturization techniques like model distillation and pruning. PaddleNLP integrates ERNIE-Tiny and provides knowledge distillation implementing DynaBERT, TinyBERT, and MiniLM.

How to handle imbalanced data distribution?

Methods include: (1) Under-sampling to reduce over-represented classes, (2) Over-sampling by duplicating under-represented samples, (3) Adjusting classification threshold instead of using 0.5, (4) Cost-sensitive learning by setting class_weight parameter in algorithms like LR.

How to resume training after interruption with warm start?

To fully restore training state, save parameters of lr, optimizer, and model using paddle.save(). Then load them using paddle.load() and set_state_dict() to resume training from the interruption point, ensuring learning rate and optimizer continue iterating correctly.

How to deploy a trained PaddleNLP model to a server?

Recommend developing in dynamic graph mode and deploying in static graph mode. Use paddle.jit.to_static for dynamic to static conversion. Deploy with Paddle Inference which includes high-performance CPU/GPU Kernels, OP fusion strategies, and TensorRT integration. Examples are available in the deploy directory.

How to specify whether to train using CPU or GPU?

Training scripts generally provide a --device option to specify the device. In Python files, set device to 'gpu' or 'cpu' using paddle.device.set_device(). For GPU-only training on systems with GPU, use export CUDA_VISIBLE_DEVICES=-1 to force CPU usage.

Can the GPU version of Paddle run on a CPU-only system?

Devices that do not support GPU can only install the CPU version of PaddlePaddle. If you want the GPU version of PaddlePaddle to run only on the CPU, you can set export CUDA_VISIBLE_DEVICES=-1 to force CPU execution.

Categories

Use cases

Browse all AI tools on NeedAnAI