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
Ficha: ejemplo de uso con el recorte de la sangría inicial
Browse files
README.md
CHANGED
|
@@ -38,11 +38,19 @@ logits en la conversión: 3.6e-05.
|
|
| 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 |
-
|
|
|
|
|
|
|
| 42 |
ids = tk(prompt, return_tensors="pt").input_ids
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
```
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
## Evaluación (repositorios retenidos, 20,000 cursores dentro de cuerpos de función)
|
| 47 |
|
| 48 |
| Métrica | Valor |
|
|
|
|
| 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 |
+
eos, pad = tk.convert_tokens_to_ids("<|endoftext|>"), tk.convert_tokens_to_ids("<pad>")
|
| 42 |
+
# FIM en formato PSM: el modelo rellena el hueco entre prefijo y sufijo
|
| 43 |
+
prompt = "<fim_prefix>def read_lines(path):\n with open(path) as f:\n <fim_suffix>\n<fim_middle>"
|
| 44 |
ids = tk(prompt, return_tensors="pt").input_ids
|
| 45 |
+
out = m.generate(ids, max_new_tokens=16, do_sample=False, eos_token_id=eos, pad_token_id=pad)
|
| 46 |
+
linea = tk.decode(out[0][ids.shape[1]:], skip_special_tokens=True).split("\n")[0]
|
| 47 |
+
print(linea.lstrip()) # -> return f.readlines()
|
| 48 |
```
|
| 49 |
|
| 50 |
+
Si el prefijo termina justo después de la sangría, el modelo tiende a empezar con espacios de más: recorta el inicio
|
| 51 |
+
de la línea (`lstrip`) o prohíbe en el primer paso las piezas que empiezan por espacio, que es lo que se hizo en los
|
| 52 |
+
experimentos.
|
| 53 |
+
|
| 54 |
## Evaluación (repositorios retenidos, 20,000 cursores dentro de cuerpos de función)
|
| 55 |
|
| 56 |
| Métrica | Valor |
|