Skip to content

Commit

Permalink
Merge branch 'main' into support-python-3-13
Browse files Browse the repository at this point in the history
  • Loading branch information
hanouticelina authored Oct 27, 2024
2 parents f67bf44 + c547c83 commit b4612d5
Show file tree
Hide file tree
Showing 121 changed files with 405 additions and 268 deletions.
2 changes: 1 addition & 1 deletion docs/source/cn/concepts/git_vs_http.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/cn/guides/repository.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/cn/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/cn/installation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/cn/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/concepts/git_vs_http.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/community.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/download.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/hf_file_system.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/inference.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/integrations.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/manage-cache.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/manage-spaces.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/model-cards.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/repository.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/search.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/upload.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/guides/webhooks_server.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/installation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
2 changes: 1 addition & 1 deletion docs/source/de/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
4 changes: 2 additions & 2 deletions docs/source/en/concepts/git_vs_http.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

# Git vs HTTP paradigm

The `huggingface_hub` 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
collection of git-based repositories (models, datasets or Spaces). There are two main
ways to access the Hub using `huggingface_hub`.

The first approach, the so-called "git-based" approach, is led by the [`Repository`] class.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/en/guides/cli.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down Expand Up @@ -139,7 +139,7 @@ If you are not logged in, an error message will be printed.

## huggingface-cli logout

This commands logs you out. In practice, it will delete all tokens stored on your machine. If you want to remove a specific token, you can specify the token name as an argument.
This command logs you out. In practice, it will delete all tokens stored on your machine. If you want to remove a specific token, you can specify the token name as an argument.

This command will not log you out if you are logged in using the `HF_TOKEN` environment variable (see [reference](../package_reference/environment_variables#hftoken)). If that is the case, you must unset the environment variable in your machine configuration.

Expand Down
6 changes: 3 additions & 3 deletions docs/source/en/guides/collections.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

# Collections

A collection is a group of related items on the Hub (models, datasets, Spaces, papers) that are organized together on the same page. Collections are useful for creating your own portfolio, bookmarking content in categories, or presenting a curated list of items you want to share. Check out this [guide](https://huggingface.co/docs/hub/collections) to understand in more detail what collections are and how they look on the Hub.

You can directly manage collections in the browser, but in this guide, we will focus on how to manage it programmatically.
You can directly manage collections in the browser, but in this guide, we will focus on how to manage them programmatically.

## Fetch a collection

Expand Down Expand Up @@ -115,7 +115,7 @@ Now that we know how to get a [`Collection`], let's create our own! Use [`create
... )
```

It will return a [`Collection`] object with the high-level metadata (title, description, owner, etc.) and an empty list of items. You will now be able to refer to this collection using it's `slug`.
It will return a [`Collection`] object with the high-level metadata (title, description, owner, etc.) and an empty list of items. You will now be able to refer to this collection using its `slug`.

```py
>>> collection.slug
Expand Down
4 changes: 2 additions & 2 deletions docs/source/en/guides/community.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down Expand Up @@ -80,7 +80,7 @@ with more detailed information about the Discussion or Pull Request. Information
and renames of the Discussion via [`DiscussionWithDetails.events`].

In case of a Pull Request, you can retrieve the raw git diff with [`DiscussionWithDetails.diff`]. All the commits of the
Pull Request are listed in [`DiscussionWithDetails.events`].
Pull Requests are listed in [`DiscussionWithDetails.events`].


## Create and edit a Discussion or Pull Request programmatically
Expand Down
2 changes: 1 addition & 1 deletion docs/source/en/guides/download.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down
4 changes: 2 additions & 2 deletions docs/source/en/guides/hf_file_system.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

# Interact with the Hub through the Filesystem API

In addition to the [`HfApi`], the `huggingface_hub` library provides [`HfFileSystem`], a pythonic [fsspec-compatible](https://filesystem-spec.readthedocs.io/en/latest/) file interface to the Hugging Face Hub. The [`HfFileSystem`] builds of top of the [`HfApi`] and offers typical filesystem style operations like `cp`, `mv`, `ls`, `du`, `glob`, `get_file`, and `put_file`.
In addition to the [`HfApi`], the `huggingface_hub` library provides [`HfFileSystem`], a pythonic [fsspec-compatible](https://filesystem-spec.readthedocs.io/en/latest/) file interface to the Hugging Face Hub. The [`HfFileSystem`] builds on top of the [`HfApi`] and offers typical filesystem style operations like `cp`, `mv`, `ls`, `du`, `glob`, `get_file`, and `put_file`.

## Usage

Expand Down
10 changes: 5 additions & 5 deletions docs/source/en/guides/inference.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down Expand Up @@ -77,7 +77,7 @@ ChatCompletionOutput(
)
```

In this example, we specified which model we want to use (`"meta-llama/Meta-Llama-3-8B-Instruct"`). You can find a list of compatible models [on this page](https://huggingface.co/models?other=conversational&sort=likes). We then gave a list of messages to complete (here, a single question) and passed an additional parameter to API (`max_token=100`). The output is a `ChatCompletionOutput` object that follows the OpenAI specification. The generated content can be access with `output.choices[0].message.content`. For more details, check out the [`~InferenceClient.chat_completion`] documentation.
In this example, we specified which model we want to use (`"meta-llama/Meta-Llama-3-8B-Instruct"`). You can find a list of compatible models [on this page](https://huggingface.co/models?other=conversational&sort=likes). We then gave a list of messages to complete (here, a single question) and passed an additional parameter to API (`max_token=100`). The output is a `ChatCompletionOutput` object that follows the OpenAI specification. The generated content can be accessed with `output.choices[0].message.content`. For more details, check out the [`~InferenceClient.chat_completion`] documentation.


<Tip warning={true}>
Expand Down Expand Up @@ -176,7 +176,7 @@ for chunk in output:
print(chunk.choices[0].delta.content)
```

And that's it! The only required changes are to replace `from openai import OpenAI` by `from huggingface_hub import InferenceClient` and `client = OpenAI(...)` by `client = InferenceClient(...)`. You can chose any LLM model from the Hugging Face Hub by passing its model id as `model` parameter. [Here is a list](https://huggingface.co/models?pipeline_tag=text-generation&other=conversational,text-generation-inference&sort=trending) of supported models. For authentication, you should pass a valid [User Access Token](https://huggingface.co/settings/tokens) as `api_key` or authenticate using `huggingface_hub` (see the [authentication guide](https://huggingface.co/docs/huggingface_hub/quick-start#authentication)).
And that's it! The only required changes are to replace `from openai import OpenAI` by `from huggingface_hub import InferenceClient` and `client = OpenAI(...)` by `client = InferenceClient(...)`. You can choose any LLM model from the Hugging Face Hub by passing its model id as `model` parameter. [Here is a list](https://huggingface.co/models?pipeline_tag=text-generation&other=conversational,text-generation-inference&sort=trending) of supported models. For authentication, you should pass a valid [User Access Token](https://huggingface.co/settings/tokens) as `api_key` or authenticate using `huggingface_hub` (see the [authentication guide](https://huggingface.co/docs/huggingface_hub/quick-start#authentication)).

All input parameters and output format are strictly the same. In particular, you can pass `stream=True` to receive tokens as they are generated. You can also use the [`AsyncInferenceClient`] to run inference using `asyncio`:

Expand All @@ -201,7 +201,7 @@ asyncio.run(main())
```

You might wonder why using [`InferenceClient`] instead of OpenAI's client? There are a few reasons for that:
1. [`InferenceClient`] is configured for Hugging Face services. You don't need to provide a `base_url` to run models on the serverless Inference API. You also don't need to provide a `token` or `api_key` if you machine is already correctly logged in.
1. [`InferenceClient`] is configured for Hugging Face services. You don't need to provide a `base_url` to run models on the serverless Inference API. You also don't need to provide a `token` or `api_key` if your machine is already correctly logged in.
2. [`InferenceClient`] is tailored for both Text-Generation-Inference (TGI) and `transformers` frameworks, meaning you are assured it will always be on-par with the latest updates.
3. [`InferenceClient`] is integrated with our Inference Endpoints service, making it easier to launch an Inference Endpoint, check its status and run inference on it. Check out the [Inference Endpoints](./inference_endpoints.md) guide for more details.

Expand Down Expand Up @@ -285,7 +285,7 @@ After installation all async API endpoints are available via [`AsyncInferenceCli
strictly the same as the sync-only version.

```py
# Code must be run in a asyncio concurrent context.
# Code must be run in an asyncio concurrent context.
# $ python -m asyncio
>>> from huggingface_hub import AsyncInferenceClient
>>> client = AsyncInferenceClient()
Expand Down
6 changes: 3 additions & 3 deletions docs/source/en/guides/integrations.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->

Expand Down Expand Up @@ -39,7 +39,7 @@ Implementation can differ between libraries, but the workflow is often similar.

### from_pretrained

This is how a `from_pretrained` method usually look like:
This is how a `from_pretrained` method usually looks like:

```python
def from_pretrained(model_id: str) -> MyModelClass:
Expand Down Expand Up @@ -390,7 +390,7 @@ class VoiceCraft(nn.Module):
...
```

One solution can be to update the `__init__` signature to `def __init__(self, pattern: str, hidden_size: int)` and update all snippets that instantiates your class. This is a perfectly valid way to fix it but it might break downstream applications using your library.
One solution can be to update the `__init__` signature to `def __init__(self, pattern: str, hidden_size: int)` and update all snippets that instantiate your class. This is a perfectly valid way to fix it but it might break downstream applications using your library.

Another solution is to provide a simple encoder/decoder to convert `argparse.Namespace` to a dictionary.

Expand Down
Loading

0 comments on commit b4612d5

Please sign in to comment.