configuration_lilt.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright 2022 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. """LiLT configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="SCUT-DLVCLab/lilt-roberta-en-base")
  19. @strict
  20. class LiltConfig(PreTrainedConfig):
  21. r"""
  22. channel_shrink_ratio (`int`, *optional*, defaults to 4):
  23. The shrink ratio compared to the `hidden_size` for the channel dimension of the layout embeddings.
  24. max_2d_position_embeddings (`int`, *optional*, defaults to 1024):
  25. The maximum value that the 2D position embedding might ever be used with. Typically set this to something
  26. large just in case (e.g., 1024).
  27. Examples:
  28. ```python
  29. >>> from transformers import LiltConfig, LiltModel
  30. >>> # Initializing a LiLT SCUT-DLVCLab/lilt-roberta-en-base style configuration
  31. >>> configuration = LiltConfig()
  32. >>> # Randomly initializing a model from the SCUT-DLVCLab/lilt-roberta-en-base style configuration
  33. >>> model = LiltModel(configuration)
  34. >>> # Accessing the model configuration
  35. >>> configuration = model.config
  36. ```"""
  37. model_type = "lilt"
  38. vocab_size: int = 30522
  39. hidden_size: int = 768
  40. num_hidden_layers: int = 12
  41. num_attention_heads: int = 12
  42. intermediate_size: int = 3072
  43. hidden_act: str = "gelu"
  44. hidden_dropout_prob: float | int = 0.1
  45. attention_probs_dropout_prob: float | int = 0.1
  46. max_position_embeddings: int = 512
  47. type_vocab_size: int = 2
  48. initializer_range: float = 0.02
  49. layer_norm_eps: float = 1e-12
  50. pad_token_id: int | None = 0
  51. bos_token_id: int | None = None
  52. eos_token_id: int | list[int] | None = None
  53. classifier_dropout: float | int | None = None
  54. channel_shrink_ratio: int = 4
  55. max_2d_position_embeddings: int = 1024
  56. __all__ = ["LiltConfig"]