Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"مشاركة النماذج المُدرَّبة مسبقًا","local":"sharing-pretrained-models","sections":[{"title":"استخدام واجهة push_to_hub البرمجية","local":"using-the-pushtohub-api","sections":[],"depth":2},{"title":"استخدام مكتبة huggingface_hub في Python","local":"using-the-huggingfacehub-python-library","sections":[],"depth":2},{"title":"استخدام واجهة الويب","local":"using-the-web-interface","sections":[],"depth":2},{"title":"رفع ملفات النموذج","local":"uploading-the-model-files","sections":[{"title":"طريقة upload_file","local":"the-uploadfile-approach","sections":[],"depth":3},{"title":"الصنف Repository","local":"the-repository-class","sections":[],"depth":3},{"title":"الطريقة القائمة على git","local":"the-git-based-approach","sections":[],"depth":3}],"depth":2}],"depth":1}"/> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/entry/start.BqEiWvSB.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/Bk8CJGef.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/DJ4HyDF4.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/entry/app.DPSHoq05.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/ChD0s6Ri.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/CVIC2OMz.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/DPmSlqhR.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/DsnmJJEf.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/nodes/0.DdOMzQoq.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/DtRvHE9i.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/nodes/5.DPajiC2M.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/Dhd0bQb6.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/C2aRDK8j.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/C6ytHtmL.js" rel="modulepreload"> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/chunks/CbXcSVcu.js" rel="modulepreload"> | |
| <!--1ofsmie--><meta name="hf:doc:metadata" content="{"title":"مشاركة النماذج المُدرَّبة مسبقًا","local":"sharing-pretrained-models","sections":[{"title":"استخدام واجهة push_to_hub البرمجية","local":"using-the-pushtohub-api","sections":[],"depth":2},{"title":"استخدام مكتبة huggingface_hub في Python","local":"using-the-huggingfacehub-python-library","sections":[],"depth":2},{"title":"استخدام واجهة الويب","local":"using-the-web-interface","sections":[],"depth":2},{"title":"رفع ملفات النموذج","local":"uploading-the-model-files","sections":[{"title":"طريقة upload_file","local":"the-uploadfile-approach","sections":[],"depth":3},{"title":"الصنف Repository","local":"the-repository-class","sections":[],"depth":3},{"title":"الطريقة القائمة على git","local":"the-git-based-approach","sections":[],"depth":3}],"depth":2}],"depth":1}"/><!----> | |
| <link href="/docs/course/pr_1372/ar/_app/immutable/assets/0.tn0RQdqM.css" rel="modulepreload"> <!--[--><!--[0--><!--[--><!--[0--><!--[--><p></p> <div class="bg-white leading-none border border-gray-100 rounded-lg flex p-0.5 w-56 text-sm mb-4"><!--[--><a class="flex justify-center flex-1 py-1.5 px-2.5 focus:outline-none !no-underline rounded-l bg-red-50 dark:bg-transparent text-red-600" href="?fw=pt"><!--[--><svg class="mr-1.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><defs><clipPath id="a"><rect x="3.05" y="0.5" width="25.73" height="31" fill="none"></rect></clipPath></defs><g clip-path="url(#a)"><path d="M24.94,9.51a12.81,12.81,0,0,1,0,18.16,12.68,12.68,0,0,1-18,0,12.81,12.81,0,0,1,0-18.16l9-9V5l-.84.83-6,6a9.58,9.58,0,1,0,13.55,0ZM20.44,9a1.68,1.68,0,1,1,1.67-1.67A1.68,1.68,0,0,1,20.44,9Z" fill="#ee4c2c"></path></g></svg><!--]--> Pytorch</a><a class="flex justify-center flex-1 py-1.5 px-2.5 focus:outline-none !no-underline rounded-r text-gray-500 filter grayscale" href="?fw=tf"><!--[--><svg class="mr-1.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="0.94em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 274"><path d="M145.726 42.065v42.07l72.861 42.07v-42.07l-72.86-42.07zM0 84.135v42.07l36.43 21.03V105.17L0 84.135zm109.291 21.035l-36.43 21.034v126.2l36.43 21.035v-84.135l36.435 21.035v-42.07l-36.435-21.034V105.17z" fill="#E55B2D"></path><path d="M145.726 42.065L36.43 105.17v42.065l72.861-42.065v42.065l36.435-21.03v-84.14zM255.022 63.1l-36.435 21.035v42.07l36.435-21.035V63.1zm-72.865 84.135l-36.43 21.035v42.07l36.43-21.036v-42.07zm-36.43 63.104l-36.436-21.035v84.135l36.435-21.035V210.34z" fill="#ED8E24"></path><path d="M145.726 0L0 84.135l36.43 21.035l109.296-63.105l72.861 42.07L255.022 63.1L145.726 0zm0 126.204l-36.435 21.03l36.435 21.036l36.43-21.035l-36.43-21.03z" fill="#F8BF3C"></path></svg><!--]--> TensorFlow</a><!--]--></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><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="sharing-pretrained-models" 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="#sharing-pretrained-models"><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><!--]--><!----></div> <!--[0--><div class="flex space-x-1 absolute z-10 right-0 top-0"><a href="https://discuss.huggingface.co/t/chapter-4-questions" target="_blank"><img alt="Ask a Question" class="!m-0" src="https://img.shields.io/badge/Ask%20a%20question-ffcb4c.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgLTEgMTA0IDEwNiI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiMyMzFmMjA7fS5jbHMtMntmaWxsOiNmZmY5YWU7fS5jbHMtM3tmaWxsOiMwMGFlZWY7fS5jbHMtNHtmaWxsOiMwMGE5NGY7fS5jbHMtNXtmaWxsOiNmMTVkMjI7fS5jbHMtNntmaWxsOiNlMzFiMjM7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5EaXNjb3Vyc2VfbG9nbzwvdGl0bGU+PGcgaWQ9IkxheWVyXzIiPjxnIGlkPSJMYXllcl8zIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik01MS44NywwQzIzLjcxLDAsMCwyMi44MywwLDUxYzAsLjkxLDAsNTIuODEsMCw1Mi44MWw1MS44Ni0uMDVjMjguMTYsMCw1MS0yMy43MSw1MS01MS44N1M4MCwwLDUxLjg3LDBaIi8+PHBhdGggY2xhc3M9ImNscy0yIiBkPSJNNTIuMzcsMTkuNzRBMzEuNjIsMzEuNjIsMCwwLDAsMjQuNTgsNjYuNDFsLTUuNzIsMTguNEwzOS40LDgwLjE3YTMxLjYxLDMxLjYxLDAsMSwwLDEzLTYwLjQzWiIvPjxwYXRoIGNsYXNzPSJjbHMtMyIgZD0iTTc3LjQ1LDMyLjEyYTMxLjYsMzEuNiwwLDAsMS0zOC4wNSw0OEwxOC44Niw4NC44MmwyMC45MS0yLjQ3QTMxLjYsMzEuNiwwLDAsMCw3Ny40NSwzMi4xMloiLz48cGF0aCBjbGFzcz0iY2xzLTQiIGQ9Ik03MS42MywyNi4yOUEzMS42LDMxLjYsMCwwLDEsMzguOCw3OEwxOC44Niw4NC44MiwzOS40LDgwLjE3QTMxLjYsMzEuNiwwLDAsMCw3MS42MywyNi4yOVoiLz48cGF0aCBjbGFzcz0iY2xzLTUiIGQ9Ik0yNi40Nyw2Ny4xMWEzMS42MSwzMS42MSwwLDAsMSw1MS0zNUEzMS42MSwzMS42MSwwLDAsMCwyNC41OCw2Ni40MWwtNS43MiwxOC40WiIvPjxwYXRoIGNsYXNzPSJjbHMtNiIgZD0iTTI0LjU4LDY2LjQxQTMxLjYxLDMxLjYxLDAsMCwxLDcxLjYzLDI2LjI5YTMxLjYxLDMxLjYxLDAsMCwwLTQ5LDM5LjYzbC0zLjc2LDE4LjlaIi8+PC9nPjwvZz48L3N2Zz4="/></a><!----> <!--[0--><a href="https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter4/section3_pt.ipynb" target="_blank"><img alt="Open In Colab" class="!m-0" src="https://colab.research.google.com/assets/colab-badge.svg"/></a><!--]--> <!--[0--><a href="https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter4/section3_pt.ipynb" target="_blank"><img alt="Open In Studio Lab" class="!m-0" src="https://studiolab.sagemaker.aws/studiolab.svg"/></a><!--]--></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>في الخطوات التالية، سنلقي نظرة على أسهل الطرق لمشاركة النماذج المُدرَّبة مسبقًا (pretrained models) على الـ 🤗 Hub. تتوفر أدوات ووسائل مساعدة تُسهِّل مشاركة النماذج وتحديثها مباشرةً على الـ Hub، وسنستكشفها فيما يلي.</p></div> <iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/9yY3RB_GSPM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>نشجّع جميع المستخدمين الذين يدرّبون النماذج على المساهمة بمشاركتها مع المجتمع (community)؛ فمشاركة النماذج، حتى تلك المُدرَّبة على مجموعات بيانات (datasets) شديدة التخصص، ستساعد الآخرين، إذ توفّر عليهم الوقت وموارد الحوسبة، وتتيح لهم الوصول إلى مخرجات تدريب مفيدة. وفي المقابل، يمكنك أنت أيضًا الاستفادة من العمل الذي أنجزه الآخرون!</p> <p>هناك ثلاث طرق لإنشاء مستودعات نماذج (model repositories) جديدة:</p> <ul><li>باستخدام واجهة <code>push_to_hub</code> البرمجية (API)</li> <li>باستخدام مكتبة <code>huggingface_hub</code> في Python</li> <li>باستخدام واجهة الويب</li></ul> <p>بعد إنشاء المستودع، يمكنك رفع الملفات إليه عبر git و git-lfs. سنرشدك في الأقسام التالية خلال خطوات إنشاء مستودعات النماذج ورفع الملفات إليها.</p> <!--[1--><h2 class="relative group"><a id="using-the-pushtohub-api" 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="#using-the-pushtohub-api"><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>استخدام واجهة push_to_hub البرمجية</span></h2><!--]--><!----></div> <!--[0--><iframe class="w-full xl:w-4/6 h-80" src="https://www.youtube-nocookie.com/embed/Zh0FfmVrKX0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>أبسط طريقة لرفع الملفات إلى الـ Hub هي الاستفادة من واجهة <code>push_to_hub</code> البرمجية.</p> <p>قبل المتابعة، ستحتاج إلى إنشاء رمز وصول (access token) للمصادقة، حتى تتعرّف واجهة <code>huggingface_hub</code> البرمجية على هويتك وعلى فضاءات الأسماء (namespaces) التي تملك صلاحية الكتابة فيها. تأكّد من أنك تعمل في بيئة مثبَّتة فيها مكتبة <code>transformers</code> (راجع <a href="/course/chapter0">الإعداد</a>). إذا كنت تعمل في دفتر (notebook)، فيمكنك استخدام الدالة التالية لتسجيل الدخول:</p></div> <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-python "><!----><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login | |
| notebook_login()<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>أما في سطر الأوامر (terminal)، فيمكنك تشغيل:</p></div> <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 "><!---->huggingface-cli login<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>في كلتا الحالتين، سيُطلب منك إدخال اسم المستخدم وكلمة المرور، وهما نفسهما اللذان تستخدمهما لتسجيل الدخول إلى الـ Hub. إذا لم يكن لديك ملف شخصي على الـ Hub بعد، فعليك إنشاء واحد <a href="https://huggingface.co/join" rel="nofollow">من هنا</a>.</p> <p>رائع! أصبح رمز الوصول الخاص بك مخزَّنًا الآن في مجلد ذاكرة التخزين المؤقت (cache). لننشئ بعض المستودعات!</p></div> <!--[0--><div dir="rtl" style="direction:rtl;text-align:right;"><p>إذا كنت قد جرّبت واجهة <code>Trainer</code> البرمجية لتدريب نموذج، فإن أسهل طريقة لرفعه إلى الـ Hub هي ضبط <code>push_to_hub=True</code> عند تعريف <code>TrainingArguments</code>:</p></div> <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 <span class="hljs-keyword">import</span> TrainingArguments | |
| training_args = TrainingArguments( | |
| <span class="hljs-string">"bert-finetuned-mrpc"</span>, save_strategy=<span class="hljs-string">"epoch"</span>, push_to_hub=<span class="hljs-literal">True</span> | |
| )<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>عند استدعاء <code>trainer.train()</code>، سيرفع <code>Trainer</code> نموذجك إلى الـ Hub في كل مرة يُحفَظ فيها (هنا في نهاية كل حقبة، أي epoch) داخل مستودع في فضاء الأسماء الخاص بك. سيحمل هذا المستودع اسم مجلد المخرجات الذي اخترته (هنا <code>bert-finetuned-mrpc</code>)، لكن يمكنك اختيار اسم مختلف باستخدام <code>hub_model_id = "a_different_name"</code>.</p> <p>لرفع نموذجك إلى منظمة (organization) أنت عضو فيها، يكفي تمرير اسمها عبر <code>hub_model_id = "my_organization/my_repo_name"</code>.</p> <p>بعد انتهاء التدريب، عليك تنفيذ <code>trainer.push_to_hub()</code> مرة أخيرة لرفع آخر إصدار من نموذجك. سيُنشئ ذلك أيضًا بطاقة نموذج (model card) تتضمن جميع البيانات الوصفية ذات الصلة، وتعرض المعاملات الفائقة (hyperparameters) المستخدمة ونتائج التقييم! إليك مثالًا على المحتوى الذي قد تجده في بطاقة نموذج كهذه:</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/model_card.png" alt="مثال على بطاقة نموذج مُنشأة تلقائيًا." width="100%"/></div></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>على مستوى أدنى، يمكن الوصول إلى منصة النماذج (Model Hub) مباشرةً من كائنات النماذج والمُرمِّزات (tokenizers) والإعدادات (configuration) عبر تابعها (method) المسمّى <code>push_to_hub()</code>. يتولّى هذا التابع إنشاء المستودع ورفع ملفات النموذج والمُرمِّز مباشرةً إليه، دون الحاجة إلى أي معالجة يدوية، على عكس الواجهة البرمجية التي سنراها لاحقًا.</p> <p>لتكوين فكرة عن طريقة عمله، لنبدأ أولًا بإنشاء نموذج ومُرمِّز:</p></div> <!--[0--><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 <span class="hljs-keyword">import</span> AutoModelForMaskedLM, AutoTokenizer | |
| checkpoint = <span class="hljs-string">"camembert-base"</span> | |
| model = AutoModelForMaskedLM.from_pretrained(checkpoint) | |
| tokenizer = AutoTokenizer.from_pretrained(checkpoint)<!----></pre></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>لك مطلق الحرية في فعل ما تشاء بهما: إضافة رموز (tokens) إلى المُرمِّز، أو تدريب النموذج، أو ضبطه ضبطًا دقيقًا (fine-tuning). وحين تصبح راضيًا عن النموذج الناتج وأوزانه (weights) والمُرمِّز، يمكنك الاستفادة من التابع <code>push_to_hub()</code> المتاح مباشرةً على الكائن <code>model</code>:</p></div> <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 "><!---->model.push_to_hub(<span class="hljs-string">"dummy-model"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>سيؤدي ذلك إلى إنشاء المستودع الجديد <code>dummy-model</code> في ملفك الشخصي، وملئه بملفات نموذجك. | |
| افعل الشيء نفسه مع المُرمِّز، لتصبح جميع الملفات متاحة الآن في هذا المستودع:</p></div> <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 "><!---->tokenizer.push_to_hub(<span class="hljs-string">"dummy-model"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>إذا كنت تنتمي إلى منظمة، فما عليك سوى تحديد الوسيط (argument) المسمّى <code>organization</code> للرفع إلى فضاء أسماء تلك المنظمة:</p></div> <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 "><!---->tokenizer.push_to_hub(<span class="hljs-string">"dummy-model"</span>, organization=<span class="hljs-string">"huggingface"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>وإذا أردت استخدام رمز وصول معيّن من Hugging Face، فيمكنك أيضًا تمريره إلى التابع <code>push_to_hub()</code>:</p></div> <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 "><!---->tokenizer.push_to_hub(<span class="hljs-string">"dummy-model"</span>, organization=<span class="hljs-string">"huggingface"</span>, use_auth_token=<span class="hljs-string">"<TOKEN>"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>توجّه الآن إلى منصة النماذج لتجد نموذجك الذي رفعته للتو: <em><a href="https://huggingface.co/user-or-organization/dummy-model" rel="nofollow">https://huggingface.co/user-or-organization/dummy-model</a></em>.</p> <p>انقر على تبويب “Files and versions” (الملفات والإصدارات)، وسترى الملفات الظاهرة في لقطة الشاشة التالية:</p></div> <!--[0--><div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/push_to_hub_dummy_model.png" alt="نموذج تجريبي يحتوي على ملفات المُرمِّز والنموذج معًا." width="80%"/></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><blockquote class="tip"><p>✏️ <strong>جرّبها بنفسك!</strong> خذ النموذج والمُرمِّز المرتبطين بنقطة الحفظ (checkpoint) المسمّاة <code>bert-base-cased</code> وارفعهما إلى مستودع في فضاء الأسماء الخاص بك باستخدام التابع <code>push_to_hub()</code>. تحقّق جيدًا من ظهور المستودع بشكل صحيح في صفحتك قبل حذفه.</p></blockquote> <p>كما رأيت، يقبل التابع <code>push_to_hub()</code> عدة وسائط، ما يتيح الرفع إلى مستودع محدد أو إلى فضاء أسماء منظمة، أو استخدام رمز وصول مختلف للواجهة البرمجية. نوصيك بالاطلاع على توصيف هذا التابع المتاح مباشرةً في <a href="https://huggingface.co/transformers/model_sharing" rel="nofollow">توثيق 🤗 Transformers</a> لتكوين فكرة عمّا هو ممكن.</p> <p>يعتمد التابع <code>push_to_hub()</code> على حزمة Python المسماة <a href="https://github.com/huggingface/huggingface_hub" rel="nofollow"><code>huggingface_hub</code></a>، التي توفر واجهة برمجية مباشرة للتعامل مع Hugging Face Hub. وهي مدمجة في 🤗 Transformers وفي عدد من مكتبات تعلّم الآلة (machine learning) الأخرى، مثل <a href="https://github.com/allenai/allennlp" rel="nofollow"><code>allenlp</code></a>. ومع أننا نركّز في هذا الفصل على تكاملها مع 🤗 Transformers، فإن دمجها في الكود أو المكتبة الخاصة بك أمر بسيط.</p> <p>انتقل إلى القسم الأخير لترى كيفية رفع الملفات إلى مستودعك الذي أنشأته حديثًا!</p> <!--[1--><h2 class="relative group"><a id="using-the-huggingfacehub-python-library" 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="#using-the-huggingfacehub-python-library"><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>استخدام مكتبة huggingface_hub في Python</span></h2><!--]--><!----> <p>مكتبة <code>huggingface_hub</code> في Python هي حزمة توفر مجموعة من الأدوات لمنصتَي النماذج ومجموعات البيانات. وهي تقدّم توابع وأصنافًا (classes) بسيطة للمهام الشائعة، مثل الحصول على معلومات حول المستودعات على الـ Hub وإدارتها. كما توفر واجهات برمجية بسيطة تعمل فوق git لإدارة محتوى تلك المستودعات ولدمج الـ Hub في مشاريعك ومكتباتك.</p> <p>على غرار استخدام واجهة <code>push_to_hub</code> البرمجية، يتطلب هذا أن يكون رمز الوصول الخاص بك محفوظًا في ذاكرة التخزين المؤقت. ولتحقيق ذلك، ستحتاج إلى استخدام الأمر <code>login</code> من واجهة سطر الأوامر (CLI)، كما ذكرنا في القسم السابق (ومرة أخرى، تأكد من إضافة الحرف <code>!</code> قبل هذه الأوامر إذا كنت تعمل في Google Colab):</p></div> <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 "><!---->huggingface-cli login<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>توفر حزمة <code>huggingface_hub</code> عدة توابع وأصناف مفيدة لغرضنا. أولًا، هناك بعض التوابع لإدارة إنشاء المستودعات وحذفها وغير ذلك:</p></div> <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-python "><!----><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> ( | |
| <span class="hljs-comment"># User management</span> | |
| login, | |
| logout, | |
| whoami, | |
| <span class="hljs-comment"># Repository creation and management</span> | |
| create_repo, | |
| delete_repo, | |
| update_repo_visibility, | |
| <span class="hljs-comment"># And some methods to retrieve/change information about the content</span> | |
| list_models, | |
| list_datasets, | |
| list_metrics, | |
| list_repo_files, | |
| upload_file, | |
| delete_file, | |
| )<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>بالإضافة إلى ذلك، توفر الحزمة الصنف <code>Repository</code> القوي جدًا لإدارة مستودع محلي. سنستكشف هذه التوابع وهذا الصنف في الأقسام القليلة التالية لفهم كيفية الاستفادة منها.</p> <p>يمكن استخدام التابع <code>create_repo</code> لإنشاء مستودع جديد على الـ Hub:</p></div> <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> huggingface_hub <span class="hljs-keyword">import</span> create_repo | |
| create_repo(<span class="hljs-string">"dummy-model"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>سيؤدي ذلك إلى إنشاء المستودع <code>dummy-model</code> في فضاء الأسماء الخاص بك. ويمكنك، إن أردت، تحديد المنظمة التي سينتمي إليها المستودع باستخدام الوسيط <code>organization</code>:</p></div> <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> huggingface_hub <span class="hljs-keyword">import</span> create_repo | |
| create_repo(<span class="hljs-string">"dummy-model"</span>, organization=<span class="hljs-string">"huggingface"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>سيؤدي ذلك إلى إنشاء المستودع <code>dummy-model</code> في فضاء الأسماء <code>huggingface</code>، على افتراض أنك تنتمي إلى تلك المنظمة. | |
| ومن الوسائط الأخرى التي قد تكون مفيدة:</p> <ul><li><code>private</code>: لتحديد ما إذا كان المستودع مرئيًا للآخرين أم لا.</li> <li><code>token</code>: إذا أردت استبدال رمز الوصول المخزَّن في ذاكرة التخزين المؤقت برمز آخر تحدده.</li> <li><code>repo_type</code>: إذا أردت إنشاء <code>dataset</code> (مجموعة بيانات) أو <code>space</code> (مساحة) بدلًا من نموذج. القيم المقبولة هي <code>"dataset"</code> و <code>"space"</code>.</li></ul> <p>بعد إنشاء المستودع، علينا إضافة الملفات إليه! انتقل إلى القسم التالي لترى الطرق الثلاث للقيام بذلك.</p> <!--[1--><h2 class="relative group"><a id="using-the-web-interface" 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="#using-the-web-interface"><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>توفر واجهة الويب أدوات لإدارة المستودعات مباشرةً على الـ Hub. وباستخدامها، يمكنك بسهولة إنشاء المستودعات، وإضافة الملفات (حتى الكبيرة منها!)، واستكشاف النماذج، وعرض الفروقات (diffs)، وغير ذلك الكثير.</p> <p>لإنشاء مستودع جديد، تفضّل بزيارة <a href="https://huggingface.co/new" rel="nofollow">huggingface.co/new</a>:</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/new_model.png" alt="صفحة تعرض الاستمارة المستخدمة لإنشاء مستودع نموذج جديد." width="80%"/></div> <p>أولًا، حدّد مالك المستودع: يمكن أن يكون أنت أو أيًّا من المنظمات التي تنتمي إليها. إذا اخترت منظمة، فسيُعرَض النموذج على صفحة المنظمة، وسيكون بمقدور كل عضو فيها المساهمة في المستودع.</p> <p>بعد ذلك، أدخل اسم نموذجك، وسيكون هذا أيضًا اسم المستودع. وأخيرًا، يمكنك تحديد ما إذا كنت تريد أن يكون نموذجك عامًّا أو خاصًّا. النماذج الخاصة تكون مخفية عن العامة.</p> <p>بعد إنشاء مستودع نموذجك، من المفترض أن ترى صفحة كهذه:</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/empty_model.png" alt="صفحة نموذج فارغة بعد إنشاء مستودع جديد." width="80%"/></div> <p>هنا سيُستضاف نموذجك. ولتبدأ في ملئه، يمكنك إضافة ملف README مباشرةً من واجهة الويب.</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/dummy_model.png" alt="ملف README يعرض إمكانيات Markdown." width="80%"/></div> <p>ملف README مكتوب بلغة Markdown، فلا تتردد في إطلاق العنان لإبداعك فيه! الجزء الثالث من هذا الفصل مخصص لإنشاء بطاقة النموذج (model card). تحظى هذه البطاقات بأهمية بالغة في إبراز قيمة نموذجك، فهي المكان الذي تخبر فيه الآخرين بما يستطيع فعله.</p> <p>إذا نظرت إلى تبويب “Files and versions”، فسترى أنه لا يحتوي على ملفات كثيرة بعد: فقط ملف <em>README.md</em> الذي أنشأته للتو، وملف <em>.gitattributes</em> الذي يتتبّع الملفات الكبيرة.</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/files.png" alt="تبويب 'Files and versions' لا يعرض سوى الملفين .gitattributes و README.md." width="80%"/></div> <p>سنلقي نظرة بعد ذلك على كيفية إضافة ملفات جديدة.</p> <!--[1--><h2 class="relative group"><a id="uploading-the-model-files" 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="#uploading-the-model-files"><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>يعتمد نظام إدارة الملفات على Hugging Face Hub على git للملفات العادية، وعلى git-lfs (اختصار لـ <a href="https://git-lfs.github.com/" rel="nofollow">Git Large File Storage</a>، أي نظام Git لتخزين الملفات الكبيرة) للملفات الأكبر حجمًا.</p> <p>في القسم التالي، نستعرض ثلاث طرق مختلفة لرفع الملفات إلى الـ Hub: عبر <code>huggingface_hub</code> وعبر أوامر git.</p> <!--[2--><h3 class="relative group"><a id="the-uploadfile-approach" 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="#the-uploadfile-approach"><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>طريقة upload_file</span></h3><!--]--><!----> <p>لا يتطلب استخدام <code>upload_file</code> تثبيت git و git-lfs على نظامك، إذ يرفع الملفات مباشرةً إلى الـ 🤗 Hub باستخدام طلبات HTTP POST. ومن قيود هذه الطريقة أنها لا تتعامل مع الملفات التي يتجاوز حجمها 5GB. | |
| إذا كانت ملفاتك أكبر من 5GB، فيُرجى اتباع إحدى الطريقتين الأخريين الموضحتين أدناه.</p> <p>يمكن استخدام هذه الواجهة البرمجية على النحو التالي:</p></div> <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> huggingface_hub <span class="hljs-keyword">import</span> upload_file | |
| upload_file( | |
| <span class="hljs-string">"<path_to_file>/config.json"</span>, | |
| path_in_repo=<span class="hljs-string">"config.json"</span>, | |
| repo_id=<span class="hljs-string">"<namespace>/dummy-model"</span>, | |
| )<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>سيؤدي ذلك إلى رفع الملف <code>config.json</code> الموجود في <code><path_to_file></code> إلى جذر المستودع <code>dummy-model</code> باسم <code>config.json</code>. | |
| ومن الوسائط الأخرى التي قد تكون مفيدة:</p> <ul><li><code>token</code>: إذا أردت استبدال رمز الوصول المخزَّن في ذاكرة التخزين المؤقت برمز آخر تحدده.</li> <li><code>repo_type</code>: إذا أردت الرفع إلى <code>dataset</code> (مجموعة بيانات) أو <code>space</code> (مساحة) بدلًا من نموذج. القيم المقبولة هي <code>"dataset"</code> و <code>"space"</code>.</li></ul> <!--[2--><h3 class="relative group"><a id="the-repository-class" 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="#the-repository-class"><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>الصنف Repository</span></h3><!--]--><!----> <p>يدير الصنف <code>Repository</code> مستودعًا محليًا بأسلوب مشابه لـ git. فهو يُخفي معظم الصعوبات التي قد يواجهها المرء مع git، ويوفّر جميع الميزات التي نحتاج إليها.</p> <p>يتطلب استخدام هذا الصنف تثبيت git و git-lfs، لذا تأكد من تثبيت git-lfs (راجع <a href="https://git-lfs.github.com/" rel="nofollow">هنا</a> للاطلاع على تعليمات التثبيت) وإعداده قبل أن تبدأ.</p> <p>للبدء في التعامل مع المستودع الذي أنشأناه للتو، يمكننا أولًا تهيئته في مجلد محلي عن طريق استنساخ (clone) المستودع البعيد:</p></div> <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> huggingface_hub <span class="hljs-keyword">import</span> Repository | |
| repo = Repository(<span class="hljs-string">"<path_to_dummy_folder>"</span>, clone_from=<span class="hljs-string">"<namespace>/dummy-model"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>أدى ذلك إلى إنشاء المجلد <code><path_to_dummy_folder></code> في مجلد العمل لدينا. لا يحتوي هذا المجلد إلا على الملف <code>.gitattributes</code>، لأنه الملف الوحيد الذي يُولَّد عند إنشاء المستودع عبر <code>create_repo</code>.</p> <p>ومن الآن فصاعدًا، يمكننا الاستفادة من عدد من توابع git التقليدية:</p></div> <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 "><!---->repo.git_pull() | |
| repo.git_add() | |
| repo.git_commit() | |
| repo.git_push() | |
| repo.git_tag()<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>وغيرها! نوصيك بالاطلاع على توثيق <code>Repository</code> المتاح <a href="https://github.com/huggingface/huggingface_hub/tree/main/src/huggingface_hub#advanced-programmatic-repository-management" rel="nofollow">هنا</a> للحصول على نظرة عامة على جميع التوابع المتاحة.</p> <p>لدينا حاليًا نموذج ومُرمِّز نرغب في رفعهما إلى الـ Hub. وبما أننا استنسخنا المستودع بنجاح، يمكننا الآن حفظ الملفات داخله.</p> <p>نتأكد أولًا من أن نسختنا المحلية محدَّثة عن طريق سحب (pull) آخر التغييرات:</p></div> <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 "><!---->repo.git_pull()<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>بعد ذلك، نحفظ ملفات النموذج والمُرمِّز:</p></div> <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 "><!---->model.save_pretrained(<span class="hljs-string">"<path_to_dummy_folder>"</span>) | |
| tokenizer.save_pretrained(<span class="hljs-string">"<path_to_dummy_folder>"</span>)<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>يحتوي المجلد <code><path_to_dummy_folder></code> الآن على جميع ملفات النموذج والمُرمِّز. نتّبع سير عمل git المعتاد: نضيف الملفات إلى منطقة التجهيز (staging area)، ثم نُجري إيداعًا (commit) لها، ثم ندفعها (push) إلى الـ Hub:</p></div> <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 "><!---->repo.git_add() | |
| repo.git_commit(<span class="hljs-string">"Add model and tokenizer files"</span>) | |
| repo.git_push()<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>تهانينا! لقد دفعت للتو أول ملفاتك إلى الـ Hub.</p> <!--[2--><h3 class="relative group"><a id="the-git-based-approach" 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="#the-git-based-approach"><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>الطريقة القائمة على git</span></h3><!--]--><!----> <p>هذه هي الطريقة الأدنى مستوى والأقل تجريدًا لرفع الملفات: سنستخدم git و git-lfs مباشرةً. تُخفي الطرق السابقة معظم الصعوبات، لكن هناك بعض المحاذير في الطريقة التالية، لذا سنتّبع حالة استخدام أكثر تعقيدًا.</p> <p>يتطلب استخدام هذا الصنف تثبيت git و git-lfs، لذا تأكد من تثبيت <a href="https://git-lfs.github.com/" rel="nofollow">git-lfs</a> (راجع هنا للاطلاع على تعليمات التثبيت) وإعداده قبل أن تبدأ.</p> <p>ابدأ أولًا بتهيئة git-lfs:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git lfs install<!----></pre></div><!----> <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 "><!---->Updated git hooks. | |
| Git LFS initialized.<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>بعد ذلك، تكون الخطوة الأولى استنساخ مستودع نموذجك:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git <span class="hljs-built_in">clone</span> https://huggingface.co/<namespace>/<your-model-id><!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>اسم المستخدم الخاص بي هو <code>lysandre</code>، وقد استخدمت اسم النموذج <code>dummy</code>، لذا يصبح الأمر لديّ على النحو التالي:</p></div> <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=" "><!---->git <span class="hljs-keyword">clone</span> <span class="hljs-title">https</span>://huggingface.co/lysandre/dummy<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>أصبح لديّ الآن مجلد باسم <em>dummy</em> في مجلد العمل. يمكنني الانتقال إليه باستخدام <code>cd</code> وإلقاء نظرة على محتوياته:</p></div> <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-built_in">cd</span> dummy && <span class="hljs-built_in">ls</span><!----></pre></div><!----> <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 "><!---->README.md<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>إذا كنت قد أنشأت مستودعك للتو باستخدام التابع <code>create_repo</code> من Hugging Face Hub، فمن المفترض ألّا يحتوي هذا المجلد إلا على ملف <code>.gitattributes</code> مخفي. أما إذا اتبعت التعليمات الواردة في القسم السابق لإنشاء مستودع باستخدام واجهة الويب، فمن المفترض أن يحتوي المجلد على ملف <em>README.md</em> واحد إلى جانب ملف <code>.gitattributes</code> المخفي، كما هو موضح هنا.</p> <p>يُضاف الملف ذو الحجم العادي، مثل ملف إعدادات أو ملف مفردات (vocabulary) أو أي ملف لا يتجاوز حجمه بضعة ميغابايتات، تمامًا كما يُضاف في أي نظام قائم على git. أما الملفات الأكبر حجمًا، فيجب تسجيلها عبر git-lfs حتى يمكن دفعها إلى <em>huggingface.co</em>.</p> <p>لنعد إلى Python قليلًا لإنشاء نموذج ومُرمِّز نرغب في إيداعهما في مستودعنا التجريبي:</p></div> <!--[0--><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 <span class="hljs-keyword">import</span> AutoModelForMaskedLM, AutoTokenizer | |
| checkpoint = <span class="hljs-string">"camembert-base"</span> | |
| model = AutoModelForMaskedLM.from_pretrained(checkpoint) | |
| tokenizer = AutoTokenizer.from_pretrained(checkpoint) | |
| <span class="hljs-comment"># Do whatever with the model, train it, fine-tune it...</span> | |
| model.save_pretrained(<span class="hljs-string">"<path_to_dummy_folder>"</span>) | |
| tokenizer.save_pretrained(<span class="hljs-string">"<path_to_dummy_folder>"</span>)<!----></pre></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>الآن بعد أن حفظنا بعض ملفات النموذج والمُرمِّز، لنلقِ نظرة أخرى على المجلد <em>dummy</em>:</p></div> <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-built_in">ls</span><!----></pre></div><!----> <!--[0--><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 "><!---->config.json pytorch_model.bin README.md sentencepiece.bpe.model special_tokens_map.json tokenizer_config.json tokenizer.json<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>إذا نظرت إلى أحجام الملفات (مثلًا باستخدام <code>ls -lh</code>)، فسترى أن ملف قاموس حالة النموذج (model state dict)، أي <em>pytorch_model.bin</em>، هو الاستثناء الوحيد، إذ يتجاوز حجمه 400 MB.</p></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><blockquote class="tip"><p>✏️ عند إنشاء المستودع من واجهة الويب، يُضبَط الملف <em>.gitattributes</em> تلقائيًا بحيث تُعامَل الملفات ذات امتدادات معيّنة، مثل <em>.bin</em> و <em>.h5</em>، على أنها ملفات كبيرة، وسيتتبّعها git-lfs دون الحاجة إلى أي إعداد من جانبك.</p></blockquote> <p>يمكننا الآن المتابعة كما نفعل عادةً مع مستودعات Git التقليدية. يمكننا إضافة جميع الملفات إلى منطقة التجهيز في Git باستخدام الأمر <code>git add</code>:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git add .<!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>يمكننا بعد ذلك إلقاء نظرة على الملفات الموجودة حاليًا في منطقة التجهيز:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git status<!----></pre></div><!----> <!--[0--><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 "><!---->On branch main | |
| Your branch is up to <span class="hljs-built_in">date</span> with <span class="hljs-string">'origin/main'</span>. | |
| Changes to be committed: | |
| (use <span class="hljs-string">"git restore --staged <file>..."</span> to unstage) | |
| modified: .gitattributes | |
| new file: config.json | |
| new file: pytorch_model.bin | |
| new file: sentencepiece.bpe.model | |
| new file: special_tokens_map.json | |
| new file: tokenizer.json | |
| new file: tokenizer_config.json<!----></pre></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>وبالمثل، يمكننا التأكد من أن git-lfs يتتبّع الملفات الصحيحة باستخدام الأمر <code>status</code> الخاص به:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git lfs status<!----></pre></div><!----> <!--[0--><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 "><!---->On branch main | |
| Objects to be pushed to origin/main: | |
| Objects to be committed: | |
| config.json (Git: bc20ff2) | |
| pytorch_model.bin (LFS: 35686c2) | |
| sentencepiece.bpe.model (LFS: 988bc5a) | |
| special_tokens_map.json (Git: cb23931) | |
| tokenizer.json (Git: 851ff3e) | |
| tokenizer_config.json (Git: f0f7783) | |
| Objects not staged <span class="hljs-keyword">for</span> commit: | |
| <!----></pre></div><!----> <div dir="rtl" style="direction:rtl;text-align:right;"><p>نلاحظ أن <code>Git</code> هو المسؤول عن معالجة جميع الملفات، باستثناء <em>pytorch_model.bin</em> و <em>sentencepiece.bpe.model</em> اللذين يعالجهما <code>LFS</code>. رائع!</p></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>لننتقل إلى الخطوات الأخيرة: إجراء الإيداع ثم الدفع إلى المستودع البعيد على <em>huggingface.co</em>:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git commit -m <span class="hljs-string">"First model version"</span><!----></pre></div><!----> <!--[0--><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 "><!---->[main b08aab1] First model version | |
| 7 files changed, 29027 insertions(+) | |
| 6 files changed, 36 insertions(+) | |
| create mode 100644 config.json | |
| create mode 100644 pytorch_model.bin | |
| create mode 100644 sentencepiece.bpe.model | |
| create mode 100644 special_tokens_map.json | |
| create mode 100644 tokenizer.json | |
| create mode 100644 tokenizer_config.json<!----></pre></div><!--]--> <div dir="rtl" style="direction:rtl;text-align:right;"><p>قد يستغرق الدفع بعض الوقت، تبعًا لسرعة اتصالك بالإنترنت وحجم ملفاتك:</p></div> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg><!----> <div class=" absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0 "><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent;"></div> Copied</div><!----></button><!----></div> <pre class="language-bash "><!---->git push<!----></pre></div><!----> <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 "><!---->Uploading LFS objects: 100% (1/1), 433 MB | 1.3 MB/s, <span class="hljs-keyword">done</span>. | |
| Enumerating objects: 11, <span class="hljs-keyword">done</span>. | |
| Counting objects: 100% (11/11), <span class="hljs-keyword">done</span>. | |
| Delta compression using up to 12 threads | |
| Compressing objects: 100% (9/9), <span class="hljs-keyword">done</span>. | |
| Writing objects: 100% (9/9), 288.27 KiB | 6.27 MiB/s, <span class="hljs-keyword">done</span>. | |
| Total 9 (delta 1), reused 0 (delta 0), pack-reused 0 | |
| To https://huggingface.co/lysandre/dummy | |
| 891b41d..b08aab1 main -> main<!----></pre></div><!----> <!--[0--><div dir="rtl" style="direction:rtl;text-align:right;"><p>إذا ألقينا نظرة على مستودع النموذج بعد انتهاء ذلك، فسنرى جميع الملفات المضافة حديثًا:</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/full_model.png" alt="أصبح تبويب 'Files and versions' يحتوي الآن على جميع الملفات المرفوعة حديثًا." width="80%"/></div> <p>تتيح لك واجهة المستخدم استكشاف ملفات النموذج والإيداعات، والاطلاع على الفروقات التي أدخلها كل إيداع:</p> <div class="flex justify-center"><img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/diffs.gif" alt="الفروقات التي أدخلها الإيداع الأخير." width="80%"/></div></div><!--]--> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/course/blob/main/chapters/ar/chapter4/3.mdx" 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_38nuky = { | |
| base: "/docs/course/pr_1372/ar", | |
| assets: "/docs/course/pr_1372/ar" | |
| }; | |
| const element = document.currentScript.parentElement; | |
| Promise.all([ | |
| import("/docs/course/pr_1372/ar/_app/immutable/entry/start.BqEiWvSB.js"), | |
| import("/docs/course/pr_1372/ar/_app/immutable/entry/app.DPSHoq05.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 5], | |
| data: [null,null], | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 100 kB
- Xet hash:
- edbd17914bb4190034cc58fe391d8667da6494aae60011237264b5803d745dae
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.