From 7351cf8bd7fff826e67b8f5a4b5d4c19c55e5500 Mon Sep 17 00:00:00 2001 From: Thomas van Dongen Date: Wed, 9 Oct 2024 17:44:27 +0200 Subject: [PATCH 1/2] Bump version (#71) * Bumped version * Bumped version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8910beb..61ef3a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "model2vec" description = "Distill a Small Fast Model from any Sentence Transformer" readme = { file = "README.md", content-type = "text/markdown" } license = { file = "LICENSE" } -version = "0.2.2" +version = "0.2.3" requires-python = ">=3.10" authors = [{ name = "Stéphan Tulkens", email = "stephantul@gmail.com"}, {name = "Thomas van Dongen", email = "thomas123@live.nl"}] From 965025c1891b6f08ec118ece473d3508d562c58c Mon Sep 17 00:00:00 2001 From: Tom Aarsen <37621491+tomaarsen@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:30:26 +0200 Subject: [PATCH 2/2] fix: Add support for huggingface_hub==0.25.0 (#73) --- model2vec/distill/distillation.py | 9 ++++++++- tests/test_distillation.py | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/model2vec/distill/distillation.py b/model2vec/distill/distillation.py index 2d8001f..35a98e3 100644 --- a/model2vec/distill/distillation.py +++ b/model2vec/distill/distillation.py @@ -3,7 +3,6 @@ import numpy as np from huggingface_hub import model_info -from huggingface_hub.utils._errors import RepositoryNotFoundError from sklearn.decomposition import PCA from tokenizers.models import BPE, Unigram from transformers import AutoModel, AutoTokenizer, PreTrainedModel, PreTrainedTokenizerFast @@ -16,6 +15,14 @@ from model2vec.distill.utils import select_optimal_device from model2vec.model import StaticModel +try: + # For huggingface_hub>=0.25.0 + from huggingface_hub.errors import RepositoryNotFoundError +except ImportError: + # For huggingface_hub<0.25.0 + from huggingface_hub.utils._errors import RepositoryNotFoundError + + logger = logging.getLogger(__name__) diff --git a/tests/test_distillation.py b/tests/test_distillation.py index b4abac2..36da266 100644 --- a/tests/test_distillation.py +++ b/tests/test_distillation.py @@ -4,13 +4,19 @@ import numpy as np import pytest -from huggingface_hub.utils._errors import RepositoryNotFoundError from pytest import LogCaptureFixture from transformers import AutoModel, BertTokenizerFast from model2vec.distill.distillation import _clean_vocabulary, _post_process_embeddings, distill, distill_from_model from model2vec.model import StaticModel +try: + # For huggingface_hub>=0.25.0 + from huggingface_hub.errors import RepositoryNotFoundError +except ImportError: + # For huggingface_hub<0.25.0 + from huggingface_hub.utils._errors import RepositoryNotFoundError + rng = np.random.default_rng()