Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Contribute to 🤗 Transformers","local":"contribute-to--transformers","sections":[{"title":"Contents","local":"contents","sections":[],"depth":2},{"title":"Set up","local":"set-up","sections":[{"title":"Windows","local":"windows","sections":[],"depth":3}],"depth":2},{"title":"Opening issues","local":"opening-issues","sections":[{"title":"Bug-related issue","local":"bug-related-issue","sections":[],"depth":3},{"title":"Feature request","local":"feature-request","sections":[],"depth":3}],"depth":2},{"title":"Adding a new model","local":"adding-a-new-model","sections":[{"title":"Model addition timeline","local":"model-addition-timeline","sections":[],"depth":3}],"depth":2},{"title":"Docs","local":"docs","sections":[],"depth":2},{"title":"Agentic contributions","local":"agentic-contributions","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/transformers/pr_39895/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/entry/start.ed44d8d9.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/scheduler.31fdf58d.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/singletons.6a6316d3.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/index.252883d5.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/paths.6325da18.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/entry/app.75a9946c.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/preload-helper.f369a5fb.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/index.2f76fdf0.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/nodes/0.4d11f797.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/nodes/37.2e3d5e97.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/CopyLLMTxtMenu.121ef535.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.92a7ab29.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/IconCopy.ac192424.js"> | |
| <link rel="modulepreload" href="/docs/transformers/pr_39895/en/_app/immutable/chunks/CodeBlock.e52df5d6.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Contribute to 🤗 Transformers","local":"contribute-to--transformers","sections":[{"title":"Contents","local":"contents","sections":[],"depth":2},{"title":"Set up","local":"set-up","sections":[{"title":"Windows","local":"windows","sections":[],"depth":3}],"depth":2},{"title":"Opening issues","local":"opening-issues","sections":[{"title":"Bug-related issue","local":"bug-related-issue","sections":[],"depth":3},{"title":"Feature request","local":"feature-request","sections":[],"depth":3}],"depth":2},{"title":"Adding a new model","local":"adding-a-new-model","sections":[{"title":"Model addition timeline","local":"model-addition-timeline","sections":[],"depth":3}],"depth":2},{"title":"Docs","local":"docs","sections":[],"depth":2},{"title":"Agentic contributions","local":"agentic-contributions","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div 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>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> </div> <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 class="" 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> <blockquote class="warning" data-svelte-h="svelte-1msvpw1"><p>The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by | |
| code agents. We are currently bottlenecked by our ability to review and respond to them. As a result, | |
| <strong>we ask that new users do not submit pure code agent PRs</strong> at this time. | |
| You may use code agents in drafting or to help you diagnose issues. We’d also ask autonomous agents | |
| not to open any PRs or issues for the moment.</p> <p>PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this | |
| repeatedly or maliciously.</p></blockquote> <details data-svelte-h="svelte-hf13dz"><summary>Our code agent philosophy in detail</summary> <p>We understand that code agents are extremely powerful tools, and many people at Hugging Face use them in their work. | |
| However, it’s important to realize that <strong>if you simply run a code agent | |
| and generate a PR to an open-source project, you are merely a middleman between the reviewers and the agent</strong>. | |
| Although doing this creates something that looks very much like a useful contribution, in reality there was no reason | |
| for you to be involved; the reviewers could have simply run the code agent themselves.</p> <p>If you want to contribute usefully to open-source in the agent era, <strong>you need to do things that agents can’t do on | |
| their own</strong>. In particular, we’ve found the following to be very helpful:</p> <ul><li>Clear diagnosis of bugs. Code agents like to quickly fix problems with a workaround that often causes 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; code agents love adding three new functions and | |
| multi-line comments to draw attention to all the hard work they did. 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. Many code agents | |
| trust the user comments too much, which results in 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. Code agents often | |
| look at the code “narrowly”, and make a fix that causes models to diverge from the rest of the codebase.</li> <li>Avoid small or “busywork” PRs. In the past, we used to accept these, but given the current flood, we simply don’t | |
| have time for small style changes or typo fixes in comments. You can provide value beyond a code | |
| agent simply by having good taste about what’s really important.</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> <p>Please bear in mind that this is an exciting, rapidly-changing but challenging era for open-source development, and indeed | |
| for the software industry as a whole. We will likely be rapidly updating these guidelines as we learn more about | |
| dealing effectively with code agents. Have patience with us if reviews are slower than normal, or if some | |
| PRs are closed without review!</p></details> <p data-svelte-h="svelte-sh4iqv">Transformers welcomes all contributions whether it is fixing bugs, submitting feature requests, implementing new models, or improving docs.</p> <p data-svelte-h="svelte-is2di9">If you aren’t sure where to start, take a look at the <a href="https://github.com/huggingface/transformers/labels/Good%20First%20Issue" rel="nofollow">Good First Issues</a> for more beginner-friendly issues. For a more challenging issue, check out the <a href="https://github.com/huggingface/transformers/labels/Good%20Second%20Issue" rel="nofollow">Good Second Issues</a>. However you choose to contribute, please be mindful and respect our <a href="https://github.com/huggingface/transformers/blob/main/CODE_OF_CONDUCT.md" rel="nofollow">code of conduct</a>.</p> <p data-svelte-h="svelte-1acpv08">If you enjoyed using Transformers, feel free to reference it and let us know how you’re using it, shout us out on Twitter, or give the repository a star!</p> <p data-svelte-h="svelte-nbwsk8">This guide was heavily inspired by the <a href="https://github.com/scikit-learn/scikit-learn/blob/main/CONTRIBUTING.md" rel="nofollow">scikit-learn guide to contributing</a>.</p> <h2 class="relative group"><a id="contents" 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="#contents"><span><svg class="" 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>Contents</span></h2> <ol data-svelte-h="svelte-1vv3e4q"><li><a href="#set-up">Set up</a> <ul><li><a href="#windows">Windows</a></li></ul></li> <li><a href="#opening-issues">Opening issues</a> <ul><li><a href="#bug-related-issue">Bug-related issue</a></li> <li><a href="#feature-request">Feature request</a></li></ul></li> <li><a href="#adding-a-new-model">Adding a new model</a> <ul><li><a href="#model-addition-timeline">Model addition timeline</a></li></ul></li> <li><a href="#docs">Docs</a></li> <li><a href="#agentic-contributions">Agentic contributions</a></li></ol> <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 class="" 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 data-svelte-h="svelte-lnc018">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 class="" 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 "><!-- HTML_TAG_START -->git <span class="hljs-built_in">clone</span> git@github.com:<your Github handle>/transformers.git | |
| <span class="hljs-built_in">cd</span> transformers<!-- HTML_TAG_END --></pre></div></li> <li><p data-svelte-h="svelte-1b0kbcj">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 class="" 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 "><!-- HTML_TAG_START -->git remote add upstream https://github.com/huggingface/transformers.git | |
| git remote -v | |
| <span class="hljs-comment"># origin git@github.com:<your Github handle>/transformers.git (fetch)</span> | |
| <span class="hljs-comment"># origin git@github.com:<your Github handle>/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><!-- HTML_TAG_END --></pre></div></li> <li><p data-svelte-h="svelte-167s5fw">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 class="" 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 "><!-- HTML_TAG_START -->git checkout main && git pull upstream main && git push origin main | |
| git switch -c a-descriptive-name-for-my-branch<!-- HTML_TAG_END --></pre></div></li> <li><p data-svelte-h="svelte-ixho3l">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 class="" 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 "><!-- HTML_TAG_START -->pip install -e <span class="hljs-string">".[dev]"</span> | |
| <span class="hljs-comment"># for model contributions</span> | |
| pip install -e <span class="hljs-string">".[torch,testing]"</span> | |
| <span class="hljs-comment"># for docs-only changes and small fixes</span> | |
| pip install -e <span class="hljs-string">".[quality]"</span><!-- HTML_TAG_END --></pre></div></li></ol> <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 class="" 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 data-svelte-h="svelte-1wljenl">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 class="" 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 "><!-- HTML_TAG_START -->git config core.autocrlf input<!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-108l07g">One way to run the <code>make</code> command on Windows is with MSYS2.</p> <ol data-svelte-h="svelte-apds4l"><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 data-svelte-h="svelte-1m7mm81">You can now use <code>make</code> from any terminal (PowerShell, cmd.exe, etc.).</p> <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 class="" 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 data-svelte-h="svelte-1lzhpu4">Use the issue <a href="https://github.com/huggingface/transformers/tree/main/.github/ISSUE_TEMPLATE" rel="nofollow">templates</a> to help you get started.</p> <h3 class="relative group"><a id="bug-related-issue" 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="#bug-related-issue"><span><svg class="" 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>Bug-related issue</span></h3> <p data-svelte-h="svelte-1h3y1tw">Make sure the bug wasn’t already reported before opening an issue (use the search bar on GitHub under Issues). The issue should be a bug in Transformers, not in your own code.</p> <p data-svelte-h="svelte-ssrjnl">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> <p data-svelte-h="svelte-1u5rwvl">Include the following so we can resolve it quickly.</p> <ul data-svelte-h="svelte-uc26ci"><li>Your <em>OS type and version</em> and <em>Python</em>, and <em>PyTorch</em> versions when applicable.</li> <li>A short, self-contained, code snippet that allows us to reproduce the bug.</li> <li>The <em>full</em> traceback if an exception is raised.</li> <li>Any other information, like screenshots, that may help.</li></ul> <p data-svelte-h="svelte-1drr0oo">To get the OS and software versions automatically, run the following command.</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 class="" 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 "><!-- HTML_TAG_START -->transformers <span class="hljs-built_in">env</span><!-- HTML_TAG_END --></pre></div> <h3 class="relative group"><a id="feature-request" 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="#feature-request"><span><svg class="" 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>Feature request</span></h3> <p data-svelte-h="svelte-1gifl5o">Open an issue and describe:</p> <ul data-svelte-h="svelte-tc6qt5"><li>The <em>motivation</em> such as a frustration with the library, a project need, or work you’ve done that could benefit the community.</li> <li>The feature in as much detail as possible.</li> <li>A <em>code snippet</em> demonstrating the feature’s usage.</li> <li>A link to the relevant paper, if applicable.</li></ul> <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 class="" 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 data-svelte-h="svelte-1vv9l17">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 data-svelte-h="svelte-zoldu0">Follow the guides below.</p> <ol data-svelte-h="svelte-14xm0w7"><li><a href="docs/source/en/modular_transformers">Add a model with modular Transformers</a> — implement the model using the modular file and generate standalone modeling files.</li> <li><a href="docs/source/en/auto_docstring">Auto-generate docstrings</a> — use the <code>@auto_docstring</code> decorator to generate consistent docstrings without boilerplate.</li> <li><a href="docs/source/en/testing">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="docs/source/en/modeling_rules">Model structure rules</a> — check your files pass the static model structure rules enforced by <code>make typing</code>.</li></ol> <p data-svelte-h="svelte-1djwum9">Some model additions need extra integration work.</p> <ul data-svelte-h="svelte-14xa27z"><li><a href="docs/source/en/add_vision_processing_components">Add vision processing components</a> if your model requires image or video inputs.</li> <li><a href="docs/source/en/weightconverter">Dynamic weight loading</a> if published checkpoint parameter names do not match the Transformers implementation.</li></ul> <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 class="" 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 data-svelte-h="svelte-om5qbx">There are four timelines for model additions depending on the model contributor and community demand for an architecture.</p> <ul data-svelte-h="svelte-1uz8ugv"><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=&labels=New+model&projects=&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>Open issues tagged <a href="https://github.com/huggingface/transformers/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+model%22" rel="nofollow">“New model”</a> are the entry point for outside contributors. Start with the most-requested architectures to maximize impact. 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="./docs/source/en/models#custom-models">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> <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 class="" 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 data-svelte-h="svelte-15o1bki">Improvements to the docs, like typos, missing content or unclear explanations, are always welcome. For API reference generated from source files, use the <a href="./docs/source/en/auto_docstring"><code>@auto_docstring</code></a> decorator when it applies. Open a pull request directly for meaningful documentation fixes.</p> <p data-svelte-h="svelte-o7my77">Refer to the docs <a href="./docs/README">README</a> for more details about how to edit the docs and the syntax we use.</p> <h2 class="relative group"><a id="agentic-contributions" 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="#agentic-contributions"><span><svg class="" 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>Agentic contributions</span></h2> <p data-svelte-h="svelte-17wlzgc">AI-assisted contributions are welcome. They must be coordinated, scoped, and verified to keep review load manageable.</p> <ul data-svelte-h="svelte-zlv13m"><li>Do not submit “pure agent” PRs. The human submitter is responsible for reviewing all changed lines, validating behavior end-to-end, and running relevant tests.</li> <li>If AI tools were used, disclose this in the PR description and include: coordination link, differentiation from existing PRs (if applicable), and test commands/results.</li> <li>Avoid one-off “busywork” PRs (single typo, isolated style cleanup, one mutable default fix, etc.). Bundle mechanical cleanups into a clear, systematic scope.</li> <li>Coordinate on issues before opening a PR, review similar PRs, and wait for approval.</li></ul> <blockquote class="note" data-svelte-h="svelte-iccvx"><p>These topics are outlined for agents in <code>AGENTS.md</code> with instruction for how to autonomously implement them.</p></blockquote> <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 data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_sw4oup = { | |
| assets: "/docs/transformers/pr_39895/en", | |
| base: "/docs/transformers/pr_39895/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/transformers/pr_39895/en/_app/immutable/entry/start.ed44d8d9.js"), | |
| import("/docs/transformers/pr_39895/en/_app/immutable/entry/app.75a9946c.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 37], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 44.2 kB
- Xet hash:
- 2fe30aa7fe2e3e84506886904d917c8edb3e35642976b95eb5fede5cb480d1c7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.