__init__.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright 2024 EleutherAI and The HuggingFace Inc. team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import TYPE_CHECKING
  15. from ...utils import (
  16. OptionalDependencyNotAvailable,
  17. _LazyModule,
  18. is_sentencepiece_available,
  19. is_tokenizers_available,
  20. is_torch_available,
  21. )
  22. _import_structure = {
  23. "configuration_olmo": ["OlmoConfig"],
  24. }
  25. try:
  26. if not is_torch_available():
  27. raise OptionalDependencyNotAvailable()
  28. except OptionalDependencyNotAvailable:
  29. pass
  30. else:
  31. _import_structure["modeling_olmo"] = [
  32. "OlmoForCausalLM",
  33. "OlmoModel",
  34. "OlmoPreTrainedModel",
  35. ]
  36. if TYPE_CHECKING:
  37. from .configuration_olmo import OlmoConfig
  38. try:
  39. if not is_torch_available():
  40. raise OptionalDependencyNotAvailable()
  41. except OptionalDependencyNotAvailable:
  42. pass
  43. else:
  44. from .modeling_olmo import (
  45. OlmoForCausalLM,
  46. OlmoModel,
  47. OlmoPreTrainedModel,
  48. )
  49. else:
  50. import sys
  51. sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)