configuration_markuplm.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2021, The Microsoft Research Asia MarkupLM Team authors
  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. """MarkupLM model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="microsoft/markuplm-base")
  19. @strict
  20. class MarkupLMConfig(PreTrainedConfig):
  21. r"""
  22. max_xpath_tag_unit_embeddings (`int`, *optional*, defaults to 256):
  23. The maximum value that the xpath tag unit embedding might ever use. Typically set this to something large
  24. just in case (e.g., 256).
  25. max_xpath_subs_unit_embeddings (`int`, *optional*, defaults to 1024):
  26. The maximum value that the xpath subscript unit embedding might ever use. Typically set this to something
  27. large just in case (e.g., 1024).
  28. tag_pad_id (`int`, *optional*, defaults to 216):
  29. The id of the padding token in the xpath tags.
  30. subs_pad_id (`int`, *optional*, defaults to 1001):
  31. The id of the padding token in the xpath subscripts.
  32. xpath_unit_hidden_size (`int`, *optional*, defaults to 32):
  33. The hidden size of each unit in xpath.
  34. max_depth (`int`, *optional*, defaults to 50):
  35. The maximum depth in xpath.
  36. Examples:
  37. ```python
  38. >>> from transformers import MarkupLMModel, MarkupLMConfig
  39. >>> # Initializing a MarkupLM microsoft/markuplm-base style configuration
  40. >>> configuration = MarkupLMConfig()
  41. >>> # Initializing a model from the microsoft/markuplm-base style configuration
  42. >>> model = MarkupLMModel(configuration)
  43. >>> # Accessing the model configuration
  44. >>> configuration = model.config
  45. ```"""
  46. model_type = "markuplm"
  47. vocab_size: int = 30522
  48. hidden_size: int = 768
  49. num_hidden_layers: int = 12
  50. num_attention_heads: int = 12
  51. intermediate_size: int = 3072
  52. hidden_act: str = "gelu"
  53. hidden_dropout_prob: float | int = 0.1
  54. attention_probs_dropout_prob: float | int = 0.1
  55. max_position_embeddings: int = 512
  56. type_vocab_size: int = 2
  57. initializer_range: float = 0.02
  58. layer_norm_eps: float = 1e-12
  59. pad_token_id: int | None = 0
  60. bos_token_id: int | None = 0
  61. eos_token_id: int | list[int] | None = 2
  62. max_xpath_tag_unit_embeddings: int = 256
  63. max_xpath_subs_unit_embeddings: int = 1024
  64. tag_pad_id: int = 216
  65. subs_pad_id: int = 1001
  66. xpath_unit_hidden_size: int = 32
  67. max_depth: int = 50
  68. use_cache: bool = True
  69. classifier_dropout: float | int | None = None
  70. __all__ = ["MarkupLMConfig"]