Text Generation
Transformers
Safetensors
mistral
Text-to-sql
conversational
text-generation-inference
Instructions to use OneGate/OGSQL-Mistral-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OneGate/OGSQL-Mistral-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OneGate/OGSQL-Mistral-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OneGate/OGSQL-Mistral-7B") model = AutoModelForCausalLM.from_pretrained("OneGate/OGSQL-Mistral-7B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OneGate/OGSQL-Mistral-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OneGate/OGSQL-Mistral-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OneGate/OGSQL-Mistral-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OneGate/OGSQL-Mistral-7B
- SGLang
How to use OneGate/OGSQL-Mistral-7B 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 "OneGate/OGSQL-Mistral-7B" \ --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": "OneGate/OGSQL-Mistral-7B", "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 "OneGate/OGSQL-Mistral-7B" \ --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": "OneGate/OGSQL-Mistral-7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use OneGate/OGSQL-Mistral-7B with Docker Model Runner:
docker model run hf.co/OneGate/OGSQL-Mistral-7B
| license: cc-by-4.0 | |
| tags: | |
| - Text-to-sql | |
| library_name: transformers | |
| # OGSQL-Mistral7B | |
|  | |
| ### Model Description | |
| OGSQL-Mistral7B was fine-tuned for the task of converting natural language text into SQL queries. | |
| - **Model type**: Mixture Of Experts (MoE) | |
| - **Language(s) (NLP)**: SQL (target language for generation) | |
| - **Finetuned from model**: Mistral 7B instruct | |
| ## Use Case | |
| OGSQL-7B is designed to facilitate the conversion of natural language queries into structured SQL commands, aiding in database querying without the need for manual SQL knowledge. | |
| ## How to Get Started with the Model | |
| ```python | |
| # Example code to load and use the model | |
| from transformers import AutoModelForSeq2SeqLM, AutoTokenizer | |
| model_name = "OGSQL-Mistral7B" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForSeq2SeqLM.from_pretrained(model_name) | |
| def generate_sql(query): | |
| inputs = tokenizer.encode(query, return_tensors="pt") | |
| outputs = model.generate(inputs) | |
| return tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| # Example use | |
| query = """ | |
| using this context: | |
| -- Create Customers Table | |
| CREATE TABLE Customers ( | |
| customer_id INTEGER PRIMARY KEY, | |
| name TEXT NOT NULL, | |
| email TEXT, | |
| join_date DATE | |
| ); | |
| -- Create Products Table | |
| CREATE TABLE Products ( | |
| product_id INTEGER PRIMARY KEY, | |
| name TEXT NOT NULL, | |
| price DECIMAL(10, 2) | |
| ); | |
| -- Create Orders Table | |
| CREATE TABLE Orders ( | |
| order_id INTEGER PRIMARY KEY, | |
| customer_id INTEGER, | |
| product_id INTEGER, | |
| order_date DATE, | |
| quantity INTEGER, | |
| total_price DECIMAL(10, 2), | |
| FOREIGN KEY (customer_id) REFERENCES Customers(customer_id), | |
| FOREIGN KEY (product_id) REFERENCES Products(product_id) | |
| ); | |
| show me all the orders from last month , sort by date | |
| """ | |
| print(generate_sql(query)) | |
| ``` | |
| ## alternatively you can use this notebook: | |
| [](https://colab.research.google.com/drive/1pQuIuCdoFMG76AH3BNZzep8PgRaZkkYS?usp=sharing) |