configuration_dpr.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2010, DPR authors, The Hugging Face Team.
  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. """DPR 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="facebook/dpr-ctx_encoder-single-nq-base")
  19. @strict
  20. class DPRConfig(PreTrainedConfig):
  21. r"""
  22. Example:
  23. ```python
  24. >>> from transformers import DPRConfig, DPRContextEncoder
  25. >>> # Initializing a DPR facebook/dpr-ctx_encoder-single-nq-base style configuration
  26. >>> configuration = DPRConfig()
  27. >>> # Initializing a model (with random weights) from the facebook/dpr-ctx_encoder-single-nq-base style configuration
  28. >>> model = DPRContextEncoder(configuration)
  29. >>> # Accessing the model configuration
  30. >>> configuration = model.config
  31. ```"""
  32. model_type = "dpr"
  33. vocab_size: int = 30522
  34. hidden_size: int = 768
  35. num_hidden_layers: int = 12
  36. num_attention_heads: int = 12
  37. intermediate_size: int = 3072
  38. hidden_act: str = "gelu"
  39. hidden_dropout_prob: float | int = 0.1
  40. attention_probs_dropout_prob: float | int = 0.1
  41. max_position_embeddings: int = 512
  42. type_vocab_size: int = 2
  43. initializer_range: float = 0.02
  44. layer_norm_eps: float = 1e-12
  45. pad_token_id: int | None = 0
  46. bos_token_id: int | None = None
  47. eos_token_id: int | list[int] | None = None
  48. projection_dim: int = 0
  49. is_decoder: bool = False
  50. add_cross_attention: bool = False
  51. __all__ = ["DPRConfig"]