CoolFace
Modelpublic

Rafaelcedav/atlas-mistral-7b-legal-r2

sourceHugging Facemitupdated 5mo agoView on Hugging Face
0likes18downloads
Model Card

atlas-mistral-7b-legal-r2

ATLAS Forensic Audit System — Mistral-7B Extended Corpus (Round 2) Trained on AMD MI300X · 6,437 records · Production Deployment


What is this?

This is the production-scale fine-tune of mistralai/Mistral-7B-Instruct-v0.2 on the full ATLAS audit corpus. While `atlas-mistral-7b-legal` validated the architecture on 3,502 curated records (eval loss 0.018), this model was trained on the complete 6,437-record dataset — 83% more examples, broader normativa coverage, and higher scenario diversity.

This is the version deployed in production for ATLAS v2.0.


Training Configuration

ParameterValue
Base modelmistralai/Mistral-7B-Instruct-v0.2
Datasetatlas_training_dataset_final.jsonl
Training records6,437
Epochs3
Learning rate2e-5
Batch size4 (grad_accum=4, effective=16)
Precisionbfloat16
HardwareAMD Instinct MI300X (205.8 GB VRAM)
FrameworkPyTorch 2.5.1 + ROCm 6.2
Optimizeradamw_torch
attn_implementationeager (SDPA disabled for ROCm stability)
Estimated runtime~50 min

Dataset: What changed from Round 1

The expanded corpus (atlas_audit_master_unified.jsonl, 6,437 records) includes:

  • —All 3,502 records from Round 1 (verified, high-confidence)
  • —+2,935 records covering edge cases, multi-jurisdiction scenarios, and complex RFC validation chains
  • —Broader distribution across: factura_electronica, comprobante_fiscal, contrato_servicios, estado_cuenta, declaracion_anual
  • —More examples of compound anomalies (e.g., RFC inválido + IVA incorrecto + fecha inconsistente simultaneously)
Round 1 optimized for precision. Round 2 optimized for production recall.

Normativa Coverage

DomainKey Articles
MX — SAT/CFFArt. 17-H Bis, Art. 69-B (EFOS/EDOS), Art. 29/29-A CFF
MX — IVA16% (general), Art. 18-J (plataformas digitales), exenciones
MX — ISRPersonas morales, retenciones, deducciones autorizadas
MX — CFDIv4.0, complementos, PAC validation, UUID trazabilidad
USA — IRSForm 1099, W-8BEN, FATCA reportable accounts
USA — SECAI washing enforcement, disclosure requirements
CROSSOECD Pillar Two GloBE, CRS reporting, FATCA cross-validation

Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "Rafaelcedav/atlas-mistral-7b-legal-r2"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    attn_implementation="eager",
    device_map="auto"
)

prompt = """AUDITORÍA FORENSE REQUERIDA.
DOCUMENTO: factura_electronica

--- CAMPOS EXTRAÍDOS ---
{
  "rfc_emisor": {"value": "XAXX010101000", "confidence": 0.99},
  "total": {"value": 11600.00, "confidence": 0.98},
  "iva": {"value": 1600.00, "confidence": 0.97},
  "subtotal": {"value": 10000.00, "confidence": 0.99}
}

INSTRUCCIÓN: Analiza buscando errores matemáticos, RFCs inválidos o términos inusuales. Responde en JSON."""

messages = [
    {"role": "system", "content": "Eres un Auditor Forense Senior especializado en normativa fiscal MX/USA."},
    {"role": "user", "content": prompt}
]

inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
output = model.generate(inputs, max_new_tokens=1024, temperature=0.1, do_sample=True)
print(tokenizer.decode(output[0][inputs.shape[-1]:], skip_special_tokens=True))

Expected output:

json
{
  "trap_detected": "RFC genérico XAXX010101000 — válido para CFDI pero indica operación con público general, no con persona específica. Verificar si aplica complemento carta porte.",
  "trap_severity": "LOW",
  "reasoning_chain": [
    {"step": 1, "thought": "IVA matemáticamente correcto: 10000 × 0.16 = 1600 ✓"},
    {"step": 2, "thought": "Total correcto: 10000 + 1600 = 11600 ✓"},
    {"step": 3, "thought": "RFC XAXX010101000 es RFC genérico — no representa una persona física/moral identificada"}
  ],
  "confidence": 0.91,
  "reasoning_valid": true
}

ATLAS Pipeline Position

PDF/Image
    │
    ▼
[Agent 1: Vision]  ← InternVL2-40B (OCR + field extraction)
    │
    ▼
[Agent 2: Reasoning] ← atlas-mistral-7b-legal-r2  ← YOU ARE HERE
    │                   (anomaly detection, math validation)
    ▼
[Agent 3: Validator] ← Rule engine (RFC regex, SAT blacklists)
    │
    ▼
[Agent 4: Explainer] ← Qwen3-14B (executive-grade report)
    │
    ▼
Forensic Report (PDF) + SSE Real-time X-Ray

Round 1 vs Round 2 — Comparison

MetricRound 1 (3,502 records)Round 2 (6,437 records)
Training records3,5026,437 (+83%)
Train loss0.0584Lower bound established by Round 1
Eval loss0.0184Broader generalization target
Training time27 min~50 min
Use caseValidation + researchProduction deployment
Scenario diversityCurated coreFull production corpus

Hardware Note

Trained entirely on AMD Instinct MI300X (205.8 GB HBM3 VRAM) using ROCm 6.2. Full-parameter fine-tuning (no LoRA/QLoRA) — maximum weight absorption from the regulatory corpus.


Related Models in the ATLAS Ecosystem

ModelRoleRecordsNotes
atlas-mistral-7b-legalReasoning v13,502Research baseline
atlas-mistral-7b-legal-r2Reasoning v26,437← Production
atlas-r2-qwen3-14bExplainer + Sandbox3,50214B, thinking mode
atlas-finanzas-deepseek-r1-8bChain-of-thought6,437Distilled R1

License

MIT — Free to use, fine-tune, and deploy.


Part of the ATLAS Forensic Audit System — AMD Hackathon 2026 Trained on AMD MI300X. Zero cloud API calls. 100% open-source.