Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update machine-learning #8280

Merged
merged 1 commit into from
Mar 31, 2024
Merged

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Mar 26, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence Type Update Pending
huggingface-hub 0.21.4 -> 0.22.0 age adoption passing confidence dependencies minor 0.22.2 (+1)
locust 2.24.0 -> 2.24.1 age adoption passing confidence dev patch
mambaorg/micromamba 881dbb6 -> 3624db3 final digest
pytest-asyncio (changelog) 0.23.5.post1 -> 0.23.6 age adoption passing confidence dev patch
pytest-mock (changelog) 3.12.0 -> 3.14.0 age adoption passing confidence dev minor
python a2eb07f -> 90f8795 stage digest
python 991e20a -> e2ed446 stage digest
ruff (source, changelog) 0.3.3 -> 0.3.4 age adoption passing confidence dev patch
uvicorn (changelog) 0.28.0 -> 0.29.0 age adoption passing confidence dependencies minor

Warning

Some dependencies could not be looked up. Check the Dependency Dashboard for more information.


Release Notes

huggingface/huggingface_hub (huggingface-hub)

v0.22.0: : Chat completion, inference types and hub mixins!

Compare Source

Discuss about the release in our Community Tab. Feedback is welcome!! 🤗

✨ InferenceClient

Support for inference tools continues to improve in huggingface_hub. At the menu in this release? A new chat_completion API and fully typed inputs/outputs!

Chat-completion API!

A long-awaited API has just landed in huggingface_hub! InferenceClient.chat_completion follows most of OpenAI's API, making it much easier to integrate with existing tools.

Technically speaking it uses the same backend as the text-generation task but requires a preprocessing step to format the list of messages into a single text prompt. The chat template is rendered server-side when models are powered by TGI, which is the case for most LLMs: Llama, Zephyr, Mistral, Gemma, etc. Otherwise, the templating happens client-side which requires minijinja package to be installed. We are actively working on bridging this gap, aiming at rendering all templates server-side in the future.

>>> from huggingface_hub import InferenceClient
>>> messages = [{"role": "user", "content": "What is the capital of France?"}]
>>> client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")

##### Batch completion
>>> client.chat_completion(messages, max_tokens=100)
ChatCompletionOutput(
    choices=[
        ChatCompletionOutputChoice(
            finish_reason='eos_token',
            index=0,
            message=ChatCompletionOutputChoiceMessage(
                content='The capital of France is Paris. The official name of the city is "Ville de Paris" (City of Paris) and the name of the country\'s governing body, which is located in Paris, is "La République française" (The French Republic). \nI hope that helps! Let me know if you need any further information.'
            )
        )
    ],
    created=1710498360
)

##### Stream new tokens one by one
>>> for token in client.chat_completion(messages, max_tokens=10, stream=True):
...     print(token)
ChatCompletionStreamOutput(choices=[ChatCompletionStreamOutputChoice(delta=ChatCompletionStreamOutputDelta(content='The', role='assistant'), index=0, finish_reason=None)], created=1710498504)
ChatCompletionStreamOutput(choices=[ChatCompletionStreamOutputChoice(delta=ChatCompletionStreamOutputDelta(content=' capital', role='assistant'), index=0, finish_reason=None)], created=1710498504)
(...)
ChatCompletionStreamOutput(choices=[ChatCompletionStreamOutputChoice(delta=ChatCompletionStreamOutputDelta(content=' may', role='assistant'), index=0, finish_reason=None)], created=1710498504)
ChatCompletionStreamOutput(choices=[ChatCompletionStreamOutputChoice(delta=ChatCompletionStreamOutputDelta(content=None, role=None), index=0, finish_reason='length')], created=1710498504)
Inference types

We are currently working towards more consistency in tasks definitions across the Hugging Face ecosystem. This is no easy job but a major milestone has recently been achieved! All inputs and outputs of the main ML tasks are now fully specified as JSONschema objects. This is the first brick needed to have consistent expectations when running inference across our stack: transformers (Python), transformers.js (Typescript), Inference API (Python), Inference Endpoints (Python), Text Generation Inference (Rust), Text Embeddings Inference (Rust), InferenceClient (Python), Inference.js (Typescript), etc.

Integrating those definitions will require more work but huggingface_hub is one of the first tools to integrate them. As a start, all InferenceClient return values are now typed dataclasses. Furthermore, typed dataclasses have been generated for all tasks' inputs and outputs. This means you can now integrate them in your own library to ensure consistency with the Hugging Face ecosystem. Specifications are open-source (see here) meaning anyone can access and contribute to them. Python's generated classes are documented here.

Here is a short example showcasing the new output types:

>>> from huggingface_hub import InferenceClient
>>> client = InferenceClient()
>>> client.object_detection("people.jpg"):
[
    ObjectDetectionOutputElement(
        score=0.9486683011054993,
        label='person',
        box=ObjectDetectionBoundingBox(xmin=59, ymin=39, xmax=420, ymax=510)
    ),
...
]

Note that those dataclasses are backward-compatible with the dict-based interface that was previously in use. In the example above, both ObjectDetectionBoundingBox(...).xmin and ObjectDetectionBoundingBox(...)["xmin"] are correct, even though the former should be the preferred solution from now on.

🧩 ModelHubMixin

ModelHubMixin is an object that can be used as a parent class for the objects in your library in order to provide built-in serialization methods to upload and download pretrained models from the Hub. This mixin is adapted into a PyTorchHubMixin that can serialize and deserialize any Pytorch model. The 0.22 release brings its share of improvements to these classes:

  1. Better support of init values. If you instantiate a model with some custom arguments, the values will be automatically stored in a config.json file and restored when reloading the model from pretrained weights. This should unlock integrations with external libraries in a much smoother way.
  2. Library authors integrating the hub mixin can now define custom metadata for their library: library name, tags, document url and repo url. These are to be defined only once when integrating the library. Any model pushed to the Hub using the library will then be easily discoverable thanks to those tags.
  3. A base modelcard is generated for each saved model. This modelcard includes default tags (e.g. model_hub_mixin) and custom tags from the library (see 2.). You can extend/modify this modelcard by overwriting the generate_model_card method.
>>> import torch
>>> import torch.nn as nn
>>> from huggingface_hub import PyTorchModelHubMixin

##### Define your Pytorch model exactly the same way you are used to
>>> class MyModel(
...         nn.Module,
...         PyTorchModelHubMixin, # multiple inheritance
...         library_name="keras-nlp",
...         tags=["keras"],
...         repo_url="https://github.com/keras-team/keras-nlp",
...         docs_url="https://keras.io/keras_nlp/",
...         # ^ optional metadata to generate model card
...     ):
...     def __init__(self, hidden_size: int = 512, vocab_size: int = 30000, output_size: int = 4):
...         super().__init__()
...         self.param = nn.Parameter(torch.rand(hidden_size, vocab_size))
...         self.linear = nn.Linear(output_size, vocab_size)

...     def forward(self, x):
...         return self.linear(x + self.param)

##### 1. Create model
>>> model = MyModel(hidden_size=128)

##### Config is automatically created based on input + default values
>>> model._hub_mixin_config
{"hidden_size": 128, "vocab_size": 30000, "output_size": 4}

##### 2. (optional) Save model to local directory
>>> model.save_pretrained("path/to/my-awesome-model")

##### 3. Push model weights to the Hub
>>> model.push_to_hub("my-awesome-model")

##### 4. Initialize model from the Hub => config has been preserved
>>> model = MyModel.from_pretrained("username/my-awesome-model")
>>> model._hub_mixin_config
{"hidden_size": 128, "vocab_size": 30000, "output_size": 4}

##### Model card has been correctly populated
>>> from huggingface_hub import ModelCard
>>> card = ModelCard.load("username/my-awesome-model")
>>> card.data.tags
["keras", "pytorch_model_hub_mixin", "model_hub_mixin"]
>>> card.data.library_name
"keras-nlp"

For more details on how to integrate these classes, check out the integration guide.

🛠️ Misc improvements

HfFileSystem download speed was limited by some internal logic in fsspec. We've now updated the get_file and read implementations to improve their download speed to a level similar to hf_hub_download.

We are aiming at moving all errors raised by huggingface_hub into a single module huggingface_hub.errors to ease the developer experience. This work has been started as a community contribution from @​Y4suyuki.

HfApi class now accepts a headers parameters that is then passed to every HTTP call made to the Hub.

📚 More documentation in Korean!

💔 Breaking changes
  • The new types returned by InferenceClient methods should be backward compatible, especially to access values either as attributes (.my_field) or as items (i.e. ["my_field"]). However, dataclasses and dicts do not always behave exactly the same so might notice some breaking changes. Those breaking changes should be very limited.

  • ModelHubMixin internals changed quite a bit, breaking some use cases. We don't think those use cases were in use and changing them should really benefit 99% of integrations. If you witness any inconsistency or error in your integration, please let us know and we will do our best to mitigate the problem. One of the biggest change is that the config values are not attached to the mixin instance as instance.config anymore but as instance._model_hub_mixin. The .config attribute has been mistakenly introduced in 0.20.x so we hope it has not been used much yet.

  • huggingface_hub.file_download.http_user_agent has been removed in favor of the officially document huggingface_hub.utils.build_hf_headers. It was a deprecated method since 0.18.x.

Small fixes and maintenance
⚙️ CI optimization

The CI pipeline has been greatly improved, especially thanks to the efforts from @​bmuskalla. Most tests are now passing in under 3 minutes, against 8 to 10 minutes previously. Some long-running tests have been greatly simplified and all tests are now ran in parallel with python-xdist, thanks to a complete decorrelation between them.

We are now also using the great uv installer instead of pip in our CI, which saves around 30-40s per pipeline.

⚙️ fixes
⚙️ internal
Significant community contributions

The following contributors have made significant changes to the library over the last release:

locustio/locust (locust)

v2.24.1

Compare Source

Full Changelog

Fixed bugs:

  • 'NoneType' object has no attribute 'get' when stream=True in FastHttpSession.request #​2640
  • Locust --processes argument generating multiple html reports #​2639
  • cannot open dashboard and console error shows 'the server responded with a MIME type of "text/plain".' #​2632
  • extend web ui not working since 2.22.0 #​2629
  • Custom parameters incomplete display #​2628

Closed issues:

  • pyproject.toml support for locust configuration #​2298

Merged pull requests:

pytest-dev/pytest-asyncio (pytest-asyncio)

v0.23.6

Compare Source

pytest-dev/pytest-mock (pytest-mock)

v3.14.0

Compare Source

  • #&#8203;415 <https://github.com/pytest-dev/pytest-mock/pull/415>_: MockType and AsyncMockType can be imported from pytest_mock for type annotation purposes.

  • #&#8203;420 <https://github.com/pytest-dev/pytest-mock/issues/420>_: Fixed a regression which would cause mocker.patch.object to not being properly cleared between tests.

v3.13.0

Compare Source

  • #&#8203;417 <https://github.com/pytest-dev/pytest-mock/pull/417>_: spy now has spy_return_list, which is a list containing all the values returned by the spied function.
  • pytest-mock now requires pytest>=6.2.5.
  • #&#8203;410 <https://github.com/pytest-dev/pytest-mock/pull/410>: pytest-mock's setup.py file is removed.
    If you relied on this file, e.g. to install pytest using setup.py install,
    please see Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html#summary>
    for alternatives.
astral-sh/ruff (ruff)

v0.3.4

Compare Source

Preview features
  • [flake8-simplify] Detect implicit else cases in needless-bool (SIM103) (#​10414)
  • [pylint] Implement nan-comparison (PLW0117) (#​10401)
  • [pylint] Implement nonlocal-and-global (E115) (#​10407)
  • [pylint] Implement singledispatchmethod-function (PLE5120) (#​10428)
  • [refurb] Implement list-reverse-copy (FURB187) (#​10212)
Rule changes
  • [flake8-pytest-style] Add automatic fix for pytest-parametrize-values-wrong-type (PT007) (#​10461)
  • [pycodestyle] Allow SPDX license headers to exceed the line length (E501) (#​10481)
Formatter
  • Fix unstable formatting for trailing subscript end-of-line comment (#​10492)
Bug fixes
  • Avoid code comment detection in PEP 723 script tags (#​10464)
  • Avoid incorrect tuple transformation in single-element case (C409) (#​10491)
  • Bug fix: Prevent fully defined links name from being reformatted (#​10442)
  • Consider raw source code for W605 (#​10480)
  • Docs: Link inline settings when not part of options section (#​10499)
  • Don't treat annotations as redefinitions in .pyi files (#​10512)
  • Fix E231 bug: Inconsistent catch compared to pycodestyle, such as when dict nested in list (#​10469)
  • Fix pylint upstream categories not showing in docs (#​10441)
  • Add missing Options references to blank line docs (#​10498)
  • 'Revert "F821: Fix false negatives in .py files when from __future__ import annotations is active (#​10362)"' (#​10513)
  • Apply NFKC normalization to unicode identifiers in the lexer (#​10412)
  • Avoid failures due to non-deterministic binding ordering (#​10478)
  • [flake8-bugbear] Allow tuples of exceptions (B030) (#​10437)
  • [flake8-quotes] Avoid syntax errors due to invalid quotes (Q000, Q002) (#​10199)
encode/uvicorn (uvicorn)

v0.29.0

Compare Source

Added
  • Cooperative signal handling (#​1600) 19/03/24

v0.28.1

Compare Source

Fixed
  • Revert raise ClientDisconnected on HTTP (#​2276) 19/03/24

Configuration

📅 Schedule: Branch creation - "on tuesday" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot added dependencies Pull requests that update a dependency file renovate labels Mar 26, 2024
Copy link

cloudflare-workers-and-pages bot commented Mar 26, 2024

Deploying immich with  Cloudflare Pages  Cloudflare Pages

Latest commit: 22d821a
Status: ✅  Deploy successful!
Preview URL: https://8a7077dc.immich.pages.dev
Branch Preview URL: https://renovate-machine-learning.immich.pages.dev

View logs

@renovate renovate bot force-pushed the renovate/machine-learning branch 3 times, most recently from e586f50 to 228480b Compare March 30, 2024 14:54
@renovate renovate bot changed the title chore(deps): update machine-learning fix(deps): update machine-learning Mar 30, 2024
@renovate renovate bot force-pushed the renovate/machine-learning branch from 428d03c to 22d821a Compare March 31, 2024 05:49
@mertalev mertalev enabled auto-merge (squash) March 31, 2024 05:51
@mertalev mertalev merged commit e2d5a8c into main Mar 31, 2024
26 checks passed
@mertalev mertalev deleted the renovate/machine-learning branch March 31, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant