Instructions to use kristiannordby/llama3-sqlcoder-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kristiannordby/llama3-sqlcoder-ft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kristiannordby/llama3-sqlcoder-ft")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kristiannordby/llama3-sqlcoder-ft") model = AutoModelForCausalLM.from_pretrained("kristiannordby/llama3-sqlcoder-ft") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use kristiannordby/llama3-sqlcoder-ft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kristiannordby/llama3-sqlcoder-ft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kristiannordby/llama3-sqlcoder-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/kristiannordby/llama3-sqlcoder-ft
- SGLang
How to use kristiannordby/llama3-sqlcoder-ft 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 "kristiannordby/llama3-sqlcoder-ft" \ --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": "kristiannordby/llama3-sqlcoder-ft", "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 "kristiannordby/llama3-sqlcoder-ft" \ --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": "kristiannordby/llama3-sqlcoder-ft", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use kristiannordby/llama3-sqlcoder-ft with Docker Model Runner:
docker model run hf.co/kristiannordby/llama3-sqlcoder-ft
Update README.md
Browse files
README.md
CHANGED
|
@@ -58,10 +58,15 @@ def build_output(sql):
|
|
| 58 |
return f"{sql.strip()}\n"
|
| 59 |
|
| 60 |
create_table_statements = "YOUR TABLE SCHEMA HERE"
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
```
|
| 66 |
|
| 67 |
|
|
|
|
| 58 |
return f"{sql.strip()}\n"
|
| 59 |
|
| 60 |
create_table_statements = "YOUR TABLE SCHEMA HERE"
|
| 61 |
+
|
| 62 |
+
def sqllamma(question):
|
| 63 |
+
input_ids = tokenizer(build_prompt(question, create_table_statements), return_tensors="pt", padding = True, truncation = True, max_length = 512).input_ids.to(model.device)
|
| 64 |
+
outputs = model.generate(input_ids, max_new_tokens=100)
|
| 65 |
+
output = tokenizer.decode(outputs[0])
|
| 66 |
+
sql = output.split("###")[3].split("[SQL]")[1].strip()
|
| 67 |
+
return sql
|
| 68 |
+
|
| 69 |
+
sqllama("YOUR QUESTION HERE")
|
| 70 |
```
|
| 71 |
|
| 72 |
|