Text Generation
Transformers
Safetensors
gemma4
image-text-to-text
chinese
wang-yangming
lora
merged
conversational
Instructions to use xihajun/gemma-wang-zh with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xihajun/gemma-wang-zh with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xihajun/gemma-wang-zh") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("xihajun/gemma-wang-zh") model = AutoModelForMultimodalLM.from_pretrained("xihajun/gemma-wang-zh") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xihajun/gemma-wang-zh with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xihajun/gemma-wang-zh" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xihajun/gemma-wang-zh", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xihajun/gemma-wang-zh
- SGLang
How to use xihajun/gemma-wang-zh 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 "xihajun/gemma-wang-zh" \ --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": "xihajun/gemma-wang-zh", "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 "xihajun/gemma-wang-zh" \ --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": "xihajun/gemma-wang-zh", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xihajun/gemma-wang-zh with Docker Model Runner:
docker model run hf.co/xihajun/gemma-wang-zh
gemma-wang-zh
Merged Wang Yangming style adapter on top of google/gemma-4-E4B-it.
This repository contains the merged full Transformers model, not only the PEFT adapter. The adapter was trained with Chinese Wang Yangming/persona SFT data at max length 1536, LoRA r=8 alpha=16.
Quick use
import torch
from transformers import AutoModelForCausalLM, AutoProcessor
repo = "xihajun/gemma-wang-zh"
processor = AutoProcessor.from_pretrained(repo)
model = AutoModelForCausalLM.from_pretrained(repo, torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{"role": "system", "content": "你将以王阳明的口吻和心学思想回答:强调致良知、知行合一、事上磨炼。不要解释风格,直接回答。"},
{"role": "user", "content": "如果我想很多但行动很少,应该怎么办?"},
]
prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = processor(text=[prompt], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(processor.decode(out[0, inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Notes
This is a merged Hugging Face/Transformers model. It is not a .litertlm mobile package yet.
- Downloads last month
- 2