📁 Seamless download to local dir
The `0.23.0` release comes with a big revamp of the download process, especially when it comes to downloading to a local directory. Previously the process was still involving the cache directory and symlinks which led to misconceptions and a suboptimal user experience. The new workflow involves a `.cache/huggingface/` folder, similar to the `.git/` one, that keeps track of the progress of a download. The main features are:
- no symlinks
- no local copy
- don't re-download when not necessary
- same behavior on both Unix and Windows
- unrelated to cache-system
Example to download q4 GGUF file for [microsoft/Phi-3-mini-4k-instruct-gguf](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct-gguf):
sh
Download q4 GGUF file from
huggingface-cli download microsoft/Phi-3-mini-4k-instruct-gguf Phi-3-mini-4k-instruct-q4.gguf --local-dir=data/phi3
With this addition, **interrupted downloads are now resumable**! This applies both for downloads in local and cache directories which should greatly improve UX for users with slow/unreliable connections. In this regard, the `resume_download` parameter is now deprecated (not relevant anymore).
* Revamp download to local dir process by Wauplin in 2223
* Rename `.huggingface/` folder to `.cache/huggingface/` by Wauplin in 2262
💡 Grammar and Tools in `InferenceClient`
It is now possible to provide a list of tools when chatting with a model using the `InferenceClient`! This major improvement has been made possible thanks to TGI that handle them natively.
py
>>> from huggingface_hub import InferenceClient
Ask for weather in the next days using tools
>>> client = InferenceClient("meta-llama/Meta-Llama-3-70B-Instruct")
>>> messages = [
... {"role": "system", "content": "Don't make assumptions about what values to plug into functions. Ask for clarification if a user request is ambiguous."},
... {"role": "user", "content": "What's the weather like the next 3 days in San Francisco, CA?"},
... ]
>>> tools = [
... {
... "type": "function",
... "function": {
... "name": "get_current_weather",
... "description": "Get the current weather",
... "parameters": {
... "type": "object",
... "properties": {
... "location": {
... "type": "string",
... "description": "The city and state, e.g. San Francisco, CA",
... },
... "format": {
... "type": "string",
... "enum": ["celsius", "fahrenheit"],
... "description": "The temperature unit to use. Infer this from the users location.",
... },
... },
... "required": ["location", "format"],
... },
... },
... },
... ...
... ]
>>> response = client.chat_completion(
... model="meta-llama/Meta-Llama-3-70B-Instruct",
... messages=messages,
... tools=tools,
... tool_choice="auto",
... max_tokens=500,
... )
>>> response.choices[0].message.tool_calls[0].function
ChatCompletionOutputFunctionDefinition(
arguments={
'location': 'San Francisco, CA',
'format': 'fahrenheit',
'num_days': 3
},
name='get_n_day_weather_forecast',
description=None
)
It is also possible to provide grammar rules to the `text_generation` task. This ensures that the output follows a precise JSON Schema specification or matches a regular expression. For more details about it, check out the [Guidance guide](https://huggingface.co/docs/text-generation-inference/conceptual/guidance) from Text-Generation-Inference docs.
* Add support for Grammar/Tools + TGI-based specs in InferenceClient by Wauplin in 2237
⚙️ Other
Mention more `chat-completion` task instead of `conversation` in documentation.
* Add `chat_completion` and remove `conversational` from Inference guide by Wauplin in 2215
`chat-completion` relies on server-side rendering in all cases, including when model is `transformers`-backed. Previously it was only the case for TGI-backed models and templates were rendered client-side otherwise.
* Render chat-template server-side for transformers-backed models by Wauplin in 2258
Improved logic to determine whether a model is served via TGI or `transformers`.
* Raise error in chat completion when unprocessable by Wauplin in 2257
* Document more chat_completion by Wauplin in 2260
🌐 📚 Korean community is on fire!
The [PseudoLab](https://pseudo-lab.com/) team is a non-profit dedicated to make AI more accessible in the Korean-speaking community. In the past few weeks, their team of contributors managed to translated (almost) entirely the `huggingface_hub` documentation. Huge shout-out to the coordination on this task! Documentation can be accessed [here](https://huggingface.co/docs/huggingface_hub/main/ko/index).
* 🌐 [i18n-KO] Translated `guides/webhooks_server.md` to Korean by nuatmochoi in 2145
* 🌐 [i18n-KO] Translated `reference/login.md` to Korean by SeungAhSon in 2151
* 🌐 [i18n-KO] Translated `package_reference/tensorboard.md` to Korean by fabxoe in 2173
* 🌐 [i18n-KO] Translated `package_reference/inference_client.md` to Korean by cjfghk5697 in 2178
* 🌐 [i18n-KO] Translated `reference/inference_endpoints.md` to Korean by harheem in 2180
* 🌐 [i18n-KO] Translated `package_reference/file_download.md` to Korean by seoyoung-3060 in 2184
* 🌐 [i18n-KO] Translated `package_reference/cache.md` to Korean by nuatmochoi in 2191
* 🌐 [i18n-KO] Translated `package_reference/collections.md` to Korean by boyunJang in 2214
* 🌐 [i18n-KO] Translated `package_reference/inference_types.md` to Korean by fabxoe in 2171
* 🌐 [i18n-KO] Translated `guides/upload.md` to Korean by junejae in 2139
* 🌐 [i18n-KO] Translated `reference/repository.md` to Korean by junejae in 2189
* 🌐 [i18n-KO] Translated `package_reference/space_runtime.md` to Korean by boyunJang in 2213
* 🌐 [i18n-KO] Translated `guides/repository.md` to Korean by cjfghk5697 in 2124
* 🌐 [i18n-KO] Translated `guides/model_cards.md` to Korean" by SeungAhSon in 2128
* 🌐 [i18n-KO] Translated `guides/community.md` to Korean by seoulsky-field in 2126
* 🌐 [i18n-KO] Translated `guides/cli.md` to Korean by harheem in 2131
* 🌐 [i18n-KO] Translated `guides/search.md` to Korean by seoyoung-3060 in 2134
* 🌐 [i18n-KO] Translated `guides/inference.md` to Korean by boyunJang in 2130
* 🌐 [i18n-KO] Translated `guides/manage-spaces.md` to Korean by boyunJang in 2220
* 🌐 [i18n-KO] Translating `guides/hf_file_system.md` to Korean by heuristicwave in 2146
* 🌐 [i18n-KO] Translated `package_reference/hf_api.md` to Korean by fabxoe in 2165
* 🌐 [i18n-KO] Translated `package_reference/mixins.md` to Korean by fabxoe in 2166
* 🌐 [i18n-KO] Translated `guides/inference_endpoints.md` to Korean by usr-bin-ksh in 2164
* 🌐 [i18n-KO] Translated `package_reference/utilities.md` to Korean by cjfghk5697 in 2196
* fix ko docs by Wauplin (direct commit on main)
* 🌐 [i18n-KO] Translated package_reference/serialization.md to Korean by seoyoung-3060 in [2233](https://github.com/huggingface/huggingface_hub/pull/2233)
* 🌐 [i18n-KO] Translated package_reference/hf_file_system.md to Korean by SeungAhSon in [2174](https://github.com/huggingface/huggingface_hub/pull/2174)
🛠️ Misc improvements
User API
bilgehanertan added support for 2 new routes:
- [`get_user_overview`](https://huggingface.co/docs/huggingface_hub/main/en/package_reference/hf_api#huggingface_hub.HfApi.get_user_overview) to retrieve high-level information about a user: username, avatar, number of models/datasets/Spaces, number of likes and upvotes, number of interactions in discussion, etc.
* User API endpoints by bilgehanertan in 2147
CLI tag
bilgehanertan added a new command to the CLI to handle tags. It is now possible to:
- tag a repo