Text Generation
Transformers
GGUF
English
therapeutics
drug-development
llama-cpp
matrixportal
conversational
Instructions to use matrixportalx/txgemma-9b-chat-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use matrixportalx/txgemma-9b-chat-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="matrixportalx/txgemma-9b-chat-GGUF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("matrixportalx/txgemma-9b-chat-GGUF", dtype="auto") - llama-cpp-python
How to use matrixportalx/txgemma-9b-chat-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="matrixportalx/txgemma-9b-chat-GGUF", filename="txgemma-9b-chat-f16.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use matrixportalx/txgemma-9b-chat-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M # Run inference directly in the terminal: llama cli -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_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 matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_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 matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
Use Docker
docker model run hf.co/matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use matrixportalx/txgemma-9b-chat-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "matrixportalx/txgemma-9b-chat-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "matrixportalx/txgemma-9b-chat-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
- SGLang
How to use matrixportalx/txgemma-9b-chat-GGUF 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 "matrixportalx/txgemma-9b-chat-GGUF" \ --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": "matrixportalx/txgemma-9b-chat-GGUF", "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 "matrixportalx/txgemma-9b-chat-GGUF" \ --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": "matrixportalx/txgemma-9b-chat-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use matrixportalx/txgemma-9b-chat-GGUF with Ollama:
ollama run hf.co/matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
- Unsloth Studio
How to use matrixportalx/txgemma-9b-chat-GGUF 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 matrixportalx/txgemma-9b-chat-GGUF 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 matrixportalx/txgemma-9b-chat-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for matrixportalx/txgemma-9b-chat-GGUF to start chatting
- Atomic Chat new
- Docker Model Runner
How to use matrixportalx/txgemma-9b-chat-GGUF with Docker Model Runner:
docker model run hf.co/matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
- Lemonade
How to use matrixportalx/txgemma-9b-chat-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull matrixportalx/txgemma-9b-chat-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.txgemma-9b-chat-GGUF-Q4_K_M
List all available models
lemonade list
| base_model: google/txgemma-9b-chat | |
| language: | |
| - en | |
| library_name: transformers | |
| license: other | |
| license_name: health-ai-developer-foundations | |
| license_link: https://developers.google.com/health-ai-developer-foundations/terms | |
| pipeline_tag: text-generation | |
| tags: | |
| - therapeutics | |
| - drug-development | |
| - llama-cpp | |
| - matrixportal | |
| extra_gated_heading: Access TxGemma on Hugging Face | |
| extra_gated_prompt: To access TxGemma on Hugging Face, you're required to review and | |
| agree to [Health AI Developer Foundation's terms of use](https://developers.google.com/health-ai-developer-foundations/terms). | |
| To do this, please ensure you're logged in to Hugging Face and click below. Requests | |
| are processed immediately. | |
| extra_gated_button_content: Acknowledge license | |
| # matrixportal/txgemma-9b-chat-GGUF | |
| This model was converted to GGUF format from [`google/txgemma-9b-chat`](https://huggingface.co/google/txgemma-9b-chat) using llama.cpp via the ggml.ai's [all-gguf-same-where](https://huggingface.co/spaces/matrixportal/all-gguf-same-where) space. | |
| Refer to the [original model card](https://huggingface.co/google/txgemma-9b-chat) for more details on the model. | |
| ## β Quantized Models Download List | |
| ### π Recommended Quantizations | |
| - **β¨ General CPU Use:** [`Q4_K_M`](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_k_m.gguf) (Best balance of speed/quality) | |
| - **π± ARM Devices:** [`Q4_0`](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_0.gguf) (Optimized for ARM CPUs) | |
| - **π Maximum Quality:** [`Q8_0`](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q8_0.gguf) (Near-original quality) | |
| ### π¦ Full Quantization Options | |
| | π Download | π’ Type | π Notes | | |
| |:---------|:-----|:------| | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q2_k.gguf) |  | Basic quantization | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q3_k_s.gguf) |  | Small size | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q3_k_m.gguf) |  | Balanced quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q3_k_l.gguf) |  | Better quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_0.gguf) |  | Fast on ARM | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_k_s.gguf) |  | Fast, recommended | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_k_m.gguf) |  β | Best balance | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q5_0.gguf) |  | Good quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q5_k_s.gguf) |  | Balanced | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q5_k_m.gguf) |  | High quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q6_k.gguf) |  π | Very good quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q8_0.gguf) |  β‘ | Fast, best quality | | |
| | [Download](https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-f16.gguf) |  | Maximum accuracy | | |
| π‘ **Tip:** Use `F16` for maximum precision when quality is critical | |
| # GGUF Model Quantization & Usage Guide with llama.cpp | |
| ## What is GGUF and Quantization? | |
| **GGUF** (GPT-Generated Unified Format) is an efficient model file format developed by the `llama.cpp` team that: | |
| - Supports multiple quantization levels | |
| - Works cross-platform | |
| - Enables fast loading and inference | |
| **Quantization** converts model weights to lower precision data types (e.g., 4-bit integers instead of 32-bit floats) to: | |
| - Reduce model size | |
| - Decrease memory usage | |
| - Speed up inference | |
| - (With minor accuracy trade-offs) | |
| ## Step-by-Step Guide | |
| ### 1. Prerequisites | |
| ```bash | |
| # System updates | |
| sudo apt update && sudo apt upgrade -y | |
| # Dependencies | |
| sudo apt install -y build-essential cmake python3-pip | |
| # Clone and build llama.cpp | |
| git clone https://github.com/ggerganov/llama.cpp | |
| cd llama.cpp | |
| make -j4 | |
| ``` | |
| ### 2. Using Quantized Models from Hugging Face | |
| My automated quantization script produces models in this format: | |
| ``` | |
| https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_k_m.gguf | |
| ``` | |
| Download your quantized model directly: | |
| ```bash | |
| wget https://huggingface.co/matrixportal/txgemma-9b-chat-GGUF/resolve/main/txgemma-9b-chat-q4_k_m.gguf | |
| ``` | |
| ### 3. Running the Quantized Model | |
| Basic usage: | |
| ```bash | |
| ./main -m txgemma-9b-chat-q4_k_m.gguf -p "Your prompt here" -n 128 | |
| ``` | |
| Example with a creative writing prompt: | |
| ```bash | |
| ./main -m txgemma-9b-chat-q4_k_m.gguf -p "[INST] Write a short poem about AI quantization in the style of Shakespeare [/INST]" -n 256 -c 2048 -t 8 --temp 0.7 | |
| ``` | |
| Advanced parameters: | |
| ```bash | |
| ./main -m txgemma-9b-chat-q4_k_m.gguf -p "Question: What is the GGUF format? | |
| Answer:" -n 256 -c 2048 -t 8 --temp 0.7 --top-k 40 --top-p 0.9 | |
| ``` | |
| ### 4. Python Integration | |
| Install the Python package: | |
| ```bash | |
| pip install llama-cpp-python | |
| ``` | |
| Example script: | |
| ```python | |
| from llama_cpp import Llama | |
| # Initialize the model | |
| llm = Llama( | |
| model_path="txgemma-9b-chat-q4_k_m.gguf", | |
| n_ctx=2048, | |
| n_threads=8 | |
| ) | |
| # Run inference | |
| response = llm( | |
| "[INST] Explain GGUF quantization to a beginner [/INST]", | |
| max_tokens=256, | |
| temperature=0.7, | |
| top_p=0.9 | |
| ) | |
| print(response["choices"][0]["text"]) | |
| ``` | |
| ## Performance Tips | |
| 1. **Hardware Utilization**: | |
| - Set thread count with `-t` (typically CPU core count) | |
| - Compile with CUDA/OpenCL for GPU support | |
| 2. **Memory Optimization**: | |
| - Lower quantization (like q4_k_m) uses less RAM | |
| - Adjust context size with `-c` parameter | |
| 3. **Speed/Accuracy Balance**: | |
| - Higher bit quantization is slower but more accurate | |
| - Reduce randomness with `--temp 0` for consistent results | |
| ## FAQ | |
| **Q: What quantization levels are available?** | |
| A: Common options include q4_0, q4_k_m, q5_0, q5_k_m, q8_0 | |
| **Q: How much performance loss occurs with q4_k_m?** | |
| A: Typically 2-5% accuracy reduction but 4x smaller size | |
| **Q: How to enable GPU support?** | |
| A: Build with `make LLAMA_CUBLAS=1` for NVIDIA GPUs | |
| ## Useful Resources | |
| 1. [llama.cpp GitHub](https://github.com/ggerganov/llama.cpp) | |
| 2. [GGUF Format Specs](https://github.com/ggerganov/ggml/blob/master/docs/gguf.md) | |
| 3. [Hugging Face Model Hub](https://huggingface.co/models) | |