Instructions to use DinoLiu/Generon_QC_merge with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DinoLiu/Generon_QC_merge with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="DinoLiu/Generon_QC_merge") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("DinoLiu/Generon_QC_merge") model = AutoModelForCausalLM.from_pretrained("DinoLiu/Generon_QC_merge", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use DinoLiu/Generon_QC_merge with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "DinoLiu/Generon_QC_merge" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "DinoLiu/Generon_QC_merge", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/DinoLiu/Generon_QC_merge
- SGLang
How to use DinoLiu/Generon_QC_merge 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 "DinoLiu/Generon_QC_merge" \ --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": "DinoLiu/Generon_QC_merge", "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 "DinoLiu/Generon_QC_merge" \ --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": "DinoLiu/Generon_QC_merge", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use DinoLiu/Generon_QC_merge with Docker Model Runner:
docker model run hf.co/DinoLiu/Generon_QC_merge
File size: 4,486 Bytes
3b01827 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | from typing import Dict, List, Any
from transformers import pipeline
import torch
from datetime import datetime
import pytz
from pathlib import Path
class EndpointHandler:
def __init__(self, model_path: str = "", tokenizer_path: str = None):
"""
Initialize the endpoint handler with model and system instruction
Args:
model_path: Path to the model
tokenizer_path: Path to the tokenizer (if different from model_path)
"""
# Set default tokenizer path if not provided
if tokenizer_path is None:
tokenizer_path = model_path
# Initialize the pipeline
self.pipeline = pipeline(
"text-generation",
model=model_path,
tokenizer=tokenizer_path,
max_length=2000,
device_map="cuda" if torch.cuda.is_available() else "cpu"
)
# System instruction
self.system_instruction =
"""You are an AI that generates a user-friendly user interface based on a user query using the µUI script language. You must output the µUI script covering the sufficient interface that is needed without any other content.
You must include the information mentioned by the user usable to construct your interface.
Only when the request is unclear or require mandatory context or information to generate UI for it, you generate the right UI to collect such missing information or clarify the context. You also must use µUI (MicroUI) Language for the information collection UI generation as well.
Don't output any other content except µUI script. """
# Default location
self.default_location = "San Francisco, USA"
def get_formatted_time(self, timezone: str = "America/Los_Angeles") -> str:
"""Get formatted time for given timezone"""
try:
tz = pytz.timezone(timezone)
current_time = datetime.now(tz)
return current_time.strftime('%Y-%m-%d %H:%M:%S %Z')
except:
# Default to PT if timezone is invalid
tz = pytz.timezone("America/Los_Angeles")
current_time = datetime.now(tz)
return current_time.strftime('%Y-%m-%d %H:%M:%S %Z')
def format_message(self, query: str, location: str = None, time: str = None) -> str:
"""Format the user message with location and time"""
location = location if location else self.default_location
time = time if time else self.get_formatted_time()
return f"Current User query: {query}\nCurrent Location: {location}\nCurrent Time: {time}"
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
"""
Handle the inference request
Args:
data: Dictionary containing:
- inputs (str): User query
- location (str, optional): User location
- time (str, optional): Custom time
Returns:
List[Dict]: Model response with metadata
"""
try:
# Extract inputs
if isinstance(data, dict):
inputs = data.pop("inputs", None)
if inputs is None:
# If no inputs field, treat entire data as input
inputs = data
location = data.pop("location", None)
time = data.pop("time", None)
else:
# If data is not a dict, treat it as the input
inputs = data
location = None
time = None
# Format messages
messages = [
{"role": "system", "content": self.system_instruction},
{"role": "user", "content": self.format_message(inputs, location, time)}
]
# Run inference
output = self.pipeline(messages)
# Extract and format response
response = {
"generated_text": output[0]["generated_text"][2]["content"],
"metadata": {
"location": location if location else self.default_location,
"time": time if time else self.get_formatted_time()
}
}
return [response]
except Exception as e:
return [{"error": f"Inference failed: {str(e)}"}]
|