Buckets:

hf-doc-build/doc / transformers /main /ja /pr_checks.html
mishig's picture
download
raw
49.8 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;プルリクエストのチェック&quot;,&quot;local&quot;:&quot;pull-request-checks&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;CIの修正&quot;,&quot;local&quot;:&quot;fixing-the-ci&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;コードの品質&quot;,&quot;local&quot;:&quot;code-quality&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;リポジトリの整合性&quot;,&quot;local&quot;:&quot;repository-consistency&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;レビュアーの割り当て&quot;,&quot;local&quot;:&quot;reviewer-assignment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;テスト&quot;,&quot;local&quot;:&quot;tests&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;テストの選択&quot;,&quot;local&quot;:&quot;test-selection&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;テストジョブのカテゴリ&quot;,&quot;local&quot;:&quot;test-job-categories&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;低速テスト&quot;,&quot;local&quot;:&quot;slow-tests&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;ドキュメントのビルド&quot;,&quot;local&quot;:&quot;documentation-build&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;# 構文からコピー&quot;,&quot;local&quot;:&quot;-copied-from-syntax&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/transformers/main/en/_app/immutable/entry/start.ByZEd4qm.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DHdg-_0Z.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/CBySwR1V.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/entry/app.CQqZS61p.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/Cdb1BouH.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/dUGfULTE.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DOLBYqcr.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/nodes/0.CEy2b_T8.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/Conj1S5Z.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/nodes/690.CT9vsX1o.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DoQ7MZQh.js" rel="modulepreload">
<!--1ge1etd--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Pull request checks&quot;,&quot;local&quot;:&quot;pull-request-checks&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Fixing the CI&quot;,&quot;local&quot;:&quot;fixing-the-ci&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Code quality&quot;,&quot;local&quot;:&quot;code-quality&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Repository consistency&quot;,&quot;local&quot;:&quot;repository-consistency&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Reviewer assignment&quot;,&quot;local&quot;:&quot;reviewer-assignment&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Tests&quot;,&quot;local&quot;:&quot;tests&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Test selection&quot;,&quot;local&quot;:&quot;test-selection&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Test job categories&quot;,&quot;local&quot;:&quot;test-job-categories&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Slow tests&quot;,&quot;local&quot;:&quot;slow-tests&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3},{&quot;title&quot;:&quot;Documentation build&quot;,&quot;local&quot;:&quot;documentation-build&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;# Copied from syntax&quot;,&quot;local&quot;:&quot;-copied-from-syntax&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/><!---->
<link href="/docs/transformers/main/en/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: inline-end; margin-inline-start: 10px; display: inline-flex; position: relative; z-index: 10;"><div dir="ltr" class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----></span> <span dir="auto">Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg><!----></button></div> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="pull-request-checks" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#pull-request-checks"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->プルリクエストのチェック<!----></span></h1><!--]--><!----> <p>プルリクエストを開くと、Hugging Face CI が複数のチェックを実行します。これらのチェックに合格する必要があります。</p> <ul><li><a href="#fixing-the-ci">CIの修正</a>では、チェックをパスするためにローカルで実行するコマンドが記載されています。</li> <li>その後のセクションでは、<a href="#code-quality">コードの品質</a>や<a href="#repository-consistency">リポジトリの一貫性</a>など、各チェックが検証する内容について説明しています。</li> <li><a href="#tests">テスト</a>では、実行されるテスト、テストのカテゴリ、およびスローテストについて説明しています。</li></ul> <!--[1--><h2 class="relative group"><a id="fixing-the-ci" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#fixing-the-ci"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->CIの修正<!----></span></h2><!--]--><!----> <p>ほとんどの場合、<code>make style</code>を実行するだけで、最もよくある失敗原因であるコード品質チェックをクリアできます。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->make style<!----></pre></div><!----> <p>リポジトリの整合性、コピー、または自動生成ファイルに関する問題が発生した場合は、<code>make fix-repo</code> を実行してください。これにより、スタイル、コピー、ドキュメント文字列、自動生成ファイルが一度のパスで修正されます。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->make fix-repo<!----></pre></div><!----> <p>より大規模な変更に対しては、以下の3コマンドのシーケンスがすべてのチェックを網羅します。負荷は大きくなりますが、pushする前にすべての問題を検出できます。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->make fix-repo <span class="hljs-comment"># auto-fix everything that can be auto-fixed</span>
make typing <span class="hljs-comment"># check types and model structure, fix any errors manually</span>
make check-repo <span class="hljs-comment"># verify all checks pass, fix anything that remains</span><!----></pre></div><!----> <p><code>make typing</code> は、手動で修正する必要がある型エラーやモデル構造の違反を検出します。<code>make check-repo</code> は、最終的な読み取り専用パスを実行して、すべてが準備完了であることを確認できます。</p> <blockquote class="note"><p>CI はときどき不安定です。変更内容と無関係な項目でチェックが失敗した場合は、メンテナーに連絡して再実行を依頼してください。</p></blockquote> <!--[1--><h2 class="relative group"><a id="code-quality" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#code-quality"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->コードの品質<!----></span></h2><!--]--><!----> <p>コード品質チェックは、フォーマット、インポート、型チェック、モデル構造のルールをカバーします。<code>make fix-repo</code> および <code>make typing</code> に相当します。</p> <p><code>make style</code>(<code>make fix-repo</code> に含まれます)は、<a href="https://docs.astral.sh/ruff/" rel="nofollow">Ruff</a> のリンティングとフォーマット、<code>__init__.py</code> のインポートの並び順、およびオートマッピングの一貫性を自動修正します。</p> <p><code>make typing</code> は <a href="https://docs.astral.sh/ty/" rel="nofollow">ty</a> を使用して型チェックを実行し、config クラスの命名規則や <code>forward()</code> シグネチャを含む TRansFormers (TRF) ルールを検証します。型エラーと TRF の違反は特定のルール番号が報告され、手動での修正が必要です。これらのルールは <a href="https://github.com/huggingface/transformers-mlinter" rel="nofollow">mlinter</a> リポジトリに格納されています。すべての TRF ルールを確認するには <code>python -m utils.mlinter --list-rules</code> を、特定のルールの完全なドキュメントを表示するには <code>python -m utils.mlinter --rule TRFXXX</code> を実行してください。</p> <p>TRFルールに例外が必要な場合は、以下のオプションのいずれかを選択してください(詳細は<a href="./modeling_rules#suppressing-violations">違反の抑制</a>を参照)。</p> <ul><li><code>utils/mlinter/rules.toml</code> の該当するルールにおいて、<code>allowlist_models</code> リストにモデル名を追加してください。モデルファイル全体に例外を適用する場合は、この方法を使用します。</li> <li><code># trf-ignore: TRFXXX</code> を、対象の構文と同じ行、またはその直前の行に追加します。例外を1つの構文にのみ適用する場合に使用します。</li></ul> <!--[1--><h2 class="relative group"><a id="repository-consistency" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#repository-consistency"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->リポジトリの整合性<!----></span></h2><!--]--><!----> <p>リポジトリの整合性チェックは<code>make check-repo</code>と同様ですが、最初の失敗で停止します。以下のカテゴリ間でリポジトリの内部整合性を保ちます。公開オブジェクトがインポート可能であること、コピーされたコードがソースと同期していること、自動生成ファイル(ダミー、ドキュメントテスト、メタデータ)がコードの現在の状態を反映していることです。新しいモデルについては、すべての新しいモデルクラスが自動マッピングに登録されていることも検証します。</p> <table><thead><tr><th>カテゴリ</th><th>検証対象</th><th>自動修正されましたか?</th></tr></thead><tbody><tr><td>Init ファイル</td><td><code>src/transformers/models/</code> 内の <code>__init__.py</code> ファイルは最新の状態です</td><td><code>make fix-repo</code></td></tr><tr><td>コピーとモジュール</td><td><code># Copied from</code> ブロックはソースと一致しており、モジュラー生成ファイルは最新の状態です</td><td><code>make fix-repo</code></td></tr><tr><td>Docstringとドキュメント</td><td>引数のドキュメント文字列は、関数のシグネチャおよびドキュメントの目次と一致しています</td><td><code>make fix-repo</code></td></tr><tr><td>自動生成ファイル</td><td>ダミー、パイプラインの型付け、doctest リスト、メタデータ、依存関係テーブル</td><td><code>make fix-repo</code></td></tr><tr><td>設定の検証</td><td>Config クラスには docstring に有効なチェックポイントが含まれており、config の属性はモデリングファイルと一致しています</td><td>マニュアル</td></tr><tr><td>レビュアーの割り当て</td><td>すべてのモデルディレクトリと、レビュアーファイル内のすべてのルールは、依然としてレビュアーに到達します</td><td>マニュアル</td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="reviewer-assignment" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#reviewer-assignment"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->レビュアーの割り当て<!----></span></h2><!--]--><!----> <p>プルリクエストがレビュー準備完了にマークされると、<code>Assign PR Reviewers</code>ワークフローが、そのプルリクエストが所有するファイル内で変更した行数に基づいてランキングされた最大2人のレビュアーをリクエストします。ドラフト状態のプルリクエストには、ドラフトから外れるまでレビュアーが割り当てられません。ワークフロー自体は <a href="https://github.com/huggingface/transformers-ci" rel="nofollow">huggingface/transformers-ci</a> に存在し、このリポジトリから呼び出されます。このリポジトリに残っているのは、ワークフローが読み取る所有権データです。</p> <p>所有権はファイルごとに解決され、より具体的なものから優先的に適用されます。</p> <table><thead><tr><th>どこ</th><th>〜のように見えます</th><th>使用用途</th></tr></thead><tbody><tr><td>モデルファイル</td><td><code># Reviewers: @login</code> を、<code>modular_&lt;model>.py</code> または <code>modeling_&lt;model>.py</code> の先頭のコメントブロックに記述します。</td><td>そのモダリティのオーナー以外の人を必要とするモデルです。モジュラーコンバーターはヘッダーを生成されたモデリングファイルにコピーするため、タグは再生成後も保持されます。</td></tr><tr><td>パスルール</td><td><code>.github/scripts/codeowners_for_review_action</code> 内の <code>/src/transformers/&lt;area>/ @login</code></td><td>モデル以外のもの</td></tr><tr><td>モダリティのテーブル</td><td><code>@@modality/vision @login</code>、同じファイル内</td><td><code>docs/source/en/_toctree.yml</code> のそのセクションにドキュメントページが配置されているすべてのモデル</td></tr><tr><td>キャッチオール</td><td><code>* @Rocketknight1 @ArthurZucker</code></td><td>何もない</td></tr></tbody></table> <p>新しいモデルにはどこにもエントリを追加する必要はありません。<code>_toctree.yml</code> にそのドキュメントページを追加するだけで、これはドキュメントの目次チェックで既に必須とされていることですが、それによりモデルが特定のモダリティに配置され、以降はモダリティのテーブルで自動的にカバーされます。</p> <p>レビューのリクエストは、リポジトリのコラボレーターに対してのみ送信できます。ワークフローは各レビュアーに対して個別の呼び出しでリクエストを行い、リクエストできないユーザーはスキップします。そのため、退社したユーザーを指定するエントリは全員ではなく1人のレビュアー分しかコストがかからず、すべてのスキップはワークフロー実行の警告として報告されます。</p> <p>プルリクエストは、自身のレビューを再ルーティングできません。<code>.github/scripts/codeowners_for_review_action</code> はベースブランチから読み込まれ、プルリクエストのヘッドからは決して読み込まれません。また、PR CI のセキュリティゲートは、コラボレーター以外からのプルリクエストが <code>src/</code>、<code>tests/</code>、<code>docs/</code>、<code>utils/</code> の外にあるファイルを変更することをブロックします。そのため、このファイルは現在のような場所に配置されています。<code># Reviewers:</code> タグはヘッドから読み込まれます。新しいモデルがこれに伴って追加されるため、このタグに指定されたすべてのログイン名は、レビュー依頼が行われる前に、コラボレーターチェックを通過する必要があります。</p> <p><code>make check-repository-consistency</code> は <code>utils/check_reviewers.py</code> を実行します。このスクリプトは、モデルがキャッチオール以外の誰にも割り当てられない場合、ルールがどのファイルにもマッチしなくなった場合、またはモダリティのテーブルが目次と一致しない場合に失敗します。このスクリプトは割り当てワークフローとリゾルバーを共有しているため、両者の間で不一致が生じることはありません。このリゾルバーは <code>transformers</code> の依存関係ではなく、<code>utils/checkers-requirements.txt</code> に記載されています。チェッカーランナーは、環境での初回実行時にこれをインストールします。インストールが実行できない場合(オフラインの場合など)、チェックはそれを報告して合格扱いとし、処理をブロックしません。
<code>src/transformers/models</code> の外側でオーナーが設定されていないパスは、注記として報告されます。リストするには:</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->python utils/check_reviewers.py --strict<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="tests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tests"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->テスト<!----></span></h2><!--]--><!----> <p>CI は、PR で変更された内容に基づいて、対象となるテストのサブセットを実行します。CI は結合したテストを検出するために、<a href="https://github.com/jbasko/pytest-random-order" rel="nofollow">pytest-random-order</a> を使用してテストをわずかにランダムな順序で実行します。実行の開始時にランダムシードが出力されるため、<code>--random-order-seed=&lt;seed></code> を使用して同じ順序を再現できます。</p> <p>テストがローカルの GPU では成功するものの CI では失敗する場合は、<code>TRANSFORMERS_TEST_DEVICE="cpu"</code> を設定して、CPU 上で失敗を再現できるか確認してください。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->TRANSFORMERS_TEST_DEVICE=<span class="hljs-string">&quot;cpu&quot;</span> pytest tests/models/my_model/ -v<!----></pre></div><!----> <p>以下のセクションでは、テストの選択方法、実行されるジョブ、および低速なテストの対処法について説明します。</p> <!--[2--><h3 class="relative group"><a id="test-selection" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#test-selection"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->テストの選択<!----></span></h3><!--]--><!----> <p>CI はすべての PR に対して完全なテストスイートを実行しません。CI はすべての PR で <code>@slow</code> で装飾されたテストをスキップし、PR がレビュー対象となった時点で、メンテナーが GPU 上でそれらをトリガーします。</p> <p><code>utils/tests_fetcher.py</code> は、変更されたファイルからインポート依存関係をトレースして影響を受けるテストを特定し、それらのテストのみを実行します。また、共有ユーティリティに変更を加えた際に、他のモデルでのリグレッションも検出します。フェッチャーは、変更されたファイルと影響を受けるテストを出力し、そのリストを <code>tests_torch_test_list.txt</code> に書き出します。</p> <p>fetcherを使用して、CIが実行する内容を正確に再現します。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->python utils/tests_fetcher.py
python -m pytest -n 8 --dist=loadfile -rA -s $(<span class="hljs-built_in">cat</span> test_preparation/tests_torch_test_list.txt)<!----></pre></div><!----> <blockquote class="tip"><p><code>modeling_utils.py</code> や <code>generation/utils.py</code> といったコアファイルを変更すると、影響を受けるサブセットだけでなく、すべてのモデルテストがトリガーされます。</p></blockquote> <p>モデルのすべてのテストを無条件で実行することもできます。直接実行はより高速なローカルでの健全性チェックですが、変更した共有コードによって他のモデルに生じたリグレッションを検出することはできません。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->pytest tests/models/my_model/ -v<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="test-job-categories" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#test-job-categories"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->テストジョブのカテゴリ<!----></span></h3><!--]--><!----> <p>テストは並列CIジョブに分割されており、各ジョブはパスパターンに基づいてファイルを選択します。モデルのPRに関連するジョブは以下の通りです。</p> <ul><li><code>tests_torch</code>: モデリングのテスト(<code>tests/models/*/test_modeling_*.py</code>)</li> <li><code>tests_tokenization</code>: トークナイザのテスト(<code>tests/models/*/test_tokenization_*.py</code>)</li> <li><code>tests_processors</code>: プロセッサーおよびフィーチャーエクストラクターのテスト(<code>tests/models/*/test_(processing|image_processing|feature_extractor)_*.py</code>)</li> <li><code>tests_generate</code>: 生成テスト</li> <li><code>pipelines_torch</code>: パイプラインのテスト</li> <li><code>tests_training_ci</code>: トレーニングループのテスト</li> <li><code>tests_tensor_parallel_ci</code>: テンソル並列テスト</li> <li><code>tests_fsdp_ci</code>: FSDP テスト</li></ul> <!--[2--><h3 class="relative group"><a id="slow-tests" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#slow-tests"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->低速テスト<!----></span></h3><!--]--><!----> <p>通常のCI実行では、<code>@slow</code>デコレータが付与されたテストはスキップされます。これらのテストは実際のチェックポイントのダウンロードや、大量の計算リソースを必要とするため、GPUインスタンス上で実行されます。また、PRがレビュー対象となった時点で、メンテナーによってトリガーされます。</p> <p>Slow tests は NVIDIA A10 で実行され、数値結果は CI ハードウェアとローカルマシンの間でわずかに異なる場合があります。新しいモデルを追加する際、必要に応じてメンテナーは通常、テスト内のこれらの値を調整します。</p> <p>以下のコマンドで、ローカル環境でスローテストを実行します。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-bash "><!---->RUN_SLOW=1 python -m pytest tests/models/my_model/ -v<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="documentation-build" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#documentation-build"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!---->ドキュメントのビルド<!----></span></h3><!--]--><!----> <p><code>build_pr_documentation</code> ジョブはドキュメントをビルドし、プレビューを生成します。ボットがPRにプレビューリンクを投稿し、マージ前にこのチェックがパスする必要があります。失敗の多くは、<code>toctree</code> へのエントリが欠けていることが原因です。ローカルでドキュメントをビルドする方法については、docs フォルダー内の <a href="https://github.com/huggingface/transformers/tree/main/docs" rel="nofollow">README.md</a> を参照してください。</p> <!--[1--><h2 class="relative group"><a id="-copied-from-syntax" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#-copied-from-syntax"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span><!----># 構文からコピー<!----></span></h2><!--]--><!----> <blockquote class="warning"><p>新しいモデルでは、<code># Copied from</code> よりも <a href="modular_transformers">モジュラーワークフロー</a>(<code>modular_*.py</code>)を常に優先してください。<code># Copied from</code> は、可能な限り避けてください。</p></blockquote> <p><code># Copied from</code> メカニズムは、コピーされたコードをソースと同期させます。<code>make fix-repo</code> が実行されると、すべての <code># Copied from</code> ブロックがチェックされ、オリジナルに合わせて更新されるため、<code># Copied from</code> ブロック内の編集は上書きされます。代わりにソースを編集し、<code>make fix-repo</code> に変更を伝播させましょう。</p> <p><code># Copied from</code>の基本的な形式には、次のものがあります。</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> コピーしました</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertSelfOutput</span>
<span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertAttention with Bert-&gt;Roberta</span>
<span class="hljs-comment"># Copied from transformers.models.bert.modeling_bert.BertForSequenceClassification with Bert-&gt;MobileBert all-casing</span><!----></pre></div><!----> <p><code>with model->newModel</code> 構文は、コピー後に文字列の置換を適用します。複数の置換はカンマで区切り、左から右の順に適用されます。<code>all-casing</code> オプションを使用すると、すべての大文字・小文字のバリアントが一度に置換されます(<code>Bert</code>、<code>bert</code>、<code>BERT</code> がそれぞれ <code>MobileBert</code>、<code>mobilebert</code>、<code>MOBILEBERT</code> に置き換わります)。</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/transformers/blob/main/docs/source/en/pr_checks.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg><!----> <span><span class="underline">Update</span> on GitHub</span></a><!----> <p></p><!--]--><!----><!--]--><!--]--><!--]--> <!--[-1--><!--]--><!--]-->
<script>
{
__sveltekit_1y3v6y9 = {
base: "/docs/transformers/main/en",
assets: "/docs/transformers/main/en"
};
const element = document.currentScript.parentElement;
Promise.all([
import("/docs/transformers/main/en/_app/immutable/entry/start.ByZEd4qm.js"),
import("/docs/transformers/main/en/_app/immutable/entry/app.CQqZS61p.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 690],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
49.8 kB
·
Xet hash:
3edfe0769fd6bc0403a91b6b050fd082427671868b2bc4c5542dc163705c962e

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.