Text Generation
Transformers
Safetensors
qwen3
llama-factory
full
Generated from Trainer
conversational
text-generation-inference
Instructions to use ayh015/myLightningOPD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ayh015/myLightningOPD with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ayh015/myLightningOPD") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ayh015/myLightningOPD") model = AutoModelForCausalLM.from_pretrained("ayh015/myLightningOPD", 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 ayh015/myLightningOPD with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ayh015/myLightningOPD" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ayh015/myLightningOPD", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ayh015/myLightningOPD
- SGLang
How to use ayh015/myLightningOPD 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 "ayh015/myLightningOPD" \ --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": "ayh015/myLightningOPD", "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 "ayh015/myLightningOPD" \ --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": "ayh015/myLightningOPD", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ayh015/myLightningOPD with Docker Model Runner:
docker model run hf.co/ayh015/myLightningOPD
File size: 6,578 Bytes
6011e08 | 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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from collections.abc import Iterable
from dataclasses import dataclass, field
from typing import Any
_MISSING = object()
# TODO: This is ugly, temporarily leave this. We should unify all the config name for dataset, default, and args. (advice from Tom.)
DATASET_RUNTIME_SPECS: dict[str, dict[str, tuple[str, ...]]] = {
"n_samples_per_eval_prompt": {
"dataset_keys": ("n_samples_per_eval_prompt",),
"default_keys": ("n_samples_per_eval_prompt",),
"arg_attrs": ("n_samples_per_eval_prompt", "n_samples_per_prompt"),
},
"temperature": {
"dataset_keys": ("temperature",),
"default_keys": ("temperature",),
"arg_attrs": ("eval_temperature", "rollout_temperature"),
},
"top_p": {
"dataset_keys": ("top_p",),
"default_keys": ("top_p",),
"arg_attrs": ("eval_top_p", "rollout_top_p"),
},
"top_k": {
"dataset_keys": ("top_k",),
"default_keys": ("top_k",),
"arg_attrs": ("eval_top_k", "rollout_top_k"),
},
"max_response_len": {
"dataset_keys": ("max_response_len",),
"default_keys": ("max_response_len",),
"arg_attrs": ("eval_max_response_len", "rollout_max_response_len"),
},
}
DATASET_SAMPLE_SPECS: dict[str, dict[str, tuple[str, ...]]] = {
"input_key": {
"dataset_keys": ("input_key",),
"default_keys": ("input_key",),
"arg_attrs": ("eval_input_key", "input_key"),
},
"label_key": {
"dataset_keys": ("label_key",),
"default_keys": ("label_key",),
"arg_attrs": ("eval_label_key", "label_key"),
},
"tool_key": {
"dataset_keys": ("tool_key",),
"default_keys": ("tool_key",),
"arg_attrs": ("eval_tool_key", "tool_key"),
},
"metadata_key": {
"dataset_keys": ("metadata_key",),
"default_keys": ("metadata_key",),
"arg_attrs": ("metadata_key",),
},
}
def _first_not_missing(*values: Any) -> Any:
for value in values:
if value is not _MISSING:
return value
return _MISSING
def _pick_from_mapping(data: dict[str, Any], key_names: tuple[str, ...] | None) -> Any:
if key_names is None:
return _MISSING
for key_name in key_names:
if key_name in data:
return data[key_name]
return _MISSING
def pick_from_args(args: Any, attrs: tuple[str, ...]) -> Any:
for attr in attrs:
value = getattr(args, attr, None)
if value is not None:
return value
return None
def _ensure_metadata_overrides(value: Any) -> dict[str, Any]:
if value is None:
return {}
if not isinstance(value, dict):
raise TypeError("metadata_overrides must be a mapping.")
return value
@dataclass
class EvalDatasetConfig:
"""Configuration for a single evaluation dataset."""
name: str
path: str
rm_type: str | None = None
# Dataset-specific overrides
input_key: str | None = None
label_key: str | None = None
tool_key: str | None = None
metadata_key: str | None = None
n_samples_per_eval_prompt: int | None = None
temperature: float | None = None
top_p: float | None = None
top_k: int | None = None
max_response_len: int | None = None
stop: list[str] | None = None
stop_token_ids: list[int] | None = None
min_new_tokens: int | None = None
metadata_overrides: dict[str, Any] = field(default_factory=dict)
def __post_init__(self) -> None:
self.metadata_overrides = _ensure_metadata_overrides(self.metadata_overrides)
@property
def cache_key(self) -> tuple[Any, ...]:
"""Return a tuple uniquely identifying dataset config for caching."""
return (
self.name,
self.path,
self.input_key,
self.label_key,
self.tool_key,
self.metadata_key,
)
def inject_metadata(self, sample_metadata: Any) -> dict[str, Any]:
"""Return updated metadata merging overrides."""
if not isinstance(sample_metadata, dict):
metadata = {}
else:
metadata = dict(sample_metadata)
if self.rm_type is not None:
metadata["rm_type"] = self.rm_type
for key, value in self.metadata_overrides.items():
metadata[key] = value
return metadata
def ensure_dataset_list(config: Any) -> list[dict[str, Any]]:
"""
Normalize OmegaConf containers into a list of dicts.
Accepts either a list or dictionary keyed by dataset name.
"""
if config is None:
return []
if isinstance(config, dict):
datasets = []
for name, cfg in config.items():
dataset = dict(cfg or {})
dataset.setdefault("name", name)
datasets.append(dataset)
return datasets
if isinstance(config, (list, tuple)):
datasets = []
for item in config:
dataset = dict(item or {})
if "name" not in dataset:
raise ValueError("Each evaluation dataset entry must include a `name` field.")
datasets.append(dataset)
return datasets
raise TypeError("eval.datasets must be either a list or a mapping.")
def _apply_dataset_field_overrides(
args: Any, dataset_cfg: dict[str, Any], defaults: dict[str, Any], spec_names: dict[str, Any]
) -> None:
for field_name, spec in spec_names.items():
dataset_value = _pick_from_mapping(dataset_cfg, spec["dataset_keys"])
default_value = _pick_from_mapping(defaults, spec["default_keys"])
resolved_value = _first_not_missing(dataset_value, default_value)
if resolved_value is not _MISSING:
dataset_cfg[field_name] = resolved_value
continue
dataset_cfg[field_name] = pick_from_args(args, spec["arg_attrs"])
def build_eval_dataset_configs(
args: Any,
raw_config: Iterable[dict[str, Any]],
defaults: dict[str, Any],
) -> list[EvalDatasetConfig]:
defaults = defaults or {}
datasets: list[EvalDatasetConfig] = []
for cfg in raw_config:
cfg_dict = dict(cfg or {})
combined_specs = {**DATASET_RUNTIME_SPECS, **DATASET_SAMPLE_SPECS}
_apply_dataset_field_overrides(args, cfg_dict, defaults, combined_specs)
dataset = EvalDatasetConfig(**cfg_dict)
datasets.append(dataset)
return datasets
|