Bên trong pipeline() của Transformers

Bên trong pipeline() của Transformers A workflow diagram generated by Archify. 01 / pipeline() — luồng chính 02 / Thứ pipeline() giấu đi Preprocessing Model inference Post-processing Văn bản thô · This movie is amazing! · pipeline() — luồng chính › Preprocessing Văn bản thô This movie is amazing! Tokenizer · AutoTokenizer · pipeline() — luồng chính › Preprocessing · cùng checkpoint với model Tokenizer AutoTokenizer cùng checkpoint với model Model inputs · input_ids + attn_mask · pipeline() — luồng chính › Preprocessing Model inputs input_ids + attn_mask Transformer body · embedding + N block · pipeline() — luồng chính › Model inference · self-attention Transformer body embedding + N block self-attention Task head · classification / LM · pipeline() — luồng chính › Post-processing Task head classification / LM Kết quả · POSITIVE 0.982 · pipeline() — luồng chính › Post-processing Kết quả POSITIVE 0.982 Subword · [CLS] Transform ##ers · Thứ pipeline() giấu đi › Preprocessing Subword [CLS] Transform ##ers Padding + mask · [batch_size, seq_length] · Thứ pipeline() giấu đi › Preprocessing Padding + mask [batch_size, seq_length] Hidden states · [batch, seq_len, hidden] · Thứ pipeline() giấu đi › Model inference Hidden states [batch, seq_len, hidden] Logits · [-1.7, 2.3] · Thứ pipeline() giấu đi › Post-processing · chưa phải xác suất Logits [-1.7, 2.3] chưa phải xác suất Softmax · [0.018, 0.982] · Thứ pipeline() giấu đi › Post-processing Softmax [0.018, 0.982] tách subword gom thành batch output thô điểm thô mỗi class chuẩn hoá token IDs tensor số biểu diễn ngữ cảnh nhãn dự đoán argmax Legend User UI Agent logic Tool action Context / trace Cloud service External system

Ba thành phần phải đi cùng nhau

  • • Kiến trúc model — số layer, hidden size, số head
  • • Trọng số đã học — safetensors
  • • Quy tắc tiền xử lý — tokenizer của đúng checkpoint

Thứ pipeline() làm thay bạn

  • • Model không đọc chuỗi — nó chỉ nhận tensor số
  • • Hidden states chưa phải dự đoán, cần một head
  • • Logits chưa phải xác suất, cần Softmax