

'''simple docstring'''



import datasets

from .evaluate import evaluate


__snake_case			:     List[str]										=      '\\n@article{hendrycks2021cuad,\n      title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n      author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n      journal={arXiv preprint arXiv:2103.06268},\n      year={2021}\n}\n'

__snake_case			:     Tuple										=      '\nThis metric wrap the official scoring script for version 1 of the Contract\nUnderstanding Atticus Dataset (CUAD).\nContract Understanding Atticus Dataset (CUAD) v1 is a corpus of more than 13,000 labels in 510\ncommercial legal contracts that have been manually labeled to identify 41 categories of important\nclauses that lawyers look for when reviewing contracts in connection with corporate transactions.\n'

__snake_case			:     Tuple										=      '\nComputes CUAD scores (EM, F1, AUPR, Precision@80%Recall, and Precision@90%Recall).\nArgs:\n    predictions: List of question-answers dictionaries with the following key-values:\n        - \'id\': id of the question-answer pair as given in the references (see below)\n        - \'prediction_text\': list of possible texts for the answer, as a list of strings\n        depending on a threshold on the confidence probability of each prediction.\n    references: List of question-answers dictionaries with the following key-values:\n        - \'id\': id of the question-answer pair (see above),\n        - \'answers\': a Dict in the CUAD dataset format\n            {\n                \'text\': list of possible texts for the answer, as a list of strings\n                \'answer_start\': list of start positions for the answer, as a list of ints\n            }\n            Note that answer_start values are not taken into account to compute the metric.\nReturns:\n    \'exact_match\': Exact match (the normalized answer exactly match the gold answer)\n    \'f1\': The F-score of predicted tokens versus the gold answer\n    \'aupr\': Area Under the Precision-Recall curve\n    \'prec_at_80_recall\': Precision at 80% recall\n    \'prec_at_90_recall\': Precision at 90% recall\nExamples:\n    >>> predictions = [{\'prediction_text\': [\'The seller:\', \'The buyer/End-User: Shenzhen LOHAS Supply Chain Management Co., Ltd.\'], \'id\': \'LohaCompanyltd_20191209_F-1_EX-10.16_11917878_EX-10.16_Supply Agreement__Parties\'}]\n    >>> references = [{\'answers\': {\'answer_start\': [143, 49], \'text\': [\'The seller:\', \'The buyer/End-User: Shenzhen LOHAS Supply Chain Management Co., Ltd.\']}, \'id\': \'LohaCompanyltd_20191209_F-1_EX-10.16_11917878_EX-10.16_Supply Agreement__Parties\'}]\n    >>> cuad_metric = datasets.load_metric("cuad")\n    >>> results = cuad_metric.compute(predictions=predictions, references=references)\n    >>> print(results)\n    {\'exact_match\': 100.0, \'f1\': 100.0, \'aupr\': 0.0, \'prec_at_80_recall\': 1.0, \'prec_at_90_recall\': 1.0}\n'



@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION	,						_KWARGS_DESCRIPTION						)
class lowerCamelCase			(  datasets.Metric						):



			'''simple docstring'''






			def lowercase__						(				self	:						Optional[Any]			)      ->		List[Any]:





									'''simple docstring'''
									return datasets.MetricInfo(
									    description=_DESCRIPTION		,      citation=_CITATION		,      inputs_description=_KWARGS_DESCRIPTION		,      features=datasets.Features(
									        {
									            """predictions""": {
									                """id""": datasets.Value("""string"""			),
									                """prediction_text""": datasets.features.Sequence(datasets.Value("""string"""			)			),
									            },
									            """references""": {
									                """id""": datasets.Value("""string"""			),
									                """answers""": datasets.features.Sequence(
									                    {
									                        """text""": datasets.Value("""string"""			),
									                        """answer_start""": datasets.Value("""int32"""			),
									                    }			),
									            },
									        }			)		,      codebase_urls=["""https://www.atticusprojectai.org/cuad"""]		,      reference_urls=["""https://www.atticusprojectai.org/cuad"""]		,      )



			def lowercase__						(				self	:						Dict		,      lowerCAmelCase_	:						str		,      lowerCAmelCase_	:						List[Any]			)      ->		Union[str, Any]:





									'''simple docstring'''
									A__					:       Union[str, Any]     ={prediction["""id"""]: prediction["""prediction_text"""] for prediction in predictions}
									A__					:       Optional[int]     =[
									    {
									        """paragraphs""": [
									            {
									                """qas""": [
									                    {
									                        """answers""": [{"""text""": answer_text} for answer_text in ref["""answers"""]["""text"""]],
									                        """id""": ref["""id"""],
									                    }
									                    for ref in references
									                ]
									            }
									        ]
									    }
									]
									A__					:       Tuple     =evaluate(dataset=lowerCAmelCase_		,      predictions=lowerCAmelCase_			)
									return score




'''simple docstring'''



from ...configuration_utils import PretrainedConfig
from ...utils import logging


__snake_case			:     Union[str, Any]										=      logging.get_logger(__name__)

__snake_case			:     Optional[int]										=      {
    'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json',
}



class lowerCamelCase			(  lowercase_						):



			'''simple docstring'''






			__snake_case        =	'gpt_bigcode'
			__snake_case        =	['past_key_values']
			__snake_case        =	{
			    'hidden_size': 'n_embd',
			    'max_position_embeddings': 'n_positions',
			    'num_attention_heads': 'n_head',
			    'num_hidden_layers': 'n_layer',
			}


			def __init__(				self	:						Optional[Any]		,      lowerCAmelCase_	:						List[str]=5_02_57		,      lowerCAmelCase_	:						str=10_24		,      lowerCAmelCase_	:						str=7_68		,      lowerCAmelCase_	:						str=12		,      lowerCAmelCase_	:						int=12		,      lowerCAmelCase_	:						Dict=None		,      lowerCAmelCase_	:						List[Any]="gelu_pytorch_tanh"		,      lowerCAmelCase_	:						Union[str, Any]=0.1		,      lowerCAmelCase_	:						Optional[Any]=0.1		,      lowerCAmelCase_	:						Optional[int]=0.1		,      lowerCAmelCase_	:						Dict=1e-5		,      lowerCAmelCase_	:						str=0.02		,      lowerCAmelCase_	:						List[Any]=True		,      lowerCAmelCase_	:						str=True		,      lowerCAmelCase_	:						str=5_02_56		,      lowerCAmelCase_	:						Dict=5_02_56		,      lowerCAmelCase_	:						Union[str, Any]=True		,      lowerCAmelCase_	:						str=True		,      lowerCAmelCase_	:						Optional[Any]=True		,      **lowerCAmelCase_	:						Optional[Any]		,      )      ->		Tuple:





									'''simple docstring'''
									A__					:       Optional[Any]     =vocab_size
									A__					:       Optional[Any]     =n_positions
									A__					:       List[str]     =n_embd
									A__					:       str     =n_layer
									A__					:       Optional[int]     =n_head
									A__					:       Optional[int]     =n_inner
									A__					:       int     =activation_function
									A__					:       int     =resid_pdrop
									A__					:       int     =embd_pdrop
									A__					:       Dict     =attn_pdrop
									A__					:       Any     =layer_norm_epsilon
									A__					:       List[Any]     =initializer_range
									A__					:       Dict     =scale_attn_weights
									A__					:       Any     =use_cache
									A__					:       List[Any]     =attention_softmax_in_fpaa
									A__					:       Optional[int]     =scale_attention_softmax_in_fpaa
									A__					:       Dict     =multi_query

									A__					:       List[str]     =bos_token_id
									A__					:       Any     =eos_token_id

									super().__init__(bos_token_id=lowerCAmelCase_		,      eos_token_id=lowerCAmelCase_		,      **lowerCAmelCase_			)

