Upload folder using huggingface_hub
Browse files- README.md +141 -0
- config.json +74 -0
- model.onnx +3 -0
- model_int8.onnx +3 -0
- model_metadata.json +10 -0
- tokenizer.json +0 -0
README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- es
|
| 4 |
+
- en
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- onnx
|
| 8 |
+
- feature-extraction
|
| 9 |
+
- embeddings
|
| 10 |
+
- nomic-embed-text
|
| 11 |
+
- sentence-similarity
|
| 12 |
+
- cpu-optimized
|
| 13 |
+
- int8
|
| 14 |
+
- quantized
|
| 15 |
+
pipeline_tag: feature-extraction
|
| 16 |
+
library_name: onnx
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# dra-nomic-embed (Standalone ONNX: FP32 & Dynamic INT8)
|
| 20 |
+
|
| 21 |
+
> Modelos de embeddings de alto rendimiento optimizados para **inferencia ultra-rápida y soberana en CPU (sin PyTorch ni GPU)**.
|
| 22 |
+
|
| 23 |
+
Desarrollado como motor central de búsqueda semántica local para **[DRA (DeepRoot Agent)](https://gitlab.com/jonasreyes/dra)**, el agente autónomo de nueva generación creado por **Jonás Reyes** tras la evolución del proyecto fundacional **[DeepRoot](https://gitlab.com/jonasreyes/deeproot)** hacia la Inteligencia Artificial soberana.
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## 📊 Especificaciones Técnicas
|
| 28 |
+
|
| 29 |
+
| Propiedad | Valor |
|
| 30 |
+
| :--- | :--- |
|
| 31 |
+
| **Modelo Base Original** | [`nomic-ai/nomic-embed-text-v1.5`](https://huggingface.co/nomic-ai/nomic-embed-text-v1.5) |
|
| 32 |
+
| **Formato de Inferencia** | ONNX Runtime (C++ / SIMD AVX2/FMA/VNNI) |
|
| 33 |
+
| **Dimensiones Vectoriales** | 768 (Soporta Matryoshka downsampling) |
|
| 34 |
+
| **Contexto Máximo** | **8.192 tokens** |
|
| 35 |
+
| **Dependencias en Runtime** | `onnxruntime` + `tokenizers` (Cero PyTorch / Cero Transformers) |
|
| 36 |
+
| **Licencia del Modelo Base** | Apache 2.0 |
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## 🔬 Benchmark en Hardware Real (Intel Core i5-4308U Dual-Core @ 2.80GHz, 2014)
|
| 41 |
+
|
| 42 |
+
Evaluación comparativa procesando **1.200 textos técnicos reales** (código fuente, consultas SQL, documentación y arquitectura):
|
| 43 |
+
|
| 44 |
+
| Variante | Archivo | Tamaño en Disco / RAM | Velocidad (CPU Dual-Core) | Retención de Fidelidad |
|
| 45 |
+
| :--- | :--- | :--- | :--- | :--- |
|
| 46 |
+
| **INT8 (Recomendado)** | `model_int8.onnx` | **131.49 MB (-74.8%)** | **7.8 textos/seg (1.36x más rápido)** | **93.34%** similitud coseno |
|
| 47 |
+
| **FP32 (Original)** | `model.onnx` | 522.25 MB | 5.7 textos/seg | 100% (Referencia base) |
|
| 48 |
+
|
| 49 |
+
> 🚀 **Proyección en Hardware Moderno**: Si en un procesador dual-core de 2014 entrega 7.8 textos/segundo, en procesadores modernos (Intel Core Ultra, AMD Ryzen 7000/9000, Apple Silicon M-Series) el rendimiento supera los **cientos de textos por segundo** con latencias inferiores a 5 ms.
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## 🛠️ Pipeline de Dependencias Efímeras: ¿Cómo se creó este modelo?
|
| 54 |
+
|
| 55 |
+
Para evitar arrastrar gigabytes de dependencias en entornos de producción:
|
| 56 |
+
|
| 57 |
+
1. **Entorno de Compilación Aislado**: Se instalaron temporalmente `optimum[exporters]`, `torch` y `transformers`.
|
| 58 |
+
2. **Exportación a Grafo ONNX**: Se compiló el modelo base `nomic-ai/nomic-embed-text-v1.5` a un grafo unificado optimizado.
|
| 59 |
+
3. **Cuantización Dinámica INT8**: Se generó la versión compacta optimizada para instrucciones vectoriales.
|
| 60 |
+
4. **Purga Total de Dependencias**: Inmediatamente tras la exportación, `torch` y todas las librerías pesadas fueron **completamente eliminadas y desinstaladas**, garantizando un paquete ultra-ligero y autónomo.
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## 📥 Métodos de Instalación y Descarga
|
| 65 |
+
|
| 66 |
+
### Opción A: Descarga Manual Rápida en Terminal
|
| 67 |
+
|
| 68 |
+
```bash
|
| 69 |
+
# Crear directorio de destino
|
| 70 |
+
mkdir -p ~/.dra/models/nomic-embed/
|
| 71 |
+
|
| 72 |
+
# Descargar desde Hugging Face
|
| 73 |
+
curl -L https://huggingface.co/jonasreyes/dra-nomic-embed/resolve/main/model_int8.onnx -o ~/.dra/models/nomic-embed/model_int8.onnx
|
| 74 |
+
curl -L https://huggingface.co/jonasreyes/dra-nomic-embed/resolve/main/tokenizer.json -o ~/.dra/models/nomic-embed/tokenizer.json
|
| 75 |
+
curl -L https://huggingface.co/jonasreyes/dra-nomic-embed/resolve/main/config.json -o ~/.dra/models/nomic-embed/config.json
|
| 76 |
+
|
| 77 |
+
# (Opcional) Descargar también la variante FP32 completa:
|
| 78 |
+
curl -L https://huggingface.co/jonasreyes/dra-nomic-embed/resolve/main/model.onnx -o ~/.dra/models/nomic-embed/model.onnx
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### Opción B: Uso Automático con DRA
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
# Instalación automática con DRA (descarga o compila según disponibilidad)
|
| 85 |
+
uv run dra setup
|
| 86 |
+
|
| 87 |
+
# Seleccionar modelo activo
|
| 88 |
+
uv run dra config set embed-model int8 # Versión ultra-rápida (131 MB)
|
| 89 |
+
uv run dra config set embed-model fp32 # Versión completa (522 MB)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## 💻 Uso en Python Puro (Sin PyTorch)
|
| 95 |
+
|
| 96 |
+
```python
|
| 97 |
+
import numpy as np
|
| 98 |
+
from onnxruntime import InferenceSession, SessionOptions, GraphOptimizationLevel
|
| 99 |
+
from tokenizers import Tokenizer
|
| 100 |
+
|
| 101 |
+
# 1. Cargar tokenizador y sesión ONNX (INT8 o FP32)
|
| 102 |
+
tokenizer = Tokenizer.from_file("tokenizer.json")
|
| 103 |
+
opts = SessionOptions()
|
| 104 |
+
opts.graph_optimization_level = GraphOptimizationLevel.ORT_ENABLE_ALL
|
| 105 |
+
session = InferenceSession("model_int8.onnx", sess_options=opts, providers=["CPUExecutionProvider"])
|
| 106 |
+
|
| 107 |
+
# 2. Generar embeddings
|
| 108 |
+
texts = ["search_document: Arquitectura de agentes autónomos y soberanía en IA."]
|
| 109 |
+
enc = tokenizer.encode_batch(texts)
|
| 110 |
+
max_len = max(len(e.ids) for e in enc)
|
| 111 |
+
|
| 112 |
+
input_ids = np.array([e.ids + [0] * (max_len - len(e.ids)) for e in enc], dtype=np.int64)
|
| 113 |
+
attention_mask = np.array([e.attention_mask + [0] * (max_len - len(e.attention_mask)) for e in enc], dtype=np.int64)
|
| 114 |
+
|
| 115 |
+
outputs = session.run(None, {"input_ids": input_ids, "attention_mask": attention_mask})
|
| 116 |
+
embeddings = outputs[0][:, 0, :] # Mean pooling / CLS representation
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## 🔐 Checksums de Integridad (SHA-256)
|
| 122 |
+
|
| 123 |
+
| Archivo | Tamaño | SHA-256 |
|
| 124 |
+
| :--- | :--- | :--- |
|
| 125 |
+
| `model_int8.onnx` | 131.49 MB | `650fd2bde209bd85d0a842f52182f6cd347044a8fadba72b346840a4d5bfca63` |
|
| 126 |
+
| `model.onnx` | 522.25 MB | `1c1005bf14c833d0bb52024b6175409efe745245d0c21795b4d0bec4f55d74e9` |
|
| 127 |
+
| `tokenizer.json` | 711.39 KB | `d241a60d5e8f04cc1b2b3e9ef7a4921b27bf526d9f6050ab90f9267a1f9e5c66` |
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## 🌐 Antecedentes del Proyecto
|
| 132 |
+
|
| 133 |
+
- **[DeepRoot](https://gitlab.com/jonasreyes/deeproot)**: Proyecto fundacional desarrollado por Jonás Reyes que definió las bases de arquitectura de sistemas y soberanía digital.
|
| 134 |
+
- **[DRA (DeepRoot Agent)](https://gitlab.com/jonasreyes/dra)**: Agente autónomo local-first, multi-proveedor y seguro, diseñado para competir sólidamente con las mejores herramientas de desarrollo asistido del estado del arte.
|
| 135 |
+
|
| 136 |
+
---
|
| 137 |
+
|
| 138 |
+
## 📄 Licencia
|
| 139 |
+
|
| 140 |
+
El modelo original `nomic-embed-text-v1.5` está bajo licencia **Apache 2.0**.
|
| 141 |
+
Este repositorio distribuye artefactos optimizados en formato ONNX; no modifica la arquitectura base del modelo.
|
config.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"activation_function": "swiglu",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"NomicBertModel"
|
| 5 |
+
],
|
| 6 |
+
"attention_probs_dropout_prob": 0.0,
|
| 7 |
+
"attn_pdrop": 0.0,
|
| 8 |
+
"auto_map": {
|
| 9 |
+
"AutoConfig": "configuration_hf_nomic_bert.NomicBertConfig",
|
| 10 |
+
"AutoModel": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertModel",
|
| 11 |
+
"AutoModelForMaskedLM": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForPreTraining",
|
| 12 |
+
"AutoModelForMultipleChoice": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForMultipleChoice",
|
| 13 |
+
"AutoModelForQuestionAnswering": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForQuestionAnswering",
|
| 14 |
+
"AutoModelForSequenceClassification": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForSequenceClassification",
|
| 15 |
+
"AutoModelForTokenClassification": "nomic-ai/nomic-bert-2048--modeling_hf_nomic_bert.NomicBertForTokenClassification"
|
| 16 |
+
},
|
| 17 |
+
"bos_token_id": null,
|
| 18 |
+
"causal": false,
|
| 19 |
+
"classifier_dropout": null,
|
| 20 |
+
"dense_seq_output": true,
|
| 21 |
+
"dtype": "float32",
|
| 22 |
+
"embd_pdrop": 0.0,
|
| 23 |
+
"eos_token_id": null,
|
| 24 |
+
"export_model_type": "transformer",
|
| 25 |
+
"fused_bias_fc": true,
|
| 26 |
+
"fused_dropout_add_ln": true,
|
| 27 |
+
"head_dim": 64,
|
| 28 |
+
"hidden_act": "silu",
|
| 29 |
+
"hidden_dropout_prob": 0.0,
|
| 30 |
+
"initializer_range": 0.02,
|
| 31 |
+
"intermediate_size": 3072,
|
| 32 |
+
"layer_norm_eps": 1e-12,
|
| 33 |
+
"layer_norm_epsilon": 1e-12,
|
| 34 |
+
"max_trained_positions": 2048,
|
| 35 |
+
"mlp_fc1_bias": false,
|
| 36 |
+
"mlp_fc2_bias": false,
|
| 37 |
+
"model_type": "nomic_bert",
|
| 38 |
+
"n_embd": 768,
|
| 39 |
+
"n_head": 12,
|
| 40 |
+
"n_inner": 3072,
|
| 41 |
+
"n_layer": 12,
|
| 42 |
+
"n_positions": 2048,
|
| 43 |
+
"pad_token_id": 0,
|
| 44 |
+
"pad_vocab_size_multiple": 64,
|
| 45 |
+
"parallel_block": false,
|
| 46 |
+
"parallel_block_tied_norm": false,
|
| 47 |
+
"prenorm": false,
|
| 48 |
+
"qkv_proj_bias": false,
|
| 49 |
+
"reorder_and_upcast_attn": false,
|
| 50 |
+
"resid_pdrop": 0.0,
|
| 51 |
+
"rope_parameters": {
|
| 52 |
+
"rope_theta": 1000.0,
|
| 53 |
+
"rope_type": "default"
|
| 54 |
+
},
|
| 55 |
+
"rotary_emb_base": 1000,
|
| 56 |
+
"rotary_emb_fraction": 1.0,
|
| 57 |
+
"rotary_emb_interleaved": false,
|
| 58 |
+
"rotary_emb_scale_base": null,
|
| 59 |
+
"rotary_scaling_factor": null,
|
| 60 |
+
"scale_attn_by_inverse_layer_idx": false,
|
| 61 |
+
"scale_attn_weights": true,
|
| 62 |
+
"summary_activation": null,
|
| 63 |
+
"summary_first_dropout": 0.0,
|
| 64 |
+
"summary_proj_to_labels": true,
|
| 65 |
+
"summary_type": "cls_index",
|
| 66 |
+
"summary_use_proj": true,
|
| 67 |
+
"transformers_version": "4.57.6",
|
| 68 |
+
"type_vocab_size": 2,
|
| 69 |
+
"use_cache": true,
|
| 70 |
+
"use_flash_attn": true,
|
| 71 |
+
"use_rms_norm": false,
|
| 72 |
+
"use_xentropy": true,
|
| 73 |
+
"vocab_size": 30528
|
| 74 |
+
}
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1c1005bf14c833d0bb52024b6175409efe745245d0c21795b4d0bec4f55d74e9
|
| 3 |
+
size 547614877
|
model_int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:650fd2bde209bd85d0a842f52182f6cd347044a8fadba72b346840a4d5bfca63
|
| 3 |
+
size 137880210
|
model_metadata.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "nomic-ai/nomic-embed-text-v1.5",
|
| 3 |
+
"dimension": 768,
|
| 4 |
+
"checksum_sha256": "1c1005bf14c833d0bb52024b6175409efe745245d0c21795b4d0bec4f55d74e9",
|
| 5 |
+
"files": {
|
| 6 |
+
"model.onnx": "/home/jonasroot/.dra/models/nomic-embed/model.onnx",
|
| 7 |
+
"tokenizer.json": "/home/jonasroot/.dra/models/nomic-embed/tokenizer.json",
|
| 8 |
+
"config.json": "/home/jonasroot/.dra/models/nomic-embed/config.json"
|
| 9 |
+
}
|
| 10 |
+
}
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|