Run this model with HF Jobs
Run hatanp/gpt-fi on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/hatanp/gpt-fi. Ask me which dataset to train on, then push the LoRA adapter to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs and Transformers to run batch inference with https://huggingface.co/hatanp/gpt-fi on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the predictions back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs and Lighteval to evaluate https://huggingface.co/hatanp/gpt-fi. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/hatanp/gpt-fi with Transformers and bitsandbytes. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use hatanp/gpt-fi with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hatanp/gpt-fi with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="hatanp/gpt-fi")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("hatanp/gpt-fi") model = AutoModelForCausalLM.from_pretrained("hatanp/gpt-fi", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use hatanp/gpt-fi with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "hatanp/gpt-fi" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "hatanp/gpt-fi", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/hatanp/gpt-fi
- SGLang
How to use hatanp/gpt-fi 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 "hatanp/gpt-fi" \ --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": "hatanp/gpt-fi", "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 "hatanp/gpt-fi" \ --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": "hatanp/gpt-fi", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use hatanp/gpt-fi with Docker Model Runner:
docker model run hf.co/hatanp/gpt-fi
Download train.py from hatanp/gpt-fi: direct link, hf CLI and curl.
- Browser
- Download file 3.42 kB
-
https://huggingface.co/hatanp/gpt-fi/resolve/main/train.py
- Command line
-
hf download hf://hatanp/gpt-fi/train.py
-
curl -L -o train.py https://huggingface.co/hatanp/gpt-fi/resolve/main/train.py
3.42 kB
| import transformers | |
| import datasets | |
| from transformers import PreTrainedTokenizerFast | |
| from transformers import ( | |
| GPT2TokenizerFast, | |
| AutoConfig, | |
| AutoModelForCausalLM, | |
| Trainer, | |
| TrainingArguments, | |
| default_data_collator | |
| ) | |
| from transformers.trainer_utils import get_last_checkpoint | |
| import torch | |
| #from transformers.utils.dummy_tokenizers_objects import PreTrainedTokenizerFast | |
| #config_name = "C:\\Users\\vin\\Documents\\Projects\\NLP\\kielimalli\\config.json" | |
| #tokenizer_file = "C:\\Users\\vin\\Documents\\Projects\\NLP\\models\\tokens.json" | |
| #input_dir = "H:\\Data_temp\\tokenized_dataset" | |
| #output_dir = "H:\\Data_temp\\checkpoints\\model1" | |
| def main(): | |
| import os | |
| #enable if required by your environment | |
| #os.environ["CUDA_VISIBLE_DEVICES"] = "0" | |
| #torch.backends.cuda.matmul.allow_tf32 = True | |
| #torch.backends.cudnn.allow_tf32 = True | |
| config_name = "config_large_bpe.json" | |
| tokenizer_files = "/path/to/tokenizer/files" | |
| input_dir = "/data/dir" | |
| output_dir = "/out/dir" | |
| training_args = TrainingArguments( | |
| output_dir=output_dir, | |
| per_device_train_batch_size=4, | |
| per_device_eval_batch_size=4, | |
| learning_rate=2.067e-5, | |
| lr_scheduler_type="linear", | |
| adam_beta1=0.95, | |
| adam_beta2=0.985, | |
| adam_epsilon=1e-8, | |
| weight_decay=0.001, | |
| gradient_accumulation_steps=32, | |
| num_train_epochs=6.7, | |
| save_total_limit=2, | |
| dataloader_num_workers=10, | |
| save_steps=100, | |
| warmup_steps=1000, | |
| do_eval=True, | |
| eval_steps=1000, | |
| evaluation_strategy="steps", | |
| logging_strategy="steps", | |
| logging_steps=100, | |
| bf16=True, | |
| tf32=True, | |
| fp16_opt_level="O2", | |
| half_precision_backend="amp", | |
| bf16_full_eval=True | |
| ) | |
| print("setting up tokenizer...") | |
| tokenizer = GPT2TokenizerFast.from_pretrained(tokenizer_files) | |
| #tokenizer.add_special_tokens({'pad_token': '[PAD]'})#Probably wrong | |
| tokenizer.add_special_tokens({'pad_token': tokenizer.eos_token}) | |
| from tokenizers.processors import TemplateProcessing | |
| tokenizer._tokenizer.post_processor = TemplateProcessing( | |
| single="$0 "+tokenizer.eos_token, | |
| pair="$A "+tokenizer.eos_token+" $B:1 "+tokenizer.eos_token, | |
| special_tokens=[(tokenizer.eos_token, 0)], | |
| ) | |
| print("loading model...") | |
| config = AutoConfig.from_pretrained(config_name) | |
| model = AutoModelForCausalLM.from_config(config) | |
| #model = AutoModelForCausalLM.from_pretrained("/checkpoint/dir") if restarting training completely and loading weights from a checkpoints | |
| model.gradient_checkpointing_enable() #Optional, affects performance | |
| print("loading data...") | |
| dataset = datasets.load_from_disk(input_dir) | |
| print("starting training...") | |
| trainer = Trainer( | |
| model=model, | |
| args=training_args, | |
| train_dataset=dataset["train"], | |
| data_collator=default_data_collator, | |
| eval_dataset=dataset["test"].select(range(10000)), #To save time do not evaluate on whole test set during training | |
| tokenizer=tokenizer | |
| ) | |
| #checkpoint = None | |
| checkpoint = get_last_checkpoint(output_dir) | |
| print("checkpoint:", checkpoint) | |
| trainer.train(resume_from_checkpoint=checkpoint) | |
| if __name__ == "__main__": | |
| main() |