Model2Vec v0.10.0

Most of this release is about training. It adds a pair-similarity trainer, lets fit take Hugging Face datasets columns directly, and adds focal loss, token dropout and faster training. It also adds a public ONNX export API that can export classifier and regressor pipelines, and fixes a number of tokenization and padding bugs.

⚠️ Breaking changes

  • StaticModel.tokenize no longer takesmax_length . Truncation now follows the model’smax_length property, which has a new setter (#356, #363).
  • encode_as_sequence ignores the model’smax_length . It only truncates if you passmax_length to the call yourself (#363).
  • The ONNX export script has been replaced by a function. scripts/export_to_onnx.py is gone, so usemodel2vec.onnx.export_model_to_onnx(model, save_path, ...) instead (#347).
  • Trainable models no longer use a pad token. The pad_token argument offrom_pretrained andfrom_static_model and thepad_id constructor argument have been removed (#390).
  • Token weights in trainable models are no longer passed through a sigmoid. They’re trained directly and start at 1 (#371). Training code that reads model.w directly will see different values.
  • freeze_weights now defaults toNone . WithNone , a model that has token weights trains them, and a model without token weights takes the unweighted mean of its token embeddings. Previously, a model without weights always learned new ones. To keep that behavior, passfreeze_weights=False (#390).
  • Dependency changes:
    • huggingface-hub>=1.0.0 is now a core dependency (#345).
    • The distill extra no longer needsscikit-learn , because PCA is now implemented in NumPy (#344). It now requiresskeletoken>=0.6.0,<0.7.0 .
    • The train extra now requiresdatasets>=4.0.0 (#387).
    • The onnx extra now includesonnxruntime ,onnxscript andskeletoken (#347).