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

Add support for huggingface_hub>=0.25.0 #73

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion model2vec/distill/distillation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__)


Expand Down
8 changes: 7 additions & 1 deletion tests/test_distillation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down