Run this model with HF Jobs
Run lan-zju/LlaTa on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/lan-zju/LlaTa. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/lan-zju/LlaTa on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use lan-zju/LlaTa with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lan-zju/LlaTa with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="lan-zju/LlaTa", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lan-zju/LlaTa", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesFiles changed (16)
- added_tokens.jsonAdded+6
- config.json+228-28
- configuration_llata.py+89-90
- generation_config.json+2-3
- merges.txtAdded
- model-00001-of-00004.safetensorsAdded+3
- model-00002-of-00004.safetensorsAdded+3
- model-00003-of-00004.safetensorsAdded+3
- model-00004-of-00004.safetensorsAdded+3
- model.safetensors.index.json+529-405
- modeling_codet5p.py+243-34
- modeling_llata.py+781-474
- special_tokens_map.jsonAdded+27
- tokenizer.jsonAdded
- tokenizer_config.jsonAdded+52
- vocab.jsonAdded
123456{ "<|endoftext|>": 151643, "<|im_end|>": 151645, "<|im_start|>": 151644, "<|table|>": 151646}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869{"_name_or_path": "model/llata/llata_codet5p_lly_orig","architectures": ["LlaTaModel"],"auto_map": {"AutoConfig": "configuration_llata.LlaTaConfig","AutoModel": "modeling_llata.LlaTaModel"},"bos_token_id": 32013,"decoder_config": {"_name_or_path": "model/deepseek-coder-1.3b-instruct","architectures": ["LlamaForCausalLM"],"bos_token_id": 32013,"eos_token_id": 32021,"hidden_size": 2048,"intermediate_size": 5504,"max_position_embeddings": 16384,"model_type": "llama","num_attention_heads": 16,"num_hidden_layers": 24,"num_key_value_heads": 16,"pad_token_id": 32021,"rope_scaling": {"factor": 4.0,"type": "linear"},"rope_theta": 100000,"torch_dtype": "bfloat16","vocab_size": 32256},"encoder_config": {"_name_or_path": "codet5p-350m-encoder","architectures": ["CodeT5pModel"],"bos_token_id": 1,"decoder_start_token_id": 50256,"gradient_checkpointing": false,"model_type": "codet5p_module","n_embd": 1024,"n_layer": 20,"rotary_dim": 32,"summary_activation": null,"summary_first_dropout": 0.1,"summary_proj_to_labels": true,"summary_type": "cls_index","summary_use_proj": true,"tokenizer_class": "GPT2Tokenizer","torch_dtype": "bfloat16","vocab_size": 51200},"eos_token_id": 32021,"max_decoder_input_len": 16384,"max_new_tokens": 512,"model_type": "llata","pad_token_id": 32021,"projector_config": {"dims": [1024,2048],"model_type": "mlp"},"torch_dtype": "float32","transformers_version": "4.42.3"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269{"_name_or_path": "checkpoints/LlaTa_codet5p-2b_qwen2-7b_proj-empty_retell_20240721_214800/checkpoint-2850","architectures": ["LlaTaForConditionalGeneration"],"auto_map": {"AutoConfig": "configuration_llata.LlaTaConfig","AutoModel": "modeling_llata.LlaTaForConditionalGeneration"},"bos_token_id": 151643,"decoder_config": {"_name_or_path": "model/Qwen2-7B-Instruct","add_cross_attention": false,"architectures": ["Qwen2ForCausalLM"],"attention_dropout": 0.0,"bad_words_ids": null,"begin_suppress_tokens": null,"bos_token_id": 151643,"chunk_size_feed_forward": 0,"cross_attention_hidden_size": null,"decoder_start_token_id": null,"diversity_penalty": 0.0,"do_sample": false,"early_stopping": false,"encoder_no_repeat_ngram_size": 0,"eos_token_id": 151645,"exponential_decay_length_penalty": null,"finetuning_task": null,"forced_bos_token_id": null,"forced_eos_token_id": null,"hidden_act": "silu","hidden_size": 3584,"id2label": {"0": "LABEL_0","1": "LABEL_1"},"initializer_range": 0.02,"intermediate_size": 18944,"is_decoder": false,"is_encoder_decoder": false,"label2id": {"LABEL_0": 0,"LABEL_1": 1},"length_penalty": 1.0,"max_length": 20,"max_position_embeddings": 32768,"max_window_layers": 28,"min_length": 0,"model_type": "qwen2","no_repeat_ngram_size": 0,"num_attention_heads": 28,"num_beam_groups": 1,"num_beams": 1,"num_hidden_layers": 28,"num_key_value_heads": 4,"num_return_sequences": 1,"output_attentions": false,"output_hidden_states": false,"output_scores": false,"pad_token_id": null,"prefix": null,"problem_type": null,"pruned_heads": {},"remove_invalid_values": false,"repetition_penalty": 1.0,"return_dict": true,"return_dict_in_generate": false,"rms_norm_eps": 1e-06,"rope_theta": 1000000.0,"sep_token_id": null,"sliding_window": 131072,"suppress_tokens": null,"task_specific_params": null,"temperature": 1.0,"tf_legacy_loss": false,"tie_encoder_decoder": false,"tie_word_embeddings": false,"tokenizer_class": null,"top_k": 50,"top_p": 1.0,"torch_dtype": "bfloat16","torchscript": false,"typical_p": 1.0,"use_bfloat16": false,"use_cache": true,"use_sliding_window": false,"vocab_size": 152064},"encoder_config": {"_name_or_path": "model/codet5p-2b-encoder","activation_function": "gelu_new","add_cross_attention": false,"architectures": ["CodeT5pModel"],"attn_pdrop": 0.0,"auto_map": {"AutoConfig": "configuration_codet5p.CodeT5pModuleConfig","AutoModel": "modeling_codet5p.CodeT5pModel"},"bad_words_ids": null,"begin_suppress_tokens": null,"bos_token_id": 1,"chunk_size_feed_forward": 0,"cross_attention_hidden_size": null,"decoder_start_token_id": 50256,"diversity_penalty": 0.0,"do_sample": false,"early_stopping": false,"embd_pdrop": 0.0,"encoder_no_repeat_ngram_size": 0,"eos_token_id": 50256,"exponential_decay_length_penalty": null,"finetuning_task": null,"forced_bos_token_id": null,"forced_eos_token_id": null,"gradient_checkpointing": false,"id2label": {"0": "LABEL_0","1": "LABEL_1"},"initializer_range": 0.02,"is_decoder": false,"is_encoder_decoder": false,"label2id": {"LABEL_0": 0,"LABEL_1": 1},"layer_norm_epsilon": 1e-05,"length_penalty": 1.0,"max_length": 20,"min_length": 0,"model_type": "codet5p_module","n_ctx": 2048,"n_embd": 1024,"n_head": 16,"n_inner": null,"n_layer": 20,"n_positions": 2048,"no_repeat_ngram_size": 0,"num_beam_groups": 1,"num_beams": 1,"num_return_sequences": 1,"output_attentions": false,"output_hidden_states": false,"output_scores": false,"pad_token_id": null,"prefix": null,"problem_type": null,"pruned_heads": {},"remove_invalid_values": false,"repetition_penalty": 1.0,"resid_pdrop": 0.0,"return_dict": true,"return_dict_in_generate": false,"rotary_dim": 32,"scale_attn_weights": true,"sep_token_id": null,"summary_activation": null,"summary_first_dropout": 0.1,"summary_proj_to_labels": true,"summary_type": "cls_index","summary_use_proj": true,"suppress_tokens": null,"task_specific_params": null,"temperature": 1.0,"tf_legacy_loss": false,"tie_encoder_decoder": false,"tie_word_embeddings": false,"tokenizer_class": "GPT2Tokenizer","top_k": 50,"top_p": 1.0,"torch_dtype": "bfloat16","torchscript": false,"typical_p": 1.0,"use_bfloat16": false,"use_cache": true,"vocab_size": 51200},"encoder_sep_token_index": 50256,"eos_token_id": 151645,"max_new_tokens": 512,"model_type": "llata","projector_config": {"_name_or_path": "model/projector/proj_llata_1024_4096_4096_3584_empty","act": "gelu","add_cross_attention": false,"architectures": ["SimpleMLP"],"auto_map": {"AutoConfig": "configuration_llata.SimpleMLPConfig","AutoModel": "modeling_llata.SimpleMLP"},"bad_words_ids": null,"begin_suppress_tokens": null,"bias": true,"bos_token_id": null,"chunk_size_feed_forward": 0,"cross_attention_hidden_size": null,"decoder_start_token_id": null,"dims": [1024,4096,4096,3584],"diversity_penalty": 0.0,"do_sample": false,"dropout": 0.0,"early_stopping": false,"encoder_no_repeat_ngram_size": 0,"eos_token_id": null,"exponential_decay_length_penalty": null,"finetuning_task": null,"forced_bos_token_id": null,"forced_eos_token_id": null,"id2label": {"0": "LABEL_0","1": "LABEL_1"},"is_decoder": false,"is_encoder_decoder": false,"label2id": {"LABEL_0": 0,"LABEL_1": 1},"length_penalty": 1.0,"max_length": 20,"min_length": 0,"model_type": "mlp","no_repeat_ngram_size": 0,"num_beam_groups": 1,"num_beams": 1,"num_return_sequences": 1,"output_attentions": false,"output_hidden_states": false,"output_scores": false,"pad_token_id": null,"prefix": null,"problem_type": null,"pruned_heads": {},"remove_invalid_values": false,"repetition_penalty": 1.0,"return_dict": true,"return_dict_in_generate": false,"sep_token_id": null,"suppress_tokens": null,"task_specific_params": null,"temperature": 1.0,"tf_legacy_loss": false,"tie_encoder_decoder": false,"tie_word_embeddings": true,"tokenizer_class": null,"top_k": 50,"top_p": 1.0,"torch_dtype": "bfloat16","torchscript": false,"typical_p": 1.0,"use_bfloat16": false},"table_token_index": 151646,"tie_word_embeddings": false,"torch_dtype": "bfloat16","transformers_version": "4.42.3"}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import loggingfrom copy import copyfrom transformers import PretrainedConfig, LlamaConfigfrom transformers.utils import loggingfrom .configuration_codet5p import CodeT5pModuleConfigfrom typing import List, Dict, Optionalclass SimpleMLPConfig(PretrainedConfig):model_type = 'mlp'def __init__(self,dims: List[int] = None,bias: bool = True,act: str = 'gelu',dropout: float = 0.,torch_dtype: str = 'bfloat16',**kwargs,):if dims is not None:assert isinstance(dims, List)self.dims = copy(dims)self.bias = biasself.act = actself.dropout = dropoutsuper().__init__(torch_dtype=torch_dtype, **kwargs)class LlaTaConfig(PretrainedConfig):model_type = "llata"def __init__(self,encoder_config: Dict = None,decoder_config: Dict = None,projector_config: Dict = None,torch_dtype: str = 'bfloat16',**kwargs,):invalid_config_flag = Falseif encoder_config is None:invalid_config_flag = Trueencoder_config = {}if decoder_config is None:invalid_config_flag = Truedecoder_config = {}else:self.max_decoder_input_len = decoder_config['max_position_embeddings']if projector_config is None:invalid_config_flag = Trueprojector_config = {}# >>> deal with generation stuff, can be ignoredkwargs.pop('bos_token_id', None)kwargs.pop('eos_token_id', None)kwargs.pop('pad_token_id', None)default_dict = {'max_new_tokens': 512,}# default_dict |= {'do_sample': True, 'top_p': 0.9, "top_k": 0,}for k, v in default_dict.items():if k not in kwargs:kwargs[k] = v if k not in decoder_config or decoder_config[k] is None else decoder_config[k]if decoder_config.get('pad_token_id', None) is None and decoder_config.get('eos_token_id', None) is not None:decoder_config |= {'pad_token_id': decoder_config['eos_token_id']}# <<< deal with generation endedif 'dim' in projector_config:assert projector_config['dim'][-1] == decoder_config['hidden_sze']else:invalid_config_flag = Trueself.encoder_config = CodeT5pModuleConfig(**encoder_config)self.decoder_config = LlamaConfig(**decoder_config)self.projector_config = SimpleMLPConfig(**projector_config)if invalid_config_flag:logger = logging.get_logger("transformers")# logger.warning('initializing a LlaTa instance whose config is not valid')super().__init__(# for generationbos_token_id=decoder_config.get('bos_token_id', None),eos_token_id=decoder_config.get('eos_token_id', None),pad_token_id=decoder_config.get('pad_token_id', None),torch_dtype=torch_dtype,**kwargs)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889import loggingfrom copy import copyfrom transformers import PretrainedConfig, LlamaConfigfrom transformers.utils import loggingfrom transformers import CONFIG_MAPPINGfrom .configuration_codet5p import CodeT5pModuleConfigfrom typing import List, Dict, Optional, Unionlogger = logging.get_logger(__name__)class SimpleMLPConfig(PretrainedConfig):model_type = 'mlp'def __init__(self,dims: List[int] = None,bias: bool = True,act: str = 'gelu',dropout: float = 0.,**kwargs,):if dims is not None:assert isinstance(dims, list)else:dims = []self.dims = copy(dims)self.bias = biasself.act = actself.dropout = dropoutsuper().__init__(**kwargs)CONFIG_MAPPING.register('codet5p_module', CodeT5pModuleConfig)CONFIG_MAPPING.register('mlp', SimpleMLPConfig)class LlaTaConfig(PretrainedConfig):model_type = "llata"def __init__(self,encoder_config: Optional[Union[Dict, PretrainedConfig]] = None,decoder_config: Optional[Union[Dict, PretrainedConfig]] = None,projector_config: Optional[Union[Dict, PretrainedConfig]] = None,table_token_index: Optional[int] = None,encoder_sep_token_index: Optional[int] = None,tie_word_embeddings: bool = False,**kwargs,):if isinstance(encoder_config, dict):encoder_config['model_type'] = encoder_config.get('model_type', 'codet5p_module')encoder_config = CONFIG_MAPPING[encoder_config['model_type']](**encoder_config)self.encoder_config = encoder_configif isinstance(decoder_config, dict):decoder_config['model_type'] = decoder_config.get('model_type', 'llama')decoder_config = CONFIG_MAPPING[decoder_config['model_type']](**decoder_config)self.decoder_config = decoder_configif isinstance(projector_config, dict):projector_config['model_type'] = projector_config.get('model_type', 'mlp')projector_config = CONFIG_MAPPING[projector_config['model_type']](**projector_config)self.projector_config = projector_configself.table_token_index = table_token_indexself.encoder_sep_token_index = encoder_sep_token_index# >>> deal with generation stuff, can be ignoredkwargs.pop('bos_token_id', None)kwargs.pop('eos_token_id', None)kwargs.pop('pad_token_id', None)default_dict = {'max_new_tokens': 512, 'bos_token_id': None, 'eos_token_id': None, 'pad_token_id': None}# default_dict |= {'do_sample': True, 'top_p': 0.9, "top_k": 0,}for k, v in default_dict.items():if k not in kwargs:kwargs[k] = v if not hasattr(decoder_config, k) or getattr(decoder_config, k) is None else getattr(decoder_config, k)# <<< deal with generation endedif hasattr(projector_config, 'dims'):assert projector_config.dims[0] == encoder_config.hidden_sizeassert projector_config.dims[-1] == decoder_config.hidden_sizesuper().__init__(# for generationtie_word_embeddings=tie_word_embeddings,**kwargs)
12345678{"_from_model_config": true,"bos_token_id": 32013,"eos_token_id": 32021,"max_new_tokens": 512,"pad_token_id": 32021,"transformers_version": "4.42.3"}1234567{"_from_model_config": true,"bos_token_id": 151643,"eos_token_id": 151645,"max_new_tokens": 512,"transformers_version": "4.42.3"}
123version https://git-lfs.github.com/spec/v1oid sha256:db56fe5a1fcc4efd581c8ab7f149979997f6d3cc0c9ece17a4ca6c344dae8389size 4909379064123version https://git-lfs.github.com/spec/v1oid sha256:4d1d32d40c576a8c7334ceb28aea2552a131540c14e624fbe9ba79e19ce8f26fsize 4991496880123version https://git-lfs.github.com/spec/v1oid sha256:9cfe446fc92f65f4c8e166179143ddb89b489fed78096fd3b4d46e86dc68d10fsize 4932773872123version https://git-lfs.github.com/spec/v1oid sha256:5d028bd960b578f750bd929d39c7358a4e387322ef485e0961d0aa706c73a9cdsize 1161322208123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411{"metadata": {"total_size": 6690902016},"weight_map": {"decoder.lm_head.weight": "model-00002-of-00002.safetensors","decoder.model.embed_tokens.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.16.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.17.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.17.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.18.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.19.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.20.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.20.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.21.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.22.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors","decoder.model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors","decoder.model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors","decoder.model.norm.weight": "model-00002-of-00002.safetensors","encoder.h.0.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.0.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.0.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.0.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.0.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.0.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.0.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.0.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.0.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.1.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.1.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.1.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.1.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.1.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.1.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.1.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.1.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.1.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.10.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.10.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.10.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.10.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.10.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.10.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.10.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.10.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.10.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.11.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.11.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.11.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.11.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.11.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.11.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.11.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.11.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.11.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.12.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.12.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.12.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.12.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.12.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.12.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.12.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.12.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.12.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.13.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.13.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.13.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.13.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.13.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.13.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.13.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.13.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.13.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.14.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.14.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.14.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.14.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.14.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.14.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.14.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.14.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.14.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.15.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.15.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.15.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.15.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.15.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.15.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.15.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.15.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.15.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.16.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.16.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.16.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.16.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.16.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.16.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.16.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.16.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.16.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.17.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.17.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.17.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.17.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.17.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.17.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.17.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.17.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.17.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.18.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.18.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.18.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.18.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.18.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.18.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.18.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.18.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.18.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.19.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.19.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.19.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.19.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.19.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.19.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.19.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.19.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.19.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.2.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.2.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.2.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.2.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.2.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.2.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.2.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.2.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.2.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.3.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.3.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.3.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.3.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.3.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.3.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.3.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.3.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.3.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.4.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.4.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.4.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.4.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.4.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.4.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.4.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.4.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.4.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.5.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.5.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.5.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.5.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.5.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.5.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.5.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.5.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.5.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.6.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.6.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.6.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.6.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.6.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.6.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.6.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.6.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.6.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.7.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.7.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.7.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.7.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.7.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.7.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.7.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.7.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.7.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.8.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.8.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.8.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.8.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.8.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.8.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.8.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.8.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.8.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.h.9.attn.causal_mask": "model-00001-of-00002.safetensors","encoder.h.9.attn.out_proj.weight": "model-00001-of-00002.safetensors","encoder.h.9.attn.qkv_proj.weight": "model-00001-of-00002.safetensors","encoder.h.9.ln_1.bias": "model-00001-of-00002.safetensors","encoder.h.9.ln_1.weight": "model-00001-of-00002.safetensors","encoder.h.9.mlp.fc_in.bias": "model-00001-of-00002.safetensors","encoder.h.9.mlp.fc_in.weight": "model-00001-of-00002.safetensors","encoder.h.9.mlp.fc_out.bias": "model-00001-of-00002.safetensors","encoder.h.9.mlp.fc_out.weight": "model-00001-of-00002.safetensors","encoder.ln_f.bias": "model-00001-of-00002.safetensors","encoder.ln_f.weight": "model-00001-of-00002.safetensors","encoder.wte.weight": "model-00001-of-00002.safetensors","projector.model.0.bias": "model-00002-of-00002.safetensors","projector.model.0.weight": "model-00002-of-00002.safetensors"}}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535{"metadata": {"total_size": 15994910720},"weight_map": {"decoder.lm_head.weight": "model-00004-of-00004.safetensors","decoder.model.embed_tokens.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.17.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.k_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.k_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.q_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.q_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.v_proj.bias": "model-00003-of-00004.safetensors","decoder.model.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors","decoder.model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.6.self_attn.k_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.q_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.v_proj.bias": "model-00001-of-00004.safetensors","decoder.model.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors","decoder.model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors","decoder.model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors","decoder.model.norm.weight": "model-00003-of-00004.safetensors","encoder.h.0.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.0.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.0.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.0.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.0.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.0.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.0.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.0.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.0.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.1.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.1.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.1.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.1.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.1.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.1.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.1.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.1.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.1.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.10.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.10.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.10.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.10.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.10.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.10.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.10.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.10.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.10.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.11.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.11.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.11.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.11.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.11.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.11.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.11.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.11.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.11.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.12.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.12.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.12.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.12.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.12.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.12.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.12.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.12.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.12.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.13.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.13.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.13.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.13.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.13.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.13.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.13.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.13.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.13.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.14.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.14.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.14.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.14.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.14.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.14.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.14.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.14.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.14.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.15.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.15.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.15.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.15.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.15.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.15.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.15.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.15.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.15.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.16.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.16.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.16.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.16.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.16.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.16.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.16.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.16.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.16.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.17.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.17.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.17.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.17.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.17.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.17.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.17.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.17.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.17.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.18.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.18.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.18.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.18.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.18.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.18.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.18.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.18.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.18.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.19.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.19.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.19.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.19.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.19.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.19.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.19.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.19.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.19.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.2.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.2.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.2.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.2.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.2.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.2.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.2.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.2.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.2.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.3.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.3.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.3.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.3.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.3.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.3.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.3.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.3.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.3.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.4.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.4.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.4.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.4.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.4.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.4.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.4.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.4.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.4.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.5.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.5.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.5.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.5.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.5.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.5.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.5.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.5.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.5.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.6.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.6.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.6.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.6.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.6.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.6.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.6.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.6.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.6.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.7.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.7.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.7.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.7.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.7.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.7.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.7.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.7.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.7.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.8.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.8.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.8.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.8.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.8.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.8.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.8.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.8.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.8.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.h.9.attn.causal_mask": "model-00001-of-00004.safetensors","encoder.h.9.attn.out_proj.weight": "model-00001-of-00004.safetensors","encoder.h.9.attn.qkv_proj.weight": "model-00001-of-00004.safetensors","encoder.h.9.ln_1.bias": "model-00001-of-00004.safetensors","encoder.h.9.ln_1.weight": "model-00001-of-00004.safetensors","encoder.h.9.mlp.fc_in.bias": "model-00001-of-00004.safetensors","encoder.h.9.mlp.fc_in.weight": "model-00001-of-00004.safetensors","encoder.h.9.mlp.fc_out.bias": "model-00001-of-00004.safetensors","encoder.h.9.mlp.fc_out.weight": "model-00001-of-00004.safetensors","encoder.ln_f.bias": "model-00001-of-00004.safetensors","encoder.ln_f.weight": "model-00001-of-00004.safetensors","encoder.wte.weight": "model-00001-of-00004.safetensors","projector.model.0.bias": "model-00004-of-00004.safetensors","projector.model.0.weight": "model-00004-of-00004.safetensors","projector.model.3.bias": "model-00004-of-00004.safetensors","projector.model.3.weight": "model-00004-of-00004.safetensors","projector.model.6.bias": "model-00004-of-00004.safetensors","projector.model.6.weight": "model-00004-of-00004.safetensors"}}
13 unmodified lines14151617181955 unmodified lines7576777879808182832 unmodified lines86878889909183 unmodified lines17517617717817918018139 unmodified lines22122222322422522622722822918 unmodified lines2482492502512522532542552562572582592602612622632 unmodified lines26626726826927027127227327427527627727814 unmodified lines2932942952962972981 unmodified line3003013023033043053063073083091 unmodified line3113123133143153163173183193203213225 unmodified lines32832933033133233333414 unmodified lines34935035135235335424 unmodified lines37938038138238338446 unmodified lines43143243343443543643733 unmodified lines47147247347447547647747847948048148248347 unmodified lines53153253353453553653753853954054115 unmodified lines5575585595605615623 unmodified lines5665675685695705715723 unmodified lines5765775785795805815825837 unmodified lines59159259359459559659759859960060160260360413 unmodified linesfrom transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput, \BaseModelOutputWithPast, CausalLMOutputWithPast, \BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentionsfrom transformers.modeling_utils import PreTrainedModelfrom transformers.configuration_utils import PretrainedConfigfrom transformers.utils import add_code_sample_docstrings, add_start_docstrings, logging55 unmodified lines# Adapted from transformers.models.codegen.modeling_codegen.CodeGenAttentionclass CodeT5pAttention(nn.Module):def __init__(self, config, is_cross_attention=False, is_decoder=True):super().__init__()max_positions = config.max_position_embeddingsself.register_buffer("causal_mask",2 unmodified lines),)self.attn_dropout = nn.Dropout(config.attn_pdrop)self.resid_dropout = nn.Dropout(config.resid_pdrop)83 unmodified linesself,hidden_states: Optional[torch.FloatTensor],attention_mask: Optional[torch.FloatTensor] = None,layer_past: Optional[Tuple[torch.Tensor]] = None,head_mask: Optional[torch.FloatTensor] = None,encoder_hidden_states: Optional[torch.Tensor] = None,encoder_attention_mask: Optional[torch.FloatTensor] = None,39 unmodified linesseq_len = key.shape[1]offset = 0if layer_past is not None:offset = layer_past[0].shape[-2]seq_len += offsetif self.rotary_dim is not None:k_rot = key[:, :, :, : self.rotary_dim]18 unmodified lineskey = key.permute(0, 2, 1, 3)query = query.permute(0, 2, 1, 3)if layer_past is not None:past_key = layer_past[0]past_value = layer_past[1]key = torch.cat((past_key, key), dim=-2)value = torch.cat((past_value, value), dim=-2)if use_cache is True:present = (key, value)else:present = None# compute self-attention: V x Softmax(QK^T)attn_output, attn_weights = self._attn(query, key, value, attention_mask, head_mask)2 unmodified linesattn_output = self.out_proj(attn_output)attn_output = self.resid_dropout(attn_output)outputs = (attn_output, present)if output_attentions:outputs += (attn_weights,)return outputs # a, present, (attentions)# Adapted from transformers.models.codegen.modeling_codegen.CodeGenMLPclass CodeT5pMLP(nn.Module):def __init__(self, intermediate_size, config): # in MLP: intermediate_size= 4 * embed_dim14 unmodified linesreturn hidden_states# Adapted from transformers.models.codegen.modeling_codegen.CodeGenBlockclass CodeT5pBlock(nn.Module):def __init__(self, config, layer_idx=None):1 unmodified lineinner_dim = config.n_inner if config.n_inner is not None else 4 * config.n_embdself.ln_1 = nn.LayerNorm(config.n_embd, eps=config.layer_norm_epsilon)if config.is_decoder is False:self.attn = CodeT5pAttention(config, is_cross_attention=False, is_decoder=False)else:self.attn = CodeT5pAttention(config)self.mlp = CodeT5pMLP(inner_dim, config)# Adding 1 cross-attention layer at the final decoder layer1 unmodified lineif config.add_cross_attention and layer_idx == config.n_layer - 1 else Falseif config.add_cross_attention and self.add_cross_attention_by_layer:self.crossattention = CodeT5pAttention(config, is_cross_attention=True)def forward(self,hidden_states: Optional[torch.FloatTensor],layer_past: Optional[Tuple[torch.Tensor]] = None,attention_mask: Optional[torch.FloatTensor] = None,head_mask: Optional[torch.FloatTensor] = None,encoder_hidden_states: Optional[torch.Tensor] = None,5 unmodified lineshidden_states = self.ln_1(hidden_states)attn_outputs = self.attn(hidden_states,layer_past=layer_past,attention_mask=attention_mask,head_mask=head_mask,use_cache=use_cache,14 unmodified lines# hidden_states = self.ln_cross_attn(residual)cross_attn_outputs = self.crossattention(hidden_states,attention_mask=attention_mask,head_mask=head_mask,encoder_hidden_states=encoder_hidden_states,24 unmodified linesbase_model_prefix = "transformer"supports_gradient_checkpointing = True_no_split_modules = ["CodeT5pBlock"]def __init__(self, *inputs, **kwargs):super().__init__(*inputs, **kwargs)46 unmodified linesdef forward(self,input_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Tuple[Tuple[torch.Tensor]]] = None,attention_mask: Optional[torch.FloatTensor] = None,token_type_ids: Optional[torch.LongTensor] = None,position_ids: Optional[torch.LongTensor] = None,33 unmodified linesif position_ids is not None:position_ids = position_ids.view(-1, input_shape[-1])if past_key_values is None:past_length = 0past_key_values = tuple([None] * len(self.h))else:past_length = past_key_values[0][0].size(-2)if position_ids is None:position_ids = torch.arange(past_length, input_shape[-1] + past_length, dtype=torch.long, device=device)position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])47 unmodified linesoutput_shape = input_shape + (hidden_states.size(-1),)presents = () if use_cache else Noneall_self_attentions = () if output_attentions else Noneall_cross_attentions = () if output_attentions and self.config.add_cross_attention else Noneall_hidden_states = () if output_hidden_states else Nonefor i, (block, layer_past) in enumerate(zip(self.h, past_key_values)):if output_hidden_states:all_hidden_states = all_hidden_states + (hidden_states,)15 unmodified linesoutputs = torch.utils.checkpoint.checkpoint(create_custom_forward(block),hidden_states,None,attention_mask,head_mask[i],3 unmodified lineselse:outputs = block(hidden_states,layer_past=layer_past,attention_mask=attention_mask,head_mask=head_mask[i],encoder_hidden_states=encoder_hidden_states,3 unmodified lines)hidden_states = outputs[0]if use_cache is True:presents = presents + (outputs[1],)if output_attentions:all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)7 unmodified linesif output_hidden_states:all_hidden_states = all_hidden_states + (hidden_states,)if not return_dict:return tuple(v for v in [hidden_states, presents, all_hidden_states, all_self_attentions, all_cross_attentions] ifv is not None)return BaseModelOutputWithPastAndCrossAttentions(last_hidden_state=hidden_states,past_key_values=presents,hidden_states=all_hidden_states,attentions=all_self_attentions,cross_attentions=all_cross_attentions,13 unmodified lines1415161718192055 unmodified lines7677787980818283848586872 unmodified lines9091929394959683 unmodified lines18018118218318418518618739 unmodified lines22722822923023123223323418 unmodified lines2532542552562572582592602 unmodified lines26326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546614 unmodified lines4814824834844854864874884894904914921 unmodified line4944954964974984995005015025035041 unmodified line5065075085095105115125135145155165175185 unmodified lines52452552652752852953053114 unmodified lines54654754854955055155224 unmodified lines57757857958058158258346 unmodified lines63063163263363463563633 unmodified lines67067167267367467567667767867968068168268368468568647 unmodified lines73473573673773873974074174274374415 unmodified lines7607617627637647657663 unmodified lines7707717727737747757767773 unmodified lines7817827837847857867877887 unmodified lines79679779879980080180280380480580680780880981081181281313 unmodified linesfrom transformers.modeling_outputs import BaseModelOutput, Seq2SeqLMOutput, \BaseModelOutputWithPast, CausalLMOutputWithPast, \BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentionsfrom transformers.cache_utils import Cache, DynamicCache, StaticCachefrom transformers.modeling_utils import PreTrainedModelfrom transformers.configuration_utils import PretrainedConfigfrom transformers.utils import add_code_sample_docstrings, add_start_docstrings, logging55 unmodified lines# Adapted from transformers.models.codegen.modeling_codegen.CodeGenAttentionclass CodeT5pAttention(nn.Module):def __init__(self, config, layer_idx, is_cross_attention=False, is_decoder=True):super().__init__()self.layer_idx = layer_idxself.max_position_embeddings = config.max_position_embeddingsmax_positions = config.max_position_embeddingsself.register_buffer("causal_mask",2 unmodified lines),)self.attn_dropout_rate = config.attn_pdropself.attn_dropout = nn.Dropout(config.attn_pdrop)self.resid_dropout = nn.Dropout(config.resid_pdrop)83 unmodified linesself,hidden_states: Optional[torch.FloatTensor],attention_mask: Optional[torch.FloatTensor] = None,position_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Cache] = None,head_mask: Optional[torch.FloatTensor] = None,encoder_hidden_states: Optional[torch.Tensor] = None,encoder_attention_mask: Optional[torch.FloatTensor] = None,39 unmodified linesseq_len = key.shape[1]offset = 0if past_key_values is not None:seq_len += past_key_values.get_seq_length(self.layer_idx)if self.rotary_dim is not None:k_rot = key[:, :, :, : self.rotary_dim]18 unmodified lineskey = key.permute(0, 2, 1, 3)query = query.permute(0, 2, 1, 3)if past_key_values is not None:key, value = past_key_values.update(key, value, self.layer_idx)# compute self-attention: V x Softmax(QK^T)attn_output, attn_weights = self._attn(query, key, value, attention_mask, head_mask)2 unmodified linesattn_output = self.out_proj(attn_output)attn_output = self.resid_dropout(attn_output)outputs = (attn_output, past_key_values)if output_attentions:outputs += (attn_weights,)return outputs # a, present, (attentions)class MixtralRotaryEmbedding(nn.Module):def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None, scaling_factor=1.0):super().__init__()self.scaling_factor = scaling_factorself.dim = dimself.max_position_embeddings = max_position_embeddingsself.base = baseinv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2, dtype=torch.int64).float().to(device) / self.dim))self.register_buffer("inv_freq", inv_freq, persistent=False)# For BC we register cos and sin cachedself.max_seq_len_cached = max_position_embeddings# Build here to make `torch.jit.trace` work.self._set_cos_sin_cache(seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype())@torch.no_grad()def _set_cos_sin_cache(self, seq_len, device, dtype):self.max_seq_len_cached = seq_lent = torch.arange(self.max_seq_len_cached, device=device, dtype=torch.int64).type_as(self.inv_freq)with torch.autocast(device_type=device.type, enabled=False):freqs = torch.outer(t, self.inv_freq)# Different from paper, but it uses a different permutation in order to obtain the same calculationemb = torch.cat((freqs, freqs), dim=-1)cos = emb.cos()sin = emb.sin()self.register_buffer("cos_cached", cos.to(dtype), persistent=False)self.register_buffer("sin_cached", sin.to(dtype), persistent=False)@torch.no_grad()def forward(self, x, seq_len=None):# x: [bs, num_attention_heads, seq_len, head_size]if seq_len > self.max_seq_len_cached:self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)return (self.cos_cached[:seq_len].to(dtype=x.dtype),self.sin_cached[:seq_len].to(dtype=x.dtype),)@staticmethoddef rotate_half(x):"""Rotates half the hidden dims of the input."""x1 = x[..., : x.shape[-1] // 2] # q0, q1, q2, ... ==> q0, q2, q4, ...x2 = x[..., x.shape[-1] // 2:] # q_{d//2}, q., q., ... ==> q1, q3, q5, ...return torch.cat((-x2, x1), dim=-1)@classmethoddef apply_rotary_pos_emb(cls, q, k, cos, sin, position_ids=None, unsqueeze_dim=1):"""Applies Rotary Position Embedding to the query and key tensors.Args:q (`torch.Tensor`): The query tensor.k (`torch.Tensor`): The key tensor.cos (`torch.Tensor`): The cosine part of the rotary embedding.sin (`torch.Tensor`): The sine part of the rotary embedding.position_ids (`torch.Tensor`, *optional*):Deprecated and unused.unsqueeze_dim (`int`, *optional*, defaults to 1):The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] andsin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, notethat cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q andk have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makescos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k havethe shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.Returns:`tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding."""cos = cos[position_ids].unsqueeze(unsqueeze_dim) # shape: (bs, 1, seq_len, dim)sin = sin[position_ids].unsqueeze(unsqueeze_dim)q_embed = (q * cos) + (cls.rotate_half(q) * sin)k_embed = (k * cos) + (cls.rotate_half(k) * sin)return q_embed, k_embedclass CodeT5pSdpaAttention(CodeT5pAttention):def __init__(self, *args, **kwargs):super().__init__(*args, **kwargs)assert self.is_cross_attention is Falseassert self.is_decoder is Falseself.rotary_emb = MixtralRotaryEmbedding(min(self.head_dim, self.rotary_dim),max_position_embeddings=self.max_position_embeddings,base=10000,)def forward(self,hidden_states: Optional[torch.FloatTensor],attention_mask: Optional[torch.FloatTensor] = None,position_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Cache] = None,head_mask: Optional[torch.FloatTensor] = None,encoder_hidden_states: Optional[torch.Tensor] = None,encoder_attention_mask: Optional[torch.FloatTensor] = None,use_cache: Optional[bool] = False,output_attentions: Optional[bool] = False,) -> Union[Tuple[torch.Tensor, Tuple[torch.Tensor]],Optional[Tuple[torch.Tensor, Tuple[torch.Tensor], Tuple[torch.Tensor, ...]]],]:def rotate(q, k):return torch.cat((q[..., ::2], q[..., 1::2]), dim=-1), torch.cat((k[..., ::2], k[..., 1::2]), dim=-1)def derotate(q, k):dim = q.shape[-1]q = torch.stack((q[..., :dim//2], q[..., dim//2:]), dim=-1).reshape(q.shape[:-1] + (dim,))k = torch.stack((k[..., :dim//2], k[..., dim//2:]), dim=-1).reshape(k.shape[:-1] + (dim,))return q, kif encoder_hidden_states is not None:assert Falseassert head_mask is Noneassert output_attentions is False# 原实现有大病bsz, input_seq_len, _ = hidden_states.shapemp_num = 4qkv = self.qkv_proj(hidden_states) # bs, seq_len, 3*hiddenqkv = qkv.view(bsz, input_seq_len, mp_num, -1)query, value, key = torch.split(qkv, self.embed_dim // mp_num, dim=-1) # bs, seq_len, mp_num, 256query = query.reshape(bsz, input_seq_len, self.num_attention_heads, self.head_dim)key = key.reshape(bsz, input_seq_len, self.num_attention_heads, self.head_dim)value = value.reshape(bsz, input_seq_len, self.num_attention_heads, self.head_dim)del qkvvalue = value.transpose(1, 2)key = key.transpose(1, 2)query = query.transpose(1, 2)offset = 0if past_key_values is not None:seq_len = past_key_values.get_seq_length(self.layer_idx) + input_seq_lenelse:seq_len = input_seq_lenif position_ids is None:position_ids = torch.arange(seq_len - input_seq_len, seq_len, device=hidden_states.device).unsqueeze(0)position_ids = position_ids.expand(bsz, input_seq_len)if self.rotary_dim is not None:k_rot = key[..., : self.rotary_dim]k_pass = key[..., self.rotary_dim:]q_rot = query[..., : self.rotary_dim]q_pass = query[..., self.rotary_dim:]sin, cos = self.rotary_emb(k_rot, seq_len)q_rot, k_rot = rotate(q_rot, k_rot)q_rot, k_rot = self.rotary_emb.apply_rotary_pos_emb(q_rot, k_rot, sin, cos, position_ids)q_rot, k_rot = derotate(q_rot, k_rot)key = torch.cat([k_rot, k_pass], dim=-1)query = torch.cat([q_rot, q_pass], dim=-1)else:sin, cos = self.rotary_emb(key, seq_len)query, key = rotate(query, key)query, key = self.rotary_emb.apply_rotary_pos_emb(query, key, sin, cos, position_ids)query, key = derotate(query, key)if past_key_values is not None:key, value = past_key_values.update(key, value, self.layer_idx)attention_mask = attention_mask.expand(bsz, self.num_attention_heads, seq_len, seq_len)# compute self-attention: V x Softmax(QK^T)attn_output = torch.nn.functional.scaled_dot_product_attention(query.to(hidden_states.dtype),key.to(hidden_states.dtype),value.to(hidden_states.dtype),attn_mask=attention_mask,dropout_p=self.attn_dropout_rate if self.training else 0.0,is_causal=False,)attn_output = self._merge_heads(attn_output, self.num_attention_heads, self.head_dim)attn_output = self.out_proj(attn_output)attn_output = self.resid_dropout(attn_output)outputs = (attn_output, past_key_values)return outputs # a, present, (attentions)# Adapted from transformers.models.codegen.modeling_codegen.CodeGenMLPclass CodeT5pMLP(nn.Module):def __init__(self, intermediate_size, config): # in MLP: intermediate_size= 4 * embed_dim14 unmodified linesreturn hidden_statesCODET5P_ATTENTION_CLASSES = {"eager": CodeT5pAttention,"sdpa": CodeT5pSdpaAttention,}# Adapted from transformers.models.codegen.modeling_codegen.CodeGenBlockclass CodeT5pBlock(nn.Module):def __init__(self, config, layer_idx=None):1 unmodified lineinner_dim = config.n_inner if config.n_inner is not None else 4 * config.n_embdself.ln_1 = nn.LayerNorm(config.n_embd, eps=config.layer_norm_epsilon)attn_class = CODET5P_ATTENTION_CLASSES[config._attn_implementation]if config.is_decoder is False:self.attn = attn_class(config, layer_idx, is_cross_attention=False, is_decoder=False)else:self.attn = attn_class(config, layer_idx)self.mlp = CodeT5pMLP(inner_dim, config)# Adding 1 cross-attention layer at the final decoder layer1 unmodified lineif config.add_cross_attention and layer_idx == config.n_layer - 1 else Falseif config.add_cross_attention and self.add_cross_attention_by_layer:self.crossattention = attn_class(config, layer_idx, is_cross_attention=True)def forward(self,hidden_states: Optional[torch.FloatTensor],position_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Cache] = None,attention_mask: Optional[torch.FloatTensor] = None,head_mask: Optional[torch.FloatTensor] = None,encoder_hidden_states: Optional[torch.Tensor] = None,5 unmodified lineshidden_states = self.ln_1(hidden_states)attn_outputs = self.attn(hidden_states,position_ids=position_ids,past_key_values=past_key_values,attention_mask=attention_mask,head_mask=head_mask,use_cache=use_cache,14 unmodified lines# hidden_states = self.ln_cross_attn(residual)cross_attn_outputs = self.crossattention(hidden_states,position_ids=position_ids,attention_mask=attention_mask,head_mask=head_mask,encoder_hidden_states=encoder_hidden_states,24 unmodified linesbase_model_prefix = "transformer"supports_gradient_checkpointing = True_no_split_modules = ["CodeT5pBlock"]_supports_sdpa = Truedef __init__(self, *inputs, **kwargs):super().__init__(*inputs, **kwargs)46 unmodified linesdef forward(self,input_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Cache] = None,attention_mask: Optional[torch.FloatTensor] = None,token_type_ids: Optional[torch.LongTensor] = None,position_ids: Optional[torch.LongTensor] = None,33 unmodified linesif position_ids is not None:position_ids = position_ids.view(-1, input_shape[-1])return_legacy_cache = Falseif use_cache and not isinstance(past_key_values, Cache): # kept for BC (non `Cache` `past_key_values` inputs)return_legacy_cache = Truepast_key_values = DynamicCache.from_legacy_cache(past_key_values)logger.warning_once("We detected that you are passing `past_key_values` as a tuple and this is deprecated and will be removed in v4.43. ""Please use an appropriate `Cache` class (https://huggingface.co/docs/transformers/v4.41.3/en/internal/generation_utils#transformers.Cache)")if position_ids is None:past_length = past_key_values.get_seq_length() if past_key_values is not None else 0position_ids = torch.arange(past_length, input_shape[-1] + past_length, dtype=torch.long, device=device)position_ids = position_ids.unsqueeze(0).view(-1, input_shape[-1])47 unmodified linesoutput_shape = input_shape + (hidden_states.size(-1),)next_decoder_cache = Noneall_self_attentions = () if output_attentions else Noneall_cross_attentions = () if output_attentions and self.config.add_cross_attention else Noneall_hidden_states = () if output_hidden_states else Nonefor i, block in enumerate(self.h):if output_hidden_states:all_hidden_states = all_hidden_states + (hidden_states,)15 unmodified linesoutputs = torch.utils.checkpoint.checkpoint(create_custom_forward(block),hidden_states,position_ids,None,attention_mask,head_mask[i],3 unmodified lineselse:outputs = block(hidden_states,position_ids=position_ids,past_key_values=past_key_values,attention_mask=attention_mask,head_mask=head_mask[i],encoder_hidden_states=encoder_hidden_states,3 unmodified lines)hidden_states = outputs[0]if use_cache:next_decoder_cache = outputs[1]if output_attentions:all_self_attentions = all_self_attentions + (outputs[2 if use_cache else 1],)7 unmodified linesif output_hidden_states:all_hidden_states = all_hidden_states + (hidden_states,)next_cache = next_decoder_cache if use_cache else Noneif return_legacy_cache:next_cache = next_cache.to_legacy_cache()if not return_dict:return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attentions, all_cross_attentions] ifv is not None)return BaseModelOutputWithPastAndCrossAttentions(last_hidden_state=hidden_states,past_key_values=next_cache,hidden_states=all_hidden_states,attentions=all_self_attentions,cross_attentions=all_cross_attentions,
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474from transformers import PreTrainedModel, PretrainedConfig, GenerationConfig, LogitsProcessorList, StoppingCriteriaListfrom transformers import LlamaForCausalLM, DynamicCache, Cachefrom transformers.generation.utils import GenerateOutputfrom transformers.modeling_outputs import BaseModelOutputWithPastfrom transformers.activations import ACT2FN, get_activationimport torchfrom torch import nnimport torch.nn.functional as Ffrom .configuration_llata import LlaTaConfig, SimpleMLPConfigfrom .modeling_codet5p import CodeT5pModelfrom .configuration_codet5p import CodeT5pConfigfrom typing import Optional, List, Union, Dict, Any, Tuple, Callable, Uniondef find_first_nonzero(t: torch.Tensor, keepdim: bool = False):"""example:[[0, 0, 1, 0, 1, 0, 0],[0, 0, 0, 1, 1, 0, 0]]-->[[2],[3]]"""indices = torch.argmax((t != 0.0).to(dtype=torch.int), dim=-1, keepdim=keepdim)return indicesclass SimpleMLP(PreTrainedModel):config_class = SimpleMLPConfigdef __init__(self, config: Optional[SimpleMLPConfig] = None):super().__init__(config)self.act = ACT2FN[config.act]dims_pairs = list(zip(config.dims[:-1], config.dims[1:]))layers = []for ind, (dim_in, dim_out) in enumerate(dims_pairs):linear = nn.Linear(dim_in, dim_out, dtype=config.torch_dtype)layers.append(linear)if config.act is not None:layers.append(self.act)layers.append(nn.Dropout(config.dropout))if config.act is not None:layers = layers[:-1]self.model = torch.nn.Sequential(*layers)def forward(self, x: torch.Tensor) -> torch.Tensor:return self.model(x)class LlaTaModel(PreTrainedModel):config_class = LlaTaConfigdef __init__(self,config: Optional[LlaTaConfig] = None,encoder: Optional[PreTrainedModel] = None,decoder: Optional[LlamaForCausalLM] = None,projector: Optional[PreTrainedModel] = None,):super().__init__(config)if encoder is not None:assert isinstance(encoder, PreTrainedModel)self.encoder = encoderelse:self.encoder = CodeT5pModel(config.encoder_config)if decoder is not None:assert isinstance(decoder, LlamaForCausalLM)self.decoder = decoderelse:self.decoder = LlamaForCausalLM(config.decoder_config)if projector is not None:assert isinstance(projector, PreTrainedModel)self.projector = projectorelse:self.projector = SimpleMLP(config.projector_config)def _prepare_decoder_input(self,projected_embeddings: torch.Tensor,encoder_attention_mask: torch.Tensor,encoder_position_ids: Optional[torch.LongTensor],pure_decoder_input_embeddings: torch.Tensor,pure_decoder_attention_mask: torch.Tensor,decoder_position_ids: Optional[torch.LongTensor],pure_decoder_labels: Optional[torch.LongTensor],pad_embedding: torch.Tensor,max_decoder_seq_len: int = None, # TODOignore_index: int = -100, # refer to torch/nn/modules/loss.py:CrossEntropyLoss) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.LongTensor], Optional[torch.LongTensor]]: # em, msk, pos, lbl"""concat projected_embeddings and pure_decoder_input_embeddingsexample:input::param projected_embeddings: | [[p p a b][c d e f]]:param encoder_attention_mask: | [[0 0 1 1][1 1 1 1]]:param pure_decoder_input_embeddings: | [[g h i j][p k l m]]:param pure_decoder_attention_mask: | [[1 1 1 1][0 1 1 1]]:return:decoder_inputs_embeddings: | [[p a b g h i j][c d e f k l m]]decoder_attention_mask: | [[0 1 1 1 1 1 1][1 1 1 1 1 1 1]]"""'''test:projected_embeddings = torch.tensor([[[0.1], [0.2], [0.3], [0.4]], [[0.5], [0.6], [0.7], [0.8]]])encoder_attention_mask = torch.tensor([[0., 0., 1., 1.], [1., 1., 1., 1.]])pure_decoder_input_embeddings = torch.tensor([[[0.9], [1.0], [1.1], [1.2]], [[1.3], [1.4], [1.5], [1.6]]])decoder_attention_mask = torch.tensor([[1., 1., 1., 1.], [0., 1., 1., 1.]])pad_embedding = torch.tensor(3.0)decoder_inputs_embeddings, decoder_attention_mask = _prepare_decoder_input(None,projected_embeddings,encoder_attention_mask,pure_decoder_input_embeddings,decoder_attention_mask,pad_embedding)print(decoder_inputs_embeddings) # tensor([[[3.0000], [0.3000], [0.4000], [0.9000], [1.0000], [1.1000], [1.2000]],[[0.5000], [0.6000], [0.7000], [0.8000], [1.4000], [1.5000], [1.6000]]])print(decoder_attention_mask) # tensor([[0., 1., 1., 1., 1., 1., 1.],[1., 1., 1., 1., 1., 1., 1.]])'''ignore_position_ids = encoder_position_ids is None and decoder_position_ids is Noneif max_decoder_seq_len is not None:assert pure_decoder_input_embeddings.shape[1] <= max_decoder_seq_len# assert pure_decoder_attention_mask[1] <= max_decoder_seq_len# assert pure_decoder_labels[1] <= max_decoder_seq_lenencoder_indices = find_first_nonzero(encoder_attention_mask)decoder_indices = find_first_nonzero(pure_decoder_attention_mask)# create a tensor at targeted sizeseq_len = encoder_attention_mask.shape[-1] + pure_decoder_attention_mask.shape[-1] - torch.argmin(encoder_indices + decoder_indices)seq_len_addition = encoder_attention_mask.shape[-1] - torch.argmin(encoder_indices + decoder_indices)decoder_attention_mask = F.pad(pure_decoder_attention_mask, (seq_len_addition, 0), 'constant', 0)decoder_inputs_embeddings = F.pad(pure_decoder_input_embeddings, (0, 0, seq_len_addition, 0), 'constant',pad_embedding).detach().requires_grad_()if not ignore_position_ids:decoder_position_ids = F.pad(decoder_position_ids, (seq_len_addition, 0), 'constant', 0)fake_decoder_position_ids = decoder_position_idselse:fake_decoder_position_ids = [None] * seq_lendecoder_labels = F.pad(pure_decoder_labels, (seq_len_addition, 0), 'constant',ignore_index) if pure_decoder_labels is not None else None# insert encoder embeds and masks# right: seq_len_addition + decoder_indices, len: encoder_attention_mask.shape[-1] - encoder_indices# TODO: 能不能不用for循环for i, (mask, emb, pos) in enumerate(zip(decoder_attention_mask, decoder_inputs_embeddings, fake_decoder_position_ids)):_right = seq_len_addition + decoder_indices[i]_len = encoder_attention_mask.shape[-1] - encoder_indices[i]_left = _right - _lenmask[_left:_right] = encoder_attention_mask[i, -_len:]emb[_left:_right, :] = projected_embeddings[i, -_len:, :]if not ignore_position_ids:pos[_left:_right] = encoder_position_ids[i, -_len:]pos[_right:] += _len# return decoder_inputs_embeddings, decoder_attention_mask, decoder_position_idsreturn decoder_inputs_embeddings, decoder_attention_mask, decoder_position_ids, decoder_labels# TODO: tokenizer_padding_sidedef forward(self,input_ids: torch.LongTensor = None, # decoderencoder_input_ids: Optional[torch.LongTensor] = None,attention_mask: Optional[torch.Tensor] = None, # decoderencoder_attention_mask: Optional[torch.Tensor] = None,position_ids: Optional[torch.LongTensor] = None,encoder_position_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Union[Cache, List[torch.FloatTensor]]] = None,inputs_embeds: Optional[torch.FloatTensor] = None,labels: Optional[torch.LongTensor] = None,use_cache: Optional[bool] = None,output_attentions: Optional[bool] = None,output_hidden_states: Optional[bool] = None,return_dict: Optional[bool] = None,cache_position: Optional[torch.LongTensor] = None,**kwargs) -> Union[Tuple, BaseModelOutputWithPast]:if inputs_embeds is not None:raise ValueError("embed inputs are not supported in LlaTaModel")if input_ids is None:raise ValueError("decoder inputs are needed")if past_key_values is None:# when kv cache is not valid, deal with inputsdecoder_input_ids = input_ids # shape: (batch_size, decoder_input_len)decoder_attention_mask = attention_mask # shape: (batch_size, decoder_input_len)if attention_mask is None:decoder_attention_mask = torch.ones_like(decoder_input_ids)if encoder_attention_mask is None:real_encoder_attention_mask = torch.ones_like(encoder_input_ids)else:real_encoder_attention_mask = encoder_attention_maskif position_ids is not None or encoder_position_ids is not None:if position_ids is None:position_ids = torch.stack([torch.cat((torch.full((index,), 0, dtype=int),torch.arange(0, decoder_attention_mask.shape[1] - index, 1)))forbatch, index in enumerate(find_first_nonzero(decoder_attention_mask))])if encoder_position_ids is None:encoder_position_ids = torch.stack([torch.cat((torch.full((index,), 0, dtype=int),torch.arange(0,encoder_attention_mask.shape[1] - index,1))) forbatch, index inenumerate(find_first_nonzero(encoder_attention_mask))])# decoder partpure_decoder_inputs = decoder_input_ids # shape: (decoder_input_len)# shape: (batch_size, decoder_input_len, decoder_embedding_len)pure_decoder_input_embeddings = self.decoder.get_input_embeddings()(pure_decoder_inputs)decoder_position_ids = position_ids# encoder partif self.encoder is not None and encoder_input_ids is not None:encoder_outputs = self.encoder.forward(input_ids=encoder_input_ids,attention_mask=real_encoder_attention_mask,)# shape: (batch_size, encoder_input_len, mm_hidden_size) -> (batch_size, decoder_input_len, hidden_size)projected_embeddings = self.projector(encoder_outputs.last_hidden_state)else:# use a tensor of seq len 0_empty_shape = pure_decoder_input_embeddings.shape[:]_empty_shape[1] = 0projected_embeddings = torch.Tensor(size=_empty_shape)# concat# decoder_inputs_embeddings = torch.cat((projected_embeddings, pure_decoder_input_embeddings), dim=1) # shape: (batch_size, encoder_input_len+decoder_input_len, decoder_embedding_len)# decoder_attention_mask = torch.cat((torch.ones(projected_embeddings.shape[:-1], device=self.device), decoder_attention_mask), dim=1) # shape: (batch_size, encoder_input_len+decoder_input_len)if self.encoder is not None and encoder_input_ids is not None:decoder_inputs_embeddings, decoder_attention_mask, decoder_position_ids, decoder_labels = self._prepare_decoder_input(projected_embeddings, real_encoder_attention_mask, encoder_position_ids,pure_decoder_input_embeddings,decoder_attention_mask, position_ids, labels, self.config.decoder_config.pad_token_id)else:decoder_inputs_embeddings = pure_decoder_input_embeddingsdecoder_labels = labelsdecoder_outputs = self.decoder.forward(inputs_embeds=decoder_inputs_embeddings,attention_mask=decoder_attention_mask,position_ids=decoder_position_ids,past_key_values=past_key_values,labels=decoder_labels,use_cache=use_cache,output_attentions=output_attentions,output_hidden_states=output_hidden_states,return_dict=return_dict,**kwargs)else:# kv cache is valid, iter next stepdecoder_outputs = self.decoder.forward(input_ids=input_ids,attention_mask=attention_mask,position_ids=position_ids,past_key_values=past_key_values,labels=labels,use_cache=use_cache,output_attentions=output_attentions,output_hidden_states=output_hidden_states,return_dict=return_dict,**kwargs)return decoder_outputs# the same as library code transformers/models/llama/modeling_llama.py# just in order to make transformers library happydef prepare_inputs_for_generation(self,input_ids,past_key_values=None,attention_mask=None,inputs_embeds=None,cache_position=None,use_cache=True,encoder_input_ids=None,encoder_attention_mask=None,**kwargs,):if use_cache and past_key_values is None:past_key_values = DynamicCache.from_legacy_cache(past_key_values)past_length = 0if past_key_values is not None:# Past key values are always initialized with a `Cache` object -> no need for if-else anymorepast_length = cache_position[0] if cache_position is not None else past_key_values.get_seq_length()max_cache_length = (torch.tensor(past_key_values.get_max_length(), device=input_ids.device)if past_key_values.get_max_length() is not Noneelse None)cache_length = past_length if max_cache_length is None else torch.min(max_cache_length, past_length)# Keep only the unprocessed tokens:# 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where# some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as input)if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:input_ids = input_ids[:, -(attention_mask.shape[1] - past_length):]# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard# input_ids based on the past_length.elif past_length < input_ids.shape[1]:input_ids = input_ids[:, past_length:]# 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.# If we are about to go beyond the maximum cache length, we need to crop the input attention mask.if (max_cache_length is not Noneand attention_mask is not Noneand cache_length + input_ids.shape[1] > max_cache_length):attention_mask = attention_mask[:, -max_cache_length:]position_ids = kwargs.get("position_ids", None)if attention_mask is not None and position_ids is None:# create position_ids on the fly for batch generationposition_ids = attention_mask.long().cumsum(-1) - 1position_ids.masked_fill_(attention_mask == 0, 1)if past_key_values:position_ids = position_ids[:, -input_ids.shape[1]:]# if `inputs_embeds` are passed, we only want to use them in the 1st generation stepif inputs_embeds is not None and past_length == 0:model_inputs = {"inputs_embeds": inputs_embeds}else:# The `contiguous()` here is necessary to have a static stride during decoding. torchdynamo otherwise# recompiles graphs as the stride of the inputs is a guard. Ref: https://github.com/huggingface/transformers/pull/29114# TODO: use `next_tokens` directly instead.model_inputs = {"input_ids": input_ids.contiguous()}input_length = position_ids.shape[-1] if position_ids is not None else input_ids.shape[-1]if cache_position is None:cache_position = torch.arange(past_length, past_length + input_length, device=input_ids.device)elif use_cache:cache_position = cache_position[-input_length:]model_inputs.update({"position_ids": position_ids,"cache_position": cache_position,"past_key_values": past_key_values,"use_cache": use_cache,"attention_mask": attention_mask,"encoder_input_ids": encoder_input_ids,"encoder_attention_mask": encoder_attention_mask,})return model_inputsdef generate(self,inputs: Optional[torch.Tensor] = None,table_inputs: Optional[torch.Tensor] = None,table_attention_mask: Optional[torch.Tensor] = None,generation_config: Optional[GenerationConfig] = None,logits_processor: Optional[LogitsProcessorList] = None,stopping_criteria: Optional[StoppingCriteriaList] = None,prefix_allowed_tokens_fn: Optional[Callable[[int, torch.Tensor], List[int]]] = None,synced_gpus: Optional[bool] = None,assistant_model: Optional[PreTrainedModel] = None,streamer: Optional["BaseStreamer"] = None,**kwargs,) -> Union[GenerateOutput, torch.LongTensor]:# 处理多余参数encoder_input_ids = table_inputsencoder_attention_mask = table_attention_maskreturn super().generate(inputs,generation_config=generation_config,logits_processor=logits_processor,stopping_criteria=stopping_criteria,prefix_allowed_tokens_fn=prefix_allowed_tokens_fn,synced_gpus=synced_gpus,assistant_model=assistant_model,streamer=streamer,encoder_input_ids=encoder_input_ids,encoder_attention_mask=encoder_attention_mask,**kwargs,)# def _prepare_decoder_input_with_none(# projected_embeddings: Optional[torch.Tensor],# encoder_attention_mask: Optional[torch.Tensor],# pure_decoder_input_embeddings: torch.Tensor,# decoder_attention_mask: Optional[torch.Tensor],# pad_embedding: torch.Tensor# ):# def find_first_nonzero(t: torch.Tensor):# """# example:# [[0, 0, 1, 0, 1, 0, 0],# [0, 0, 0, 1, 1, 0, 0]]# --># [[2],# [3]]# """# indices = torch.argmax((t != 0.0).to(dtype=torch.int), dim=-1)# return indices## # deal with None# _attention_cal_flag = encoder_attention_mask is not None or decoder_attention_mask is not None# _embedding_cal_flag = projected_embeddings is not None# if encoder_attention_mask is None and _attention_cal_flag:# encoder_attention_mask = torch.ones(projected_embeddings.shape[:-1])# if decoder_attention_mask is None and _attention_cal_flag:# decoder_attention_mask = torch.ones(pure_decoder_input_embeddings.shape[:-1])## encoder_indices = find_first_nonzero(encoder_attention_mask)# decoder_indices = find_first_nonzero(decoder_attention_mask)## # create a tensor at targeted size# # last_dim_len = encoder_attention_mask.shape[-1] + decoder_attention_mask.shape[-1] - torch.argmin(encoder_indices + decoder_indices)# last_dim_len_addition = encoder_attention_mask.shape[-1] - torch.argmin(encoder_indices + decoder_indices)# decoder_attention_mask = F.pad(decoder_attention_mask, (last_dim_len_addition, 0), 'constant',# 0) if _attention_cal_flag else decoder_attention_mask# decoder_inputs_embeddings = F.pad(pure_decoder_input_embeddings, (0, 0, last_dim_len_addition, 0), 'constant',# pad_embedding) if _embedding_cal_flag else pure_decoder_input_embeddings## # insert encoder embeds and masks# # right: last_dim_len_addition + decoder_indices, len: encoder_attention_mask.shape[-1] - encoder_indices# # TODO: 能不能不用for循环# if _attention_cal_flag or _embedding_cal_flag:# for i, (mask, emb) in enumerate(zip(decoder_attention_mask, decoder_inputs_embeddings)):# _right = last_dim_len_addition + decoder_indices[i]# _len = encoder_attention_mask.shape[-1] - encoder_indices[i]# _left = _right - _len# if _attention_cal_flag:# mask[_left:_right] = encoder_attention_mask[i, -_len:]# if _embedding_cal_flag:# emb[_left:_right, :] = projected_embeddings[i, -_len:, :]## return decoder_inputs_embeddings, decoder_attention_maskLlaTaConfig.register_for_auto_class()LlaTaModel.register_for_auto_class("AutoModel")SimpleMLPConfig.register_for_auto_class()SimpleMLP.register_for_auto_class("AutoModel")123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781from dataclasses import dataclassfrom typing import Optional, List, Union, Dict, Any, Tuple, Callable, Unionfrom transformers import PreTrainedModel, AutoModel, AutoModelForCausalLM, DynamicCache, Cachefrom transformers.activations import ACT2FNfrom transformers.utils import ModelOutputimport torchfrom torch import nnimport torch.nn.functional as Ffrom .configuration_llata import LlaTaConfig, SimpleMLPConfig# import because Auto classes need themfrom .modeling_codet5p import CodeT5pModelfrom .configuration_codet5p import CodeT5pConfig# loggingimport logginglogger = logging.getLogger('modeling_llata')class SimpleMLP(PreTrainedModel):config_class = SimpleMLPConfigdef __init__(self, config: Optional[SimpleMLPConfig] = None):super().__init__(config)self.act = ACT2FN[config.act]dims_pairs = list(zip(config.dims[:-1], config.dims[1:]))layers = []for ind, (dim_in, dim_out) in enumerate(dims_pairs):linear = nn.Linear(dim_in, dim_out, dtype=config.torch_dtype)layers.append(linear)if config.act is not None:layers.append(self.act)layers.append(nn.Dropout(config.dropout))layers = layers[:-2] if config.act is not None else layers[:-1]self.model = torch.nn.Sequential(*layers)def forward(self, x: torch.Tensor, **kwargs) -> torch.Tensor:if len(kwargs):raise ValueError('SimpleMLP is not meant to be used directly')return self.model(x)@dataclass# Copied from transformers.models.idefics.modeling_idefics.IdeficsCausalLMOutputWithPast with Idefics->Llata with minor fixesclass LlataCausalLMOutputWithPast(ModelOutput):"""Base class for LlavaNext causal language model (or autoregressive) outputs.Args:loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):Language modeling loss (for next-token prediction).logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).past_key_values (`tuple(tuple(torch.FloatTensor))` or `Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape`(batch_size, num_heads, sequence_length, embed_size_per_head)`)Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see`past_key_values` input) to speed up sequential decoding.hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):Tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):Tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,sequence_length)`.Attentions weights after the attention softmax, used to compute the weighted average in the self-attentionheads.table_hidden_states (`torch.FloatTensor`, *optional*):The output of the table embeddings, `(batch_size, sequence_length, hidden_size)`.table_hidden_states of the model produced by the table encoder, and optionally by the perceiver"""loss: Optional[torch.FloatTensor] = Nonelogits: torch.FloatTensor = Nonepast_key_values: Optional[Union[Cache, Tuple[Tuple[torch.FloatTensor]]]] = Nonehidden_states: Optional[Tuple[torch.FloatTensor]] = Noneattentions: Optional[Tuple[torch.FloatTensor]] = Nonetable_hidden_states: Optional[torch.FloatTensor] = Nonelabels: Optional[torch.LongTensor] = None# Copied from transformers.models.llava.modeling_llava.LlavaPreTrainedModel with fixesclass LlaTaPreTrainedModel(PreTrainedModel):config_class = LlaTaConfigbase_model_prefix = "model"supports_gradient_checkpointing = False # TODO_no_split_modules = ["SimpleMLP"] # TODO_skip_keys_device_placement = "past_key_values"_supports_flash_attn_2 = False # TODOconfig: LlaTaConfigdef _init_weights(self, module):# important: this ported version of LlaTa isn't meant for training from scratch - only# inference and fine-tuning - so the proper init weights code has been removed.# 真的有人要不使用现成的LLM自己预训练吗?std = (self.config.initializer_rangeif hasattr(self.config, "initializer_range")else self.config.decoder_config.initializer_range)# TODOif hasattr(module, "class_embedding"):module.class_embedding.data.normal_(mean=0.0, std=std)if isinstance(module, (nn.Linear, nn.Conv2d)):module.weight.data.normal_(mean=0.0, std=std)if module.bias is not None:module.bias.data.zero_()elif isinstance(module, nn.Embedding):module.weight.data.normal_(mean=0.0, std=std)if module.padding_idx is not None:module.weight.data[module.padding_idx].zero_()@propertydef _supports_sdpa(self):"""Retrieve language_model's attribute to check whether the model supportsSDPA or not."""return self.language_model._supports_sdpaclass LlaTaForConditionalGeneration(LlaTaPreTrainedModel):# TODO: trust_remote_codedef __init__(self,config: LlaTaConfig,# intended for use existed modelencoder: Optional[PreTrainedModel] = None,decoder: Optional[PreTrainedModel] = None,projector: Optional[PreTrainedModel] = None,):super().__init__(config)if encoder is not None:assert isinstance(config.encoder_config, encoder.config_class)self.encoder = encoderelif config.encoder_config.model_type == "codet5p_module":self.encoder = CodeT5pModel._from_config(config.encoder_config,attn_implementation=config._attn_implementation)else:self.encoder = AutoModel.from_config(config.encoder_config, trust_remote_code=True,attn_implementation=config._attn_implementation)if decoder is not None:assert isinstance(config.decoder_config, decoder.config_class)self.decoder = decoderelse:self.decoder = AutoModelForCausalLM.from_config(config.decoder_config, trust_remote_code=True,attn_implementation=config._attn_implementation)if projector is not None:assert isinstance(config.projector_config, projector.config_class)self.projector = projectorelif config.projector_config.model_type == "mlp":self.projector = SimpleMLP(config.projector_config)else:self.projector = AutoModel.from_config(config.projector_config, trust_remote_code=True)self.vocab_size = config.decoder_config.vocab_size# quick fix when DP trainingself._flag_decoder_pad_to_fixed_len = Falseself._decoder_pad_fixed_len = None# if attention bias is used, we need a buffer to deal with kv-cacheself._flag_attention_bias: bool = getattr(self.config.decoder_config, 'attention_bias', True)if self._flag_attention_bias:self._id_cache: int = 0self._buffer_previous_attention: torch.Tensor = torch.Tensor([])self.post_init()def get_input_embeddings(self):return self.decoder.get_input_embeddings()def set_input_embeddings(self, value):self.decoder.set_input_embeddings(value)def get_output_embeddings(self):return self.decoder.get_output_embeddings()def set_output_embeddings(self, new_embeddings):self.decoder.set_output_embeddings(new_embeddings)def set_decoder(self, decoder):self.decoder.set_decoder(decoder)def get_decoder(self):return self.decoder.get_decoder()def tie_weights(self):return self.decoder.tie_weights()def resize_token_embeddings(self, new_num_tokens: Optional[int] = None, pad_to_multiple_of=None) -> nn.Embedding:model_embeds = self.language_model.resize_token_embeddings(new_num_tokens, pad_to_multiple_of)# update vocab sizeself.config.text_config.vocab_size = model_embeds.num_embeddingsself.vocab_size = model_embeds.num_embeddingsreturn model_embedsdef _merge_input_ids_with_table_features(self,table_features: torch.Tensor,table_feature_lens: torch.Tensor,inputs_embeds: torch.Tensor,input_ids: torch.Tensor,attention_mask: torch.Tensor,position_ids: Optional[torch.LongTensor], # ignored!labels: Optional[torch.LongTensor],table_token_index: Optional[int] = None,ignore_index: int = -100, # refer to torch/nn/modules/loss.py:CrossEntropyLoss) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.LongTensor], Optional[torch.LongTensor]]: # em, msk, pos, lbl"""Merge input_ids with table features into final embeddingsArgs:table_features (`torch.Tensor` of shape `(all_feature_length, embed_dim)`):All table vectors of all tables in the batchtable_feature_lens (`torch.LongTensor` of shape `(num_table_items)`):The length of table embeddings of each table item as stacked in `table_features`inputs_embeds (`torch.Tensor` of shape `(batch_size, sequence_length, embed_dim)`):Token embeddings before merging with table embeddingsinput_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):Input_ids of tokens, possibly filled with `<|table|>` tokenattention_mask (`torch.LongTensor` of shape `(batch_size, sequence_length)`):Mask to avoid performing attention on padding token indices.position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):IGNORED FOR NOW!Indices of positions of each input sequence tokens in the position embeddings.Selected in the range `[0, config.n_positions - 1]`.labels (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):abels need to be recalculated to support training (if provided)table_token_index (`int`, *optional*)Token id used to indicate the special `<|table|>` token. Defaults to `config.table_token_index`ignore_index (`int`, *optional*)Value that is used to pad `labels` and will be ignored when calculated loss. Default: -100.Returns:final_embedding, final_attention_mask, position_ids, final_labelsExplanation:each table item has variable length embeddings, with length specified by table_feature_lenstable_features is concatenation of all table embed vectorstask: fill each <|table|> with the correct number of table embeddingsExample:table_features = X (len 5), Y (len 3), Z (len 8)X, Y are in the same sequence (in-context learning), because 2 <|table|> in input_ids[0]if right paddinginput_ids: [[a b c d e f T g h i j k T l m] T = <|table|>[o p q r T s t u v _ _ _ _ _ _]]input_ids should be: [[a b c d e f X X X X X g h i j k Y Y Y l m][o p q r Z Z Z Z Z Z Z Z s t u v _ _ _ _ _]]labels should be: [[a b c d e f _ _ _ _ _ g h i j k _ _ _ l m][o p q r _ _ _ _ _ _ _ _ s t u v _ _ _ _ _]]elif left paddinginput_ids: [[a b c d e f T g h i j k T l m] T = <|table|>[_ _ _ _ _ _ o p q r T s t u v]]input_ids should be: [[a b c d e f X X X X X g h i j k Y Y Y l m][_ _ _ _ _ o p q r Z Z Z Z Z Z Z Z s t u v]]labels should be: [[a b c d e f _ _ _ _ _ g h i j k _ _ _ l m][_ _ _ _ _ o p q r _ _ _ _ _ _ _ _ s t u v]]Edge cases:If padding side cannot be inferred, use left padding."""table_token_index = table_token_index if table_token_index is not None else self.config.table_token_indexignore_index = ignore_index if ignore_index is not None else self.config.ignore_index# WARNING: position id is ignored because it's hard to distinguish between two consecutive <|table|> tokens# TODO: deal with devicewith torch.no_grad():num_tables = table_feature_lens.shape[0]num_table_features, embed_dim = table_features.shapebatch_size, input_sequence_length = input_ids.shape # TODO: input_sequence_length not usedif table_feature_lens.sum() != num_table_features:raise ValueError(f'({table_feature_lens.sum()=}) != ({table_features.shape[0]=})')if embed_dim != inputs_embeds.shape[-1]:raise ValueError(f'input embd dim {inputs_embeds.shape[-1]} != table embd dim {embed_dim}')if not torch.all(attention_mask[input_ids == table_token_index]):raise ValueError(f'attention mask is 0 at table token index')# decide whether to use left padding or right paddingleft_padding = self.padding_side == "left" if hasattr(self, "padding_side") else Trueif torch.any(attention_mask[:, -1] == 0): # noqaleft_padding = Falseif torch.any(attention_mask[:, -1] == 0): # noqaleft_padding = True# 1. Create a mask to know where special table tokens aretable_token_mask = input_ids == table_token_index # shape: (batch_size, sequence_length)num_table_tokens_pre_batch = torch.sum(table_token_mask, dim=-1) # shape: (batch_size)total_num_table_tokens = torch.sum(num_table_tokens_pre_batch)if total_num_table_tokens != num_tables:raise ValueError(f'Number of table tokens in input_ids ({total_num_table_tokens}) != 'f'num_tables ({num_tables})')# Compute the maximum embed dimension# table_feature_num_per_batch = table_feature_lens.split(num_table_tokens_pre_batch.tolist(),# dim=0) # shape: (batch_size, num_batch_table_tokens)# table_feature_total_len_per_batch = torch.tensor([x.sum() for x in table_feature_num_per_batch],# device=self.device) # shape: (batch_size)table_feature_num_per_batch_ind = torch.arange(batch_size, device=self.device).repeat_interleave(num_table_tokens_pre_batch) # shape: (num_all_table_tokens)table_feature_total_len_per_batch = torch.zeros(batch_size, dtype=torch.int64,device=self.device) # shape: (batch_size)table_feature_total_len_per_batch.index_add_(0, table_feature_num_per_batch_ind, table_feature_lens)final_embed_sequence_lengths = attention_mask.long().sum(dim=-1) - num_table_tokens_pre_batch + table_feature_total_len_per_batch # shape: (batch_size)max_embed_dim = final_embed_sequence_lengths.max().item()if self._flag_decoder_pad_to_fixed_len:assert max_embed_dim <= self._decoder_pad_fixed_lenmax_embed_dim = self._decoder_pad_fixed_len# 2. Compute the positions where text should be written# Calculate new positions for text tokens in merged table-text sequence.batch_indices, text_token_old_indices_in_batch = torch.where((input_ids != table_token_index) & (attention_mask == 1)) # noqa, shape: both (num_text_tokens)batch_indices = batch_indices.to(self.device)text_token_old_indices_in_batch = text_token_old_indices_in_batch.to(self.device)# calculate how much tokens should be reserved for each old token(table or text)new_token_len_in_old = table_token_mask.long() # shape: (batch_size, sequence_length)new_token_len_in_old[table_token_mask] = table_feature_lens - 1 # shape: (batch_size, sequence_length)# if position_ids is not None:# position_ids_offset_in_new = torch.cumsum(new_token_len_in_old, dim=-1) # shape: (batch_size, sequence_length)# `torch.cumsum` computes how each table token shifts subsequent text token positions.# the right calculation is new_token_positions = torch.cat((torch.Tensor(0), torch.cumsum(new_token_len_in_old + 1, dim=-1)[:, :-1), dim=-1)# but it is enough to use with minus 1 because we don't use it for table tokensnew_token_positions = torch.cumsum(new_token_len_in_old + attention_mask, dim=-1) - 1 # shape:(bsz,seq_len)if left_padding:# shift right token positions so that they are ending at the same numbernew_token_positions += max_embed_dim - 1 - new_token_positions[:, -1:] # shape: (bsz, sequence_length)text_token_new_indices_in_batch = new_token_positions[batch_indices, text_token_old_indices_in_batch]# 3. Create the full embedding, already padded to the maximum positionfinal_embedding = torch.zeros(batch_size, max_embed_dim, embed_dim, dtype=inputs_embeds.dtype, device=self.device)final_attention_mask = torch.zeros(batch_size, max_embed_dim, dtype=attention_mask.dtype, device=self.device)# final_input_ids = torch.full(# (batch_size, max_embed_dim), self.pad_token_id, dtype=input_ids.dtype, device=self.device# )if labels is not None:final_labels = torch.full((batch_size, max_embed_dim), ignore_index, dtype=labels.dtype, device=self.device)else:final_labels = None# if position_ids is not None:# final_position_ids = torch.full(# (batch_size, max_embed_dim), 1, dtype=position_ids.dtype, device=self.device# )# else:# final_position_ids = None# 4. Fill the embeddings based on the mask.# first fill text tokensfinal_embedding[batch_indices, text_token_new_indices_in_batch] = inputs_embeds[batch_indices, text_token_old_indices_in_batch]final_attention_mask[batch_indices, text_token_new_indices_in_batch] = attention_mask[batch_indices, text_token_old_indices_in_batch]# final_input_ids[batch_indices, text_token_new_indices_in_batch] = input_ids[batch_indices, text_token_old_indices_in_batch]if labels is not None:final_labels[batch_indices, text_token_new_indices_in_batch] = labels[batch_indices, text_token_old_indices_in_batch]# if position_ids is not None:# final_position_ids[batch_indices, text_token_new_indices_in_batch] = (position_ids + position_ids_offset_in_new)[batch_indices, text_token_old_indices_in_batch]# then, no need to fill pad tokens# finally, fill table tokenswith torch.no_grad():# produce all True masktable_token_mask_in_final = torch.full((batch_size, max_embed_dim), True, dtype=torch.bool, device=self.device) # shape: (batch_size, max_embed_dim)# remove text tokenstable_token_mask_in_final[batch_indices, text_token_new_indices_in_batch] = False# remove pad tokensembed_indices_in_batch = torch.arange(max_embed_dim, device=self.device)[None, :]embed_indices_in_batch = embed_indices_in_batch.expand(batch_size, max_embed_dim) # shape:(bsz,max_emb_dim)if left_padding:table_token_mask_in_final[embed_indices_in_batch < (max_embed_dim - final_embed_sequence_lengths)[:, None]] = Falseelse:table_token_mask_in_final[embed_indices_in_batch >= final_embed_sequence_lengths[:, None]] = False# got table_token_mask_in_finalfinal_embedding[table_token_mask_in_final] = table_featuresfinal_attention_mask |= table_token_mask_in_final# return our position idsif position_ids is not None:position_ids = (torch.cumsum(final_attention_mask, dim=-1) - 1).masked_fill_(final_attention_mask == 0, 1) # noqareturn final_embedding, final_attention_mask, position_ids, final_labelsdef _split_table_features(self,table_inputs: torch.LongTensor,table_features: torch.FloatTensor,table_attention_mask: torch.LongTensor,sep_token_index: Optional[int] = None,):"""split features in one batch and concat them.Args:table_inputs (`torch.LongTensor` of shape `(batch_size, sequence_length)`):Input_ids of tokens, possibly filled with `<sep>` tokentable_features (`torch.Tensor` of shape `(batch_size, sequence_length, embed_dim)`):All table vectors of all tables in the batchtable_attention_mask (`torch.LongTensor` of shape `(batch_size, sequence_length)`):Mask to avoid performing attention on padding token indices.sep_token_index (`int`, *optional*)Token id used to indicate the special `<sep>` token. Defaults to `config.encoder_sep_token_index`If sep_token_index is not provided, fall back to just concat them.Returns:final_table_features, table_feature_lens"""if sep_token_index is None:table_feature_lens = table_attention_mask.sum(dim=-1)final_table_features = table_features[table_attention_mask.bool()]return final_table_features, table_feature_lenswith torch.no_grad():batch_size, _, embed_dim = table_features.shape# 1. add <sep> to end of each batch and get positionsep_token_mask: torch.Tensor = table_inputs == sep_token_index # noqa, shape: (batch_size, sequence_length)sep_token_mask = torch.cat((sep_token_mask, torch.full((batch_size, 1), True, dtype=torch.bool, device=self.device)),dim=-1) # shape: (batch_size, sequence_length + 1)sep_token_batch, sep_token_pos = torch.where(sep_token_mask)# 2. get count between <sep>stext_token_count = torch.cumsum((table_inputs != sep_token_index) & (table_attention_mask.eq(1)), dim=-1)text_token_count = torch.cat((text_token_count, text_token_count[:, -1:]), dim=-1)# accumulate each row by last item of last rowtext_token_count[1:, :] += text_token_count[:-1, -1].cumsum(dim=0).unsqueeze(1)feature_lens = text_token_count[sep_token_batch[1:], sep_token_pos[1:]] - text_token_count[sep_token_batch[:-1], sep_token_pos[:-1]]# add feature len before the first <sep>feature_lens = torch.cat((text_token_count[sep_token_batch[:1], sep_token_pos[:1]], feature_lens), dim=0)# drop zerosfeature_lens = feature_lens[feature_lens.nonzero()].flatten()batch_indices, text_token_old_indices_in_batch = torch.where((table_inputs != sep_token_index) & (table_attention_mask == 1)) # noqa, shape: both(num_normal_tokens)final_table_features = table_features[batch_indices, text_token_old_indices_in_batch]return final_table_features, feature_lensdef forward(self,input_ids: Optional[torch.LongTensor] = None,attention_mask: Optional[torch.Tensor] = None,position_ids: Optional[torch.LongTensor] = None,table_inputs: Optional[torch.LongTensor] = None,table_attention_mask: Optional[torch.LongTensor] = None,table_position_ids: Optional[torch.LongTensor] = None,past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.Tensor]]]] = None,inputs_embeds: Optional[torch.FloatTensor] = None,labels: Optional[torch.LongTensor] = None,use_cache: Optional[bool] = None,output_attentions: Optional[bool] = None,output_hidden_states: Optional[bool] = None,return_dict: Optional[bool] = None,) -> Union[Tuple, LlataCausalLMOutputWithPast]:# get flags from configoutput_attentions = output_attentions if output_attentions is not None else self.config.output_attentionsoutput_hidden_states = (output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states)return_dict = return_dict if return_dict is not None else self.config.use_return_dict# deal with inputsif input_ids is None:raise ValueError("decoder inputs are needed")if input_ids is not None and inputs_embeds is not None:raise ValueError("cannot use input_ids and input_embeds simultaneously")if input_ids is None and inputs_embeds is None:raise ValueError("please pass at least one of input_ids and input_embeds")if table_inputs is None:raise ValueError("table_inputs is None, why not use a language model?")if table_position_ids is not None:raise ValueError("table_position_ids is not supported now")if past_key_values is not None and not isinstance(past_key_values, Cache):raise ValueError("tuple cache is not supported")if inputs_embeds is None and input_ids is not None:# 1. Extract the input embeddings# In case table_token_index is not in the embeddings (extra token but embedding don't have it)masked_input_ids = input_ids.clone()masked_input_ids[(input_ids == self.config.table_token_index)] = 0inputs_embeds = self.get_input_embeddings()(masked_input_ids)# not generation or generation with no cacheif past_key_values is None or past_key_values.get_seq_length() == 0:# assert no table_token_id in input_ids now# have table inputsif table_inputs is not None and table_inputs.shape[0] > 0:# 2. get table inputs# only encoder with output type XXXXWithCrossAttentions can get last_hidden_statetable_features = self.encoder(input_ids=table_inputs,attention_mask=table_attention_mask,position_ids=table_position_ids,use_cache=False,output_attentions=False,output_hidden_states=False,return_dict=True,).last_hidden_state# if there is a [CLS] token, we need to clip it# table_features = table_features[:, 1:]# 3. process table features and projecttable_features, table_feature_lens = self._split_table_features(table_inputs=table_inputs,table_features=table_features,table_attention_mask=table_attention_mask,sep_token_index=self.config.encoder_sep_token_index,)table_features = self.projector(table_features)# 4. merge input_ids with table featuresinputs_embeds, attention_mask, position_ids, labels = self._merge_input_ids_with_table_features(table_features=table_features,table_feature_lens=table_feature_lens,inputs_embeds=inputs_embeds,input_ids=input_ids,attention_mask=attention_mask,position_ids=position_ids,labels=labels,table_token_index=self.config.table_token_index,)else:# no tables availablepasselse:# generation with cache# note: 在上面的代码中,我们合并了table部分和text部分,生成了新的attention mask和position id,# 但是因为生成的attention mask和position id在decoder执行完后就被丢失,# 而外层的generate()函数不知道这个修改,仍然按照这个函数的输入来传递attention mask和position id,是不能用的# 因此我们需要在这里重新生成kv-cache部分的attention mask和position id。target_length = input_ids.shape[1]past_length = past_key_values.get_seq_length()# TODO: testif self._flag_attention_bias:_id_cache_now = id(past_key_values.key_cache[-1]) if len(past_key_values.key_cache) else 0 # noqa# K矩阵计算过程包含bias,这阻止我们使用下面的方法if attention_mask.shape[0] == self._buffer_previous_attention.shape[0] and (_id_cache_now == self._id_cache or _id_cache_now == 0) and (past_length <= self._buffer_previous_attention.shape[1]):extended_attention_mask = self._buffer_previous_attention[:, -past_length:]else:# can't infer attention mask at all, give upraise ValueError('cannot infer attention mask, please disable kv-cache')else:# 由于在_merge_input_ids_with_table_features()中,我们对input_embeds中padding部分填零处理,# 因此找到首层K矩阵为0的项即为padding部分# 本来我们需要确认所有head的所有dim都为0,一般来说取head0的dim0判断即可,# 但是根据llava的经验及代码,检查dim0的所有head的和为0更加保险first_layer_past_key_state = past_key_values[0][0][:, :, :, 0] # shape: (bsz, n_head, seq_len)# TODO: .float()?batch_index, padding_tokens_in_batch = torch.where(first_layer_past_key_state.float().sum(dim=-2) == 0)extended_attention_mask = torch.ones((attention_mask.shape[0], past_length),dtype=attention_mask.dtype,device=self.device,)# 我们只考虑kv-cache内的padding部分,其他部分不予考虑。有以下两种边界情况:# - decoder使用了static cache,或者cache本身因各种原因超过实际需要长度# - 用户传进来一个自己的cachevalid_indices = padding_tokens_in_batch < past_lengthnew_batch_index = batch_index[valid_indices]new_non_attended_tokens = padding_tokens_in_batch[valid_indices]# 把kv-cache内padding部分填0extended_attention_mask[new_batch_index, new_non_attended_tokens] = 0attention_mask = torch.cat((extended_attention_mask, attention_mask[:, -target_length:]), dim=1)# 最后生成position idposition_ids = torch.arange(target_length, device=self.device)[None, :] + (torch.sum(attention_mask, dim=1, keepdim=True) - 1)if use_cache and self._flag_attention_bias:self._buffer_previous_attention = attention_mask.clone().detach()# all prepared, call decoderoutputs = self.decoder(attention_mask=attention_mask,position_ids=position_ids,past_key_values=past_key_values,inputs_embeds=inputs_embeds,use_cache=use_cache,output_attentions=output_attentions,output_hidden_states=output_hidden_states,return_dict=return_dict,)if use_cache and self._flag_attention_bias:self._id_cache = id(outputs.past_key_values.key_cache[-1]) if len(outputs.past_key_values.key_cache) else 0# we didn't pass input_ids to decoder, so we need to calculate loss herelogits = outputs[0]loss = Noneif labels is not None:if attention_mask is not None:shift_attention_mask = attention_mask[..., 1:]shift_logits = logits[..., :-1, :][shift_attention_mask.bool()].flatten(end_dim=-2).contiguous()shift_labels = labels[..., 1:][shift_attention_mask.bool()].flatten().contiguous()else:shift_logits = logits[..., :-1, :].flatten(end_dim=-2).contiguous()shift_labels = labels[..., 1:].flatten().contiguous()shift_labels = shift_labels.to(shift_logits.device)loss_fct = nn.CrossEntropyLoss()loss = loss_fct(shift_logits, shift_labels)if not return_dict:output = (logits,) + outputs[1:]return (loss,) + output if loss is not None else outputreturn LlataCausalLMOutputWithPast(loss=loss,logits=logits,past_key_values=outputs.past_key_values,hidden_states=outputs.hidden_states,attentions=outputs.attentions,labels=labels,# table_hidden_states=table_features if hasattr(locals(), 'table_features') else None,)# Copied from transformers.models.llama.modeling_llama.LlamaForCasualLM with fixesdef prepare_inputs_for_generation(self,input_ids: torch.Tensor,inputs_embeds: torch.Tensor = None,attention_mask: Optional[torch.Tensor] = None,position_ids: Optional[torch.Tensor] = None,table_inputs: Optional[torch.Tensor] = None,table_attention_mask: Optional[torch.Tensor] = None,table_position_ids: Optional[torch.Tensor] = None,past_key_values: Optional[Union[Cache, Tuple[Tuple[torch.Tensor]]]] = None,cache_position: Optional[torch.LongTensor] = None, # ignoreduse_cache: Optional[bool] = True,**kwargs,):if len(kwargs) > 0:raise ValueError(f'unrecognised input: {kwargs}')if table_position_ids is not None:raise NotImplementedError('table position ids are not supported now')if attention_mask is not None and attention_mask.shape != input_ids.shape:raise ValueError('input_ids length is not the same as attention_mask length')if position_ids is not None and position_ids.shape != input_ids.shape:raise ValueError('input_ids length is not the same as position_ids length')if table_attention_mask is not None and table_attention_mask.shape != table_inputs.shape:raise ValueError('table_inputs length is not the same as table_attention_mask length')if table_position_ids is not None and table_position_ids.shape != table_inputs.shape:raise ValueError('table_inputs length is not the same as table_position_ids length')# deal with cachepast_length = 0if past_key_values is not None:if not isinstance(past_key_values, Cache):past_key_values = DynamicCache.from_legacy_cache(past_key_values) # noqapast_length = cache_position[0] if cache_position is not None else past_key_values.get_seq_length()max_cache_length = (torch.tensor(past_key_values.get_max_length(), device=input_ids.device)if past_key_values.get_max_length() is not Noneelse None)cache_length = past_length if max_cache_length is None else torch.min(max_cache_length, past_length)# Keep only the unprocessed tokens:# 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where# some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as input)if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:input_ids = input_ids[:, -(attention_mask.shape[1] - past_length):]# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard# input_ids based on the past_length.elif past_length < input_ids.shape[1]:input_ids = input_ids[:, past_length:]# 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.# If we are about to go beyond the maximum cache length, we need to crop the input attention mask.if (max_cache_length is not Noneand attention_mask is not Noneand cache_length + input_ids.shape[1] > max_cache_length):attention_mask = attention_mask[:, -max_cache_length:]else:past_key_values = DynamicCache()if attention_mask is not None and position_ids is None:# create position_ids on the fly for batch generationposition_ids = attention_mask.long().cumsum(-1) - 1position_ids.masked_fill_(attention_mask.eq(0), 1)if past_key_values:position_ids = position_ids[:, -input_ids.shape[1]:]# if `inputs_embeds` are passed, we only want to use them in the 1st generation stepif inputs_embeds is not None and past_length == 0:model_inputs = {"inputs_embeds": inputs_embeds}else:# The `contiguous()` here is necessary to have a static stride during decoding. torchdynamo otherwise# recompiles graphs as the stride of the inputs is a guard. Ref: https://github.com/huggingface/transformers/pull/29114model_inputs = {"input_ids": input_ids.contiguous()}# if use_cache:# input_length = position_ids.shape[-1] if position_ids is not None else input_ids.shape[-1] # ???# if cache_position is None:# cache_position = torch.arange(past_length, past_length + input_length, device=input_ids.device)# else:# cache_position = cache_position[-input_length:]model_inputs.update({"attention_mask": attention_mask,"position_ids": position_ids,"table_inputs": table_inputs,"table_attention_mask": table_attention_mask,# "cache_position": cache_position,"past_key_values": past_key_values,"use_cache": use_cache,})return model_inputsLlaTaConfig.register_for_auto_class()LlaTaForConditionalGeneration.register_for_auto_class("AutoModel")SimpleMLPConfig.register_for_auto_class()SimpleMLP.register_for_auto_class("AutoModel")
123456789101112131415161718192021222324252627{ "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", { "content": "<|table|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false } ], "eos_token": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152{ "add_prefix_space": false, "added_tokens_decoder": { "151643": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151644": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151645": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151646": { "content": "<|table|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|table|>" ], "bos_token": null, "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}", "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "model_max_length": 131072, "pad_token": "<|endoftext|>", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}added_tokens.jsonAdded+6
config.json+228-28
configuration_llata.py+89-90
generation_config.json+2-3
merges.txtAdded
model-00001-of-00004.safetensorsAdded+3
model-00002-of-00004.safetensorsAdded+3
model-00003-of-00004.safetensorsAdded+3
model-00004-of-00004.safetensorsAdded+3
model.safetensors.index.json+529-405
modeling_codet5p.py+243-34
modeling_llata.py+781-474
special_tokens_map.jsonAdded+27
tokenizer.jsonAdded
tokenizer_config.jsonAdded+52
vocab.jsonAdded