Instructions to use tel1980/qwen-python-slm-v2-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use tel1980/qwen-python-slm-v2-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf tel1980/qwen-python-slm-v2-gguf # Run inference directly in the terminal: llama cli -hf tel1980/qwen-python-slm-v2-gguf
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf tel1980/qwen-python-slm-v2-gguf # Run inference directly in the terminal: llama cli -hf tel1980/qwen-python-slm-v2-gguf
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf tel1980/qwen-python-slm-v2-gguf # Run inference directly in the terminal: ./llama-cli -hf tel1980/qwen-python-slm-v2-gguf
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf tel1980/qwen-python-slm-v2-gguf # Run inference directly in the terminal: ./build/bin/llama-cli -hf tel1980/qwen-python-slm-v2-gguf
Use Docker
docker model run hf.co/tel1980/qwen-python-slm-v2-gguf
- LM Studio
- Jan
- Ollama
How to use tel1980/qwen-python-slm-v2-gguf with Ollama:
ollama run hf.co/tel1980/qwen-python-slm-v2-gguf
- Unsloth Studio
How to use tel1980/qwen-python-slm-v2-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for tel1980/qwen-python-slm-v2-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for tel1980/qwen-python-slm-v2-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for tel1980/qwen-python-slm-v2-gguf to start chatting
- Pi
How to use tel1980/qwen-python-slm-v2-gguf with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tel1980/qwen-python-slm-v2-gguf
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "tel1980/qwen-python-slm-v2-gguf" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use tel1980/qwen-python-slm-v2-gguf with Docker Model Runner:
docker model run hf.co/tel1980/qwen-python-slm-v2-gguf
- Lemonade
How to use tel1980/qwen-python-slm-v2-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull tel1980/qwen-python-slm-v2-gguf
Run and chat with the model
lemonade run user.qwen-python-slm-v2-gguf-{{QUANT_TAG}}List all available models
lemonade list
- Hermes Agent
How to use tel1980/qwen-python-slm-v2-gguf with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tel1980/qwen-python-slm-v2-gguf
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default tel1980/qwen-python-slm-v2-gguf
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use tel1980/qwen-python-slm-v2-gguf with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf tel1980/qwen-python-slm-v2-gguf
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "tel1980/qwen-python-slm-v2-gguf" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 7,455 Bytes
10e3126 | 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | # Model Card: qwen-python-slm v2
## Visão geral
`qwen-python-slm` é um modelo de linguagem pequeno (SLM) especializado em gerar código para o ecossistema de **Engenharia de Dados, Data Science, Machine Learning, Deep Learning, LLMs, Agentes de IA, DataOps e MLOps**.
Esta é a **versão 2** do modelo, um ajuste fino (SFT com QLoRA) do [`Qwen/Qwen2.5-Coder-1.5B-Instruct`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B-Instruct), mantendo a arquitetura de 1,5 bilhão de parâmetros e adicionando adaptadores LoRA treinados para responder a instruções técnicas de dados/IA em **Python**, **SQL** e **PySpark**.
- **Tipo de modelo:** Causal LM para geração de código
- **Idioma:** Português (instruções) + código multilíngue (Python/SQL/PySpark)
- **Licença:** Apache 2.0
- **Formatos disponíveis:**
- Pesos completos (merged, FP16) no Hugging Face Hub
- GGUF quantizado em Q4_K_M para uso local via Ollama / llama.cpp / Continue.dev
---
## Uso pretendido
- Geração de scripts Python para ETL/ELT, análise de dados e ML.
- Escrita de consultas SQL compatíveis com SQLite/PostgreSQL.
- Geração de código PySpark para processamento distribuído.
- Prototipagem de agentes de IA com LangChain, LlamaIndex, CrewAI etc.
- Automação de pipelines de MLOps/DataOps (Airflow, dbt, MLflow).
- Uso educacional e produtividade de desenvolvedores de dados.
> **Não recomendado para:** produção crítica sem revisão humana; geração de código com dados sensíveis sem validação de segurança; substituição de engenheiros especialistas.
---
## Comandos de linguagem
O modelo reconhece prefixos no prompt para forçar a linguagem/domínio desejado:
```text
/python Código Python genérico
/sql Consultas SQL
/pyspark Código PySpark
/ml Machine Learning (scikit-learn, PyTorch, etc.)
/llm LLMs e fine-tuning (transformers, peft, vLLM, etc.)
/agent Agentes de IA (LangChain, LlamaIndex, CrewAI, etc.)
/dataops Pipelines/DataOps/MLOps (Airflow, dbt, MLflow, etc.)
```
Exemplo:
```bash
ollama run thiago_lange/qwen-python-slm "/sql Liste os 10 produtos mais vendidos no último trimestre."
```
---
## Detalhes do treinamento
- **Modelo base:** `Qwen/Qwen2.5-Coder-1.5B-Instruct`
- **Técnica:** Supervised Fine-Tuning (SFT) com QLoRA (4-bit NF4)
- **Versão:** v2
- **Tamanho de contexto:** 2048 tokens
- **Hardware de treino:** NVIDIA GeForce RTX 5050 (8 GB VRAM)
- **Hiperparâmetros LoRA:**
- `r = 32`
- `alpha = 64`
- `dropout = 0.05`
- Módulos alvo: `q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`
- **Hiperparâmetros de treino:**
- Batch size efetivo: 32 (1 × 32 gradient accumulation)
- Learning rate: 2e-4
- Max steps: 1500
- Warmup steps: 75
- Otimizador: `paged_adamw_8bit`
- **Parâmetros treináveis:** 36,9M (2,34% do total)
---
## Dados de treino
Dataset final combinado: **141.838 amostras**, com splits de treino/teste estratificados por fonte. A avaliação usa apenas os holdouts de teste, nunca os dados de treino.
- **Dataset principal:** `iamtarun/python_code_instructions_18k_alpaca` (Python, filtrado por keywords de dados/IA)
- **Datasets Python extras:** `flytech/python-codes-25k`, `m-a-p/CodeFeedback-Filtered-Instruction` (filtrado para Python, subamostrado para 30k), `datasets/python_docs_synthetic.json` (2.500 amostras sintéticas)
- **Dataset SQL:** combinação de `b-mc2/sql-create-context`, `numbersstation/NSText2SQL`, `shainalcon/synthetic-text-to-sql` e queries sintéticas por dialeto (~48.600 amostras de treino)
- **Dataset PySpark:** ~9.263 amostras sintéticas + 292 oficiais da documentação Spark
- **Filtro de domínio:** amostras são mantidas apenas se contiverem palavras-chave do ecossistema de dados/IA (pandas, sklearn, PyTorch, Spark, Airflow, MLflow, LangChain etc.)
- **Prompt de sistema:** engenheiro de dados/ML sênior, especializado em Python/SQL/PySpark para dados e IA.
---
## Métricas de avaliação
Avaliação executada com `src/evaluate.py` (Python) e `src/evaluate_extended.py` (SQL e PySpark), 30 amostras por linguagem, usando exclusivamente os **holdouts de teste** (`datasets/splits/*_test.json`). Os dados de teste não foram vistos durante o treino, então as métricas refletem generalização.
| Métrica | Valor |
|---|---|
| Taxa de compilação Python válida | 96,67% |
| Taxa de execução Python sem erros | 43,33% |
| Taxa de parse SQL válido | 100,00% |
| Taxa de sintaxe PySpark válida | 100,00% |
| BLEU médio — Python | 0,144 |
| BLEU médio — SQL | 0,798 |
| BLEU médio — PySpark | 0,802 |
Observações:
- A queda na taxa de execução Python em relação à v1 (83,33%) é esperada: desta vez a avaliação usa holdout de teste real, não amostras do treino.
- Os erros de execução Python foram principalmente ambientais (biblioteca externa ausente como `bs4`, `tensorflow`, `mysql`; arquivos CSV locais inexistentes; dados NLTK não baixados), não falhas de sintaxe.
- SQL e PySpark são avaliados apenas por sintaxe/parse, já que a execução real exigiria banco de dados e cluster Spark.
- BLEU mede similaridade com a referência, não correção semântica.
Futuramente, recomenda-se adicionar **pass@1** em benchmarks como HumanEval, MBPP e Spider/BIRD (SQL), com dados nunca vistos no treino.
---
## Limitações
- O modelo foi treinado com recursos limitados (RTX 5050 8 GB, 1500 steps), então pode apresentar alucinações ou código não executável.
- SQL é validado sintaticamente, mas não executado contra um banco real — a semântica depende do schema fornecido.
- PySpark é tratado como Python; a execução real exige ambiente Spark configurado.
- O domínio é voltado para dados/IA; código fora desse escopo (frontend, mobile, etc.) pode ter qualidade inferior.
- O modelo pode reproduzir vieses presentes nos dados de treino.
---
## Como usar
### Ollama (GGUF)
```bash
ollama run thiago_lange/qwen-python-slm-v2 "/python Crie uma DAG do Airflow que baixe um CSV e salve no S3."
```
### Transformers (pesos merged)
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "tel1980/qwen-python-slm-v2"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
messages = [
{"role": "system", "content": "Você é um engenheiro de dados e Machine Learning sênior."},
{"role": "user", "content": "/sql Liste os clientes com mais de 5 pedidos."},
]
inputs = tokenizer.apply_chat_template(messages, return_tensors="pt", add_generation_prompt=True).to(model.device)
outputs = model.generate(inputs, max_new_tokens=512, temperature=0.2)
print(tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True))
```
---
## Licença
Este modelo é distribuído sob a licença **Apache 2.0**, a mesma do modelo base Qwen2.5-Coder-1.5B-Instruct.
---
## Citação
Se você usar este modelo em trabalhos acadêmicos, cite o modelo base:
```bibtex
@article{qwen2.5,
title={Qwen2.5 Technical Report},
author={Qwen Team},
journal={arXiv preprint arXiv:2409.12186},
year={2024}
}
```
---
## Links
- Código-fonte: `https://github.com/tel1980/SLM_python`
- Pesos merged v2 (FP16): `https://huggingface.co/tel1980/qwen-python-slm-v2`
- GGUF quantizado v2: `https://huggingface.co/tel1980/qwen-python-slm-v2-gguf`
- Versão anterior (v1): `https://huggingface.co/tel1980/qwen-python-slm`
|