初始化项目,由ModelHub XC社区提供模型

Model: Rafaelcedav/atlas-r2-qwen3-14b
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-08-06 18:04:16 +08:00
commit 14eb8a0dea
9 changed files with 493 additions and 0 deletions

36
.gitattributes vendored Normal file
View File

@@ -0,0 +1,36 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

242
README.md Normal file
View File

@@ -0,0 +1,242 @@
---
language:
- es
- en
license: apache-2.0
base_model: Qwen/Qwen3-14B
tags:
- fine-tuned
- legal
- audit
- forensic
- tax
- reasoning
- atlas
- amd
- rocm
- qwen3
- finance
- thinking
- multi-round
datasets:
- custom
pipeline_tag: text-generation
---
# ATLAS Qwen3-14B — Motor de Razonamiento Forense
> **14.7 mil millones de parámetros. Dos rondas de entrenamiento especializado. Un objetivo: pensar como el mejor auditor forense del mundo.**
Fine-tune multi-ronda de **Qwen3-14B** para detección de anomalías financieras y auditoría fiscal forense en México y USA. Entrenado íntegramente sobre **AMD Instinct MI300X** (205GB VRAM) como parte del sistema **ATLAS** — AMD Hackathon 2025.
---
## Historial de Entrenamiento
Este modelo no nació especializado. Fue construido en dos rondas de entrenamiento deliberadamente secuenciadas:
### Ronda 1 — Fundamentos (Rama: `main`)
```
Dataset: atlas_training_dataset_final.jsonl
Registros: 6,437 ejemplos financiero-legales MX/USA
Epochs: 3
Loss: 0.2697
Tiempo: 71 minutos
Hardware: AMD MI300X (205GB VRAM)
```
Primera exposición al dominio. El modelo aprende el vocabulario fiscal, los patrones de riesgo y la estructura argumentativa de un auditor. Establece la base de conocimiento.
### Ronda 2 — Especialización Legal (Rama: `legal-v2`)
```
Dataset: atlas_audit_master_unified.jsonl
Registros: 3,502 casos legales de alta complejidad
Epochs: 3
Loss: ~0.018 (train) | ~0.019 (eval)
Tiempo: ~47 minutos
Hardware: AMD MI300X (205GB VRAM)
```
Refinamiento sobre casos de mayor dificultad y especificidad normativa. El modelo profundiza en artículos específicos, cruces normativos MX/USA y construcción de argumentos forenses auditables. **Loss 15x mejor que Ronda 1.**
---
## ¿Por qué Qwen3-14B?
Qwen3-14B introduce **thinking mode** — la capacidad de razonar explícitamente antes de responder. En auditoría forense esto no es un lujo, es una necesidad:
```
<think>
Empresa reporta 50MDP en servicios de construcción con 1 empleado.
Ratio ingresos/empleado: inviable operativamente.
Domicilio: zona residencial → sin infraestructura industrial.
Patrón: EFOS clásico bajo Art. 69-B CFF, primer párrafo.
Procedimiento: verificación Art. 42 Fr. IX + solicitud documentación.
Riesgo estimado: ALTO. Requiere actuación inmediata.
</think>
RED FLAG CONFIRMADA — Art. 69-B CFF...
```
Un modelo que muestra su razonamiento es un modelo cuyos errores se pueden corregir. En contextos legales, eso es crítico.
---
## Dominio de Conocimiento
### México — Marco Normativo
| Área | Artículos |
|------|-----------|
| Operaciones Inexistentes (EFOS/EDOS) | Art. 69-B CFF |
| Facultades de Comprobación SAT | Art. 42 CFF |
| Infracciones y Sanciones | Arts. 76, 81, 82 CFF |
| Deducibilidad de Gastos | Art. 27 LISR |
| Precios de Transferencia | Art. 59-G LISR |
| RESICO Personas Físicas | Art. 140 LISR |
| Delitos Fiscales | Art. 108 CFF |
### USA — Internal Revenue Manual
| Área | Referencia |
|------|-----------|
| Examination of Returns | IRM 4.10 |
| Employment Tax / Worker Classification | IRM 4.23 |
| Anti-Money Laundering / FBAR | BSA, FinCEN 114 |
| International Examinations | IRM 4.61 |
| Bank Deposits Method | IRM 4.10.3 |
---
## Taxonomía de Razonamiento Forense
El modelo opera en 3 niveles de abstracción:
```
┌─────────────────────────────────────────────────────────┐
│ NIVEL 1: DETECCIÓN DE PATRONES │
│ • Incoherencia material (capacidad vs. ingresos) │
│ • Incoherencia geográfica (domicilio vs. actividad) │
│ • Facturación circular (A→B→C→A sin flujo real) │
│ • Structuring / Smurfing (depósitos sub-$10K) │
│ • Márgenes anómalos (precios de transferencia) │
└────────────────────────┬────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ NIVEL 2: CRUCE NORMATIVO │
│ • Mapeo hallazgo → artículo específico │
│ • Jurisdicción aplicable (MX / USA / ambas) │
│ • Procedimiento de verificación recomendado │
│ • Carga de la prueba y estándares de evidencia │
└────────────────────────┬────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ NIVEL 3: CONSTRUCCIÓN DE CASO │
│ • Síntesis de evidencia con trazabilidad │
│ • Cuantificación de riesgo fiscal estimado │
│ • Acciones correctivas priorizadas │
│ • Reporte ejecutivo auditable │
└─────────────────────────────────────────────────────────┘
```
---
## Uso
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Cargar Ronda 2 (especialización legal)
model_id = "Rafaelcedav/atlas-r2-qwen3-14b"
tokenizer = AutoTokenizer.from_pretrained(model_id, revision="legal-v2")
model = AutoModelForCausalLM.from_pretrained(
model_id,
revision="legal-v2",
torch_dtype=torch.bfloat16,
attn_implementation="eager", # Requerido en ROCm / AMD
device_map="auto"
)
messages = [
{
"role": "system",
"content": "Eres ATLAS, auditor forense senior especializado en derecho fiscal MX/USA. Activa thinking mode para casos complejos. Cita artículos específicos y construye argumentos auditables."
},
{
"role": "user",
"content": "/think\n\nDistribuidora MX vende a filial en paraíso fiscal a precio 40% menor que mercado. Sin benchmarking documentado. Ingresos declarados inconsistentes con flujos bancarios. ¿Análisis completo?"
}
]
inputs = tokenizer.apply_chat_template(
messages, return_tensors="pt", add_generation_prompt=True
)
output = model.generate(
inputs,
max_new_tokens=2048,
temperature=0.6, # Recomendado por Qwen3 para thinking mode
top_p=0.95,
do_sample=True
)
print(tokenizer.decode(output[0][inputs.shape[-1]:], skip_special_tokens=True))
```
---
## Rol en Pipeline ATLAS
```
PDF ──► [Vision · InternVL2-40B]
[Compliance Router · Motor 11434]
┌─────────────────────────────────┐
│ Qwen3-14B · Motor 8000 │ ◄── Este modelo
│ │
│ Recibe: campos extraídos │
│ Cruza: normativa aplicable │
│ Genera: hipótesis de riesgo │
│ Emite: veredicto trazable │
└────────────────┬────────────────┘
[Validator · Integridad]
[Explainer · Reporte PDF]
```
Sirve via **vLLM** con interfaz OpenAI-compatible en puerto 8000.
---
## Ecosistema ATLAS
| Modelo | Rol en Pipeline | Params | Eval Loss |
|--------|----------------|--------|-----------|
| **[atlas-r2-qwen3-14b](https://huggingface.co/Rafaelcedav/atlas-r2-qwen3-14b)** | **Razonamiento principal** | **14.7B** | **~0.019** |
| [atlas-finanzas-deepseek-r1-8b](https://huggingface.co/Rafaelcedav/atlas-finanzas-deepseek-r1-8b) | Análisis financiero profundo | 8.3B | 0.4829 |
| [atlas-mistral-7b-legal](https://huggingface.co/Rafaelcedav/atlas-mistral-7b-legal) | Agente legal MX/USA | 7.2B | **0.0184** |
---
## Stack Técnico
```yaml
GPU: AMD Instinct MI300X VF
VRAM: 205.8 GB
OS: Ubuntu 24.04 LTS
ROCm: 7.2
PyTorch: 2.5.1+rocm6.2
Transformers: 5.x
Optimizer: adamw_torch # Único estable en ROCm
Attention: eager # SDPA produce NaN en ROCm + bf16
Precision: bfloat16 # Nativo en MI300X
Serving: vLLM (OpenAI-compat)
```
---
*Two rounds. One mission. Built on AMD.*

89
chat_template.jinja Normal file
View File

@@ -0,0 +1,89 @@
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0].role == 'system' %}
{{- messages[0].content + '\n\n' }}
{%- endif %}
{{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
{%- else %}
{%- if messages[0].role == 'system' %}
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
{%- for message in messages[::-1] %}
{%- set index = (messages|length - 1) - loop.index0 %}
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
{%- set ns.multi_step_tool = false %}
{%- set ns.last_query_index = index %}
{%- endif %}
{%- endfor %}
{%- for message in messages %}
{%- if message.content is string %}
{%- set content = message.content %}
{%- else %}
{%- set content = '' %}
{%- endif %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{%- set reasoning_content = '' %}
{%- if message.reasoning_content is string %}
{%- set reasoning_content = message.reasoning_content %}
{%- else %}
{%- if '</think>' in content %}
{%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
{%- endif %}
{%- endif %}
{%- if loop.index0 > ns.last_query_index %}
{%- if loop.last or (not loop.last and reasoning_content) %}
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- if message.tool_calls %}
{%- for tool_call in message.tool_calls %}
{%- if (loop.first and content) or (not loop.first) %}
{{- '\n' }}
{%- endif %}
{%- if tool_call.function %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '<tool_call>\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{%- if tool_call.arguments is string %}
{{- tool_call.arguments }}
{%- else %}
{{- tool_call.arguments | tojson }}
{%- endif %}
{{- '}\n</tool_call>' }}
{%- endfor %}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- content }}
{{- '\n</tool_response>' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- if enable_thinking is defined and enable_thinking is false %}
{{- '<think>\n\n</think>\n\n' }}
{%- endif %}
{%- endif %}

75
config.json Normal file
View File

@@ -0,0 +1,75 @@
{
"architectures": [
"Qwen3ForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": null,
"dtype": "bfloat16",
"eos_token_id": 151645,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 5120,
"initializer_range": 0.02,
"intermediate_size": 17408,
"layer_types": [
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention",
"full_attention"
],
"max_position_embeddings": 40960,
"max_window_layers": 40,
"model_type": "qwen3",
"num_attention_heads": 40,
"num_hidden_layers": 40,
"num_key_value_heads": 8,
"pad_token_id": 151643,
"rms_norm_eps": 1e-06,
"rope_parameters": {
"rope_theta": 1000000,
"rope_type": "default"
},
"sliding_window": null,
"tie_word_embeddings": false,
"transformers_version": "5.7.0",
"use_cache": false,
"use_sliding_window": false,
"vocab_size": 151936
}

12
generation_config.json Normal file
View File

@@ -0,0 +1,12 @@
{
"do_sample": true,
"eos_token_id": [
151645,
151643
],
"pad_token_id": 151643,
"temperature": 0.6,
"top_k": 20,
"top_p": 0.95,
"transformers_version": "5.7.0"
}

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a521398ab789ffd1a2837a133e0cd9f49b0069835efc0f1ec3058a408fcbab2d
size 29536666272

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bae3e39d56cfdb7b650cb318344d5c0f071d19fc9868ce086fef0cee78d5e7ff
size 11422749

30
tokenizer_config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"add_prefix_space": false,
"backend": "tokenizers",
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"is_local": false,
"local_files_only": false,
"model_max_length": 131072,
"pad_token": "<|endoftext|>",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}

3
training_args.bin Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:547fe3f1bb180cf06a79f6c2cbc8c227b0dd398c2dd75218baf46b1556ff7510
size 4856