Text Generation
Transformers
Russian
English
gpt2
causal-lm
experimental
trained-from-scratch
spacemodel
undertrained
Instructions to use openmodelai/Galactic-2.5-Mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openmodelai/Galactic-2.5-Mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openmodelai/Galactic-2.5-Mini")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("openmodelai/Galactic-2.5-Mini", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openmodelai/Galactic-2.5-Mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openmodelai/Galactic-2.5-Mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openmodelai/Galactic-2.5-Mini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openmodelai/Galactic-2.5-Mini
- SGLang
How to use openmodelai/Galactic-2.5-Mini 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 "openmodelai/Galactic-2.5-Mini" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openmodelai/Galactic-2.5-Mini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "openmodelai/Galactic-2.5-Mini" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openmodelai/Galactic-2.5-Mini", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openmodelai/Galactic-2.5-Mini with Docker Model Runner:
docker model run hf.co/openmodelai/Galactic-2.5-Mini
File size: 2,327 Bytes
1440c49 | 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 | """Offline load/forward/generation/round-trip checks of the exported checkpoint."""
import hashlib
import json
from pathlib import Path
import torch
from safetensors import safe_open
from transformers import AutoTokenizer, AutoModelForCausalLM, set_seed
root = Path(__file__).resolve().parent
path = root/'model'
torch.set_num_threads(2)
tok = AutoTokenizer.from_pretrained(path, local_files_only=True, trust_remote_code=False)
model = AutoModelForCausalLM.from_pretrained(path, local_files_only=True,
trust_remote_code=False, torch_dtype=torch.float32).eval()
count = sum(p.numel() for p in model.parameters())
assert count == 49999872
assert len(tok) == 23258
with safe_open(str(path/'model.safetensors'), framework='pt') as f:
tensor_count = len(f.keys())
assert all(f.get_tensor(k).dtype == torch.float16 for k in f.keys())
assert all(torch.isfinite(f.get_tensor(k)).all() for k in f.keys())
samples = []
for text in ['Однажды вечером', 'Once upon a time']:
assert tok.decode(tok.encode(text)) == text
set_seed(42)
inputs = tok(text, return_tensors='pt')
with torch.inference_mode():
logits = model(**inputs).logits
assert torch.isfinite(logits).all()
generated = model.generate(**inputs, max_new_tokens=48, do_sample=True,
temperature=.8, top_p=.9, repetition_penalty=1.1,
pad_token_id=tok.pad_token_id, eos_token_id=tok.eos_token_id)
samples.append({'prompt':text,'output':tok.decode(generated[0],skip_special_tokens=True)})
report = {'offline_transformers_load':'passed','trust_remote_code':False,
'parameters':count,'vocabulary_size':len(tok),'tensor_count':tensor_count,
'weights_dtype':'float16','finite_weights_and_logits':True,
'russian_english_tokenizer_roundtrip':'passed',
'generation_test':'execution only, NOT linguistic-quality certification',
'generation_seed':42,'max_new_tokens':48,'temperature':.8,'top_p':.9,
'repetition_penalty':1.1,'uncurated_samples':samples,
'safetensors_bytes':(path/'model.safetensors').stat().st_size,
'safetensors_sha256':hashlib.sha256((path/'model.safetensors').read_bytes()).hexdigest()}
(path/'verification.json').write_text(json.dumps(report,ensure_ascii=False,indent=2),encoding='utf-8')
print(json.dumps(report,ensure_ascii=False,indent=2))
|