Fine tuning Text2SQL based on Mistral-7B using LoRA on MLX e3678d1
军舰 commited on
How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL")
model = AutoModelForCausalLM.from_pretrained("mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL", device_map="auto")How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with llama.cpp:
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0 # Run inference directly in the terminal: llama cli -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0 # Run inference directly in the terminal: llama cli -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
# 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 mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
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 mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
docker model run hf.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL" \
--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": "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL" \
--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": "mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with Ollama:
ollama run hf.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with Docker Model Runner:
docker model run hf.co/mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
How to use mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL with Lemonade:
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mlx-community/Mistral-7B-v0.1-LoRA-Text2SQL:Q8_0
lemonade run user.Mistral-7B-v0.1-LoRA-Text2SQL-Q8_0
lemonade list