Optimum

Latest version: v1.20.0

Safety actively analyzes 634963 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 14 of 16

1.2.3

* Remove intel sub-package, migrating to [`optimum-intel`](https://github.com/huggingface/optimum-intel) (#212)
* Fix the loading and saving of `ORTModel` optimized and quantized models (214)

1.2.2

* Extend `QuantizationPreprocessor` to dynamic quantization (https://github.com/huggingface/optimum/pull/196)
* Introduce unified approach to create transformers vs optimized models benchmark (https://github.com/huggingface/optimum/pull/194)
* Bump `huggingface_hub` version and `protobuf` fix (https://github.com/huggingface/optimum/pull/205)

1.2.1

DeepSpeed

This release brings support for DeepSpeed. It is now possible to train bigger models on Gaudi with Optimum Habana!
- Add support for DeepSpeed 93

Check the documentation [here](https://huggingface.co/docs/optimum/habana_deepspeed) to know how to use it.


Computer Vision Models

Two computer-vision models have been validated for performing image classification in both single- and multi-cards configurations:
- ViT 80
- Swin

You can see how to use them [in this example](https://github.com/huggingface/optimum-habana/tree/main/examples/image-classification).

1.2.0

ORTModel

[`ORTModelForXXX`](https://huggingface.co/docs/optimum/main/en/onnxruntime/modeling_ort) classes such as [`ORTModelForSequenceClassification`](https://huggingface.co/docs/optimum/main/en/onnxruntime/modeling_ort#optimum.onnxruntime.ORTModelForSequenceClassification) were integrated with the [Hugging Face Hub](https://hf.co/models) in order to easily export models through the ONNX format, load ONNX models, as well as easily save the resulting model and push it to the 🤗 Hub by using respectively the `save_pretrained` and `push_to_hub` methods. An already optimized and / or quantized ONNX model can also be loaded using the [ORTModelForXXX]() classes using the `from_pretrained` method.

Below is an example that downloads a DistilBERT model from the Hub, exports it through the ONNX format and saves it :

python
from optimum.onnxruntime import ORTModelForSequenceClassification

Load model from hub and export it through the ONNX format
model = ORTModelForSequenceClassification.from_pretrained(
"distilbert-base-uncased-finetuned-sst-2-english",
from_transformers=True
)

Save the exported model
model.save_pretrained("a_local_path_for_convert_onnx_model")


Pipelines

Built-in support for [transformers pipelines](https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#pipelines) was added. This allows us to leverage the same API used from Transformers, with the power of accelerated runtimes such as [ONNX Runtime](https://onnxruntime.ai/).

The currently supported tasks with the default model for each are the following :

* Text Classification ([DistilBERT](https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english) model fine-tuned on SST-2)
* Question Answering ([DistilBERT](https://huggingface.co/distilbert-base-cased-distilled-squad) model fine-tuned on SQuAD v1.1)
* Token Classification([BERT](https://huggingface.co/dbmdz/bert-large-cased-finetuned-conll03-english) large fine-tuned on CoNLL2003)
* Feature Extraction ([DistilBERT](https://huggingface.co/distilbert-base-cased))
* Zero Shot Classification ([BART](https://huggingface.co/facebook/bart-large-mnli) model fine-tuned on MNLI)
* Text Generation ([DistilGPT2](https://huggingface.co/distilgpt2))

Below is an example that downloads a RoBERTa model from the Hub, exports it through the ONNX format and loads it with `transformers` pipeline for `question-answering`.

python
from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForQuestionAnswering

load vanilla transformers and convert to onnx
model = ORTModelForQuestionAnswering.from_pretrained("deepset/roberta-base-squad2",from_transformers=True)
tokenizer = AutoTokenizer.from_pretrained("deepset/roberta-base-squad2")

test the model with using transformers pipeline, with handle_impossible_answer for squad_v2
optimum_qa = pipeline(task, model=model, tokenizer=tokenizer, handle_impossible_answer=True)
prediction = optimum_qa(
question="What's my name?", context="My name is Philipp and I live in Nuremberg."
)

print(prediction)
{'score': 0.9041663408279419, 'start': 11, 'end': 18, 'answer': 'Philipp'}


Improvements
* Add loss when performing the evalutation step using an instance of `ORTTrainer`, previously not enabled when inference was performed with ONNX Runtime in [152](https://github.com/huggingface/optimum/pull/152)

1.1.2

This patch release fixes a bug where it is possible to initialize processes multiple times in distributed mode, leading to an error.

1.1.1

This patch release fixes a bug where the loss is equal to NaN from the first training iteration with Transformers 4.21.0.

Page 14 of 16

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.