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 모델을 다른 아키텍처와 구별하는 것이 중요합니다.

  • Vs. 표준 분류: 기본 이미지 분류에 사용되는 것과 같은 표준 분류기는 이미지 분류에 사용되는 것과 같은 표준 분류기는 단일 입력 (예: 이미지)을 단일 클래스 레이블에 매핑합니다. 이와 대조적으로 Seq2Seq 모델은 시퀀스를 시퀀스에 매핑하여 다음과 같이 가변 출력 길이를 허용합니다.
  • Vs. 객체 탐지: Ultralytics 같은 모델은 단일 프레임 내 공간적 탐지에 집중하여 객체와 그 위치를 식별합니다. YOLO 구조적으로 이미지를 YOLO 반면, Seq2Seq 모델은 데이터를 시간적으로 처리합니다. 그러나 객체 추적과 같은 작업에서는 영역이 중첩되는데, 동영상 프레임에 걸쳐 객체 궤적을 식별하는 것은 순차적 데이터 분석을 필요로 합니다.
  • Vs. 트랜스포머: 트랜스포머 트랜스포머 아키텍처는 현대적으로 진화한 Seq2Seq. 기존 Seq2Seq 모델은 RNN과 게이트 리커런트 유닛(GRU)에 의존했습니다, 트랜스포머는 자체 주의력을 활용하여 시퀀스를 병렬로 처리하므로 속도와 정확도가 크게 개선되었습니다.

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의 미래에 동참하세요. 글로벌 혁신가들과 연결하고, 협력하고, 성장하세요.

지금 참여하기