Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Scrierea testelor pentru modele","local":"scrierea-testelor-pentru-modele","sections":[{"title":"Alege o clasă de test de bază","local":"alege-o-clasă-de-test-de-bază","sections":[],"depth":2},{"title":"CausalLMModelTest","local":"causallmmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în CausalLMTester","local":"suprascrierea-valorilor-implicite-în-causallmtester","sections":[],"depth":3}],"depth":2},{"title":"VLMModelTest","local":"vlmmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în VLMModelTester","local":"suprascrierea-valorilor-implicite-în-vlmmodeltester","sections":[],"depth":3}],"depth":2},{"title":"ALMModelTest","local":"almmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în ALMModelTester","local":"suprascrierea-valorilor-implicite-în-almmodeltester","sections":[],"depth":3}],"depth":2},{"title":"Scrie teste pentru alte arhitecturi","local":"scrie-teste-pentru-alte-arhitecturi","sections":[{"title":"ModelTester și ModelTest","local":"modeltester-și-modeltest","sections":[],"depth":3},{"title":"Mixin-uri de test","local":"mixin-uri-de-test","sections":[],"depth":3},{"title":"Scrierea unui test de model","local":"scrierea-unui-test-de-model","sections":[],"depth":3},{"title":"Organizarea fișierelor","local":"organizarea-fișierelor","sections":[],"depth":3}],"depth":2},{"title":"Teste de config","local":"teste-de-config","sections":[],"depth":2},{"title":"Teste de integrare și modele mici","local":"teste-de-integrare-și-modele-mici","sections":[{"title":"Scrierea testelor de integrare","local":"scrierea-testelor-de-integrare","sections":[{"title":"Teste de integrare pentru generare","local":"teste-de-integrare-pentru-generare","sections":[],"depth":4},{"title":"Așteptări specifice hardware-ului","local":"așteptări-specifice-hardware-ului","sections":[],"depth":4}],"depth":3},{"title":"Crearea modelelor mici","local":"crearea-modelelor-mici","sections":[],"depth":3}],"depth":2},{"title":"Controlează ce se testează","local":"controlează-ce-se-testează","sections":[],"depth":2},{"title":"Pașii următori","local":"pașii-următori","sections":[],"depth":2}],"depth":1}"/> | |
| <link href="/docs/transformers/main/ro/_app/immutable/entry/start.Cj0_j3du.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/CUCuKvpH.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/Dm_uEeBC.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/entry/app.2x2TdrVN.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/BFzpZI28.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/DM0RASQS.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/DJ5hodCp.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/GYau11Sm.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/nodes/0.BonRETMf.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/B1k23FAg.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/utTYfj_T.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/nodes/32.B67rMDgP.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/BcKuJYrM.js" rel="modulepreload"> | |
| <link href="/docs/transformers/main/ro/_app/immutable/chunks/BGhUAj7r.js" rel="modulepreload"> | |
| <!--6vfrt7--><meta name="hf:doc:metadata" content="{"title":"Scrierea testelor pentru modele","local":"scrierea-testelor-pentru-modele","sections":[{"title":"Alege o clasă de test de bază","local":"alege-o-clasă-de-test-de-bază","sections":[],"depth":2},{"title":"CausalLMModelTest","local":"causallmmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în CausalLMTester","local":"suprascrierea-valorilor-implicite-în-causallmtester","sections":[],"depth":3}],"depth":2},{"title":"VLMModelTest","local":"vlmmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în VLMModelTester","local":"suprascrierea-valorilor-implicite-în-vlmmodeltester","sections":[],"depth":3}],"depth":2},{"title":"ALMModelTest","local":"almmodeltest","sections":[{"title":"Suprascrierea valorilor implicite în ALMModelTester","local":"suprascrierea-valorilor-implicite-în-almmodeltester","sections":[],"depth":3}],"depth":2},{"title":"Scrie teste pentru alte arhitecturi","local":"scrie-teste-pentru-alte-arhitecturi","sections":[{"title":"ModelTester și ModelTest","local":"modeltester-și-modeltest","sections":[],"depth":3},{"title":"Mixin-uri de test","local":"mixin-uri-de-test","sections":[],"depth":3},{"title":"Scrierea unui test de model","local":"scrierea-unui-test-de-model","sections":[],"depth":3},{"title":"Organizarea fișierelor","local":"organizarea-fișierelor","sections":[],"depth":3}],"depth":2},{"title":"Teste de config","local":"teste-de-config","sections":[],"depth":2},{"title":"Teste de integrare și modele mici","local":"teste-de-integrare-și-modele-mici","sections":[{"title":"Scrierea testelor de integrare","local":"scrierea-testelor-de-integrare","sections":[{"title":"Teste de integrare pentru generare","local":"teste-de-integrare-pentru-generare","sections":[],"depth":4},{"title":"Așteptări specifice hardware-ului","local":"așteptări-specifice-hardware-ului","sections":[],"depth":4}],"depth":3},{"title":"Crearea modelelor mici","local":"crearea-modelelor-mici","sections":[],"depth":3}],"depth":2},{"title":"Controlează ce se testează","local":"controlează-ce-se-testează","sections":[],"depth":2},{"title":"Pașii următori","local":"pașii-următori","sections":[],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/transformers/main/ro/_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: 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> <!--[-1--><!--]--></div><!----> <!--[0--><h1 class="relative group"><a id="scrierea-testelor-pentru-modele" 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="#scrierea-testelor-pentru-modele"><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>Scrierea testelor pentru modele</span></h1><!--]--><!----> <p>Suita de teste Transformers folosește o arhitectură bazată pe mixin-uri ca să auto-genereze 100+ teste din cod minimal. Scrii o cantitate mică de cod specific modelului, iar mixin-urile se ocupă de save/load, generare, pipeline-uri, antrenare și tensor parallelism.</p> <p>Rulează testele modelului tău cu comenzile de mai jos.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!----><span class="hljs-comment"># rulează testele modelului tău</span> | |
| pytest tests/models/mymodel/test_modeling_mymodel.py -v | |
| <span class="hljs-comment"># rulează un test specific</span> | |
| pytest tests/models/mymodel/test_modeling_mymodel.py::MyModelTest::test_model | |
| <span class="hljs-comment"># rulează testele care se potrivesc cu un pattern de cuvinte cheie (util ca să rulezi toate testele de integrare)</span> | |
| pytest tests/models/mymodel/ -k integration -v | |
| <span class="hljs-comment"># include testele de integrare slow</span> | |
| RUN_SLOW=1 pytest tests/models/mymodel/ -v<!----></pre></div><!----> <p>CI-ul Hugging Face rulează testele de model fără <code>@slow</code> la fiecare pull request, iar testele slow rulează pe un program nightly (vezi <a href="./pr_checks">Verificările pentru pull request</a> pentru ce validează CI-ul).</p> <!--[1--><h2 class="relative group"><a id="alege-o-clasă-de-test-de-bază" 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="#alege-o-clasă-de-test-de-bază"><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>Alege o clasă de test de bază</span></h2><!--]--><!----> <p>Trei clase de bază acoperă cele mai comune familii de modele. Alege-o pe cea care se potrivește cu modalitatea modelului tău.</p> <table><thead><tr><th>Clasă de bază</th><th>Folosit pentru</th><th>Mixin-uri</th></tr></thead><tbody><tr><td><code>CausalLMModelTest</code></td><td>Modele cauzale de limbaj</td><td><code>ModelTesterMixin</code>, <code>GenerationTesterMixin</code>, <code>PipelineTesterMixin</code>, <code>TrainingTesterMixin</code>, <code>TensorParallelTesterMixin</code></td></tr><tr><td><code>VLMModelTest</code></td><td>Modele vizual-lingvistice</td><td><code>ModelTesterMixin</code>, <code>GenerationTesterMixin</code>, <code>PipelineTesterMixin</code></td></tr><tr><td><code>ALMModelTest</code></td><td>Modele audio-lingvistice</td><td><code>ModelTesterMixin</code>, <code>GenerationTesterMixin</code>, <code>PipelineTesterMixin</code></td></tr></tbody></table> <p><code>VLMModelTest</code> și <code>ALMModelTest</code> partajează un părinte comun <code>MultiModalModelTest</code> care îmbricuiește sub-config-uri într-un config compus de nivel superior și plasează token-uri placeholder de modalitate în <code>input_ids</code> alături de features-urile brute de modalitate (audio sau vizuale). <code>CausalLMModelTest</code> nu folosește părintele multimodal. Se bazează pe cele trei mixin-uri partajate și adaugă <code>TrainingTesterMixin</code> și <code>TensorParallelTesterMixin</code> pentru acoperire de antrenare și tensor-parallel.</p> <p>Pentru arhitecturi care nu se potrivesc cu niciunul din cele trei (encoder-only, encoder-decoder etc.), construiește infrastructura de test direct din <a href="#modeltester-%C8%99i-modeltest">pattern-ul cu două clase</a> și <a href="#mixin-uri-de-test">mixin-urile de test</a> descrise mai jos.</p> <!--[1--><h2 class="relative group"><a id="causallmmodeltest" 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="#causallmmodeltest"><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>CausalLMModelTest</span></h2><!--]--><!----> <p><code>CausalLMModelTest</code> este clasa de bază recomandată pentru testarea modelelor cauzale de limbaj. Moștenește din cinci <a href="#mixin-uri-de-test">mixin-uri de test</a> și auto-generează teste pentru save/load, generare, pipeline-uri, antrenare și tensor parallelism.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">import</span> unittest | |
| <span class="hljs-keyword">from</span> transformers.testing_utils <span class="hljs-keyword">import</span> require_torch | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> is_torch_available | |
| <span class="hljs-keyword">from</span> ...causal_lm_tester <span class="hljs-keyword">import</span> CausalLMModelTest, CausalLMModelTester | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> MyModel | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelTester</span>(<span class="hljs-title class_ inherited__">CausalLMModelTester</span>): | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| base_model_class = MyModel | |
| <span class="hljs-meta">@require_torch</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelTest</span>(CausalLMModelTest, unittest.TestCase): | |
| model_tester_class = MyModelTester<!----></pre></div><!----> <p>Aceste două clase oferă acoperire completă de teste pentru <code>MyModel</code> și toate clasele sale head (<code>MyModelForCausalLM</code>, <code>MyModelForSequenceClassification</code> etc.). Vezi <a href="https://github.com/huggingface/transformers/blob/main/tests/models/llama/test_modeling_llama.py" rel="nofollow">tests/models/llama/test_modeling_llama.py</a> pentru un exemplu real.</p> <p><code>CausalLMModelTester</code> necesită doar <code>base_model_class</code>. Tester-ul elimină sufixul <code>Model</code> ca să obțină un nume de bază (<code>LlamaModel</code> devine <code>Llama</code>), apoi adaugă sufixe precum <code>Config</code> sau <code>ForCausalLM</code> ca să descopere clasele conexe. Dacă o clasă nu există în modul, atributul rămâne <code>None</code> și tester-ul sare peste testele corespunzătoare.</p> <!--[2--><h3 class="relative group"><a id="suprascrierea-valorilor-implicite-în-causallmtester" 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="#suprascrierea-valorilor-implicite-în-causallmtester"><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>Suprascrierea valorilor implicite în CausalLMTester</span></h3><!--]--><!----> <p>Dacă modelul tău nu urmează denumirea standard, sau trebuie să personalizezi comportamentul, suprascrie atributele pe tester sau pe clasa de test.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelTester</span>(<span class="hljs-title class_ inherited__">CausalLMModelTester</span>): | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| base_model_class = MyModel | |
| <span class="hljs-comment"># suprascrie dacă numele clasei nu urmează convenția</span> | |
| causal_lm_class = MyCustomCausalLM | |
| <span class="hljs-meta">@require_torch</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelTest</span>(CausalLMModelTest, unittest.TestCase): | |
| model_tester_class = MyModelTester | |
| <span class="hljs-comment"># dezactivează testele de resize ale embedding-urilor</span> | |
| test_resize_embeddings = <span class="hljs-literal">False</span><!----></pre></div><!----> <p>Pentru modele care necesită parametri personalizați de constructor pe tester, suprascrie <code>__init__</code> și apelează <code>super().__init__(parent=parent)</code> înainte de a seta atribute suplimentare. Vezi <a href="https://github.com/huggingface/transformers/blob/main/tests/models/youtu/test_modeling_youtu.py" rel="nofollow">tests/models/youtu/test_modeling_youtu.py</a> pentru un exemplu real.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">YoutuModelTester</span>(<span class="hljs-title class_ inherited__">CausalLMModelTester</span>): | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| base_model_class = YoutuModel | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, parent, kv_lora_rank=<span class="hljs-number">16</span>, q_lora_rank=<span class="hljs-number">32</span></span>): | |
| <span class="hljs-built_in">super</span>().__init__(parent=parent) | |
| <span class="hljs-variable language_">self</span>.kv_lora_rank = kv_lora_rank | |
| <span class="hljs-variable language_">self</span>.q_lora_rank = q_lora_rank<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="vlmmodeltest" 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="#vlmmodeltest"><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>VLMModelTest</span></h2><!--]--><!----> <p><code>VLMModelTest</code> este clasa de bază pentru modelele vizual-lingvistice. Moștenește din trei mixin-uri (<code>ModelTesterMixin</code>, <code>GenerationTesterMixin</code>, <code>PipelineTesterMixin</code>) și setează <code>_is_composite = True</code> ca să gestioneze mai multe sub-modele.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">import</span> unittest | |
| <span class="hljs-keyword">from</span> transformers.testing_utils <span class="hljs-keyword">import</span> require_torch | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> is_torch_available | |
| <span class="hljs-keyword">from</span> ...vlm_tester <span class="hljs-keyword">import</span> VLMModelTest, VLMModelTester | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> ( | |
| MyVLMConfig, | |
| MyVLMModel, | |
| MyVLMTextConfig, | |
| MyVLMVisionConfig, | |
| MyVLMForConditionalGeneration, | |
| ) | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyVLMTester</span>(<span class="hljs-title class_ inherited__">VLMModelTester</span>): | |
| <span class="hljs-keyword">if</span> is_torch_available(): | |
| base_model_class = MyVLMModel | |
| config_class = MyVLMConfig | |
| text_config_class = MyVLMTextConfig | |
| vision_config_class = MyVLMVisionConfig | |
| conditional_generation_class = MyVLMForConditionalGeneration | |
| <span class="hljs-meta">@require_torch</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyVLMTest</span>(VLMModelTest, unittest.TestCase): | |
| model_tester_class = MyVLMTester<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="suprascrierea-valorilor-implicite-în-vlmmodeltester" 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="#suprascrierea-valorilor-implicite-în-vlmmodeltester"><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>Suprascrierea valorilor implicite în VLMModelTester</span></h3><!--]--><!----> <p>Când VLM-ul necesită parametri de viziune personalizați sau valori de config non-implicite, suprascrie <code>__init__</code>. Setează valorile implicite cu <code>setdefault</code> înainte de a apela <code>super().__init__(parent, **kwargs)</code>. Exemplul de mai jos arată primele câteva valori implicite din <a href="https://github.com/huggingface/transformers/blob/main/tests/models/qianfan_ocr/test_modeling_qianfan_ocr.py" rel="nofollow">tests/models/qianfan_ocr/test_modeling_qianfan_ocr.py</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> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">QianfanOCRVisionText2TextModelTester</span>(<span class="hljs-title class_ inherited__">VLMModelTester</span>): | |
| base_model_class = QianfanOCRModel | |
| config_class = QianfanOCRConfig | |
| text_config_class = Qwen3Config | |
| vision_config_class = QianfanOCRVisionConfig | |
| conditional_generation_class = QianfanOCRForConditionalGeneration | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, parent, **kwargs</span>): | |
| kwargs.setdefault(<span class="hljs-string">"image_token_id"</span>, <span class="hljs-number">1</span>) | |
| kwargs.setdefault(<span class="hljs-string">"image_size"</span>, <span class="hljs-number">32</span>) | |
| kwargs.setdefault(<span class="hljs-string">"patch_size"</span>, <span class="hljs-number">4</span>) | |
| kwargs.setdefault(<span class="hljs-string">"num_channels"</span>, <span class="hljs-number">3</span>) | |
| <span class="hljs-comment"># ... mai multe valori implicite</span> | |
| <span class="hljs-built_in">super</span>().__init__(parent, **kwargs)<!----></pre></div><!----> <p>Testele VLM diferă de <code>CausalLMModelTest</code> în câteva moduri.</p> <ul><li>Trebuie să setezi <code>config_class</code>, <code>text_config_class</code>, <code>vision_config_class</code> și <code>conditional_generation_class</code> pe tester.</li> <li><code>VLMModelTest</code> nu include <code>TrainingTesterMixin</code> sau <code>TensorParallelTesterMixin</code>.</li> <li><code>__init__</code>-ul tester-ului acceptă parametri de viziune (<code>image_size</code>, <code>patch_size</code>, <code>num_channels</code>, <code>num_image_tokens</code>) din <code>**kwargs</code> și <code>setdefault()</code>.</li> <li><code>ConfigTester</code> folosește <code>has_text_modality=False</code> pentru că config-ul de nivel superior este un config compus, nu un config de model text.</li></ul> <!--[1--><h2 class="relative group"><a id="almmodeltest" 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="#almmodeltest"><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>ALMModelTest</span></h2><!--]--><!----> <p><code>ALMModelTest</code> este clasa de bază pentru modelele audio-lingvistice (ALM) precum Qwen2Audio, AudioFlamingo3 și GraniteSpeech. Oglindește pattern-ul VLM cu același părinte <code>MultiModalModelTest</code> și auto-descoperirea claselor head. Mecanismul vizual este înlocuit cu features audio, un sub-config audio și o strategie de plasare a token-urilor audio.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyALMTester</span>(<span class="hljs-title class_ inherited__">ALMModelTester</span>): | |
| config_class = MyALMConfig | |
| text_config_class = MyALMTextConfig | |
| audio_config_class = MyALMAudioConfig | |
| conditional_generation_class = MyALMForConditionalGeneration | |
| audio_mask_key = <span class="hljs-string">"feature_attention_mask"</span> | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyALMTest</span>(ALMModelTest, unittest.TestCase): | |
| model_tester_class = MyALMTester<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="suprascrierea-valorilor-implicite-în-almmodeltester" 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="#suprascrierea-valorilor-implicite-în-almmodeltester"><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>Suprascrierea valorilor implicite în ALMModelTester</span></h3><!--]--><!----> <p><code>__init__</code>-ul tester-ului setează valori implicite specifice ALM (<code>feat_seq_length=128</code>, <code>num_mel_bins=80</code>, <code>audio_token_id=0</code>). Suprascrie-le cu <code>setdefault</code> înainte de a apela <code>super().__init__(parent, **kwargs)</code>.</p> <p>Două atribute de clasă îi spun tester-ului cum sunt denumite lucrurile în modelul tău.</p> <ul><li><code>audio_mask_key</code>: numele kwarg-ului pe care modelul tău îl așteaptă pentru masca audio (<code>"feature_attention_mask"</code>, <code>"input_features_mask"</code> etc.). Lasă-l <code>None</code> dacă modelul tău nu consumă o mască audio separată.</li> <li><code>audio_config_key</code>: numele atributului pe care config-ul tău de nivel superior îl folosește ca să îmbricuieze sub-config-ul audio. Implicit <code>"audio_config"</code>, dar modele precum GraniteSpeech folosesc <code>"encoder_config"</code>.</li></ul> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">Qwen2AudioModelTester</span>(<span class="hljs-title class_ inherited__">ALMModelTester</span>): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">__init__</span>(<span class="hljs-params">self, parent, **kwargs</span>): | |
| kwargs.setdefault(<span class="hljs-string">"feat_seq_length"</span>, <span class="hljs-number">60</span>) | |
| kwargs.setdefault(<span class="hljs-string">"max_source_positions"</span>, kwargs[<span class="hljs-string">"feat_seq_length"</span>] // <span class="hljs-number">2</span>) | |
| <span class="hljs-built_in">super</span>().__init__(parent, **kwargs)<!----></pre></div><!----> <p><code>ALMModelTester</code> îți cere să suprascrii un hook, <code>get_audio_embeds_mask(audio_mask)</code>, și expune câteva opțiuni pentru personalizare.</p> <ul><li><code>get_audio_embeds_mask(audio_mask)</code>: returnează masca per-batch a pozițiilor de embedding audio după downsampling-ul encoder-ului. Tester-ul folosește suma sa row-wise ca să decidă câte placeholder-uri <code>audio_token_id</code> să insereze în <code>input_ids</code>, deci numărul trebuie să corespundă cu ce emite encoder-ul tău.</li> <li><code>create_audio_features()</code>: returnează tensorul de features audio. Forma implicită este <code>[batch_size, num_mel_bins, feat_seq_length]</code>. Suprascrie când modelul tău, precum GraniteSpeech, așteaptă features time-first (<code>[batch_size, feat_seq_length, num_mel_bins]</code>).</li> <li><code>create_audio_mask()</code>: returnează masca de attention la nivel audio. Implicit construiește o regiune validă contiguă aleatorie per rând în batch. Suprascrie cu o mască deterministă full-length dacă testele tale compară două invocații <code>prepare_config_and_inputs_for_common()</code> una față de alta, sau dacă encoder-ul tău audio se duce la un backend care respinge măști non-null.</li> <li><code>place_audio_tokens(input_ids, config, num_audio_tokens)</code>: plasează token-urile placeholder audio contiguu după <code>BOS</code>. Suprascrie doar dacă modelul tău are nevoie de un layout diferit.</li> <li><code>get_audio_feature_key()</code>: returnează cheia din dict-ul de inputuri pentru features audio (<code>"input_features"</code> implicit).</li></ul> <p>Pe lângă testele multimodale moștenite, <code>ALMModelTest</code> adaugă <code>test_mismatching_num_audio_tokens</code>. Testul afirmă că modelul ridică un <code>ValueError</code> clar când numărul de features audio nu corespunde cu numărul de token-uri placeholder audio din <code>input_ids</code> și verifică că un prompt cu mai multe segmente audio se face forward cu succes.</p> <!--[1--><h2 class="relative group"><a id="scrie-teste-pentru-alte-arhitecturi" 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="#scrie-teste-pentru-alte-arhitecturi"><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>Scrie teste pentru alte arhitecturi</span></h2><!--]--><!----> <p>Pentru arhitecturi encoder-only, encoder-decoder, audio sau alte arhitecturi non-standard, construiește infrastructura de test direct din pattern-ul cu două clase și mixin-urile de test descrise mai jos.</p> <!--[2--><h3 class="relative group"><a id="modeltester-și-modeltest" 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="#modeltester-și-modeltest"><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>ModelTester și ModelTest</span></h3><!--]--><!----> <p>Fiecare fișier de test pentru modele urmează aceeași structură.</p> <ol><li><code>ModelTester</code> (clasă simplă) creează config-uri mici și inputuri dummy pentru testare și poate conține și teste mici de regresie specifice modelului.</li> <li><code>ModelTest</code> (<code>unittest.TestCase</code> + mixin-uri) moștenește testele auto-generate și le rulează pe fiecare variantă de model.</li></ol> <p><code>ModelTest</code> apelează <code>prepare_config_and_inputs_for_common()</code> pe tester ca să obțină un tuple <code>(config, inputs_dict)</code>. Toate mixin-urile se bazează pe <code>prepare_config_and_inputs_for_common()</code> pentru datele de test.</p> <!--[2--><h3 class="relative group"><a id="mixin-uri-de-test" 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="#mixin-uri-de-test"><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>Mixin-uri de test</span></h3><!--]--><!----> <p>Alege mixin-urile de care are nevoie modelul tău.</p> <table><thead><tr><th>Mixin</th><th>Fișier sursă</th><th>Ce testează</th></tr></thead><tbody><tr><td><code>ModelTesterMixin</code></td><td><code>tests/test_modeling_common.py</code></td><td>Save/load, gradient checkpointing, semnătura forward, atribute comune</td></tr><tr><td><code>GenerationTesterMixin</code></td><td><code>tests/generation/test_utils.py</code></td><td>Greedy, sampling, beam search, assisted decoding</td></tr><tr><td><code>PipelineTesterMixin</code></td><td><code>tests/test_pipeline_mixin.py</code></td><td>Un test per task de pipeline</td></tr><tr><td><code>TrainingTesterMixin</code></td><td><code>tests/test_training_mixin.py</code></td><td>Overfitting pe un batch mic</td></tr><tr><td><code>TensorParallelTesterMixin</code></td><td><code>tests/test_tensor_parallel_mixin.py</code></td><td>Tensor parallelism distribuit</td></tr></tbody></table> <!--[2--><h3 class="relative group"><a id="scrierea-unui-test-de-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="#scrierea-unui-test-de-model"><span><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg><!----></span></a> <span>Scrierea unui test de model</span></h3><!--]--><!----> <p>Vezi <a href="https://github.com/huggingface/transformers/blob/main/tests/models/modernbert/test_modeling_modernbert.py" rel="nofollow">tests/models/modernbert/test_modeling_modernbert.py</a> pentru un exemplu complet funcțional. Pașii cheie sunt subliniați mai jos.</p> <ol><li><p>Clasa <code>ModelTester</code> construiește config-uri mici și inputuri dummy. Ține dimensiunile mici ca testele să se termine în secunde pe CPU. Folosește cei trei helpers de tensor de mai jos ca să construiești inputuri.</p> <ul><li><code>ids_tensor(shape, vocab_size)</code>: tensor de întregi aleatori în <code>[0, vocab_size)</code>. Folosește pentru <code>input_ids</code>, <code>token_type_ids</code> și tensori de label.</li> <li><code>random_attention_mask(shape)</code>: tensor binar (0 și 1) unde primul token este întotdeauna 1. Folosește pentru <code>attention_mask</code>.</li> <li><code>floats_tensor(shape, scale=1.0)</code>: tensor de float-uri aleatorii. Folosește pentru inputuri continue precum <code>pixel_values</code> sau <code>inputs_embeds</code>.</li></ul> <p>Tester-ul trebuie să implementeze <code>get_config()</code>, <code>prepare_config_and_inputs()</code> și <code>prepare_config_and_inputs_for_common()</code>. Adaugă metode <code>create_and_check_*</code> pentru fiecare head de task (model de bază, clasificare de secvențe, clasificare de token-uri etc.).</p></li> <li><p>Moștenești din mixin-urile de care are nevoie modelul tău, setezi <code>all_model_classes</code> și <code>pipeline_model_mapping</code> și definești <code>setUp()</code>. Scrii metode <code>test_*</code> care deleghează la metodele <code>create_and_check_*</code> ale tester-ului.</p></li> <li><p>Pentru fiecare head de task, adaugi o metodă <code>create_and_check_*</code> pe tester care instanțiază modelul, rulează un forward pass și afirmă formele de ieșire. Apoi adaugi o metodă <code>test_*</code> corespunzătoare pe clasa de test.</p></li></ol> <!--[2--><h3 class="relative group"><a id="organizarea-fișierelor" 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="#organizarea-fișierelor"><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>Organizarea fișierelor</span></h3><!--]--><!----> <p>Fișierele de test trăiesc în <code>tests/models/mymodel/</code> urmând structura de mai jos.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-text "><!---->tests/models/mymodel/ | |
| ├── __init__.py | |
| ├── test_modeling_mymodel.py # teste de model (obligatoriu) | |
| ├── test_tokenization_mymodel.py # teste de tokenizer (dacă ai tokenizer personalizat) | |
| ├── test_image_processing_mymodel.py # teste pentru procesorul de imagini (dacă e model vizual) | |
| ├── test_feature_extraction_mymodel.py # teste pentru feature extractor (dacă e model audio/speech) | |
| └── test_processing_mymodel.py # teste de procesor (dacă e multimodal)<!----></pre></div><!----> <p>Testele pentru tokenizer urmează același pattern. Moștenești <code>TokenizerTesterMixin</code> din <code>tests/test_tokenization_common.py</code>, setezi câteva atribute și primești teste auto-generate. Vezi <a href="https://github.com/huggingface/transformers/blob/main/tests/models/llama/test_tokenization_llama.py" rel="nofollow">tests/models/llama/test_tokenization_llama.py</a> pentru un exemplu.</p> <!--[1--><h2 class="relative group"><a id="teste-de-config" 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="#teste-de-config"><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>Teste de config</span></h2><!--]--><!----> <p><code>ConfigTester</code> verifică că o clasă de config gestionează serializarea, save/load și proprietățile standard corect. <code>CausalLMModelTest</code> și <code>VLMModelTest</code> includ testele de config automat. Pentru calea generală cu <code>ModelTester</code> și <code>ModelTest</code>, definești tester-ul de config manual în <code>setUp()</code>.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> tests.test_configuration_common <span class="hljs-keyword">import</span> ConfigTester | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">setUp</span>(<span class="hljs-params">self</span>): | |
| <span class="hljs-variable language_">self</span>.config_tester = ConfigTester(<span class="hljs-variable language_">self</span>, config_class=MyModelConfig, hidden_size=<span class="hljs-number">32</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_config</span>(<span class="hljs-params">self</span>): | |
| <span class="hljs-variable language_">self</span>.config_tester.run_common_tests()<!----></pre></div><!----> <p><code>run_common_tests()</code> rulează mai multe verificări.</p> <ul><li>Verifică că proprietăți comune precum <code>hidden_size</code>, <code>num_attention_heads</code> și <code>num_hidden_layers</code> există (și <code>vocab_size</code> dacă <code>has_text_modality=True</code>).</li> <li>Testează serializarea JSON cu <code>to_json_string()</code> și <code>to_json_file()</code>.</li> <li>Face round-trip cu <code>save_pretrained()</code> și <code>from_pretrained()</code>.</li> <li>Confirmă consistența <code>id2label</code> și <code>label2id</code>.</li> <li>Creează un config fără argumente ca să valideze inițializarea cu valori implicite.</li> <li>Setează kwargs comune precum <code>output_hidden_states</code> și confirmă că sunt stocate corect.</li></ul> <p>Pasează <code>has_text_modality=False</code> pentru modelele exclusiv vizuale care nu au <code>vocab_size</code> și pasează <code>**kwargs</code> suplimentar ca să suprascrieți valorile implicite ale config-ului.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-variable language_">self</span>.config_tester = ConfigTester( | |
| <span class="hljs-variable language_">self</span>, config_class=MyVisionConfig, has_text_modality=<span class="hljs-literal">False</span>, hidden_size=<span class="hljs-number">64</span> | |
| )<!----></pre></div><!----> <!--[1--><h2 class="relative group"><a id="teste-de-integrare-și-modele-mici" 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="#teste-de-integrare-și-modele-mici"><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>Teste de integrare și modele mici</span></h2><!--]--><!----> <p>Testele bazate pe mixin-uri folosesc config-uri mici cu weights aleatorii ca să verifice rapid comportamentul modelului. Testele de integrare rulează inferența cu weights preantrenate reale ca să valideze corectitudinea ieșirii. Modelele mici de pe Hub sunt suficient de mici pentru CI rapid, dar structurate ca checkpoint-uri reale.</p> <!--[2--><h3 class="relative group"><a id="scrierea-testelor-de-integrare" 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="#scrierea-testelor-de-integrare"><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>Scrierea testelor de integrare</span></h3><!--]--><!----> <p>Pune testele de integrare într-o clasă de test separată și marcheaz-le cu <code>@slow</code>. Fiecare test descarcă weights reale, rulează inferența și verifică ieșirile față de valorile așteptate. Apelează <code>cleanup(torch_device, gc_collect=False)</code> în <code>setUp</code> și <code>tearDown</code> ca să eviți memory leaks.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer | |
| <span class="hljs-keyword">from</span> transformers.testing_utils <span class="hljs-keyword">import</span> cleanup, require_torch, slow, torch_device | |
| <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelIntegrationTest</span>(unittest.TestCase): | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">setUp</span>(<span class="hljs-params">self</span>): | |
| cleanup(torch_device, gc_collect=<span class="hljs-literal">False</span>) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">tearDown</span>(<span class="hljs-params">self</span>): | |
| cleanup(torch_device, gc_collect=<span class="hljs-literal">False</span>) | |
| <span class="hljs-meta"> @slow</span> | |
| <span class="hljs-meta"> @require_torch</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_inference</span>(<span class="hljs-params">self</span>): | |
| model = MyModelForCausalLM.from_pretrained(<span class="hljs-string">"myorg/mymodel-base"</span>).to(torch_device) | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"myorg/mymodel-base"</span>) | |
| inputs = tokenizer(<span class="hljs-string">"Hello, world"</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(torch_device) | |
| <span class="hljs-keyword">with</span> torch.no_grad(): | |
| outputs = model(**inputs) | |
| <span class="hljs-comment"># verifică față de valorile așteptate</span> | |
| expected_slice = torch.tensor([[-<span class="hljs-number">0.1234</span>, <span class="hljs-number">0.5678</span>, -<span class="hljs-number">0.9012</span>]]) | |
| torch.testing.assert_close(outputs.logits[<span class="hljs-number">0</span>, :<span class="hljs-number">1</span>, :<span class="hljs-number">3</span>], expected_slice, atol=<span class="hljs-number">1e-4</span>, rtol=<span class="hljs-number">1e-4</span>)<!----></pre></div><!----> <p>Marchează orice test cu <code>@slow</code> dacă descarcă weights, încarcă un dataset mare sau durează mai mult de câteva secunde. <a href="./pr_checks">CI-ul pentru pull request</a> sare peste testele slow, dar programul nightly le rulează.</p> <!--[3--><h4 class="relative group"><a id="teste-de-integrare-pentru-generare" 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="#teste-de-integrare-pentru-generare"><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>Teste de integrare pentru generare</span></h4><!--]--><!----> <p>Folosește <code>do_sample=False</code> în testele de generare ca ieșirea să fie deterministă la rulări și hardware diferite. Pentru modelele Mixture-of-Experts, apelează și <code>model.set_experts_implementation("eager")</code> înainte de generare ca să forțezi o cale de dispatching stabilă a experților. Fără asta, diferențe numerice mici în router pot schimba ce expert gestionează un token și pot schimba ieșirea.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-meta">@slow</span> | |
| <span class="hljs-meta">@require_torch</span> | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">test_generate</span>(<span class="hljs-params">self</span>): | |
| model = MyModelForCausalLM.from_pretrained(<span class="hljs-string">"myorg/mymodel-base"</span>).to(torch_device) | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"myorg/mymodel-base"</span>) | |
| inputs = tokenizer(<span class="hljs-string">"Hello, world"</span>, return_tensors=<span class="hljs-string">"pt"</span>).to(torch_device) | |
| <span class="hljs-comment"># model.set_experts_implementation("eager") # decomentează pentru modelele MoE</span> | |
| generated_ids = model.generate(**inputs, max_new_tokens=<span class="hljs-number">20</span>, do_sample=<span class="hljs-literal">False</span>) | |
| output = tokenizer.batch_decode(generated_ids, skip_special_tokens=<span class="hljs-literal">True</span>) | |
| <span class="hljs-variable language_">self</span>.assertEqual(output, [<span class="hljs-string">"Hello, world! This is the expected continuation..."</span>])<!----></pre></div><!----> <!--[3--><h4 class="relative group"><a id="așteptări-specifice-hardware-ului" 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="#așteptări-specifice-hardware-ului"><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>Așteptări specifice hardware-ului</span></h4><!--]--><!----> <p>CI-ul Transformers rulează testele slow pe un NVIDIA A10. Rezultatele numerice pot varia ușor între generații de GPU, deci testele de integrare folosesc clasa <a href="https://github.com/huggingface/transformers/blob/main/src/transformers/testing_utils.py#L3247" rel="nofollow">Expectations</a> ca să înregistreze valori așteptate per dispozitiv. <code>Expectations</code> alege cea mai bună potrivire pentru hardware-ul curent pe baza cheilor SM <code>(device_type, (major, minor))</code> și revine la un default când nu se potrivește nimic.</p> <p>Rulează <code>torch.cuda.get_device_capability()</code> ca să printezi versiunea SM locală (e.g. <code>(8, 6)</code> pentru A10, <code>(9, 0)</code> pentru H100).</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">from</span> transformers.testing_utils <span class="hljs-keyword">import</span> Expectations | |
| expected_texts = Expectations( | |
| { | |
| (<span class="hljs-string">"cuda"</span>, (<span class="hljs-number">8</span>, <span class="hljs-number">6</span>)): [<span class="hljs-string">"Hello, world! This is the A10 continuation..."</span>], | |
| (<span class="hljs-string">"cuda"</span>, (<span class="hljs-number">9</span>, <span class="hljs-number">0</span>)): [<span class="hljs-string">"Hello, world! This is the H100 continuation..."</span>], | |
| } | |
| ).get_expectation() | |
| <span class="hljs-variable language_">self</span>.assertEqual(output, expected_texts)<!----></pre></div><!----> <!--[2--><h3 class="relative group"><a id="crearea-modelelor-mici" 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="#crearea-modelelor-mici"><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>Crearea modelelor mici</span></h3><!--]--><!----> <p>Modelele mici cu weights aleatorii trăiesc pe Hub sub organizația <a href="https://huggingface.co/hf-internal-testing" rel="nofollow">hf-internal-testing</a>. Testele de pipeline se bazează pe modele mici când au nevoie de un checkpoint găzduit pe Hub, dar nu le pasă de calitatea ieșirii. Testele fast smoke încarcă și ele modele mici ca să verifice formele forward pass-ului fără să descarce checkpoint-uri mari.</p> <p>Modelele mici sunt ultimul resort pentru testele de integrare. Folosește-le doar când cel mai mic checkpoint disponibil depășește ~24 GB de VRAM. Folosește weights preantrenate originale când e posibil, ca să prinzi regresii numerice reale.</p> <p>Scriptul <code>utils/create_dummy_models.py</code> generează modele mici din <code>ModelTester.get_config()</code>. Scriptul extrage hyperparametri mici din tester-ul tău, construiește un model cu weights aleatorii și încarcă rezultatul pe Hub.</p> <p>Generează modele mici local.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->python utils/create_dummy_models.py output_dir -m your_model_type<!----></pre></div><!----> <p>Încarcă-le pe Hub.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->python utils/create_dummy_models.py output_dir -m your_model_type --upload --organization hf-internal-testing<!----></pre></div><!----> <p>Fiecare model folosește numele <code>hf-internal-testing/tiny-random-{ModelClassName}</code> și este înregistrat în <code>tests/utils/tiny_model_summary.json</code>. Un workflow CI (<code>.github/workflows/check_tiny_models.yml</code>) regenerează modelele mici zilnic.</p> <!--[1--><h2 class="relative group"><a id="controlează-ce-se-testează" 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="#controlează-ce-se-testează"><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>Controlează ce se testează</span></h2><!--]--><!----> <p>Flag-urile booleene pe <code>ModelTesterMixin</code> comută testele auto-generate. Suprascrie orice flag pe clasa ta de test ca să activezi sau dezactivezi verificări specifice.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-py "><!----><span class="hljs-keyword">class</span> <span class="hljs-title class_">MyModelTest</span>(CausalLMModelTest, unittest.TestCase): | |
| model_tester_class = MyModelTester | |
| test_resize_embeddings = <span class="hljs-literal">False</span> | |
| test_all_params_have_gradient = <span class="hljs-literal">False</span> <span class="hljs-comment"># când nu toți parametrii sunt activați în fiecare forward pass</span><!----></pre></div><!----> <table><thead><tr><th>Flag</th><th>Implicit</th><th>Ce controlează</th></tr></thead><tbody><tr><td><code>test_resize_embeddings</code></td><td><code>True</code></td><td>Redimensionarea layer-ului de embedding</td></tr><tr><td><code>test_resize_position_embeddings</code></td><td><code>False</code></td><td>Redimensionarea embedding-urilor de poziție</td></tr><tr><td><code>test_mismatched_shapes</code></td><td><code>True</code></td><td>Gestionarea formelor nepotrivite input/output</td></tr><tr><td><code>test_missing_keys</code></td><td><code>True</code></td><td>Avertismente pentru chei lipsă la încărcare</td></tr><tr><td><code>test_torch_exportable</code></td><td><code>True</code></td><td>Compatibilitate <code>torch.export</code></td></tr><tr><td><code>test_all_params_have_gradient</code></td><td><code>True</code></td><td>Toți parametrii primesc gradienți (setează <code>False</code> când nu toți parametrii sunt activați în fiecare forward pass, cum ar fi experții MoE)</td></tr><tr><td><code>is_encoder_decoder</code></td><td><code>False</code></td><td>Teste specifice encoder-decoder</td></tr><tr><td><code>has_attentions</code></td><td><code>True</code></td><td>Teste de ieșire attention</td></tr><tr><td><code>_is_composite</code></td><td><code>False</code></td><td>Gestionarea modelelor compuse/multimodale</td></tr><tr><td><code>model_split_percents</code></td><td><code>[0.5, 0.7, 0.9]</code></td><td>Procentaje de split pentru testele de model parallelism</td></tr></tbody></table> <!--[1--><h2 class="relative group"><a id="pașii-următori" 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="#pașii-următori"><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>Pașii următori</span></h2><!--]--><!----> <ul><li>Răsfoiește documentația <a href="https://docs.pytest.org/en/latest/getting-started.html" rel="nofollow">pytest</a> pentru mai mult despre selecția testelor, fixtures, logging și altele.</li></ul> <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/ro/testing.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_1piag1k = { | |
| base: "/docs/transformers/main/ro", | |
| assets: "/docs/transformers/main/ro" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/transformers/main/ro/_app/immutable/entry/start.Cj0_j3du.js"), | |
| import("/docs/transformers/main/ro/_app/immutable/entry/app.2x2TdrVN.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 32], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 89.8 kB
- Xet hash:
- 61171f26827fa96ffd639cb23f77e79b7c5cd8bf0c41b1a56ae91597ed2104e3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.