How baidu/senta works
Senta is a PaddlePaddle sentiment-analysis toolkit: it offers SKEP pretraining and model training, plus a one-call prediction interface for sentence sentiment, aspect sentiment, and opinion extraction. The training path configures a model and trainer, prepares task data, and runs training/evaluation; the documented prediction path initializes a supported model and predicts on text. The graph preserves the documented task breadth, but several task-specific readers and prediction internals were not sampled, so uncertain wiring is omitted.
Main entry points: base_trainer.py Base trainer · ernie_classification.py Classification models · pretraining.py Pretraining entry · train.py Training entry
Components 20
Prediction API
- Senta API
senta/train.py - Sentiment tasks
Data preparation
- Dataset
senta/data/data_set.py - Task readers
senta/data/data_set_reader - Field readers
senta/data/field_reader - Tokenizers
senta/data/tokenizer - Batch preparation
senta/data/util_helper.py
Models
- Classification models
senta/models/ernie_classification.py - Sequence labeling
senta/models/ernie_crf_sequence_label.py - Language models
senta/models/ernie_multil_task_language_model.py - ERNIE encoder
senta/modules/ernie.py - ERNIE embedding
senta/modules/token_embedding/ernie_embedding.py
Training and evaluation
- Pretraining entry
pretraining.py - Training entry
senta/train.py - Component registry
senta/common/register.py - Base trainer
senta/training/base_trainer.py - GLUE task trainer
senta/training/glue_task_trainer.py - Metrics
senta/metrics/metrics.py - GLUE evaluation
senta/metrics/glue_eval.py
Other components
- User
Connections 18
- User → Senta API: initializes and predicts
README.md - Senta API → Sentiment tasks: returns predictions
README.md - Pretraining entry → Task readers: selects readers
pretraining.py - Pretraining entry → Language models: constructs model
pretraining.py - Pretraining entry → Base trainer: uses trainer
pretraining.py - Training entry → Component registry: resolves components
senta/train.py - Training entry → Classification models: constructs model
senta/train.py - Training entry → Base trainer: builds trainer
senta/train.py - Dataset → Field readers: uses fields
senta/data/data_set.py - Field readers → Batch preparation: formats batches
senta/data/field_reader/ernie_classification_field_reader.py - Field readers → ERNIE embedding: uses embedding
senta/data/field_reader/ernie_classification_field_reader.py - ERNIE embedding → ERNIE encoder: builds embeddings
senta/modules/token_embedding/ernie_embedding.py - Classification models → ERNIE encoder: runs encoder
senta/models/ernie_classification.py - Classification models → Metrics: computes metrics
senta/models/ernie_classification.py - Base trainer → GLUE task trainer: specialized by
senta/training/glue_task_trainer.py - GLUE task trainer → Base trainer: extends
senta/training/glue_task_trainer.py - Base trainer → Metrics: evaluates outputs
- Classification models → GLUE evaluation: uses task evaluation
senta/models/ernie_one_sent_classification_ch.py