Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Git vs HTTP paradigm","local":"git-vs-http-paradigm","sections":[{"title":"Repository: the historical git-based approach","local":"repository-the-historical-git-based-approach","sections":[],"depth":2},{"title":"HfApi: a flexible and convenient HTTP client","local":"hfapi-a-flexible-and-convenient-http-client","sections":[],"depth":2},{"title":"What should I use ? And when ?","local":"what-should-i-use--and-when-","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/huggingface_hub/main/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/entry/start.6016e146.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/scheduler.6062bdaf.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/singletons.bc0a1d9c.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/paths.a6e41bef.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/entry/app.02edeb61.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/index.4bca734e.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/nodes/0.e222eee0.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/nodes/2.2aaaf41d.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/Tip.b9ac1f03.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/main/en/_app/immutable/chunks/EditOnGithub.74ab2baa.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Git vs HTTP paradigm","local":"git-vs-http-paradigm","sections":[{"title":"Repository: the historical git-based approach","local":"repository-the-historical-git-based-approach","sections":[],"depth":2},{"title":"HfApi: a flexible and convenient HTTP client","local":"hfapi-a-flexible-and-convenient-http-client","sections":[],"depth":2},{"title":"What should I use ? And when ?","local":"what-should-i-use--and-when-","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <h1 class="relative group"><a id="git-vs-http-paradigm" 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="#git-vs-http-paradigm"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Git vs HTTP paradigm</span></h1> <p data-svelte-h="svelte-109fppz">The <code>huggingface_hub</code> library is a library for interacting with the Hugging Face Hub, which is a | |
| collections of git-based repositories (models, datasets or Spaces). There are two main | |
| ways to access the Hub using <code>huggingface_hub</code>.</p> <p data-svelte-h="svelte-udnnu9">The first approach, the so-called “git-based” approach, is led by the <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class. | |
| This method uses a wrapper around the <code>git</code> command with additional functions specifically | |
| designed to interact with the Hub. The second option, called the “HTTP-based” approach, | |
| involves making HTTP requests using the <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> client. Let’s examine the pros and cons | |
| of each approach.</p> <h2 class="relative group"><a id="repository-the-historical-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="#repository-the-historical-git-based-approach"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Repository: the historical git-based approach</span></h2> <p data-svelte-h="svelte-4k0jhw">At first, <code>huggingface_hub</code> was mostly built around the <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class. It provides | |
| Python wrappers for common <code>git</code> commands such as <code>"git add"</code>, <code>"git commit"</code>, <code>"git push"</code>, | |
| <code>"git tag"</code>, <code>"git checkout"</code>, etc.</p> <p data-svelte-h="svelte-mpix11">The library also helps with setting credentials and tracking large files, which are often | |
| used in machine learning repositories. Additionally, the library allows you to execute its | |
| methods in the background, making it useful for uploading data during training.</p> <p data-svelte-h="svelte-b0wyfz">The main advantage of using a <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> is that it allows you to maintain a local | |
| copy of the entire repository on your machine. This can also be a disadvantage as | |
| it requires you to constantly update and maintain this local copy. This is similar to | |
| traditional software development where each developer maintains their own local copy and | |
| pushes changes when working on a feature. However, in the context of machine learning, | |
| this may not always be necessary as users may only need to download weights for inference | |
| or convert weights from one format to another without the need to clone the entire | |
| repository.</p> <div class="course-tip course-tip-orange bg-gradient-to-br dark:bg-gradient-to-r before:border-orange-500 dark:before:border-orange-800 from-orange-50 dark:from-gray-900 to-white dark:to-gray-950 border border-orange-50 text-orange-700 dark:text-gray-400"><p data-svelte-h="svelte-j0sdv2"><a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> is now deprecated in favor of the http-based alternatives. Given its large adoption in legacy code, the complete removal of <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> will only happen in release <code>v1.0</code>.</p></div> <h2 class="relative group"><a id="hfapi-a-flexible-and-convenient-http-client" 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="#hfapi-a-flexible-and-convenient-http-client"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>HfApi: a flexible and convenient HTTP client</span></h2> <p data-svelte-h="svelte-1v5bf2u">The <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class was developed to provide an alternative to local git repositories, which | |
| can be cumbersome to maintain, especially when dealing with large models or datasets. The | |
| <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class offers the same functionality as git-based approaches, such as downloading | |
| and pushing files and creating branches and tags, but without the need for a local folder | |
| that needs to be kept in sync.</p> <p data-svelte-h="svelte-1hj1jj0">In addition to the functionalities already provided by <code>git</code>, the <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class offers | |
| additional features, such as the ability to manage repos, download files using caching for | |
| efficient reuse, search the Hub for repos and metadata, access community features such as | |
| discussions, PRs, and comments, and configure Spaces hardware and secrets.</p> <h2 class="relative group"><a id="what-should-i-use--and-when-" 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="#what-should-i-use--and-when-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>What should I use ? And when ?</span></h2> <p data-svelte-h="svelte-1myrvrv">Overall, the <strong>HTTP-based approach is the recommended way to use</strong> <code>huggingface_hub</code> | |
| in all cases. <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> allows to pull and push changes, work with PRs, tags and branches, interact with discussions and much more. Since the <code>0.16</code> release, the http-based methods can also run in the background, which was the last major advantage of the <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class.</p> <p data-svelte-h="svelte-n1wg4d">However, not all git commands are available through <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a>. Some may never be implemented, but we are always trying to improve and close the gap. If you don’t see your use case covered, please open <a href="https://github.com/huggingface/huggingface_hub" rel="nofollow">an issue on Github</a>! We welcome feedback to help build the 🤗 ecosystem with and for our users.</p> <p data-svelte-h="svelte-ctif0n">This preference of the http-based <a href="/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> over the git-based <a href="/docs/huggingface_hub/main/en/package_reference/repository#huggingface_hub.Repository">Repository</a> does not mean that git versioning will disappear from the Hugging Face Hub anytime soon. It will always be possible to use <code>git</code> commands locally in workflows where it makes sense.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/concepts/git_vs_http.md" target="_blank"><span data-svelte-h="svelte-1kd6by1"><</span> <span data-svelte-h="svelte-x0xyl0">></span> <span data-svelte-h="svelte-1dajgef"><span class="underline ml-1.5">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_1y7w8l8 = { | |
| assets: "/docs/huggingface_hub/main/en", | |
| base: "/docs/huggingface_hub/main/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/huggingface_hub/main/en/_app/immutable/entry/start.6016e146.js"), | |
| import("/docs/huggingface_hub/main/en/_app/immutable/entry/app.02edeb61.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 2], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 14.2 kB
- Xet hash:
- 1b7a7197bc7459cbd17d0c531776fd06cc7d3854ebe40957dae8d522f868f906
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.