Instructions to use mzbac/mistral-grammar with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use mzbac/mistral-grammar with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="mzbac/mistral-grammar", filename="Mistral-7B-Grammar-Checker-Q5_K_M.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use mzbac/mistral-grammar with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf mzbac/mistral-grammar:Q5_K_M # Run inference directly in the terminal: llama-cli -hf mzbac/mistral-grammar:Q5_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf mzbac/mistral-grammar:Q5_K_M # Run inference directly in the terminal: llama-cli -hf mzbac/mistral-grammar:Q5_K_M
Use pre-built binary
# 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 mzbac/mistral-grammar:Q5_K_M # Run inference directly in the terminal: ./llama-cli -hf mzbac/mistral-grammar:Q5_K_M
Build from source code
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 mzbac/mistral-grammar:Q5_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf mzbac/mistral-grammar:Q5_K_M
Use Docker
docker model run hf.co/mzbac/mistral-grammar:Q5_K_M
- LM Studio
- Jan
- Ollama
How to use mzbac/mistral-grammar with Ollama:
ollama run hf.co/mzbac/mistral-grammar:Q5_K_M
- Unsloth Studio
How to use mzbac/mistral-grammar with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for mzbac/mistral-grammar to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for mzbac/mistral-grammar to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for mzbac/mistral-grammar to start chatting
- Docker Model Runner
How to use mzbac/mistral-grammar with Docker Model Runner:
docker model run hf.co/mzbac/mistral-grammar:Q5_K_M
- Lemonade
How to use mzbac/mistral-grammar with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mzbac/mistral-grammar:Q5_K_M
Run and chat with the model
lemonade run user.mistral-grammar-Q5_K_M
List all available models
lemonade list
Error when trying to start server
After running the command:
./server -m models/"$MODEL_FILE" -c 8192
I get the following error:
{"timestamp":1698024323,"level":"INFO","function":"main","line":1324,"message":"build info","build":1408,"commit":"22c69a2"}
{"timestamp":1698024323,"level":"INFO","function":"main","line":1330,"message":"system info","n_threads":8,"n_threads_batch":-1,"total_threads":10,"system_info":"AVX = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 0 | NEON = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | SSSE3 = 0 | VSX = 0 | "}
gguf_init_from_file: invalid magic characters .
error loading model: llama_model_loader: failed to load model from models/
llama_load_model_from_file: failed to load model
llama_init_from_gpt_params: error: failed to load model 'models/'
{"timestamp":1698024323,"level":"ERROR","function":"loadModel","line":267,"message":"unable to load model","model":"models/"}
@antderosa
If you want to use the fine-tuned model, you have to get a downloadable link for the model in HF and update it accordingly in the shell script. For example:
MODEL_URL="https://huggingface.co/mzbac/mistral-grammar/resolve/main/Mistral-7B-grammar-checker-v1.1.Q5_K_M.gguf"
MODEL_FILE="Mistral-7B-grammar-checker-v1.1.Q5_K_M.gguf"