· Xiaojing Yang · NLP and LLMs · 2 min read
中文Sequence-to-Sequence Models
The encoder-decoder idea behind machine translation, summarization, and many generation tasks.
Core idea
Seq2seq models turn one sequence into another by encoding meaning and decoding output step by step.
1. The task shape
Many NLP tasks are naturally sequence-to-sequence: translation, summarization, question answering, data-to-text generation, and grammatical correction.
input tokens
context representation
what has been generated
predict one step
complete output
2. Why it mattered
Before Transformers, encoder-decoder RNNs made neural machine translation practical. Attention improved them by letting the decoder look back at source states instead of relying on one fixed vector.
| Component | Role |
|---|---|
| Encoder | reads the source |
| Decoder | generates the target |
| Attention | selects relevant source information |
| Teacher forcing | trains with gold previous tokens |
3. Hugging Face practice
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
name = "Helsinki-NLP/opus-mt-en-no"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModelForSeq2SeqLM.from_pretrained(name)4. My research connection
English—Norwegian MT is a seq2seq problem. Domain adaptation asks whether the model can generate technically correct target text when the source contains rare petroleum terminology and formal document style.
Core strength
Seq2seq maps variable-length input to variable-length output.
Core risk
Generation can be fluent while still missing source details.
Takeaway
Seq2seq is the task grammar behind MT: input text becomes output text, but faithfulness must be evaluated carefully.
Interview pattern
My interview answer would usually be:
- define the concept in one sentence;
- explain the data flow;
- name the main failure mode;
- connect it to evaluation, multilinguality, or fine-tuning.
References
- Hugging Face Course
- Hugging Face Transformers documentation
- Hugging Face tokenizer summary
- Hugging Face fine-tuning guide
- Hugging Face PEFT
- The Illustrated Transformer
- Speech and Language Processing, Jurafsky & Martin
- Stanford CS224N readings
- Attention Is All You Need
- COMET: A Neural Framework for MT Evaluation