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

ONNX Support #346

Merged
merged 85 commits into from
May 30, 2023
Merged

ONNX Support #346

merged 85 commits into from
May 30, 2023

Conversation

guillaume-be
Copy link
Owner

  • Addition of support for ONNX models (encoder, decoders, encoder-decoders) via the ort onnxruntime bindings
  • Integration of ONNX models to the sequence classification, token classification, question answering, zero-shot classification, text generation, summarization and translation pipelines

Further changes:

  • Read the decoder_start_token_id from the provided configuration rather than using a hard-coded default value
  • (BREAKING) Changed the return type of the LanguageGenerator and pipelines functions float, half, set_device to Result<(), RustBertError> as these become fallible for ONNX models
  • (BREAKING) Wrapped the model resources specification for the pipeline Config objects into an Enum to allow handling both torch-based and ONNX models.
    The model_resources field now needs to be wrapped in the corresponding enum variant, e.g. model_resources: ModelResources::TORCH(model_resource) for Torch-based models
  • (BREAKING) Added the forced_bos_token_id and forced_eos_token_id fields to text generation models.
    If these are not None, this will trigger a forced BOS/EOS token generation at the first of max_length positions (aligns with the Pytorch Transformers library)

Fixes #292

@guillaume-be
Copy link
Owner Author

Pending publication of changes introduced in LaurentMazare/tch-rs#662 and update of the tch dependency to cargo

@masc-it
Copy link
Contributor

masc-it commented Apr 13, 2023

news about this?

# Conflicts:
#	CHANGELOG.md
#	Cargo.toml
#	src/pipelines/common.rs
#	src/pipelines/masked_language.rs
#	src/pipelines/question_answering.rs
#	src/pipelines/sequence_classification.rs
#	src/pipelines/summarization.rs
#	src/pipelines/text_generation.rs
#	src/pipelines/token_classification.rs
#	src/pipelines/zero_shot_classification.rs
# Conflicts:
#	CHANGELOG.md
#	Cargo.toml
#	src/bart/bart_model.rs
#	src/fnet/attention.rs
#	src/gpt2/gpt2_model.rs
#	src/gpt_j/gpt_j_model.rs
#	src/gpt_neo/gpt_neo_model.rs
#	src/longt5/longt5_model.rs
#	src/m2m_100/m2m_100_model.rs
#	src/marian/marian_model.rs
#	src/mbart/mbart_model.rs
#	src/openai_gpt/openai_gpt_model.rs
#	src/pegasus/pegasus_model.rs
#	src/pipelines/generation_utils.rs
#	src/pipelines/masked_language.rs
#	src/pipelines/sentence_embeddings/pipeline.rs
#	src/pipelines/sequence_classification.rs
#	src/pipelines/summarization.rs
#	src/pipelines/text_generation.rs
#	src/pipelines/translation/translation_pipeline.rs
#	src/prophetnet/prophetnet_model.rs
#	src/reformer/attention.rs
#	src/reformer/reformer_model.rs
#	src/t5/t5_model.rs
#	src/xlnet/xlnet_model.rs
#	tests/fnet.rs
#	tests/longformer.rs
#	tests/mobilebert.rs
# Conflicts:
#	src/bart/bart_model.rs
#	src/common/error.rs
#	src/common/resources/mod.rs
#	src/gpt2/gpt2_model.rs
#	src/gpt_j/gpt_j_model.rs
#	src/gpt_neo/gpt_neo_model.rs
#	src/longt5/longt5_model.rs
#	src/m2m_100/m2m_100_model.rs
#	src/marian/marian_model.rs
#	src/mbart/mbart_model.rs
#	src/openai_gpt/openai_gpt_model.rs
#	src/pegasus/pegasus_model.rs
#	src/pipelines/masked_language.rs
#	src/pipelines/question_answering.rs
#	src/pipelines/sequence_classification.rs
#	src/pipelines/token_classification.rs
#	src/pipelines/zero_shot_classification.rs
#	src/prophetnet/prophetnet_model.rs
#	src/reformer/reformer_model.rs
#	src/t5/t5_model.rs
#	src/xlnet/xlnet_model.rs
@guillaume-be guillaume-be marked this pull request as ready for review May 26, 2023 18:40
@guillaume-be guillaume-be merged commit 540c926 into master May 30, 2023
11 checks passed
@guillaume-be guillaume-be deleted the onnx-runtime branch August 13, 2023 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onnx model
2 participants