Instructions to use unsqldotai/unSQLv1-7b-sqlite-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsqldotai/unSQLv1-7b-sqlite-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsqldotai/unSQLv1-7b-sqlite-lora")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsqldotai/unSQLv1-7b-sqlite-lora") model = AutoModelForCausalLM.from_pretrained("unsqldotai/unSQLv1-7b-sqlite-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsqldotai/unSQLv1-7b-sqlite-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsqldotai/unSQLv1-7b-sqlite-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsqldotai/unSQLv1-7b-sqlite-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/unsqldotai/unSQLv1-7b-sqlite-lora
- SGLang
How to use unsqldotai/unSQLv1-7b-sqlite-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 "unsqldotai/unSQLv1-7b-sqlite-lora" \ --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": "unsqldotai/unSQLv1-7b-sqlite-lora", "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 "unsqldotai/unSQLv1-7b-sqlite-lora" \ --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": "unsqldotai/unSQLv1-7b-sqlite-lora", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use unsqldotai/unSQLv1-7b-sqlite-lora with Docker Model Runner:
docker model run hf.co/unsqldotai/unSQLv1-7b-sqlite-lora
Update README.md
Browse files
README.md
CHANGED
|
@@ -69,20 +69,30 @@ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
| 69 |
## Sagemaker Endpoint I/O Example
|
| 70 |
|
| 71 |
|
| 72 |
-
```
|
| 73 |
-
{
|
| 74 |
"inputs": "### Schema and the Natural Language Query:\nCREATE TABLE stadium (\n stadium_id number,\n location text,\n name text,\n capacity number,\n highest number,\n lowest number,\n average number\n)\n\nCREATE TABLE singer (\n singer_id number,\n name text,\n country text,\n song_name text,\n song_release_year text,\n age number,\n is_male others\n)\n\nCREATE TABLE concert (\n concert_id number,\n concert_name text,\n theme text,\n stadium_id text,\n year text\n)\n\nCREATE TABLE singer_in_concert (\n concert_id number,\n singer_id text\n)\n\n-- Using valid SQLite, answer the following questions for the tables provided above.\n\n-- What is the maximum, the average, and the minimum capacity of stadiums ?",
|
| 75 |
"parameters": {
|
| 76 |
"maxNewTokens": 512,
|
| 77 |
"topP": 0.9,
|
| 78 |
-
"temperature": 0.2
|
| 79 |
-
"decoderInputDetails": true,
|
| 80 |
-
"details": true
|
| 81 |
}
|
| 82 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
```
|
| 84 |
|
| 85 |
-
```
|
| 86 |
{
|
| 87 |
"body": [
|
| 88 |
{
|
|
|
|
| 69 |
## Sagemaker Endpoint I/O Example
|
| 70 |
|
| 71 |
|
| 72 |
+
```py
|
| 73 |
+
payload = {
|
| 74 |
"inputs": "### Schema and the Natural Language Query:\nCREATE TABLE stadium (\n stadium_id number,\n location text,\n name text,\n capacity number,\n highest number,\n lowest number,\n average number\n)\n\nCREATE TABLE singer (\n singer_id number,\n name text,\n country text,\n song_name text,\n song_release_year text,\n age number,\n is_male others\n)\n\nCREATE TABLE concert (\n concert_id number,\n concert_name text,\n theme text,\n stadium_id text,\n year text\n)\n\nCREATE TABLE singer_in_concert (\n concert_id number,\n singer_id text\n)\n\n-- Using valid SQLite, answer the following questions for the tables provided above.\n\n-- What is the maximum, the average, and the minimum capacity of stadiums ?",
|
| 75 |
"parameters": {
|
| 76 |
"maxNewTokens": 512,
|
| 77 |
"topP": 0.9,
|
| 78 |
+
"temperature": 0.2
|
|
|
|
|
|
|
| 79 |
}
|
| 80 |
}
|
| 81 |
+
|
| 82 |
+
client = boto3.client('runtime.sagemaker')
|
| 83 |
+
endpoint_name = 'deployed_model_name'
|
| 84 |
+
response = client.invoke_endpoint(
|
| 85 |
+
EndpointName=endpoint_name,
|
| 86 |
+
ContentType='application/json',
|
| 87 |
+
Body=json.dumps(payload).encode('utf-8'),
|
| 88 |
+
)
|
| 89 |
+
response = response["Body"].read().decode("utf8")
|
| 90 |
+
response = json.loads(response)
|
| 91 |
+
print(response[0]['generated_text'])
|
| 92 |
+
|
| 93 |
```
|
| 94 |
|
| 95 |
+
```json
|
| 96 |
{
|
| 97 |
"body": [
|
| 98 |
{
|