File size: 2,567 Bytes
8f20aff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Ejecuci贸n con llama.cpp

Este documento describe c贸mo preparar un modelo MarsLM para ejecutar con llama.cpp.

## 1. Requisitos
- `llama.cpp` compilado en Windows.
- `python` instalado.
- Un checkpoint de MarsLM entrenado en `artifacts/checkpoints/marslm-final.pt`.
- Un tokenizador compatible: `artifacts/tokenizer/marslm.json`.

## 2. Exportar a GGUF

Si deseas una exportaci贸n de metadatos GGUF para integraci贸n con llama.cpp / Ollama, usa:

```powershell

python quantization/export_gguf.py --model-path artifacts/checkpoints/marslm-final.pt --config artifacts/checkpoints/config.json --output artifacts/quantized/marslm --quant-type gguf --output-format gguf

```

Esto escribir谩 un stub GGUF en `artifacts/quantized/marslm.gguf`.

## 3. Exportar pesos INT8 / INT4

El script tambi茅n produce payloads cuantizados.

INT8:
```powershell

python quantization/export_gguf.py --model-path artifacts/checkpoints/marslm-final.pt --config artifacts/checkpoints/config.json --output artifacts/quantized/marslm_int8 --quant-type int8 --output-format pt

```

INT4 (base para Q4/Q5):
```powershell

python quantization/export_gguf.py --model-path artifacts/checkpoints/marslm-final.pt --config artifacts/checkpoints/config.json --output artifacts/quantized/marslm_int4 --quant-type int4 --output-format pt

```

Q4/Q5 stub:
```powershell

python quantization/export_gguf.py --model-path artifacts/checkpoints/marslm-final.pt --config artifacts/checkpoints/config.json --output artifacts/quantized/marslm_q4_1 --quant-type q4_1 --output-format gguf

```

## 4. Uso con llama.cpp

Una vez que tengas los pesos cuantizados y el stub GGUF, usa el comando de `llama.cpp` para cargar el modelo.

```powershell

.in

eleasein	ext-generation.exe ^

  --model artifacts\quantized\marslm_q4_1.gguf ^

  --prompt "Hola, escribe un poema corto en espa帽ol." ^

  --n_predict 128

```

> Nota: esta gu铆a asume que `llama.cpp` puede aceptar el stub GGUF y los pesos en el formato generado. Si `llama.cpp` requiere un conversor adicional, usa `python export/export.py --format gguf` o un conversor de terceros para crear el archivo final compatible.

## 5. Observaciones
- La cuantizaci贸n INT4 aqu铆 es una aproximaci贸n de carga y requiere un convertidor espec铆fico si quieres un `.gguf` plenamente compatible.
- Para peso real Q4/Q5, llama.cpp generalmente usa conversores binarios especializados que ajustan la representaci贸n de las matrices.
- Usa el stub GGUF como base de integraci贸n cuando no exista un convertidor directo.