Instructions to use David-Evora/infofrota-text2sql-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use David-Evora/infofrota-text2sql-lora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Llama-3.1-8B-Instruct") model = PeftModel.from_pretrained(base_model, "David-Evora/infofrota-text2sql-lora") - Transformers
How to use David-Evora/infofrota-text2sql-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="David-Evora/infofrota-text2sql-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("David-Evora/infofrota-text2sql-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use David-Evora/infofrota-text2sql-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "David-Evora/infofrota-text2sql-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "David-Evora/infofrota-text2sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/David-Evora/infofrota-text2sql-lora
- SGLang
How to use David-Evora/infofrota-text2sql-lora 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 "David-Evora/infofrota-text2sql-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "David-Evora/infofrota-text2sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "David-Evora/infofrota-text2sql-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "David-Evora/infofrota-text2sql-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use David-Evora/infofrota-text2sql-lora with Docker Model Runner:
docker model run hf.co/David-Evora/infofrota-text2sql-lora
|
Download README.md from David-Evora/infofrota-text2sql-lora: direct link, hf CLI and curl.
- Browser
- Download file 3.27 kB
-
https://huggingface.co/David-Evora/infofrota-text2sql-lora/resolve/main/README.md
- Command line
-
hf download hf://David-Evora/infofrota-text2sql-lora/README.md
-
curl -L -o README.md https://huggingface.co/David-Evora/infofrota-text2sql-lora/resolve/main/README.md
3.27 kB
| base_model: unsloth/Llama-3.1-8B-Instruct | |
| library_name: peft | |
| pipeline_tag: text-generation | |
| language: | |
| - pt | |
| license: llama3.1 | |
| tags: | |
| - base_model:adapter:unsloth/Llama-3.1-8B-Instruct | |
| - lora | |
| - qlora | |
| - text-to-sql | |
| - transformers | |
| # InfoFrota Text-to-SQL (adaptador LoRA para Llama 3.1 8B Instruct) | |
| Adaptador LoRA que ensina o Llama 3.1 8B Instruct a transformar perguntas em português em consultas SQLite para o banco **sintético** do projeto InfoFrota (ocupação de ônibus, alertas de lotação, linhas e paradas). | |
| - Código, dados sintéticos e benchmark: https://github.com/David-Evora/InfoFrota | |
| - Kaggle Notebook: https://www.kaggle.com/code/davidevora/notebook-portifolio-infofrota | |
| - Projeto independente, sem endosso nem parceria com órgãos ou operadoras de transporte. Só os rótulos das linhas vêm de um CSV aberto (CC0) da CETURB-ES. | |
| ## Variante | |
| Este repositório contém o adaptador treinado **sem contexto recuperado** (resultado definido antes de qualquer ajuste). | |
| ## Uso pretendido e limites | |
| Pesquisa e demonstração de Text-to-SQL em português sobre o esquema do InfoFrota. **Não use em produção** nem para decisões operacionais: o modelo foi treinado e medido apenas em dados simulados. O SQL gerado deve sempre passar por uma guarda somente leitura (o repositório traz uma, em três camadas). | |
| ## Treino | |
| - Base: `unsloth/Llama-3.1-8B-Instruct` (mesmos pesos do Llama 3.1 8B Instruct), quantização 4 bits nf4, QLoRA. | |
| - LoRA: r=16, alpha=32, dropout 0,05, nos módulos q, k, v, o, gate, up e down. | |
| - 3 épocas, lote efetivo 16, taxa de aprendizado 2e-4 com cosseno. GPU T4 no Kaggle. | |
| - Dados: 738 exemplos construídos por famílias de modelos de pergunta e SQL (679 treino, 59 validação), com 8% de recusas para perguntas fora do domínio ou pedidos de escrita. | |
| - Filtros contra vazamento do teste (similaridade de Jaccard, esqueleto de SQL, famílias próximas excluídas): ver `training/REPORT.md` no repositório. | |
| ## Avaliação | |
| Benchmark congelado v2.1 com 56 perguntas, zero-shot, critério "o resultado contém o esperado". | |
| | Condição | Acertos | Acurácia | | |
| |---|---:|---:| | |
| | Base, prompt compacto | 19/56 | 33,9% | | |
| | Este adaptador, prompt compacto | 36/56 | 64,3% | | |
| Leitura honesta dos números: | |
| - Com 56 perguntas, diferenças de um ou dois acertos são ruído. | |
| - O nível difícil continua baixo. | |
| - A pergunta D06 tem defeito conhecido na referência; a pontuação publicada não foi ajustada depois de ver o resultado. | |
| - Os números vêm de dados sintéticos e não medem desempenho em operação real. | |
| ## Como carregar | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig | |
| from peft import PeftModel | |
| base = "unsloth/Llama-3.1-8B-Instruct" | |
| tok = AutoTokenizer.from_pretrained(base) | |
| modelo = AutoModelForCausalLM.from_pretrained( | |
| base, device_map="auto", | |
| quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_quant_type="nf4")) | |
| modelo = PeftModel.from_pretrained(modelo, "David-Evora/infofrota-text2sql-lora") | |
| ``` | |
| O prompt esperado está em `infofrota_ai/prompts.py` do repositório (modo `compacto`). | |
| ## Licença | |
| Adaptador derivado do Llama 3.1: use sob a Llama 3.1 Community License. Built with Llama. | |
| ### Framework versions | |
| - PEFT 0.21.2 |