Text Generation
Transformers
Safetensors
code
llama
python
code-completion
fill-in-the-middle
tiny
text-generation-inference
Instructions to use esraderey/chispa-20m-python with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use esraderey/chispa-20m-python with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="esraderey/chispa-20m-python")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("esraderey/chispa-20m-python") model = AutoModelForCausalLM.from_pretrained("esraderey/chispa-20m-python", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use esraderey/chispa-20m-python with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "esraderey/chispa-20m-python" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "esraderey/chispa-20m-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/esraderey/chispa-20m-python
- SGLang
How to use esraderey/chispa-20m-python with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "esraderey/chispa-20m-python" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "esraderey/chispa-20m-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "esraderey/chispa-20m-python" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "esraderey/chispa-20m-python", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use esraderey/chispa-20m-python with Docker Model Runner:
docker model run hf.co/esraderey/chispa-20m-python
CHISPA-20M-python: modelo base de RFC-CHISPA-3 (formato LLaMA)
Browse files- README.md +59 -0
- chispa_export.json +5 -0
- config.json +32 -0
- generation_config.json +9 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +13 -0
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language: [code]
|
| 4 |
+
library_name: transformers
|
| 5 |
+
pipeline_tag: text-generation
|
| 6 |
+
tags: [code, python, code-completion, fill-in-the-middle, tiny, llama]
|
| 7 |
+
datasets: [codeparrot/codeparrot-clean]
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# CHISPA-20M-python
|
| 11 |
+
|
| 12 |
+
Modelo diminuto (20.1M parámetros) de completado de línea de Python, entrenado desde cero como
|
| 13 |
+
laboratorio de la serie de RFC CHISPA. **Es un artefacto de investigación, no un asistente de código**: completa
|
| 14 |
+
el resto de una línea; no escribe funciones a partir de un docstring.
|
| 15 |
+
|
| 16 |
+
*A tiny (~20M) Python line-completion model trained from scratch with fill-in-the-middle. Research
|
| 17 |
+
artifact, not a coding assistant. Code, preregistration and experiments: https://github.com/esraderey/chispa*
|
| 18 |
+
|
| 19 |
+
## Arquitectura
|
| 20 |
+
|
| 21 |
+
LLaMA: d=320, 12 capas, 5 cabezas de 64, SwiGLU 864, RMSNorm, RoPE, embeddings atados, contexto 1,024.
|
| 22 |
+
Tokenizador BPE a nivel de byte de 16,384 piezas con pretokenización alineada a lexemas de Python (identificador,
|
| 23 |
+
número, puntuación, salto de línea con sangría). Convertido desde el formato del laboratorio; diferencia máxima de
|
| 24 |
+
logits en la conversión: 3.6e-05.
|
| 25 |
+
|
| 26 |
+
## Datos y entrenamiento
|
| 27 |
+
|
| 28 |
+
- `codeparrot/codeparrot-clean`, solo archivos con licencia permisiva (MIT, Apache-2.0, BSD-2/3, ISC, Unlicense),
|
| 29 |
+
3228316 archivos de 280112 repositorios de entrenamiento. El 3 % de los
|
| 30 |
+
repositorios (por hash del nombre) se reservó para evaluación y no se vio al entrenar.
|
| 31 |
+
- 521M tokens, el 50 % de los documentos en formato FIM (PSM); la mitad de ellos con el hueco al
|
| 32 |
+
final de una línea.
|
| 33 |
+
- AdamW, pico 3e-3, calendario WSD, lote de 131,072 tokens, bf16, una H100. Pérdida final de entrenamiento: 1.56971.
|
| 34 |
+
|
| 35 |
+
## Uso
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 39 |
+
tk = AutoTokenizer.from_pretrained("esraderey/chispa-20m-python")
|
| 40 |
+
m = AutoModelForCausalLM.from_pretrained("esraderey/chispa-20m-python")
|
| 41 |
+
prompt = "<fim_prefix>def area(r):\n return <fim_suffix>\n<fim_middle>"
|
| 42 |
+
ids = tk(prompt, return_tensors="pt").input_ids
|
| 43 |
+
print(tk.decode(m.generate(ids, max_new_tokens=16, do_sample=False)[0][ids.shape[1]:]))
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Evaluación (repositorios retenidos, 20,000 cursores dentro de cuerpos de función)
|
| 47 |
+
|
| 48 |
+
| Métrica | Valor |
|
| 49 |
+
|---|---|
|
| 50 |
+
| Coincidencia exacta del primer identificador de la línea | 17.1% |
|
| 51 |
+
| Coincidencia exacta de la línea completa | 1.2% |
|
| 52 |
+
| Completados que introducen un nombre indefinido | 11.0% (IC90 10.3%–11.6%) |
|
| 53 |
+
|
| 54 |
+
Detalle, intervalos y experimentos E1–E5: https://github.com/esraderey/chispa
|
| 55 |
+
|
| 56 |
+
## Limitaciones
|
| 57 |
+
|
| 58 |
+
Modelo de 20M: inventa nombres, no conoce APIs poco comunes y su ventana es de 1,024 tokens. Solo Python. Las métricas
|
| 59 |
+
son offline y no se validaron con usuarios. El corpus procede de GitHub y puede contener código con errores o inseguro.
|
chispa_export.json
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"origen": "runs_srv/B20/final.pt",
|
| 3 |
+
"paso": 3814,
|
| 4 |
+
"dif_max_logits": 3.612041473388672e-05
|
| 5 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 1,
|
| 8 |
+
"dtype": "float32",
|
| 9 |
+
"eos_token_id": 2,
|
| 10 |
+
"head_dim": 64,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 320,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 864,
|
| 15 |
+
"max_position_embeddings": 1024,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 5,
|
| 19 |
+
"num_hidden_layers": 12,
|
| 20 |
+
"num_key_value_heads": 5,
|
| 21 |
+
"pad_token_id": null,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"rope_theta": 10000.0,
|
| 26 |
+
"rope_type": "default"
|
| 27 |
+
},
|
| 28 |
+
"tie_word_embeddings": true,
|
| 29 |
+
"transformers_version": "5.2.0",
|
| 30 |
+
"use_cache": true,
|
| 31 |
+
"vocab_size": 16384
|
| 32 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 2,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"transformers_version": "5.2.0",
|
| 8 |
+
"use_cache": true
|
| 9 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dbd944c1f6defb09fbdc75c6b282efd5d888ffcb797e04c99c9e04fa1398fbb8
|
| 3 |
+
size 80489416
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|endoftext|>",
|
| 4 |
+
"eos_token": "<|endoftext|>",
|
| 5 |
+
"extra_special_tokens": [
|
| 6 |
+
"<fim_prefix>",
|
| 7 |
+
"<fim_suffix>",
|
| 8 |
+
"<fim_middle>"
|
| 9 |
+
],
|
| 10 |
+
"model_max_length": 1024,
|
| 11 |
+
"pad_token": "<pad>",
|
| 12 |
+
"tokenizer_class": "TokenizersBackend"
|
| 13 |
+
}
|