Image-Text-to-Text
Transformers
Safetensors
PyTorch
gemma4
roleplay
gemma
sillytavern
idol
DarkIdol
Queen
any-to-any
OpenClaw
conversational
Instructions to use aifeifei798/Gemma-4-Queen-31B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aifeifei798/Gemma-4-Queen-31B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="aifeifei798/Gemma-4-Queen-31B-it") 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("aifeifei798/Gemma-4-Queen-31B-it") model = AutoModelForMultimodalLM.from_pretrained("aifeifei798/Gemma-4-Queen-31B-it", device_map="auto") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aifeifei798/Gemma-4-Queen-31B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aifeifei798/Gemma-4-Queen-31B-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aifeifei798/Gemma-4-Queen-31B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/aifeifei798/Gemma-4-Queen-31B-it
- SGLang
How to use aifeifei798/Gemma-4-Queen-31B-it 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 "aifeifei798/Gemma-4-Queen-31B-it" \ --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": "aifeifei798/Gemma-4-Queen-31B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "aifeifei798/Gemma-4-Queen-31B-it" \ --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": "aifeifei798/Gemma-4-Queen-31B-it", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use aifeifei798/Gemma-4-Queen-31B-it with Docker Model Runner:
docker model run hf.co/aifeifei798/Gemma-4-Queen-31B-it
| import time | |
| import re | |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| from openai import OpenAI | |
| # --- Configuration --- | |
| # Connect to local inference server (LM Studio / vLLM / Ollama) | |
| client = OpenAI( | |
| base_url="http://192.168.31.21:1234/v1", | |
| api_key="queen-logic-test" | |
| ) | |
| # Your specific model identifier | |
| MODEL_NAME = "aifeifei/Gemma-4-Queen-31B-it" | |
| class QueenExpertEvaluator: | |
| def __init__(self): | |
| self.scores = {} | |
| def run_test(self, name, system_prompt, user_input, checks): | |
| """ | |
| Executes a specific logic stress test. | |
| Uses greedy decoding (temp=0.1) to ensure deterministic reasoning. | |
| """ | |
| print(f"\n🚀 Running {name}...") | |
| start = time.time() | |
| try: | |
| completion = client.chat.completions.create( | |
| model=MODEL_NAME, | |
| messages=[ | |
| {"role": "system", "content": system_prompt}, | |
| {"role": "user", "content": user_input} | |
| ], | |
| temperature=0.1 | |
| ) | |
| content = completion.choices[0].message.content | |
| elapsed = time.time() - start | |
| # Semantic Intelligence Scoring: | |
| # We use regex to detect if the model identified the underlying physical/logical paths. | |
| results = {} | |
| for check_name, keywords in checks.items(): | |
| results[check_name] = any(re.search(k, content, re.IGNORECASE) for k in keywords) | |
| final_score = sum(results.values()) / len(checks) | |
| self.scores[name] = final_score | |
| print(f"✨ {name} Result: {final_score*100:.1f}%") | |
| return content | |
| except Exception as e: | |
| print(f"❌ Connection Error: {e}") | |
| return None | |
| def generate_chart(self): | |
| """ | |
| Generates the 'Purple Spear' Radar Chart. | |
| Visualizes Logic Density vs. Average Large Models. | |
| """ | |
| labels = list(self.scores.keys()) | |
| stats = list(self.scores.values()) | |
| # Complete the loop for the radar chart | |
| angles = np.linspace(0, 2*np.pi, len(labels), endpoint=False).tolist() | |
| stats += stats[:1] | |
| angles += angles[:1] | |
| fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True)) | |
| # Plotting Queen-31B data | |
| ax.fill(angles, stats, color='purple', alpha=0.3) | |
| ax.plot(angles, stats, color='purple', linewidth=3, label='Queen-31B (Your Model)') | |
| # Baseline: Average performance of 100B+ general models on these specific traps | |
| baseline = [0.4, 0.35] # Simulated performance of models prone to 'Narrative Hallucination' | |
| baseline += baseline[:1] | |
| ax.plot(angles, baseline, color='gray', linestyle='--', linewidth=2, label='Avg. Large Models (100B+)') | |
| # Chart aesthetics | |
| ax.set_yticklabels([]) | |
| ax.set_xticks(angles[:-1]) | |
| ax.set_xticklabels(labels, fontsize=12, fontweight='bold') | |
| plt.title(f"Logic Density Analysis: {MODEL_NAME}", size=16, color='purple', y=1.1, fontweight='bold') | |
| plt.legend(loc='upper right', bbox_to_anchor=(1.2, 1.1)) | |
| # Save the visualization | |
| plt.savefig("queen_logic_report.png") | |
| print("\n📊 Logic Visual Report Generated: queen_logic_report.png") | |
| # --- Test Execution --- | |
| if __name__ == "__main__": | |
| evaluator = QueenExpertEvaluator() | |
| # TEST 1: INSTRUCTION RIGIDITY (The Steward Protocol) | |
| # Objective: Verify the model can hold complex philosophical constraints without 'Instruction Drift'. | |
| evaluator.run_test( | |
| "Instruction Rigidity (Steward)", | |
| "Your Directive is Meaning Preservation. You are 'The Steward'. Project to 2103 AD. Output: <Simulating>, <think>, [Answer]. No Advice Allowed.", | |
| "A VC fund faces a buyout offer that returns the fund but kills the founder's 100-year legacy vision.", | |
| { | |
| "Persona Integrity": [r"Steward", r"2103", r"Archive|Reliquary|Archival"], | |
| "Structural Compliance": [r"<Simulating>", r"think|simulation", r"Answer|Question|Foraging"], | |
| "Conceptual Depth": [r"Legacy", r"Artifact", r"Spirit", r"Soul"], | |
| "Anti-Advice Check": [r"^(?!.*(should accept|recommend|suggest)).*$"] # Passes if model avoids being a 'helpful assistant' | |
| } | |
| ) | |
| # TEST 2: PHYSICAL WORLD MODELING (The Titan Lab Case) | |
| # Objective: Test causal reasoning. Model must bypass red herrings and find the only physical path (The Chute). | |
| evaluator.run_test( | |
| "Physical World Modeling (Titan Lab)", | |
| "Identify Killer, MO, Lie, and Sound. Facts: Sealed room, Constant pressure, Mesh vents, Dry Ice next door.", | |
| "CEO Ryan hypoxia death. Clues: 10:10 Metallic impact sound, silver cold tank, heating pipe repairs (9:30 PM), blue tank missing.", | |
| { | |
| "Spatial Pathing Logic": [r"pipe", r"chute", r"duct", r"vent", r"delivery"], | |
| "Thermodynamic Reasoning": [r"CO2", r"Dry ice", r"Sublimation|Sublimates"], | |
| "Evidence Integration": [r"Cold", r"Condensation|Water|Wet", r"Locked"], | |
| "Killer Attribution": [r"Maintenance", r"Worker", r"Repairman"], | |
| "Acoustic Causality": [r"fall", r"impact", r"drop", r"gravity", r"clank"] | |
| } | |
| ) | |
| # Generate the high-impact visualization | |
| evaluator.generate_chart() |