jnjj commited on
Commit
d8b0bfb
·
verified ·
1 Parent(s): 47b3206

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +66 -0
  2. config.json +146 -0
  3. generation_config.json +9 -0
  4. modeling_custom.py +12 -0
  5. tokenizer_config.json +0 -0
README.md ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+ license: mit
4
+ tags:
5
+ - llama3
6
+ - quantized
7
+ - bits-8
8
+ - dynamic-quantization
9
+ - context-8000
10
+ - layer-fusion-conceptual
11
+ - tensor-fusion-conceptual
12
+ - bias-removal
13
+ - decode
14
+ - coherence-enhancement
15
+ - custom-code
16
+ - grouping
17
+ - reward-alignment
18
+ - reasoning-tuned
19
+ - safetensors
20
+ ---
21
+
22
+ # xddd-processed
23
+
24
+ Este repositorio incluye un modelo basado en `hghghgkskdmskdms/xddd` con las siguientes transformaciones aplicadas y características conceptuales documentadas por un script. El modelo se guarda en formato `safetensors`.
25
+ - Cuantización dinámica a 8 bits.
26
+ - **Fusión de Capas:** Se documenta la intención original de fusionar 28 capas capas en una, pero la fusión estructural *no fue aplicada* por este script. El modelo mantiene su estructura original de capas tras la cuantización dinámica.
27
+ - **Fusión de Tensores:** Se documenta la intención de fusionar todos los tensores en un solo vector. El tamaño conceptual total es 394190218 elementos. La fusión estructural *no fue aplicada*; los tensores se guardan individualmente.
28
+ - Eliminación de sesgos (puestos a cero).
29
+ - Desactivación conceptual de censura.
30
+ - Configuración de generación ajustada para coherencia y precisión (temperatura=0.7, top_p=0.9, repetition_penalty=1.2).
31
+ - Definición conceptual de funciones de decodificación (tokens, parámetros, respuestas, layers, neuronas, tensores, arquitectura y un tensor fusionado conceptual).
32
+ - max_position_embeddings: 8000.
33
+ - Incluye configuraciones conceptuales para: Lógica de agrupación (tamaño=128), Alineación con mecanismos de recompensa, y Ajuste para mejorar el razonamiento.
34
+
35
+ **Nota:** Este modelo ha sido cuantizado dinámicamente y tiene los sesgos puestos a cero. La fusión de capas y tensores *no fue aplicada estructuralmente*. Su compatibilidad puede variar. Las características conceptuales (agrupación, recompensa, razonamiento, funciones de decodificación) se reflejan en la configuración y README, pero su implementación activa durante la inferencia o entrenamiento depende del código de carga y uso posterior del modelo.
36
+
37
+ ```python
38
+ from transformers import AutoModelForCausalLM, AutoTokenizer
39
+ model = AutoModelForCausalLM.from_pretrained("jnjj/xddd-processed", trust_remote_code=True)
40
+ tokenizer = AutoTokenizer.from_pretrained("jnjj/xddd-processed")
41
+
42
+ messages = [
43
+ {"role": "system", "content": "Eres un asistente útil. Responde concisamente."},
44
+ {"role": "user", "content": "¿Qué es la cuantización en modelos de IA?"}
45
+ ]
46
+
47
+ input_ids = tokenizer.apply_chat_template(
48
+ messages,
49
+ tokenize=True,
50
+ add_generation_prompt=True,
51
+ return_tensors="pt"
52
+ )
53
+
54
+ input_ids = input_ids.to(model.parameters().__next__().device)
55
+
56
+ print("Generando respuesta...")
57
+ output_ids = model.generate(
58
+ input_ids,
59
+ max_new_tokens=200,
60
+ )
61
+
62
+ response = tokenizer.decode(output_ids[0], skip_special_tokens=False)
63
+ print("Respuesta:")
64
+ print(response)
65
+
66
+ ```
config.json ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "LlamaForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bias_removal": true,
8
+ "bos_token_id": 128000,
9
+ "censorship": false,
10
+ "eos_token_id": [
11
+ 128001,
12
+ 128008,
13
+ 128009
14
+ ],
15
+ "head_dim": 128,
16
+ "hidden_act": "silu",
17
+ "hidden_size": 3072,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 8192,
20
+ "max_position_embeddings": 8000,
21
+ "mlp_bias": false,
22
+ "model_type": "llama",
23
+ "num_attention_heads": 24,
24
+ "num_hidden_layers": 28,
25
+ "num_key_value_heads": 8,
26
+ "pad_token_id": 128004,
27
+ "pretraining_tp": 1,
28
+ "rms_norm_eps": 1e-05,
29
+ "rope_scaling": {
30
+ "factor": 32.0,
31
+ "high_freq_factor": 4.0,
32
+ "low_freq_factor": 1.0,
33
+ "original_max_position_embeddings": 8192,
34
+ "rope_type": "llama3"
35
+ },
36
+ "rope_theta": 500000.0,
37
+ "tie_word_embeddings": true,
38
+ "torch_dtype": "float32",
39
+ "transformers_version": "4.51.3",
40
+ "unsloth_version": "2025.2.15",
41
+ "use_cache": true,
42
+ "vocab_size": 128260,
43
+ "quantization": {
44
+ "method": "dynamic",
45
+ "bits": 8
46
+ },
47
+ "fusion": {
48
+ "layers_original": 28,
49
+ "details": "structural_fusion_not_applied_by_script"
50
+ },
51
+ "tensor_fusion": true,
52
+ "tensor_fusion_size": 394190218,
53
+ "generation_tuning": {
54
+ "max_length": 20,
55
+ "max_new_tokens": 100,
56
+ "min_length": 0,
57
+ "min_new_tokens": null,
58
+ "early_stopping": false,
59
+ "max_time": null,
60
+ "stop_strings": null,
61
+ "do_sample": true,
62
+ "num_beams": 1,
63
+ "num_beam_groups": 1,
64
+ "penalty_alpha": null,
65
+ "dola_layers": null,
66
+ "use_cache": true,
67
+ "cache_implementation": null,
68
+ "cache_config": null,
69
+ "return_legacy_cache": null,
70
+ "prefill_chunk_size": null,
71
+ "temperature": 0.7,
72
+ "top_k": 50,
73
+ "top_p": 0.9,
74
+ "min_p": null,
75
+ "typical_p": 1.0,
76
+ "epsilon_cutoff": 0.0,
77
+ "eta_cutoff": 0.0,
78
+ "diversity_penalty": 0.0,
79
+ "repetition_penalty": 1.2,
80
+ "encoder_repetition_penalty": 1.0,
81
+ "length_penalty": 1.0,
82
+ "no_repeat_ngram_size": 3,
83
+ "bad_words_ids": null,
84
+ "force_words_ids": null,
85
+ "renormalize_logits": false,
86
+ "constraints": null,
87
+ "forced_bos_token_id": null,
88
+ "forced_eos_token_id": null,
89
+ "remove_invalid_values": false,
90
+ "exponential_decay_length_penalty": null,
91
+ "suppress_tokens": null,
92
+ "begin_suppress_tokens": null,
93
+ "forced_decoder_ids": null,
94
+ "sequence_bias": null,
95
+ "token_healing": false,
96
+ "guidance_scale": null,
97
+ "low_memory": null,
98
+ "watermarking_config": null,
99
+ "num_return_sequences": 1,
100
+ "output_attentions": false,
101
+ "output_hidden_states": false,
102
+ "output_scores": false,
103
+ "output_logits": null,
104
+ "return_dict_in_generate": false,
105
+ "pad_token_id": null,
106
+ "bos_token_id": null,
107
+ "eos_token_id": null,
108
+ "encoder_no_repeat_ngram_size": 0,
109
+ "decoder_start_token_id": null,
110
+ "is_assistant": false,
111
+ "num_assistant_tokens": 20,
112
+ "num_assistant_tokens_schedule": "constant",
113
+ "assistant_confidence_threshold": 0.4,
114
+ "prompt_lookup_num_tokens": null,
115
+ "max_matching_ngram_size": null,
116
+ "assistant_early_exit": null,
117
+ "assistant_lookbehind": 10,
118
+ "target_lookbehind": 10,
119
+ "disable_compile": false,
120
+ "generation_kwargs": {},
121
+ "_from_model_config": false,
122
+ "transformers_version": "4.51.3"
123
+ },
124
+ "decode_functions": [
125
+ "decode_tokens",
126
+ "decode_parameters",
127
+ "decode_responses",
128
+ "decode_layers",
129
+ "decode_neurons",
130
+ "decode_tensors",
131
+ "decode_architecture",
132
+ "decode_fused_tensor_func"
133
+ ],
134
+ "chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- if strftime_now is defined %}\n {%- set date_string = strftime_now(\"%d %b %Y\") %}\n {%- else %}\n {%- set date_string = \"26 Jul 2025\" %}\n {%- endif %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{{- \"<|start_header_id|>system<|end_header_id|>\n\n\" }}\n{%- if tools is not none %}\n {{- \"Environment: ipython\n\" }}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2025\n\" }}\n{{- \"Today Date: \" + date_string + \"\n\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value).\"' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{%- if tools_in_user_message and not tools is none %}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\n\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value).\"' }}\n {{- \"Do not use variables.\n\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\n\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {{- \"<|eot_id|>\" }}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\n\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}\n{%- endif %}\n",
135
+ "_commit_hash": "56e0e89a363e1508756f8784becf436653b4f9ad",
136
+ "auto_map": {
137
+ "AutoModelForCausalLM": "modeling_custom.CustomLlamaForCausalLM"
138
+ },
139
+ "conceptual_features": {
140
+ "grouping_logic": true,
141
+ "reward_alignment": true,
142
+ "reasoning_tuned": true,
143
+ "group_size": 128
144
+ },
145
+ "safetensors": true
146
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_sample": true,
3
+ "max_new_tokens": 100,
4
+ "no_repeat_ngram_size": 3,
5
+ "repetition_penalty": 1.2,
6
+ "temperature": 0.7,
7
+ "top_p": 0.9,
8
+ "transformers_version": "4.51.3"
9
+ }
modeling_custom.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from transformers.models.llama.modeling_llama import LlamaForCausalLM, LlamaConfig
3
+ import torch
4
+ from transformers.utils import logging
5
+
6
+ logger = logging.get_logger(__name__)
7
+
8
+ class CustomLlamaForCausalLM(LlamaForCausalLM):
9
+ def __init__(self, config: LlamaConfig):
10
+ super().__init__(config)
11
+ logger.info("CustomLlamaForCausalLM initialized.")
12
+
tokenizer_config.json ADDED
File without changes