Buckets:

download
raw
37.6 kB
<meta charset="utf-8" /><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Contribute to 🤗 Transformers&quot;,&quot;local&quot;:&quot;contribute-to--transformers&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Contribution rules&quot;,&quot;local&quot;:&quot;contribution-rules&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Set up&quot;,&quot;local&quot;:&quot;set-up&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Windows&quot;,&quot;local&quot;:&quot;windows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Opening issues&quot;,&quot;local&quot;:&quot;opening-issues&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Adding a new model&quot;,&quot;local&quot;:&quot;adding-a-new-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Model addition timeline&quot;,&quot;local&quot;:&quot;model-addition-timeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Docs&quot;,&quot;local&quot;:&quot;docs&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2}],&quot;depth&quot;:1}"/>
<link href="/docs/transformers/main/en/_app/immutable/entry/start.DYIO-UII.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DSYYoqAA.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/BovLmb3z.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/entry/app.D2_KizbC.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/WyYpyc-L.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/DYBfcveH.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.ByO_lNbj.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/ZtBhN-Ei.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/nodes/40.BE1gI297.js" rel="modulepreload">
<link href="/docs/transformers/main/en/_app/immutable/chunks/D-dvW--N.js" rel="modulepreload">
<!--122tzrt--><meta name="hf:doc:metadata" content="{&quot;title&quot;:&quot;Contribute to 🤗 Transformers&quot;,&quot;local&quot;:&quot;contribute-to--transformers&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Contribution rules&quot;,&quot;local&quot;:&quot;contribution-rules&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Set up&quot;,&quot;local&quot;:&quot;set-up&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Windows&quot;,&quot;local&quot;:&quot;windows&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Opening issues&quot;,&quot;local&quot;:&quot;opening-issues&quot;,&quot;sections&quot;:[],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Adding a new model&quot;,&quot;local&quot;:&quot;adding-a-new-model&quot;,&quot;sections&quot;:[{&quot;title&quot;:&quot;Model addition timeline&quot;,&quot;local&quot;:&quot;model-addition-timeline&quot;,&quot;sections&quot;:[],&quot;depth&quot;:3}],&quot;depth&quot;:2},{&quot;title&quot;:&quot;Docs&quot;,&quot;local&quot;:&quot;docs&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="contribute-to--transformers" 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="#contribute-to--transformers"><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><!---->Contribute to 🤗 Transformers<!----></span></h1><!--]--><!----> <!--[1--><h2 class="relative group"><a id="contribution-rules" 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="#contribution-rules"><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><!---->Contribution rules<!----></span></h2><!--]--><!----> <p>There are two ways to open a PR: fix an issue that’s open for contributions, or open a standalone PR that carries its own evidence. New models can also be added with a standalone PR, see <a href="#adding-a-new-model">Adding a new model</a>. Hugging Face staff, maintainers and some long-standing contributors are exempt from these rules.</p> <p><strong>Fixing an issue.</strong> Link the issue with a closing keyword like <code>Fixes #123</code> in the PR description. You can work on:</p> <ul><li>an issue you opened, once a maintainer has labeled it <code>triaged</code></li> <li>an issue labeled <a href="https://github.com/huggingface/transformers/labels/contributions-welcome" rel="nofollow"><code>contributions-welcome</code></a></li> <li>an issue labeled <a href="https://github.com/huggingface/transformers/labels/New%20model" rel="nofollow"><code>New model</code></a>, see <a href="#adding-a-new-model">Adding a new model</a></li></ul> <p>Other people’s issues aren’t open for PRs unless a maintainer has said so. PRs that link an issue you can’t work on will be closed.</p> <p>You don’t need to ask before working on an issue that qualifies, and we don’t assign issues to people. Comments like “can I work on this?” or “please assign this to me” just add noise, so skip them and open your PR. The first PR for an issue gets priority.</p> <p>Before working on a <code>contributions-welcome</code> or <code>New model</code> issue, check whether someone has already opened a PR for it. If so, don’t open another one. If you spot mistakes, leave suggestions on the existing PR instead. Only open a competing PR if the existing one is fundamentally flawed, or stale: its author hasn’t responded to review comments or pushed changes for two weeks. A PR that’s waiting on a maintainer review isn’t stale. Either way, explain why in the issue before opening yours.</p> <p><strong>Standalone PRs.</strong> If nobody has reported the problem yet, you can open a PR without an issue. Standalone PRs are for short changes with real impact, like a bug fix, a performance improvement, or a fix for a broken example in the docs. The PR description needs the same evidence as an issue:</p> <ul><li>for a bug, a short script that fails on <code>main</code> and passes with your fix, using a published checkpoint, a default config, or a documented workflow</li> <li>for a performance improvement, before and after numbers on a realistic workload, like a published checkpoint or default config, and the hardware you ran on. A faster microbenchmark of a function that isn’t on a hot path doesn’t count.</li></ul> <p>If an issue already exists for the problem, your PR goes through that issue whether you link it or not. Standalone PRs that fix an existing issue, or that come without evidence, will be closed. These requirements don’t apply to new models.</p> <p><strong>Changes that need an issue first.</strong> Mechanical cleanups that don’t affect correctness or performance, and bulk fixes to typos or wording in the docs, need an issue before a PR. Propose the change, how you’d make it, and how many files it touches. A single typo fix is too small for a PR on either path.</p> <p><strong>Reviewing other people’s PRs.</strong> Reviews from the community are welcome when they tell us something new, but maintainers read every comment on a PR, and we already run our own review tools. Before you comment on a PR you didn’t open, make sure you have something specific to say:</p> <ul><li>If you found a problem or have a concrete change to propose, leave an inline comment on the relevant lines, ideally as a GitHub suggestion the author can apply directly. A reproducer helps if you’re reporting a bug.</li> <li>If you reported the issue the PR fixes, a quick note saying whether it fixes your case is really useful.</li> <li>Please don’t post general summaries or “I tested this and it works” reports. Approvals from non-maintainers don’t affect whether a PR gets merged, and a long comment that restates the PR costs us time without changing the outcome.</li></ul> <p>How you write your code is up to you, but you’re responsible for everything you submit, and we may block accounts that repeatedly open low-quality issues or PRs. Please also respect our <a href="https://github.com/huggingface/transformers/blob/main/CODE_OF_CONDUCT.md" rel="nofollow">code of conduct</a>.</p> <details><summary>What we look for in issues and PRs</summary> <ul><li>Clear diagnosis of bugs. Quick workarounds often cause code bloat or incompatibilities with other models. Spending time to track down the exact cause of a problem, and in particular
locating the first commit where it appeared (for example with <a href="https://git-scm.com/docs/git-bisect" rel="nofollow">git bisect</a>) is valuable.</li> <li>Minimize the diff. Check your PR to eliminate any unnecessary changes. Ensure that you did not commit any testing scripts
or unrelated files. Add comments only if they’re really necessary. If your PR can be a 1-line fix,
make it a 1-line fix. This makes the PR much easier to review and improves the chances that it will be accepted.</li> <li>Take the time to reproduce the problem. Very often when a user reports an issue, the issue is actually caused by
environment issues on their machine, or they misdiagnose the problem and suggest an invalid solution. Trusting the
report too much leads to bad solutions, sometimes for problems that do not exist! Writing a simple reproducer script and running it to make sure you see the problem is valuable.</li> <li>Compare against other models. The Transformers repo is very large, and many models are doing similar things. When
fixing a bug, it’s valuable to see if the bug exists in other models. If your PR says
“fixed by using the same approach as (other model)”, with a link to the relevant code, that is very helpful for maintainers,
because it tells us that the fix is likely to be correct and compatible with the rest of the codebase.</li> <li>Avoid “busywork” PRs. We don’t have time for small style changes or typo fixes in comments, and we don’t accept
fixes for “theoretical bugs” found by code analysis that rarely if ever cause problems in practice, unless they can
be exploited by an attacker.</li> <li>Verify tests locally and in the CI. Before opening a PR, run <code>make fix-repo</code> and use <code>utils/tests_fetcher.py</code> to
see a list of tests that cover the files you have changed in your PR branch. Run those tests locally, and make sure
they pass before you open a PR. After you open your PR, please verify that the CI is green and fix any issues before
pinging anyone for review! This reduces notification spam a lot, which keeps maintainers sane.</li></ul></details> <!--[1--><h2 class="relative group"><a id="set-up" 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="#set-up"><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><!---->Set up<!----></span></h2><!--]--><!----> <ol><li><p>Fork <a href="https://github.com/huggingface/transformers" rel="nofollow">Transformers</a> with the <strong>Fork</strong> button on GitHub to get a copy under your account, then clone it locally.</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> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git <span class="hljs-built_in">clone</span> git@github.com:&lt;your Github handle&gt;/transformers.git
<span class="hljs-built_in">cd</span> transformers<!----></pre></div><!----></li> <li><p>Add the Transformers repository as a remote named <code>upstream</code>. <code>origin</code> points at your fork and <code>upstream</code> points at the source of truth. That lets you sync your local <code>main</code> before pushing to <code>origin</code> and opening a PR.</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> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git remote add upstream https://github.com/huggingface/transformers.git
git remote -v
<span class="hljs-comment"># origin git@github.com:&lt;your Github handle&gt;/transformers.git (fetch)</span>
<span class="hljs-comment"># origin git@github.com:&lt;your Github handle&gt;/transformers.git (push)</span>
<span class="hljs-comment"># upstream https://github.com/huggingface/transformers.git (fetch)</span>
<span class="hljs-comment"># upstream https://github.com/huggingface/transformers.git (push)</span><!----></pre></div><!----></li> <li><p>Keep your fork up to date and start a branch to work on. You can also sync your fork from the GitHub UI with the <strong>Sync fork</strong> button.</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> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git checkout main &amp;&amp; git pull upstream main &amp;&amp; git push origin main
git switch -c a-descriptive-name-for-my-branch<!----></pre></div><!----></li> <li><p>Install the library in editable mode. Use <code>[dev]</code> for most contributions because it includes the development tools needed for style and quality checks. Use <code>[torch,testing]</code> for model contributions, or <code>[quality]</code> for docs-only changes and small fixes when the full development dependency set is not needed.</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> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->pip install -e <span class="hljs-string">&quot;.[dev]&quot;</span>
<span class="hljs-comment"># for model contributions</span>
pip install -e <span class="hljs-string">&quot;.[torch,testing]&quot;</span>
<span class="hljs-comment"># for docs-only changes and small fixes</span>
pip install -e <span class="hljs-string">&quot;.[quality]&quot;</span><!----></pre></div><!----></li></ol> <!--[2--><h3 class="relative group"><a id="windows" 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="#windows"><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><!---->Windows<!----></span></h3><!--]--><!----> <p>On Windows, unless you’re using <a href="https://learn.microsoft.com/en-us/windows/wsl/" rel="nofollow">WSL</a>, configure git to convert <code>CRLF</code> line endings to <code>LF</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> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git config core.autocrlf input<!----></pre></div><!----> <p>One way to run the <code>make</code> command on Windows is with MSYS2.</p> <ol><li><a href="https://www.msys2.org/" rel="nofollow">Download MSYS2</a> (we assume it’s installed in <code>C:\msys64</code>).</li> <li>Open the command line <code>C:\msys64\msys2.exe</code> (it should be available from the <strong>Start</strong> menu).</li> <li>Run in the shell: <code>pacman -Syu</code> and install <code>make</code> with <code>pacman -S make</code>.</li> <li>Add <code>C:\msys64\usr\bin</code> to your PATH environment variable.</li></ol> <p>You can now use <code>make</code> from any terminal (PowerShell, cmd.exe, etc.).</p> <!--[1--><h2 class="relative group"><a id="opening-issues" 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="#opening-issues"><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><!---->Opening issues<!----></span></h2><!--]--><!----> <p>Use the issue <a href="https://github.com/huggingface/transformers/tree/main/.github/ISSUE_TEMPLATE" rel="nofollow">templates</a>, and make sure the issue wasn’t already reported (use the search bar on GitHub under Issues). A bug report should be about a bug in Transformers, not in your own code, and it should affect real use and real checkpoints; a “theoretical bug” found by reading the code that requires a very nonstandard config to trigger won’t be triaged unless it’s a security issue. Include a short, self-contained script that reproduces the bug on the latest release or <code>main</code>, using a published checkpoint or default config. Bug reports without a runnable reproducer won’t be triaged.</p> <p>If you’re unsure whether the bug is in your code or the library, ask in the <a href="https://discuss.huggingface.co/" rel="nofollow">forum</a> or on <a href="https://discord.com/invite/hugging-face-879548962464493619" rel="nofollow">Discord</a> first. That helps keep GitHub focused on actionable library issues.</p> <!--[1--><h2 class="relative group"><a id="adding-a-new-model" 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="#adding-a-new-model"><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><!---->Adding a new model<!----></span></h2><!--]--><!----> <p>Adding a model to Transformers makes it available for anyone to load and fine-tune it or run inference. Before you start the implementation, isolate the differences between your architecture and recent state-of-the-art models that are already in Transformers. Explain those differences in the issue or PR so reviewers can quickly understand what challenges the model brings, what parts can reuse existing patterns, and what should be standardized across models.</p> <p>Follow the guides below.</p> <ol><li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/modular_transformers.md" rel="nofollow">Add a model with modular Transformers</a> — implement the model using the modular file and generate standalone modeling files.</li> <li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/auto_docstring.md" rel="nofollow">Auto-generate docstrings</a> — use the <code>@auto_docstring</code> decorator to generate consistent docstrings without boilerplate.</li> <li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/testing.md" rel="nofollow">Testing</a> — write and run model tests to verify correctness and keep the contribution maintainable. For causal language models, inherit from the causal LM tester where possible. Prioritize integration tests because they verify the full processor, tokenizer, and model path against real checkpoints.</li> <li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/modeling_rules.md" rel="nofollow">Model structure rules</a> — check your files pass the static model structure rules enforced by <code>make typing</code>.</li></ol> <p>Some model additions need extra integration work.</p> <ul><li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/add_vision_processing_components.md" rel="nofollow">Add vision processing components</a> if your model requires image or video inputs.</li> <li><a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/weightconverter.md" rel="nofollow">Dynamic weight loading</a> if published checkpoint parameter names do not match the Transformers implementation.</li></ul> <!--[2--><h3 class="relative group"><a id="model-addition-timeline" 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="#model-addition-timeline"><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><!---->Model addition timeline<!----></span></h3><!--]--><!----> <p>There are four timelines for model additions depending on the model contributor and community demand for an architecture.</p> <ul><li><p>Day-0 integration: make the model available in Transformers on release day with a new version release. We provide help to support the most important core features (quantization, FlashAttention, KV-cache, etc.), review early drafts, and can also take care of the model implementation depending on timelines.</p> <p>Email <a href="mailto:transformers@huggingface.co">transformers@huggingface.co</a> a few weeks ahead, especially for novel architectures. We’ll iterate with you on a private fork until your checkpoint and release are ready.</p></li> <li><p>Same-week integration: high-demand models usually land within a week, even when the author doesn’t reach out.</p> <p>Open an issue with the <a href="https://github.com/huggingface/transformers/issues/new?assignees=&amp;labels=New+model&amp;projects=&amp;template=new-model-addition.yml" rel="nofollow">new model template</a> to request one. Issues with more activity move up the queue faster.</p></li> <li><p>Post-release integration: models without strong demand, or that we don’t have bandwidth to take on, land after the upstream release.</p> <p>Outside contributors can open a PR for a new model directly, with or without an issue. Before you start, check the open <a href="https://github.com/huggingface/transformers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+model%22" rel="nofollow">“New model”</a> issues and the open PRs to make sure nobody is already adding it. We’ll review and guide you through it.</p></li> <li><p>Hub-first release: ship your model directly on the Hub via Transformers’ <a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/models.md#custom-models" rel="nofollow">remote-code</a> support, with no upstream PR required.</p> <p>Popular Hub-first models often get integrated into Transformers later, which unlocks first-class docs, maintenance, and optimization. Hub-first is the lowest-friction way to add a model. However, it can be more fragile if a model requires weight conversion or other backward compatibility issues.</p></li></ul> <!--[1--><h2 class="relative group"><a id="docs" 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="#docs"><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><!---->Docs<!----></span></h2><!--]--><!----> <p>For API reference generated from source files, use the <a href="https://github.com/huggingface/transformers/blob/main/docs/source/en/auto_docstring.md" rel="nofollow"><code>@auto_docstring</code></a> decorator when it applies. Refer to the docs <a href="https://github.com/huggingface/transformers/blob/main/docs/README.md" rel="nofollow">README</a> for more details about how to edit the docs and the syntax we use.</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/contributing.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_1m6yd5j = {
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.DYIO-UII.js"),
import("/docs/transformers/main/en/_app/immutable/entry/app.D2_KizbC.js")
]).then(([kit, app]) => {
kit.start(app, element, {
node_ids: [0, 40],
data: [null,null],
form: null,
error: null
});
});
}
</script>

Xet Storage Details

Size:
37.6 kB
·
Xet hash:
c5754d14a580b35f3c9a270a20cccb30d0ed00e2d64dde3dcdd4b10dd56f8daf

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