Instructions to use aolans/gemma-2-9b_q4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aolans/gemma-2-9b_q4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aolans/gemma-2-9b_q4")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aolans/gemma-2-9b_q4") model = AutoModelForCausalLM.from_pretrained("aolans/gemma-2-9b_q4") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aolans/gemma-2-9b_q4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aolans/gemma-2-9b_q4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aolans/gemma-2-9b_q4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aolans/gemma-2-9b_q4
- SGLang
How to use aolans/gemma-2-9b_q4 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 "aolans/gemma-2-9b_q4" \ --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": "aolans/gemma-2-9b_q4", "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 "aolans/gemma-2-9b_q4" \ --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": "aolans/gemma-2-9b_q4", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aolans/gemma-2-9b_q4 with Docker Model Runner:
docker model run hf.co/aolans/gemma-2-9b_q4
Authors: aolans
Model Card for gemma-2-9b_q4
本モデルは、google/gemma-2-9b をUnslothを使用して量子化しただけのモデルです。
Unsloth版の「Unsloth/gemma-2-9b」が適用されないよう
ローカルにオリジナル版 google/gemma-2-9b をダウンロードした後に加工しています。
追加学習のベースとして利用します。
Model Information
詳細は本家ページをご参照ください ⇒ google/gemma-2-9b
Usage
pip install unsloth
pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
from unsloth import FastLanguageModel
# unslothのFastLanguageModelで元のモデルをロード。
dtype = None # Noneにしておけば自動で設定
load_in_4bit = True # 今回は13Bモデルを扱うためTrue
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="aolans/gemma-2-9b_q4",
dtype=dtype,
load_in_4bit=load_in_4bit,
trust_remote_code=True,
)
# 推論するためにモデルのモードを変更
FastLanguageModel.for_inference(model)
input_text = "Write me a poem about Machine Learning."
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")
outputs = model.generate(**input_ids, max_new_tokens=32)
print(tokenizer.decode(outputs[0]))
This gemma2 model was trained 2x faster with Unsloth and Huggingface's TRL library.
- Downloads last month
- 1
