Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"自动生成文档字符串","local":"auto-generating-docstrings","sections":[{"title":"@auto_docstring","local":"autodocstring","sections":[],"depth":2},{"title":"用法","local":"usage","sections":[{"title":"模型类","local":"model-classes","sections":[],"depth":3},{"title":"配置类","local":"config-classes","sections":[],"depth":3},{"title":"处理器类","local":"processor-classes","sections":[{"title":"图像和视频处理器","local":"image-and-video-processors","sections":[],"depth":4}],"depth":3},{"title":"函数","local":"functions","sections":[],"depth":3},{"title":"记录参数","local":"documenting-arguments","sections":[],"depth":3}],"depth":2},{"title":"检查文档字符串","local":"checking-the-docstrings","sections":[],"depth":2},{"title":"快速参考清单","local":"quick-reference-checklist","sections":[],"depth":2},{"title":"工作原理","local":"how-it-works","sections":[],"depth":2}],"depth":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/11.CgcRyIiP.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/en/_app/immutable/chunks/D-dvW--N.js" rel="modulepreload"> | |
| <!--1wlpssc--><meta name="hf:doc:metadata" content="{"title":"Auto-generating docstrings","local":"auto-generating-docstrings","sections":[{"title":"@auto_docstring","local":"autodocstring","sections":[],"depth":2},{"title":"Usage","local":"usage","sections":[{"title":"Model classes","local":"model-classes","sections":[],"depth":3},{"title":"Config classes","local":"config-classes","sections":[],"depth":3},{"title":"Processor classes","local":"processor-classes","sections":[{"title":"Image and video processors","local":"image-and-video-processors","sections":[],"depth":4}],"depth":3},{"title":"Functions","local":"functions","sections":[],"depth":3},{"title":"Documenting arguments","local":"documenting-arguments","sections":[],"depth":3}],"depth":2},{"title":"Checking the docstrings","local":"checking-the-docstrings","sections":[],"depth":2},{"title":"Quick-reference checklist","local":"quick-reference-checklist","sections":[],"depth":2},{"title":"How it works","local":"how-it-works","sections":[],"depth":2}],"depth":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="auto-generating-docstrings" 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="#auto-generating-docstrings"><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><code>@auto_docstring</code> 装饰器会为模型类和方法生成一致的文档字符串。它会自动引入标准的参数描述,因此您只需为新参数或自定义参数编写文档。在<a href="./modular_transformers">添加新模型</a>时,可以跳过样板代码,专注于新增内容。</p> <!--[1--><h2 class="relative group"><a id="autodocstring" 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="#autodocstring"><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><!---->@auto_docstring<!----></span></h2><!--]--><!----> <p>在 <code>modular_model.py</code> 文件(对于较旧的模型,则为 <code>modeling_model.py</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-python "><!----><span class="hljs-keyword">from</span> ...utils <span class="hljs-keyword">import</span> auto_docstring<!----></pre></div><!----> <p>如果你的模型在模块化文件中继承自另一个库的模型,<code>@auto_docstring</code> 已在父类中应用。<code>make fix-repo</code> 会将其复制到生成的 <code>modeling_model.py</code> 文件中。仅在需要自定义其行为时(例如独立模型、自定义介绍或覆盖参数),才显式应用该装饰器。</p> <blockquote class="warning"><p>在模块化文件中重写任何装饰器时,请包含父函数或类中的<strong>所有</strong>装饰器。如果只重写其中一部分,其余的装饰器将不会出现在生成的 modeling 文件中。</p></blockquote> <p>该装饰器接受以下可选参数:</p> <table><thead><tr><th>参数</th><th>描述</th></tr></thead><tbody><tr><td><code>custom_intro</code></td><td>类或方法的描述,插入在 Args 部分之前。对于不以 <a href="#how-it-works">可识别的后缀</a>(如 <code>ForCausalLM</code> 或 <code>ForTokenClassification</code>)结尾的类,此项为必填。</td></tr><tr><td><code>custom_args</code></td><td>特定参数的文档字符串文本。当相同的自定义参数在建模文件的多个位置出现时,此功能非常有用。</td></tr><tr><td><code>checkpoint</code></td><td>用于生成使用示例的模型检查点标识符(<code>"org/my-model"</code>)。它会覆盖从配置类自动推断出的检查点。通常设置在配置类上。</td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="usage" 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="#usage"><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>@auto_docstring</code> 的工作方式取决于你所装饰的对象。模型类会从 <code>__init__</code> 中提取参数文档,配置类会从类级别的注解中提取,处理器类会根据其组件自动生成简介,而 <code>forward</code> 等方法则会获得返回类型和使用示例。</p> <!--[2--><h3 class="relative group"><a id="model-classes" 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-classes"><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>@auto_docstring</code> 直接放在类定义上方。该装饰器会根据 <code>__init__</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-python "><!----><span class="hljs-keyword">from</span> transformers.modeling_utils <span class="hljs-keyword">import</span> PreTrainedModel | |
| <span class="hljs-keyword">from</span> ...utils <span class="hljs-keyword">import</span> auto_docstring | |
| <span class="hljs-meta">@auto_docstring</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyAwesomeModel</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, config, custom_parameter: <span class="hljs-built_in">int</span> = <span class="hljs-number">10</span>, another_custom_arg: <span class="hljs-built_in">str</span> = <span class="hljs-string">"default"</span></span>): | |
| <span class="hljs-string">r""" | |
| custom_parameter (`int`, *optional*, defaults to 10): | |
| Description of the custom_parameter for MyAwesomeModel. | |
| another_custom_arg (`str`, *optional*, defaults to "default"): | |
| Documentation for another unique argument. | |
| """</span> | |
| <span class="hljs-built_in">super</span>().__init__(config) | |
| <span class="hljs-variable language_">self</span>.custom_parameter = custom_parameter | |
| <span class="hljs-variable language_">self</span>.another_custom_arg = another_custom_arg | |
| <span class="hljs-comment"># ... rest of your init</span> | |
| <span class="hljs-comment"># ... other methods</span><!----></pre></div><!----> <p><code>custom_intro</code> 和 <code>custom_args</code> 以获取更精细的控制。自定义参数可以放在 <code>custom_args</code> 中,也可以放在 <code>__init__</code> 的 docstring 中。当相同的参数在多个方法中重复出现时,请使用 <code>custom_args</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-python "><!----><span class="hljs-meta">@auto_docstring(<span class="hljs-params"> | |
| custom_intro=<span class="hljs-string">"""This model performs specific synergistic operations. | |
| It builds upon the standard Transformer architecture with unique modifications."""</span>, | |
| custom_args=<span class="hljs-string">""" | |
| custom_parameter (`type`, *optional*, defaults to `default_value`): | |
| A concise description for custom_parameter if not defined or overriding the description in `auto_docstring.py`. | |
| internal_helper_arg (`type`, *optional*, defaults to `default_value`): | |
| A concise description for internal_helper_arg if not defined or overriding the description in `auto_docstring.py`. | |
| """</span> | |
| </span>)</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MySpecialModel</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, config: ConfigType, custom_parameter: <span class="hljs-string">"type"</span> = <span class="hljs-string">"default_value"</span>, internal_helper_arg=<span class="hljs-literal">None</span></span>): | |
| <span class="hljs-comment"># ...</span><!----></pre></div><!----> <p>同样将 <code>@auto_docstring</code> 应用于继承自 <a href="/docs/transformers/main/zh/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> 的类。</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-python "><!----><span class="hljs-meta">@auto_docstring(<span class="hljs-params"> | |
| custom_intro=<span class="hljs-string">""" | |
| Custom model outputs with additional fields. | |
| """</span> | |
| </span>)</span> | |
| <span class="hljs-meta">@dataclass</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelOutput</span>(<span class="hljs-title class_ inherited__">ImageClassifierOutput</span>): | |
| <span class="hljs-string">r""" | |
| loss (`torch.Tensor`, *optional*): | |
| The loss of the model. | |
| custom_field (`torch.Tensor` of shape `(batch_size, hidden_size)`, *optional*): | |
| A custom output field specific to this model. | |
| """</span> | |
| <span class="hljs-comment"># Standard fields (hidden_states, logits, attentions, etc.) are documented automatically when</span> | |
| <span class="hljs-comment"># the description matches the standard text. Loss typically varies per model, so document it above.</span> | |
| loss: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span> | |
| logits: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span> | |
| hidden_states: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">tuple</span>[torch.Tensor, ...]] = <span class="hljs-literal">None</span> | |
| attentions: <span class="hljs-type">Optional</span>[<span class="hljs-built_in">tuple</span>[torch.Tensor, ...]] = <span class="hljs-literal">None</span> | |
| <span class="hljs-comment"># Custom fields need to be documented in the docstring above</span> | |
| custom_field: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="config-classes" 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="#config-classes"><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>@auto_docstring</code> 直接放在 <a href="/docs/transformers/main/zh/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> 子类的上方,与 <code>@strict</code> 装饰器并列。 <code>@strict</code> 会添加运行时类型验证,并将该类转换为经过验证的数据类。配置参数是 <em>类级别注解</em>(而非 <code>__init__</code> 参数),<code>@auto_docstring</code> 会从类主体中读取这些注解以生成文档。</p> <p><code>ConfigArgs</code> 提供了诸如 <code>vocab_size</code>、<code>hidden_size</code> 和 <code>num_hidden_layers</code> 等标准参数,因此除非其行为有所不同,否则无需对其进行描述。<a href="/docs/transformers/main/zh/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> 的基类参数会被自动排除。<code>checkpoint</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-python "><!----><span class="hljs-keyword">from</span> huggingface_hub.dataclasses <span class="hljs-keyword">import</span> strict | |
| <span class="hljs-keyword">from</span> ...configuration_utils <span class="hljs-keyword">import</span> PreTrainedConfig | |
| <span class="hljs-keyword">from</span> ...utils <span class="hljs-keyword">import</span> auto_docstring | |
| <span class="hljs-meta">@strict</span> | |
| <span class="hljs-meta">@auto_docstring(<span class="hljs-params">checkpoint=<span class="hljs-string">"org/my-model-checkpoint"</span></span>)</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelConfig</span>(<span class="hljs-title class_ inherited__">PreTrainedConfig</span>): | |
| <span class="hljs-string">r""" | |
| custom_param (`int`, *optional*, defaults to 64): | |
| Description of a parameter specific to this model. | |
| another_param (`str`, *optional*, defaults to `"gelu"`): | |
| Description of another model-specific parameter. | |
| ```python | |
| from transformers import MyModelConfig, MyModel | |
| configuration = MyModelConfig() | |
| model = MyModel(configuration) | |
| configuration = model.config | |
| ``` | |
| """</span> | |
| model_type = <span class="hljs-string">"my_model"</span> | |
| <span class="hljs-comment"># Standard params (vocab_size, hidden_size, etc.) are auto-documented from ConfigArgs.</span> | |
| vocab_size: <span class="hljs-built_in">int</span> = <span class="hljs-number">32000</span> | |
| hidden_size: <span class="hljs-built_in">int</span> = <span class="hljs-number">768</span> | |
| num_hidden_layers: <span class="hljs-built_in">int</span> = <span class="hljs-number">12</span> | |
| <span class="hljs-comment"># Model-specific params must be documented in the class docstring above.</span> | |
| custom_param: <span class="hljs-built_in">int</span> = <span class="hljs-number">64</span> | |
| another_param: <span class="hljs-built_in">str</span> = <span class="hljs-string">"gelu"</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="processor-classes" 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="#processor-classes"><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>多模态处理器(<a href="/docs/transformers/main/zh/main_classes/processors#transformers.ProcessorMixin">ProcessorMixin</a> 的子类,<code>processing_*.py</code>)始终使用裸的 <code>@auto_docstring</code>。类介绍是自动生成的。只需记录 <code>__init__</code> 中尚未被 <code>ProcessorArgs</code>(<code>image_processor</code>、<code>tokenizer</code>、<code>chat_template</code> 等)覆盖的参数。</p> <p>如果所有参数都是标准的,请省略 docstring。同样,使用 <code>@auto_docstring</code> 装饰 <code>__call__</code>。其函数体 docstring 仅包含 <code>Returns:</code> 部分以及任何额外的模型特定调用参数。<code>return_tensors</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-python "><!----><span class="hljs-keyword">from</span> ...processing_utils <span class="hljs-keyword">import</span> ProcessorMixin, ProcessingKwargs, Unpack | |
| <span class="hljs-keyword">from</span> ...utils <span class="hljs-keyword">import</span> auto_docstring | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelProcessorKwargs</span>(ProcessingKwargs, total=<span class="hljs-literal">False</span>): | |
| <span class="hljs-string">""" | |
| custom_call_kwarg (`bool`, *optional*, defaults to `False`): | |
| A parameter with a default that can passed to __call__ which is not | |
| covered by the standard processor arguments (including each modality). | |
| """</span> | |
| custom_call_kwarg: <span class="hljs-built_in">bool</span> | |
| <span class="hljs-meta">@auto_docstring</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelProcessor</span>(<span class="hljs-title class_ inherited__">ProcessorMixin</span>): | |
| valid_processor_kwargs = MyModelProcessorKwargs | |
| custom_call_kwarg = <span class="hljs-literal">False</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, image_processor=<span class="hljs-literal">None</span>, tokenizer=<span class="hljs-literal">None</span>, custom_param: <span class="hljs-built_in">int</span> = <span class="hljs-number">4</span>, **kwargs</span>): | |
| <span class="hljs-string">r""" | |
| custom_param (`int`, *optional*, defaults to 4): | |
| A parameter specific to this processor not covered by the standard ProcessorArgs. | |
| """</span> | |
| <span class="hljs-built_in">super</span>().__init__(image_processor, tokenizer) | |
| <span class="hljs-variable language_">self</span>.custom_param = custom_param | |
| <span class="hljs-meta"> @auto_docstring</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__call__</span>(<span class="hljs-params">self, images=<span class="hljs-literal">None</span>, text=<span class="hljs-literal">None</span>, **kwargs: Unpack[MyModelProcessorKwargs]</span>): | |
| <span class="hljs-string">r""" | |
| Returns: | |
| [BatchFeature](/docs/transformers/main/en/main_classes/feature_extractor#transformers.BatchFeature): A [BatchFeature](/docs/transformers/main/en/main_classes/feature_extractor#transformers.BatchFeature) with the following fields: | |
| - **input_ids** -- Token ids to be fed to the model. | |
| - **pixel_values** -- Pixel values to be fed to the model. | |
| """</span> | |
| <span class="hljs-comment"># ...</span><!----></pre></div><!----> <!--[3--><h4 class="relative group"><a id="image-and-video-processors" 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="#image-and-video-processors"><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></h4><!--]--><!----> <p>图像和视频处理器(<code>BaseImageProcessor</code> 的子类,<code>image_processing_*.py</code>)遵循两种模式之一。</p> <p>如果处理器具有模型特定的参数,请定义一个带有这些参数文档字符串的 <code>XxxImageProcessorKwargs(ImagesKwargs, total=False)</code> TypedDict,在类上设置 <code>valid_kwargs</code>,并使用裸的 <code>@auto_docstring</code>。<code>__init__</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-python "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelImageProcessorKwargs</span>(ImagesKwargs, total=<span class="hljs-literal">False</span>): | |
| <span class="hljs-string">r""" | |
| custom_threshold (`float`, *optional*, defaults to `self.custom_threshold`): | |
| A parameter specific to this image processor. | |
| """</span> | |
| custom_threshold: <span class="hljs-built_in">float</span> | <span class="hljs-literal">None</span> | |
| <span class="hljs-meta">@auto_docstring</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelImageProcessor</span>(<span class="hljs-title class_ inherited__">TorchvisionBackend</span>): | |
| valid_kwargs = MyModelImageProcessorKwargs | |
| custom_threshold: <span class="hljs-built_in">float</span> = <span class="hljs-number">0.5</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, **kwargs: Unpack[MyModelImageProcessorKwargs]</span>): | |
| <span class="hljs-built_in">super</span>().__init__(**kwargs)<!----></pre></div><!----> <p>如果该类仅设置了标准的类级属性(<code>size</code>、<code>resample</code>、<code>image_mean</code> 等),且没有自定义 kwargs,请改用 <code>@auto_docstring(custom_intro="Constructs a MyModel image processor.")</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-python "><!----><span class="hljs-meta">@auto_docstring(<span class="hljs-params">custom_intro=<span class="hljs-string">"Constructs a MyModel image processor."</span></span>)</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelImageProcessor</span>(<span class="hljs-title class_ inherited__">TorchvisionBackend</span>): | |
| resample = PILImageResampling.BICUBIC | |
| image_mean = IMAGENET_STANDARD_MEAN | |
| image_std = IMAGENET_STANDARD_STD | |
| size = {<span class="hljs-string">"height"</span>: <span class="hljs-number">224</span>, <span class="hljs-string">"width"</span>: <span class="hljs-number">224</span>}<!----></pre></div><!----> <p>重写 <code>preprocess</code> 时,请使用 <code>@auto_docstring</code> 对其进行装饰,并仅记录 <code>ImageProcessorArgs</code> 中未包含的参数。标准参数和 <code>return_tensors</code> 会自动包含在内。</p> <!--[2--><h3 class="relative group"><a id="functions" 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="#functions"><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>@auto_docstring</code> 直接放在函数定义上方。该装饰器会根据函数签名推导参数描述。</p> <p>该装饰器根据 <code>ModelOutput</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-python "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModel</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>): | |
| <span class="hljs-comment"># ...</span> | |
| <span class="hljs-meta"> @auto_docstring</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params"> | |
| self, | |
| input_ids: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span>, | |
| attention_mask: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span>, | |
| new_custom_argument: <span class="hljs-type">Optional</span>[torch.Tensor] = <span class="hljs-literal">None</span>, | |
| <span class="hljs-comment"># ... other arguments</span> | |
| </span>) -> <span class="hljs-type">Union</span>[<span class="hljs-type">Tuple</span>, ModelOutput]: | |
| <span class="hljs-string">r""" | |
| new_custom_argument (`torch.Tensor`, *optional*): | |
| Description of this new custom argument and its expected shape or type. | |
| """</span> | |
| <span class="hljs-comment"># ...</span><!----></pre></div><!----> <p>传入 <code>custom_intro</code> 和 <code>custom_args</code> 以获得更多控制。当相同参数出现在多个方法中时,使用 <code>custom_args</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-python "><!---->MODEL_COMMON_CUSTOM_ARGS = <span class="hljs-string">r""" | |
| common_arg_1 (`torch.Tensor`, *optional*, defaults to `default_value`): | |
| Description of common_arg_1 | |
| common_arg_2 (`torch.Tensor`, *optional*, defaults to `default_value`): | |
| Description of common_arg_2 | |
| """</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModel</span>(<span class="hljs-title class_ inherited__">PreTrainedModel</span>): | |
| <span class="hljs-comment"># ...</span> | |
| <span class="hljs-meta"> @auto_docstring(<span class="hljs-params"> | |
| custom_intro=<span class="hljs-string">"""This is a custom introduction for the function."""</span>, | |
| custom_args=MODEL_COMMON_CUSTOM_ARGS | |
| </span>)</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, input_ids=<span class="hljs-literal">None</span>, common_arg_1=<span class="hljs-literal">None</span>, common_arg_2=<span class="hljs-literal">None</span></span>) -> ModelOutput: | |
| <span class="hljs-string">r"""method-specific args go here"""</span> | |
| <span class="hljs-comment"># ...</span><!----></pre></div><!----> <p>在 docstring 中手动编写 <code>Returns</code> 和 <code>Examples</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-python "><!----> <span class="hljs-keyword">def</span> <span class="hljs-title function_">forward</span>(<span class="hljs-params">self, input_ids=<span class="hljs-literal">None</span></span>) -> torch.Tensor: | |
| <span class="hljs-string">r""" | |
| Returns: | |
| `torch.Tensor`: A custom Returns section for non-ModelOutput return types. | |
| Example: | |
| ```python | |
| model = MyModel.from_pretrained("org/my-model") | |
| output = model(input_ids) | |
| ``` | |
| """</span> | |
| <span class="hljs-comment"># ...</span><!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="documenting-arguments" 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="#documenting-arguments"><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>在记录不同的参数类型时,请遵循以下规则。</p> <ul><li><p><code>auto_docstring.py</code> 定义了标准参数(<code>input_ids</code>、<code>attention_mask</code>、<code>pixel_values</code> 等),并会自动包含它们。除非该参数在你的模型中行为不同,否则不要重新定义它们。</p> <p>如果标准参数在您的模型中表现不同,请在 <code>r""" """</code> 块中对其进行局部覆盖。局部定义具有优先权。例如,<code>labels</code> 参数通常会根据模型进行自定义,并且经常需要覆盖。</p></li> <li><p>标准配置参数(<code>vocab_size</code>、<code>hidden_size</code>、<code>num_hidden_layers</code> 等)遵循相同的原则,但来自 <code>ConfigArgs</code>。标准处理器参数(<code>image_processor</code>、<code>tokenizer</code>、<code>do_resize</code>、<code>return_tensors</code> 等)来自 <code>ProcessorArgs</code> 和 <code>ImageProcessorArgs</code>。仅当参数是模型特有的,或其行为与标准描述不同时,才对其进行文档说明。</p></li> <li><p>在 <code>r""" """</code> 块中记录新的或自定义的参数。对于函数,请将其放在签名之后;对于模型或处理器类,请放在 <code>__init__</code> 的文档字符串中;对于配置类,请放在类体的文档字符串中;对于图像处理器,请放在 <code>XxxImageProcessorKwargs</code> TypedDict 的主体中。</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 "><!---->argument_name (`<span class="hljs-built_in">type</span>`, *optional*, defaults to `X`): | |
| Description of the argument. | |
| Explain its purpose, expected shape/<span class="hljs-built_in">type</span> <span class="hljs-keyword">if</span> <span class="hljs-built_in">complex</span>, <span class="hljs-keyword">and</span> default behavior. | |
| This can span multiple lines.<!----></pre></div><!----> <ul><li>将 <code>type</code> 放在反引号中。</li> <li>如果参数不是必需的或具有默认值,请添加 <em>optional</em>。</li> <li>如果存在默认值,请添加“默认为 X”。如果默认值为 <code>None</code>,则无需添加“默认为 <code>None</code>”。</li> <li>当相同的参数在多个方法中重复出现时,请将相同的代码块传入 <code>custom_args</code>(参见上方的 <a href="#functions">函数示例</a>)。</li></ul></li> <li><p>该装饰器会自动从函数签名中提取类型。如果参数带有类型注解,则无需在文档字符串的格式字符串中重复该类型。当两者同时存在时,签名中的类型优先。文档字符串中的类型作为未注解参数的回退方案。</p></li></ul> <!--[1--><h2 class="relative group"><a id="checking-the-docstrings" 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="#checking-the-docstrings"><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 会运行该脚本并检查以下内容。</p> <blockquote class="tip"><p>如果在输出中看到 <code>[ERROR]</code>,请将相应参数的描述添加到 <code>auto_docstring.py</code> 中的 docstring 或对应的 Args 类中。</p></blockquote> <ul><li>检查 <code>@auto_docstring</code> 是否已应用于相关的模型类和公共方法。</li> <li>验证参数的完整性和一致性:文档中记录的参数必须存在于函数签名中,且类型和默认值必须匹配。未提供本地描述的未知参数将被标记。</li> <li>标记不完整的占位符,例如 <code><fill_type></code> 和 <code><fill_docstring></code>。</li> <li>验证文档字符串是否符合预期的格式风格。</li></ul> <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 "><!---->make fix-repo<!----></pre></div><!----> <p><code>make fix-repo</code> 还会运行其他几项检查。如果只想运行 docstring 和 auto-docstring 检查,请使用以下命令。</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 "><!----><span class="hljs-comment"># to only check files included in the diff without fixing them</span> | |
| python utils/check_docstrings.py | |
| <span class="hljs-comment"># to fix and overwrite the files in the diff</span> | |
| <span class="hljs-comment"># python utils/check_docstrings.py --fix_and_overwrite</span> | |
| <span class="hljs-comment"># to fix and overwrite all files</span> | |
| <span class="hljs-comment"># python utils/check_docstrings.py --fix_and_overwrite --check_all</span><!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="quick-reference-checklist" 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="#quick-reference-checklist"><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><!--]--><!----> <table><thead><tr><th>执行</th><th>不要</th></tr></thead><tbody><tr><td>将 <code>@auto_docstring</code> 应用于模型、配置和处理器类及其主要方法(<code>forward</code>、<code>__call__</code>、<code>preprocess</code>)。</td><td>在模块化文件中,为继承的模型添加 <code>@auto_docstring</code>,因为它会自动继承。</td></tr><tr><td>仅记录新增的或特定于模型的参数。</td><td>重新定义标准参数(<code>input_ids</code>、<code>attention_mask</code>、<code>vocab_size</code> 等),使其行为与默认描述保持一致。</td></tr><tr><td>将配置参数作为类级别注释,放在类主体的文档字符串中。</td><td>将配置参数放在 <code>__init__</code> 中。</td></tr><tr><td>将图像处理器参数放入 <code>XxxImageProcessorKwargs</code> TypedDict 中。</td><td>将图像处理器参数放入 <code>__init__</code> 中。</td></tr><tr><td>在提交之前,请运行 <code>python utils/check_docstrings.py --fix_and_overwrite</code>。</td><td>忽略 <code>[ERROR]</code> 输出,因为它表示某个参数没有文档说明。</td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="how-it-works" 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="#how-it-works"><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>@auto_docstring</code> 装饰器通过以下步骤生成文档字符串。</p> <ol><li><p>该装饰器会检查签名,以从被装饰类的 <code>__init__</code> 或被装饰的函数中读取参数、类型和默认值。对于配置类,它会沿继承链向上遍历类级别的注解,并在到达 <a href="/docs/transformers/main/zh/main_classes/configuration#transformers.PreTrainedConfig">PreTrainedConfig</a> 之前停止,从而排除基类字段。</p> <p>它会自动过滤掉诸如 <code>self</code>、<code>kwargs</code>、<code>args</code>、<code>deprecated_arguments</code> 以及以 <code>_</code> 为前缀的名称。部分私有参数会被重命名为其对应的公开参数(例如,对于 backbone 模型,<code>_out_features</code> → <code>out_features</code>)。</p></li> <li><p>常见的参数描述来自 <code>auto_docstring.py</code>:<code>ModelArgs</code>(模型输入)、<code>ModelOutputArgs</code>(输出字段,例如 <code>hidden_states</code>)、<code>ImageProcessorArgs</code>(图像预处理)、<code>ProcessorArgs</code>(多模态处理器组件)以及 <code>ConfigArgs</code>(配置超参数)。</p></li> <li><p>每个参数的描述遵循以下优先级链:</p> <ul><li>手动编写的文档字符串(<code>r""" """</code> 块或 <code>custom_args</code>)具有更高的优先级。</li> <li>预定义的源字典(<code>ModelArgs</code>、<code>ModelForArgs</code>、<code>ConfigArgs</code>、<code>ImageProcessorArgs</code>、<code>ProcessorArgs</code>、<code>ModelOutputArgs</code>)是回退方案。</li> <li>如果两个来源都没有描述,该参数将在构建输出中被标记为 <code>[ERROR]</code>。</li></ul></li> <li><p>对于具有标准名称(如 <code>ModelForCausalLM</code>)的模型类,或映射到某个 pipeline 的类,<code>@auto_docstring</code> 会生成简介。对于多模态处理器,简介会列出该类封装了哪些组件(例如 tokenizer、image processor 等)。完整的列表请参阅 <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/utils/auto_docstring.py#L2437" rel="nofollow">ClassDocstring</a>。</p> <p>如果类名不在 <code>ClassDocstring</code> 中,请设置 <code>custom_intro</code>。</p></li> <li><p>预定义的文档字符串可以引用 Transformers 的 <a href="https://github.com/huggingface/transformers/tree/main/src/transformers/models/auto" rel="nofollow">auto_modules</a> 中的动态值,例如 <code>{processor_class}</code>、<code>{image_processor_class}</code> 和 <code>{config_class}</code>。这些占位符会自动解析。</p></li> <li><p>该装饰器会根据模型的任务或流水线兼容性来选择使用示例。它会从配置类中读取检查点元数据,以便示例使用真实的模型 ID。<code>checkpoint</code> 参数会覆盖从配置类文档字符串中推断出的检查点。请在配置类上设置 <code>checkpoint</code>,或者在检查点推断失败时设置。如果看到类似 <code>"Config not found for <model_name>"</code> 的错误,请在 <code>auto_docstring.py</code> 中的 <code>HARDCODED_CONFIG_FOR_MODELS</code> 添加一个条目。</p></li> <li><p>对于 <code>forward</code> 之类的方法,装饰器会根据方法的返回类型生成 <code>Returns</code> 部分。当返回类型是 <a href="/docs/transformers/main/zh/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> 的子类时,<code>@auto_docstring</code> 会从该类的文档字符串中提取字段描述。函数文档字符串中自定义的 <code>Returns</code> 块具有更高的优先级。</p></li> <li><p>对于 <code>UNROLL_KWARGS_METHODS</code> 中的方法和 <code>UNROLL_KWARGS_CLASSES</code> 中的类,该装饰器会展开使用 <code>Unpack[KwargsTypedDict]</code> 进行类型标注的 <code>**kwargs</code>。<code>TypedDict</code> 中的每个键都会成为一个有文档记录的参数。</p> <p>同样的展开规则也适用于 <a href="/docs/transformers/main/zh/main_classes/image_processor#transformers.BaseImageProcessor">BaseImageProcessor</a> 和 <a href="/docs/transformers/main/zh/main_classes/processors#transformers.ProcessorMixin">ProcessorMixin</a> 子类的 <code>__call__</code> 和 <code>preprocess</code> 方法。通用基类类型(<code>TextKwargs</code>、<code>ImagesKwargs</code>、<code>VideosKwargs</code>、<code>AudioKwargs</code>)会被跳过。只有模型特定的子类会被展开。</p></li></ol> <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/auto_docstring.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, 11], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 68.8 kB
- Xet hash:
- db8495303760effc06bf83c9738a4ca117c5fce10587cb06b1547b3bccb5fbfd
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.