* tokenizers output type conversion
* WIP hf Tokenizers support (2)
* finalize interface methods for hf tokenizers
* Addition of GPT2 example with hf tokenizers
* Made hf-tokenizers optional, added doc for HFTokenizer
* Addition of tests for hf tokenizers, addition to CI
* Updated changelog, extended documentation
* Fix Clippy warnings
* Fixed Clippy warnings
* Revert "Shallow clone optimization (#243)"
This reverts commit ba584653bc.
* updated dependencies
* tryouts
* GPT2 tryouts
* WIP GPT2
* input mapping
* Cache storage
* Initial GPT2 prototype
* Initial ONNX Config and decoder implementation
* ONNXDecoder first draft
* Use Decoders in example
* Automated tch-ort conversion, decoder implementation
* ONNXCausalDecoder implementation
* Refactored _get_var_store to be optional, added get_device to gen trait
* updated example
* Added decoder_start_token_id to ConfigOption
* Addition of ONNXModelConfig, make max_position_embeddigs optional
* Addition of forward pass function for ONNXModel
* Working ONNX causal decoder
* Simplify tensor conversion
* refactor translation to facilitate ONNX integration
* Implementation of ONNXEncoder
* Implementation of ONNXConditionalGenerator
* working ONNXCausalGenerator
* - Reworked model resources type for pipelines and generators
* Aligned ONNXConditionalGenerator with other generators to use GenerateConfig for creation
* Moved force_token_id_generation to common utils function, fixed tests, Translation implementation
* generalized forced_bos and forced_eos tokens generation
* Aligned the `encode_prompt_text` method across language models
* Fix prompt encoding for causal generation
* Fix prompt encoding for causal generation
* Support for ONNX models for SequenceClassification
* Support for ONNX models for TokenClassification
* Support for ONNX models for POS and NER pipelines
* Support for ONNX models for ZeroShotClassification pipeline
* Support for ONNX models for QuestionAnswering pipeline
* Support for ONNX models for MaskedLM pipeline
* Added token_type_ids , updated layer cache i/o parsing for ONNX pipelines
* Support for ONNX models for TextGenerationPipeline, updated examples for remote resources
* Remove ONNX zero-shot classification example (lack of correct pretrained model)
* Addition of tests for ONNX pipelines support
* Made onnx feature optional
* Fix device lookup with onnx feature enabled
* Updates from main branch
* Flexible tokenizer creation for M2M100 (NLLB support), make NLLB test optional du to their size
* Fixed Clippy warnings
* Addition of documentation for ONNX
* Added documentation for ONNX support
* upcoming tch 1.12 fixes
* Fix merge conflicts
* Fix merge conflicts (2)
* Add download libtorch feature to ONNX tests
* Add download-onnx feature
* attempt to enable onnx download
* add remote resources feature
* onnx download
* pin ort version
* Update ort version
* Introduce in-memory resource abstraction
This follows from discussion in #366.
The goal of this change is to allow for weights to be loaded from a copy
of `rust_model.ot` that is already present in memory. There are two ways
in which that data might be present:
1. As a `HashMap<String, Tensor>` from previous interaction with `tch`
2. As a contiguous buffer of the file data
One or the other mechanism might be preferable depending on how user
code is using the model data. In some sense, implementing a provider
based on the second option is more of a convenience method for the user
to avoid the `tch::nn::VarStore::load_from_stream` interaction.
I've changed the definition of the `ResourceProvider` trait to require
that it be both `Send` and `Sync`. There are currently certain contexts
where `dyn ResourceProvider + Send` is required, but in theory before
this change an implementation might not be `Send` (or `Sync`). The
existing providers are both `Send` and `Sync`, and it seems reasonable
(if technically incorrect) for user code to assume this to be true. I
don't see a downside to making this explicit, but that part of this
change might be better suited for separate discussion. I am not trying
to sneak it in.
The `enum Resource` data type is used here as a means to abstract over
the possible ways a `ResourceProvider` might represent an underlying
resource. Without this, it would be necessary to either call different
trait methods until one succeeded or implement `as_any` and downcast in
order to implement `load_weights` similarly to how it is now. Those
options seemed less preferable to creating a wrapper.
While it would be possible to replace all calls to `get_local_path` with
the `get_resource` API, removal of the existing function would be a very
big breaking change. As such, this change also introduces
`RustBertError::UnsupportedError` to allow for the different methods to
coexist. An alternative would be for the new `ResourceProvider`s to
write their resources to a temporary disk location and return an
appropriate path, but that is counter to the purpose of the new
`ResourceProvider`s and so I chose not to implement that.
* - Add `impl<T: ResourceProvider + ?Sized> ResourceProvider for Box<T>`
- Remove `Resource::NamedTensors`
- Change `BufferResource` to contain a `&[u8]` rather than `Vec<u8>`
* Further rework proposal for resources
* Use mutable references and locks
* Make model resources mutable in tests/examples
* Remove unnecessary mutability and TensorResource references
* Add `BufferResource` example
---------
Co-authored-by: Guillaume Becquin <guillaume.becquin@gmail.com>
* - Fixed Clippy warnings
- Updated `tch` dependency
- Updated README to avoid confusion with respect to the required `LIBTORCH` version for the repository and published package versions
* Fixed Clippy warnings (2)
* Fixed Clippy warnings (3)
* ad support for loading local moddel in SequenceClassificationConfig
* adjust config to match the SequenceClassificationConfig
* add piplines::masked_language
* add support and example for codebert
* provide an optional mask_token String field for asked_language pipline
* update example for masked_language pipeline
* codebert support revocation
* revoke support for loading local moddel
* solve conflicts
* update MaskedLanguageConfig
* fix doctest error in zero_shot_classification.rs
* MaskedLM pipeline updates
* fix multiple masked token, added test
* Updated changelog and docs
Co-authored-by: Guillaume Becquin <guillaume.becquin@gmail.com>
* Add checked prediction methods
- Add checked prediction methods to ZeroShotClassificationModel.
These methods return Option and convert any underlying errors into None,
to allow callers to implement appropriate error handling logic.
* Update ZeroShot example to use checked method.
* Add tests for ZeroShot checked methods
* Change checked prediction methods to return Result
* refactor: rename *_checked into try_*
Rename *_checked methods into try_* methods.
This is more idiomatic vis-a-vis the Rust standard library.
* refactor: remove try_ prefix from predict methods
* refactor: change return from Option to Result
Change return type of ZeroShotClassificationModel.prepare_for_model
from option into Result. This simplifies the code, and returns
the error closer to its origin.
This addresses comments from @guillaume-be.
* refactor: address clippy lints in tests
Co-authored-by: guillaume-be <guillaume.becquin@gmail.com>
* - made `merges` resource optional for all pipelines
- allow mixing local and remote resources for pipelines
* Updated changelog
* Fixed Clippy warnings
* Make generics less generic.
Fix examples, tests and docs.
* Address outstanding issues
* Take less ownership where possible
* Fixup some clippy warnings
* Updated tokenizer crate version
Co-authored-by: Guillaume Becquin <guillaume.becquin@gmail.com>