Text Generation
PEFT
Safetensors
Transformers
qwen2
lora
coding
code-generation
conversational
text-generation-inference
Instructions to use girish00/ConicAI_LLM_model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use girish00/ConicAI_LLM_model with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct") model = PeftModel.from_pretrained(base_model, "girish00/ConicAI_LLM_model") - Transformers
How to use girish00/ConicAI_LLM_model with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="girish00/ConicAI_LLM_model") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("girish00/ConicAI_LLM_model") model = AutoModelForCausalLM.from_pretrained("girish00/ConicAI_LLM_model") 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
- vLLM
How to use girish00/ConicAI_LLM_model with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "girish00/ConicAI_LLM_model" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "girish00/ConicAI_LLM_model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/girish00/ConicAI_LLM_model
- SGLang
How to use girish00/ConicAI_LLM_model 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 "girish00/ConicAI_LLM_model" \ --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": "girish00/ConicAI_LLM_model", "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 "girish00/ConicAI_LLM_model" \ --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": "girish00/ConicAI_LLM_model", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use girish00/ConicAI_LLM_model with Docker Model Runner:
docker model run hf.co/girish00/ConicAI_LLM_model
update endpoint helper files
Browse files- infer_local.py +44 -26
infer_local.py
CHANGED
|
@@ -286,13 +286,19 @@ def main():
|
|
| 286 |
parser.add_argument("--base-model", type=str, default="Qwen/Qwen2.5-Coder-0.5B-Instruct")
|
| 287 |
parser.add_argument("--prompt", type=str, required=True)
|
| 288 |
parser.add_argument("--max-new-tokens", type=int, default=320)
|
| 289 |
-
parser.add_argument("--temperature", type=float, default=0.25)
|
| 290 |
-
parser.add_argument("--top-p", type=float, default=0.9)
|
| 291 |
-
parser.add_argument("--do-sample", action="store_true")
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
f"Model path not found: {args.model_path}. Train first using run_pipeline.py."
|
| 297 |
)
|
| 298 |
|
|
@@ -301,20 +307,28 @@ def main():
|
|
| 301 |
full_model_weights_present = has_full_model_weights(args.model_path)
|
| 302 |
|
| 303 |
if os.path.exists(adapter_config_path) and adapter_weights_present:
|
| 304 |
-
peft_config = PeftConfig.from_pretrained(args.model_path)
|
| 305 |
-
base_model_name = peft_config.base_model_name_or_path or args.base_model
|
| 306 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
else:
|
| 319 |
# Graceful fallback when local model folder has config/tokenizer but no weight files.
|
| 320 |
fallback_base = args.base_model
|
|
@@ -343,11 +357,15 @@ def main():
|
|
| 343 |
),
|
| 344 |
file=sys.stderr,
|
| 345 |
)
|
| 346 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if tokenizer.pad_token is None:
|
| 352 |
tokenizer.pad_token = tokenizer.eos_token
|
| 353 |
model.eval()
|
|
|
|
| 286 |
parser.add_argument("--base-model", type=str, default="Qwen/Qwen2.5-Coder-0.5B-Instruct")
|
| 287 |
parser.add_argument("--prompt", type=str, required=True)
|
| 288 |
parser.add_argument("--max-new-tokens", type=int, default=320)
|
| 289 |
+
parser.add_argument("--temperature", type=float, default=0.25)
|
| 290 |
+
parser.add_argument("--top-p", type=float, default=0.9)
|
| 291 |
+
parser.add_argument("--do-sample", action="store_true")
|
| 292 |
+
parser.add_argument(
|
| 293 |
+
"--allow-downloads",
|
| 294 |
+
action="store_true",
|
| 295 |
+
help="Allow Transformers to download missing model files from Hugging Face.",
|
| 296 |
+
)
|
| 297 |
+
args = parser.parse_args()
|
| 298 |
+
local_files_only = not args.allow_downloads
|
| 299 |
+
|
| 300 |
+
if not os.path.exists(args.model_path):
|
| 301 |
+
raise FileNotFoundError(
|
| 302 |
f"Model path not found: {args.model_path}. Train first using run_pipeline.py."
|
| 303 |
)
|
| 304 |
|
|
|
|
| 307 |
full_model_weights_present = has_full_model_weights(args.model_path)
|
| 308 |
|
| 309 |
if os.path.exists(adapter_config_path) and adapter_weights_present:
|
| 310 |
+
peft_config = PeftConfig.from_pretrained(args.model_path)
|
| 311 |
+
base_model_name = peft_config.base_model_name_or_path or args.base_model
|
| 312 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 313 |
+
base_model_name,
|
| 314 |
+
local_files_only=local_files_only,
|
| 315 |
+
)
|
| 316 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 317 |
+
base_model_name,
|
| 318 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 319 |
+
local_files_only=local_files_only,
|
| 320 |
+
)
|
| 321 |
+
model = PeftModel.from_pretrained(base_model, args.model_path)
|
| 322 |
+
elif full_model_weights_present and not os.path.exists(adapter_config_path):
|
| 323 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 324 |
+
args.model_path,
|
| 325 |
+
local_files_only=local_files_only,
|
| 326 |
+
)
|
| 327 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 328 |
+
args.model_path,
|
| 329 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 330 |
+
local_files_only=local_files_only,
|
| 331 |
+
)
|
| 332 |
else:
|
| 333 |
# Graceful fallback when local model folder has config/tokenizer but no weight files.
|
| 334 |
fallback_base = args.base_model
|
|
|
|
| 357 |
),
|
| 358 |
file=sys.stderr,
|
| 359 |
)
|
| 360 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 361 |
+
fallback_base,
|
| 362 |
+
local_files_only=local_files_only,
|
| 363 |
+
)
|
| 364 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 365 |
+
fallback_base,
|
| 366 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
| 367 |
+
local_files_only=local_files_only,
|
| 368 |
+
)
|
| 369 |
if tokenizer.pad_token is None:
|
| 370 |
tokenizer.pad_token = tokenizer.eos_token
|
| 371 |
model.eval()
|