PaddleNLP

repository·develop·Indexed 11 days ago

https://github.com/paddlepaddle/paddlenlp

A comprehensive development suite for Large Language Models (LLMs) built on PaddlePaddle. It provides end-to-end capabilities including high-performance distributed training, efficient fine-tuning (PEFT), model compression, and high-throughput inference across hardware such as NVIDIA GPUs, Ascend NPUs, and SDAA. It supports reinforcement learning algorithms like PPO and GRPO, FlashMask Reward Model training, and high-throughput deployment of models like DeepSeek-R1.

Tokens
292.6K
Snippets
764
Records
1.1K
Agent score
95%

What's inside PaddleNLP

  1. Overview of Industrial NLP Application Scenarios

    develop

    PaddleNLP offers end-to-end solutions for various NLP tasks. Use the following table to find the appropriate version for your needs:

    ScenarioPipelines VersionCustomizable VersionNotebook
    RetrievalSemantic SearchNeural SearchBuild Retrieval System
    QAFAQ, Unsupervised, SupervisedFAQ, UnsupervisedFAQ System
    Text ClassificationN/AText Classification, Zero-shotIntent Recognition
    Information ExtractionN/AInformation ExtractionUIE Experience
    Sentiment AnalysisSentiment AnalysisSentiment AnalysisSentiment Analysis
    Document IntelligenceDoc QACross-modal Doc QADoc QA
    Text-to-ImageText-to-ImageRefer to PaddleMIXN/A
    SummarizationN/AText SummarizationSummarization
  2. Overview of the Analysis module

    develop

    The Analysis module provides tools for evaluating text classification models, performing interpretability analysis, and optimizing training data. It is designed to help developers understand model predictions and improve performance through:

    • Model Evaluation: Assessing overall and per-category classification performance and identifying misclassified samples (bad cases).
    • Interpretability Analysis: Using TrustAI to perform word-level and sentence-level analysis to understand why a model made a specific prediction.
    • Data Optimization: Utilizing TrustAI and Data Augmentation APIs to implement sparse data filtering, dirty data cleaning, and data augmentation strategies.
  3. Overview of Document Information Extraction Application

    develop

    This application provides an end-to-end solution for document information extraction based on fine-tuning the UIE (Universal Information Extraction) model. It covers the entire workflow from data annotation, model training, and model tuning to prediction and deployment.

    Key capabilities include:

    • Versatile Scenarios: Supports extraction of entities, relations, events, and opinions across documents, images, tables, and plain text.
    • Industry-Agnostic: Does not limit industry domains or specific extraction targets, making it suitable for rapid adaptation to specific business needs.
    • High Performance: Uses UIE-X (a model with strong multimodal capabilities) as the training base.
    • Ease of Use: Features Taskflow for quick zero-shot inference with minimal code, and simplified commands for training and deployment.
  4. Overview of ERNIE-M Multilingual Model

    develop

    ERNIE-M is a multilingual language model developed by Baidu designed to align representations of multiple languages with monolingual corpora. It overcomes the limitations of small parallel corpora by integrating a back-translation mechanism into the pre-training process to generate pseudo-parallel sentence pairs from monolingual data. This enhances cross-lingual semantic modeling.

    ERNIE-M utilizes two primary methods to model alignment relationships between languages:

    1. Cross-Attention Masked Language Modeling (CAMLM): Captures alignment information using limited bilingual corpora. It requires the model to reconstruct masked words in a target sentence without utilizing the source sentence context, establishing initial cross-lingual alignment.
    2. Back-Translation Masked Language Modeling (BTMLM): Learns alignment from monolingual corpora via back-translation. It uses CAMLM to generate pseudo-parallel corpora and then trains the model on these generated pairs to better model semantic alignment using monolingual data.
  5. Overview of Large Model Inference in PaddleNLP

    develop

    PaddleNLP provides a high-performance, one-stop inference experience for large language models (LLMs). Key features include:

    • Performance Optimizations: Built-in dynamic insertion, full-loop operator fusion, PageAttention, and FlashDecoding.
    • Quantization: Supports Weight Only INT8/INT4, and WAC (Weight/Activation/Cache KV) quantization using INT8 or FP8.
    • Deployment: Supports both dynamic and static graph inference modes, continuous batching, and streaming output via HTTP interfaces.
    • Multi-Hardware Support: Optimized for GPU, CPU, Kunlun XPU, Ascend NPU, Hygon DCU, Enflame GCU, and more.
  6. Overview of RLHF with PPO in PaddleNLP

    develop

    PaddleNLP provides tools and complete examples for aligning Large Language Models (LLMs) with human preferences using the Proximal Policy Optimization (PPO) reinforcement learning algorithm.

    Key features include:

    • 3D Distributed Parallel Training: Supports distributed training across multiple hardware components.
    • Generation Acceleration: Accelerates the rollout phase via prediction optimization.
    • PPO Stabilization: Implements strategies such as reward normalization and pretraining loss, referencing the PKU-Alignment/safe-rlhf implementation.

    This module is designed to support large-scale RLHF capabilities with a focus on performance, cost-efficiency, and high efficiency.

  7. Overview of Information Extraction Applications

    develop

    PaddleNLP provides industrial-grade solutions for Information Extraction (IE) that support multi-domain, multi-task, and cross-modal capabilities. Based on the UIE (Unified Information Extraction) modeling philosophy, the application allows extracting structured information (entities, relations, events, opinions, etc.) from text, documents, images, and tables.

    Key capabilities include:

    • Full Lifecycle Support: Covers data labeling, model training, fine-tuning, and deployment.
    • Zero-shot & Few-shot Learning: Use Taskflow for immediate zero-shot prediction without labeled data, or fine-tune with minimal data (e.g., 5-shot) to improve performance in specific domains.
    • Multi-modal Support: Beyond pure text, it supports end-to-end extraction from documents, images, and tables.
  8. Overview of Hierarchical Text Classification

    develop

    The Hierarchical Text Classification application provides an end-to-end solution for fine-tuning pre-trained models to handle text data where labels have a specific hierarchical structure (e.g., News Category -> Sports -> Football).

    Key Features:

    • High Performance: Uses the ERNIE 3.0 lightweight series as the training base, offering various model sizes for different efficiency and accuracy needs.
    • Efficient Optimization: Integrates with TrustAI and PaddleNLP's Data Augmentation APIs to provide model analysis, sparse data filtering, dirty data cleaning, and data augmentation.
    • Ease of Use: Designed for developers without deep machine learning backgrounds; requires only formatted annotated data and a single command to start training.

    Alternative Approaches: Depending on your specific constraints, you may choose different workflows:

  9. Overview of Document Information Extraction in PaddleNLP

    develop

    PaddleNLP provides an industrial-grade Information Extraction (IE) solution designed to extract structured information from text, pictures, or scanned documents. The solution supports multi-domain, multi-task, and cross-modal capabilities, covering the full lifecycle from data labeling to model deployment.

    Key Capabilities:

    • Extraction Targets: Extract entities, relations, events, and opinions.
    • Input Modalities: Supports plain text as well as cross-modal extraction from documents, tables, and pictures.
    • Flexible Prompting: Uses natural language prompts to specify extraction targets.
    • Task Coverage: Includes mainstream IE tasks for both plain text and document-based scenarios across multiple languages.
    • Model Variety: Features the UIE (Universal Information Extraction) model series with various pretrained sizes and domain-adapted models for specific industry sectors.
  10. Overview of Few-Shot Multi-Label Text Classification

    develop

    This project provides a solution for multi-label text classification in few-shot scenarios. Instead of traditional fine-tuning, it utilizes Prompt Learning based on the ERNIE 3.0 model.

    Key Concepts

    • Multi-Label Classification: Predicting multiple non-mutually exclusive labels for a single input (e.g., extracting multiple legal elements from a court document).
    • Prompt Learning vs. Fine-tuning:
      • Fine-tuning: Uses a randomly initialized classifier on top of the [CLS] vector. It requires large amounts of labeled data to perform well.
      • Prompt Learning: Converts the classification task into a Masked Language Modeling (MLM) task by constructing a prompt (e.g., "The elements included in this sentence are [MASK]"). This leverages the pre-trained weights of the model to predict the missing token, significantly reducing the dependency on large labeled datasets.

    When to use this solution

    • Use Fine-tuning if you have abundant labeled data.
    • Use Prompt Learning (this project) if you have limited or no labeled data (few-shot/zero-shot scenarios).
  11. Overview of ERNIE-Health Chinese Medical Pre-trained Model

    develop

    ERNIE-Health (model name: ernie-health-chinese) is a Chinese medical pre-trained language model designed for medical language understanding tasks. It is built upon Baidu's ERNIE architecture and enhanced with medical knowledge through several specialized techniques:

    • Medical Entity Masking: Learns entity-level knowledge for professional medical terms.
    • Medical QA Matching: Learns the relationships between patient symptom descriptions and professional medical treatments using over 40 million medical QA pairs.
    • Multi-level Semantic Discrimination: Improves learning efficiency for medical knowledge.
    • Architecture: The model structure is similar to ELECTRA, consisting of a generator and a discriminator.

    It has been trained on over 600,000 medical professional terms and 40 million medical QA data points to improve modeling capabilities for unstructured and non-standardized medical text (e.g., electronic medical records, biomedical literature).

  12. Overview of ChatGLM2-6B models

    develop

    ChatGLM2-6B is a second-generation open-source Chinese-English bilingual conversational model. It builds upon the original ChatGLM-6B and introduces technical improvements such as FlashAttention and Multi-Query Attention to enhance performance and deployment efficiency.

    Supported model identifiers in PaddleNLP include:

    • THUDM/chatglm2-6b
    • THUDM/chatglm3-6b