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 data/train_tokenizer.py from hatanp/gpt-fi: direct link, hf CLI and curl.
- Browser
- Download file 914 Bytes
-
https://huggingface.co/hatanp/gpt-fi/resolve/refs%2Fpr%2F2/data/train_tokenizer.py
- Command line
-
hf download hf://hatanp/gpt-fi@refs/pr/2/data/train_tokenizer.py
-
curl -L -o train_tokenizer.py https://huggingface.co/hatanp/gpt-fi/resolve/refs%2Fpr%2F2/data/train_tokenizer.py
914 Bytes
| from tokenizers import Tokenizer, normalizers, models, pre_tokenizers, processors, ByteLevelBPETokenizer | |
| import tokenizers | |
| from tokenizers.models import WordPiece, BPE | |
| from tokenizers.trainers import WordPieceTrainer, BpeTrainer | |
| from tokenizers.pre_tokenizers import Whitespace, Punctuation, Sequence | |
| from tokenizers.processors import TemplateProcessing | |
| import os | |
| from transformers import AutoTokenizer | |
| old_tokenizer = AutoTokenizer.from_pretrained("gpt2") | |
| import datasets | |
| input_dir = "/dataset/location" | |
| dataset = datasets.load_from_disk(input_dir) | |
| def get_training_corpus(): | |
| for start_idx in range(0, len(dataset), 10000): | |
| samples = dataset[start_idx : start_idx + 10000] | |
| yield samples["text"] | |
| print("start") | |
| tokenizer = old_tokenizer.train_new_from_iterator(get_training_corpus(), vocab_size=50000) | |
| print("end") | |
| tokenizer.save_vocabulary("/tokenizer_location") | |