/usr/local/lib/python3.6/site-packages/transformers/data/datasets/__pycache__
NameSizeModeActions
glue.cpython-36.pyc47010644editdlrm
language_modeling.cpython-36.pyc137320644editdlrm
squad.cpython-36.pyc60580644editdlrm
__init__.cpython-36.pyc5210644editdlrm
Edit: /usr/local/lib/python3.6/site-packages/transformers/data/datasets/__pycache__/squad.cpython-36.pyc (6058B)
3 EgJ#@sddlZddlZddlmZmZddlmZddlmZm Z m Z m Z ddl Z ddl mZddlmZddlmZdd lmZdd lmZd d lmZmZmZmZejeZeej Z!e"d de!DZ#eGdddZ$GdddeZ%GdddeZ&dS)N) dataclassfield)Enum)DictListOptionalUnion)Dataset)FileLock)$MODEL_FOR_QUESTION_ANSWERING_MAPPING)PreTrainedTokenizer)logging) SquadFeaturesSquadV1ProcessorSquadV2Processor"squad_convert_examples_to_featuresccs|] }|jVqdS)N) model_type).0confrJ/usr/local/lib/python3.6/site-packages/transformers/data/datasets/squad.py #src@s eZdZUdZeddddjeidZeedddidZ e eddd idZ e  eddd idZ e  ed dd idZ e  ed ddidZe edddidZeedddidZeedddidZeedddidZe edddidZe edddidZe dS)SquadDataTrainingArgumentszb Arguments pertaining to what data we are going to input our model for training and eval. Nhelpz!Model type selected in the list: z, )defaultmetadatazFThe input data dir. Should contain the .json files for the SQuAD task.zThe maximum total input sequence length after tokenization. Sequences longer than this will be truncated, sequences shorter will be padded.zVWhen splitting up a long document into chunks, how much stride to take between chunks.@zkThe maximum number of tokens for the question. Questions longer than this will be truncated to this length.zThe maximum length of an answer that can be generated. This is needed because the start and end predictions are not conditioned on one another.Fz1Overwrite the cached training and evaluation setszDIf true, the SQuAD examples contain some that do not have an answer.gzIIf null_score - best_non_null is greater than the threshold predict null.rzjlanguage id of input for language-specific xlm models (see tokenization_xlm.PRETRAINED_INIT_CONFIGURATION)z3multiple threads for converting example to features)__name__ __module__ __qualname____doc__rjoin MODEL_TYPESrstrdata_dirmax_seq_lengthint doc_stridemax_query_lengthZmax_answer_lengthoverwrite_cacheboolversion_2_with_negativeZnull_score_diff_thresholdfloatZ n_best_sizelang_idthreadsrrrrr&s: rc@seZdZdZdZdS)SplittraindevN)r#r$r%r6r7rrrrr5`sr5c @seZdZUdZeeee  e  de j dddfeeeeeee fee eeeedddZdd Zeeejfd d d ZdS) SquadDatasetzH This will be superseded by a framework-agnostic approach soon. NFpt)args tokenizer limit_lengthmodeis_language_sensitive cache_dirdataset_formatc Cs||_||_|jrtnt|_t|trTy t|}Wnt k rRt dYnX||_ |jrddnd}t j j |dk rz|n|jd|jd|jjd|jd|} | d} t| Ft j j| o|j rVtj} tj| |_|jd|_|jjdd|_|jjd d|_tjd | d tj| |jdksB|jdkrtj d | d n|tj!krt|jj"|j|_n|jj#|j|_t$|j||j|j%|j&|tj'k|j(|d\|_|_tj} tj)|j|j|jd| tjd| dtj| ddWdQRXdS)Nzmode is not a valid split namev2v1Zcached__z.lockfeaturesdatasetexamplesz"Loading features from cached file z [took %.3f s]zDeleting cached file z; will allow dataset and examples to be cached in future run)rFr;r+r-r.Z is_trainingr4Zreturn_dataset)rDrErFz!Saving features into cached file z [took z.3fz s])*r:r>r1rr processor isinstancer)r5KeyErrorr=ospathr'r*value __class__r#r+r existsr/timetorchloadZ old_featuresrDgetrErFloggerinfowarningr7Zget_dev_examplesZget_train_examplesrr-r.r6r4save) selfr:r;r<r=r>r?r@Z version_tagZcached_features_fileZ lock_pathstartrrr__init__osX   &    zSquadDataset.__init__cCs t|jS)N)lenrD)rWrrr__len__szSquadDataset.__len__)returnc Cs6|j|}tj|jtjd}tj|jtjd}tj|jtjd}tj|jtjd}tj|jtj d}tj|j tj d}|||d} |j j d kr| d=|j j dkr| j ||d |j jr| j d |i|jr| j d tj|jtjd|j ji|jtjkr2tj|jtjd} tj|jtjd} | j | | d | S)N)Zdtype) input_idsattention_masktoken_type_idsxlmroberta distilbert camembertr_xlnet) cls_indexp_mask is_impossibleZlangs)start_positions end_positions)r`rarbrc)rdr`)rDrPZtensorr]longr^r_rerfr2rgr:rupdater1r>ZonesshapeZint64r3r=r5r6Zstart_positionZ end_position) rWifeaturer]r^r_rerfrginputsrhrirrr __getitem__s.   $zSquadDataset.__getitem__)r#r$r%r&rr:rrrDr5r=r0r>r6r rr,rr)rYr[rrPZTensorrprrrrr8es 6Br8)'rJrOZ dataclassesrrenumrtypingrrrrrPZtorch.utils.datar Zfilelockr Zmodels.auto.modeling_autor Ztokenization_utilsr utilsrZprocessors.squadrrrr get_loggerr#rSlistkeysZMODEL_CONFIG_CLASSEStupler(rr5r8rrrrs"        :