Yolo 深圳
深セン
今すぐ参加
用語集

Sequence-to-Sequenceモデル

Explore Sequence-to-Sequence (Seq2Seq) models. Learn how encoder-decoder architectures and Transformers power translation, NLP, and multi-modal AI tasks.

Sequence-to-Sequence (Seq2Seq) models are a powerful class of machine learning architectures designed to convert sequences from one domain into sequences in another. Unlike standard image classification tasks where the input and output sizes are fixed, Seq2Seq models excel at handling inputs and outputs of variable lengths. This flexibility makes them the backbone of many modern natural language processing (NLP) applications, such as translation and summarization, where the length of the input sentence does not necessarily dictate the length of the output sentence.

コア・アーキテクチャと機能性

The fundamental structure of a Seq2Seq model relies on the encoder-decoder framework. This architecture splits the model into two primary components that work in tandem to process sequential data.

  • The Encoder: This component processes the input sequence (e.g., a sentence in English or a sequence of audio frames) one element at a time. It compresses the information into a fixed-length context vector, also known as the hidden state. In traditional architectures, the encoder is often built using Recurrent Neural Networks (RNN) or Long Short-Term Memory (LSTM) networks, which are designed to retain information over time steps.
  • The Decoder: Once the input is encoded, the decoder takes the context vector and predicts the output sequence (e.g., the corresponding sentence in French) step-by-step. It uses the previous prediction to influence the next one, ensuring grammatical and contextual continuity.

While early versions relied heavily on RNNs, modern Seq2Seq models predominantly use the Transformer architecture. Transformers utilize the attention mechanism, which allows the model to "pay attention" to specific parts of the input sequence regardless of their distance from the current step, significantly improving performance on long sequences as detailed in the seminal paper Attention Is All You Need.

実際のアプリケーション

The versatility of Seq2Seq models allows them to bridge the gap between text analysis and computer vision, enabling complex multi-modal interactions.

  • Machine Translation: Perhaps the most famous application, Seq2Seq models power tools like Google Translate. The model accepts a sentence in a source language and outputs a sentence in a target language, handling differences in grammar and sentence structure fluently.
  • テキストの要約これらの このモデルは長い文書や記事を取り込み、簡潔な要約を生成することができる。入力テキストの核となる意味を理解することで デコーダは、入力テキストの核となる意味を理解することで、重要な情報を保持した短いシーケンスを生成する。 自動化されたニュース集約に不可欠な技術である。
  • 画像キャプション生成:視覚と言語を組み合わせることで、Seq2Seqモデルは画像の内容を記述できる。畳み込みニューラルネットワーク(CNN)がエンコーダとして視覚特徴を抽出し、再帰型ネットワーク(RNN)がデコーダとして説明文を生成する。これはマルチモーダルモデルの代表例である。
  • 音声認識これらのシステムでは このシステムでは、入力は音声信号フレームのシーケンスであり、出力はテキスト文字または単語のシーケンスである。 この技術は SiriやAlexaのようなバーチャル・アシスタントを支えている。

Code Example: Basic Building Block

While high-level frameworks abstract much of the complexity, understanding the underlying mechanism is helpful. The following code demonstrates a basic LSTM layer in PyTorch, which often serves as the recurrent unit within the encoder or decoder of a traditional Seq2Seq model.

import torch
import torch.nn as nn

# Initialize an LSTM layer (common in Seq2Seq encoders)
# input_size: number of features per time step (e.g., word embedding size)
# hidden_size: size of the context vector/hidden state
lstm_layer = nn.LSTM(input_size=10, hidden_size=20, batch_first=True)

# Create a dummy input sequence: Batch size 3, Sequence length 5, Features 10
input_seq = torch.randn(3, 5, 10)

# Pass the sequence through the LSTM
# output contains features for each time step; hn is the final hidden state
output, (hn, cn) = lstm_layer(input_seq)

print(f"Output shape: {output.shape}")  # Shape: [3, 5, 20]
print(f"Final Hidden State shape: {hn.shape}")  # Shape: [1, 3, 20]

関連概念との比較

Seq2Seqモデルを他のアーキテクチャと区別することは、その特異的な有用性を理解する上で重要である。

  • 対標準的な分類:基本的な画像分類に使われるような標準的な分類器は 標準的な分類器は、単一の入力 (画像など)を単一のクラスラベルに対応付ける。対照的に、Seq2Seqモデルはシーケンスをシーケンスに対応付け、可変の出力長を可能にする。 可変の出力長。
  • 対 物体検出: Ultralytics のようなモデルは、単一フレーム内の空間的検出に焦点を当て、物体とその位置を特定する。YOLO 画像を構造的にYOLO に対し、Seq2Seqモデルはデータを時間的に処理する。ただし、物体追跡のようなタスクでは領域が重なり、動画フレームにわたる物体の軌跡を特定するには時系列データ解析が必要となる。
  • 対トランスフォーマートランスフォーマー Transformerアーキテクチャは Seq2Seqを現代的に進化させたものだ。オリジナルのSeq2SeqモデルはRNNと ゲーテッド・リカレント・ユニット(GRU)に依存していた、 Transformerは自己アテンションを利用してシーケンスを並列処理し、スピードと精度を大幅に向上させた。 の向上を実現している。

Importance in the AI Ecosystem

Seq2Seq models have fundamentally changed how machines interact with human language and temporal data. Their ability to handle sequence-dependent data has enabled the creation of sophisticated chatbots, automated translators, and code generation tools. For developers working with large datasets required to train these models, using the Ultralytics Platform can streamline data management and model deployment workflows. As research progresses into Generative AI, the principles of sequence modeling remain central to the development of Large Language Models (LLMs) and advanced video understanding systems.

Ultralytics コミュニティに参加する

AIの未来を共に切り開きましょう。グローバルなイノベーターと繋がり、協力し、成長を。

今すぐ参加