Inside Transformers' pipeline()

Inside Transformers' pipeline() A workflow diagram generated by Archify. 01 / pipeline() — main flow 02 / What pipeline() hides Preprocessing Model inference Post-processing Raw text · This movie is amazing! · pipeline() — main flow › Preprocessing Raw text This movie is amazing! Tokenizer · AutoTokenizer · pipeline() — main flow › Preprocessing · model checkpoint Tokenizer AutoTokenizer model checkpoint Model inputs · input_ids + attn_mask · pipeline() — main flow › Preprocessing Model inputs input_ids + attn_mask Transformer body · embedding + N block · pipeline() — main flow › Model inference · self-attention Transformer body embedding + N block self-attention Task head · classification / LM · pipeline() — main flow › Post-processing Task head classification / LM Result · POSITIVE 0.982 · pipeline() — main flow › Post-processing Result POSITIVE 0.982 Subword · [CLS] Transform ##ers · What pipeline() hides › Preprocessing Subword [CLS] Transform ##ers Padding + mask · [batch_size, seq_length] · What pipeline() hides › Preprocessing Padding + mask [batch_size, seq_length] Hidden states · [batch, seq_len, hidden] · What pipeline() hides › Model inference Hidden states [batch, seq_len, hidden] Logits · [-1.7, 2.3] · What pipeline() hides › Post-processing · not probabilities Logits [-1.7, 2.3] not probabilities Softmax · [0.018, 0.982] · What pipeline() hides › Post-processing Softmax [0.018, 0.982] split subwords batch up raw output raw class scores normalize token IDs numeric tensors context vectors predicted label argmax Legend User UI Agent logic Tool action Context / trace Cloud service External system