# TransformersとAttention (Data Science & ML) > attentionメカニズム、self-attention、multi-head attention、Transformerアーキテクチャ、positional encoding - 24 面接問題 - Senior - [面接問題: Data Science & ML](https://sharpskill.dev/ja/technologies/data-science/interview-questions.md) ## 1. シーケンス処理においてattentionメカニズムがRNNに対して持つ主な利点は何ですか? **回答** attentionメカニズムは、シーケンス内の任意の位置への直接アクセスを可能にし、RNNの順次処理のボトルネックを排除します。情報を段階的に伝播する必要があるRNNとは異なり、attentionはすべての位置間の直接的な接続を計算し、大規模な並列化を可能にし、勾配の劣化なしに長距離依存関係を捉えます。 ## 2. attentionメカニズムにおいて、Query (Q)、Key (K)、Value (V) のベクトルは何を表しますか? **回答** Queryはトークンが探しているものを表し、Keyは各トークンが一致として提供できるものを表し、Valueは取得すべき情報を含みます。attentionスコアはQとKの間で計算され、相対的な重要度を決定し、Vに重み付けします。このアナロジーは、クエリがキーと比較されて値を取得する情報検索システムから来ています。 ## 3. scaled dot-product attentionの式は何ですか、そしてなぜdkの平方根で割るのですか? **回答** 式はAttention(Q,K,V) = softmax(QK^T / sqrt(dk)) * Vです。sqrt(dk)で割ることは重要です。なぜなら、高次元ベクトルのドット積は大きな値を持つ傾向があり、softmaxを非常に小さな勾配の領域に押しやるためです。この正規化はattentionスコアの分散を安定させ、効率的な学習を保証します。 ## さらに21問利用可能 - attentionとself-attentionの基本的な違いは何ですか? - なぜ単一のattentionヘッドではなくmulti-head attentionを使うのですか? 無料で登録: https://sharpskill.dev/ja/login ## その他のData Science & ML面接トピック - [Pythonの基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/python-basics.md): 25問, Junior - [Pythonオブジェクト指向プログラミング](https://sharpskill.dev/ja/technologies/data-science/interview-questions/python-oop.md): 20問, Junior - [Pythonのデータ構造](https://sharpskill.dev/ja/technologies/data-science/interview-questions/python-data-structures.md): 20問, Junior - [Git の基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/git-fundamentals.md): 18問, Junior - [SQLの基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/sql-basics.md): 20問, Junior - [NumPyの基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/numpy-fundamentals.md): 22問, Junior - [Pandasの基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/pandas-basics.md): 22問, Junior - [Jupyter & Google Colab](https://sharpskill.dev/ja/technologies/data-science/interview-questions/jupyter-colab.md): 16問, Junior - [SQL Joinsと高度なクエリ](https://sharpskill.dev/ja/technologies/data-science/interview-questions/sql-joins-advanced.md): 22問, Mid-Level - [Pandas応用](https://sharpskill.dev/ja/technologies/data-science/interview-questions/pandas-advanced.md): 24問, Mid-Level - [Matplotlib & Seabornによる可視化](https://sharpskill.dev/ja/technologies/data-science/interview-questions/matplotlib-seaborn.md): 20問, Mid-Level - [Plotlyによるインタラクティブな可視化](https://sharpskill.dev/ja/technologies/data-science/interview-questions/plotly-interactive.md): 18問, Mid-Level - [記述統計](https://sharpskill.dev/ja/technologies/data-science/interview-questions/statistics-descriptive.md): 20問, Mid-Level - [推測統計学](https://sharpskill.dev/ja/technologies/data-science/interview-questions/statistics-inferential.md): 24問, Mid-Level - [Web Scraping](https://sharpskill.dev/ja/technologies/data-science/interview-questions/web-scraping.md): 18問, Mid-Level - [BigQuery & Cloud Data](https://sharpskill.dev/ja/technologies/data-science/interview-questions/bigquery-cloud.md): 18問, Mid-Level - [Feature Engineering](https://sharpskill.dev/ja/technologies/data-science/interview-questions/feature-engineering.md): 22問, Mid-Level - [教師あり機械学習:回帰](https://sharpskill.dev/ja/technologies/data-science/interview-questions/ml-supervised-regression.md): 24問, Mid-Level - [教師あり機械学習:分類](https://sharpskill.dev/ja/technologies/data-science/interview-questions/ml-supervised-classification.md): 24問, Mid-Level - [決定木とアンサンブル](https://sharpskill.dev/ja/technologies/data-science/interview-questions/ml-trees-ensembles.md): 24問, Mid-Level - [教師なしML](https://sharpskill.dev/ja/technologies/data-science/interview-questions/ml-unsupervised.md): 22問, Mid-Level - [MLパイプラインと検証](https://sharpskill.dev/ja/technologies/data-science/interview-questions/ml-pipelines-validation.md): 22問, Mid-Level - [時系列と予測](https://sharpskill.dev/ja/technologies/data-science/interview-questions/time-series-forecasting.md): 22問, Mid-Level - [Deep Learningの基礎](https://sharpskill.dev/ja/technologies/data-science/interview-questions/deep-learning-fundamentals.md): 24問, Senior - [TensorFlow & Keras](https://sharpskill.dev/ja/technologies/data-science/interview-questions/tensorflow-keras.md): 22問, Senior - [CNN と画像分類](https://sharpskill.dev/ja/technologies/data-science/interview-questions/cnn-image-classification.md): 24問, Senior - [RNNとシーケンス](https://sharpskill.dev/ja/technologies/data-science/interview-questions/rnn-sequences.md): 22問, Senior - [NLPとHugging Face](https://sharpskill.dev/ja/technologies/data-science/interview-questions/nlp-huggingface.md): 24問, Senior - [GenAIとLangChain](https://sharpskill.dev/ja/technologies/data-science/interview-questions/genai-langchain.md): 24問, Senior - [MLOps とデプロイ](https://sharpskill.dev/ja/technologies/data-science/interview-questions/mlops-deployment.md): 24問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/data-science/interview-questions/transformers-attention