Instructions to use yhavinga/gpt-neo-125M-dutch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yhavinga/gpt-neo-125M-dutch with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yhavinga/gpt-neo-125M-dutch")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("yhavinga/gpt-neo-125M-dutch") model = AutoModelForMultimodalLM.from_pretrained("yhavinga/gpt-neo-125M-dutch") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yhavinga/gpt-neo-125M-dutch with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yhavinga/gpt-neo-125M-dutch" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yhavinga/gpt-neo-125M-dutch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yhavinga/gpt-neo-125M-dutch
- SGLang
How to use yhavinga/gpt-neo-125M-dutch 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 "yhavinga/gpt-neo-125M-dutch" \ --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": "yhavinga/gpt-neo-125M-dutch", "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 "yhavinga/gpt-neo-125M-dutch" \ --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": "yhavinga/gpt-neo-125M-dutch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yhavinga/gpt-neo-125M-dutch with Docker Model Runner:
docker model run hf.co/yhavinga/gpt-neo-125M-dutch
| ''''This script was used to replace the final index of tokenizer.json and vocab.json | |
| with "<|endoftext|>" token. Also reassociate the corresponding merges''' | |
| import json | |
| tokenizer_path = 'tokenizer.json' | |
| model_config_path = 'config.json' | |
| vocab_path = 'vocab.json' | |
| with open(vocab_path, "r") as f: | |
| vocab_data = json.load(f) | |
| with open(tokenizer_path, "r") as f: | |
| tokenizer_data = json.load(f) | |
| with open(model_config_path, "r") as f: | |
| model_config = json.load(f) | |
| model_vocab_size = model_config['vocab_size'] | |
| tokenizer_vocab = tokenizer_data['model']['vocab'] | |
| mergeslength = len(tokenizer_data['model']['merges']) | |
| #readjust added_tokens 'id' to model_vocab_size - 1 | |
| tokenizer_data['added_tokens'][-1]['id'] = model_vocab_size - 1 | |
| final_index = model_vocab_size - 1 | |
| eos = '<|endoftext|>' | |
| #retrieve the key of final index | |
| old_key_final_index_tokenizer = list(tokenizer_data['model']['vocab'].keys())[final_index] | |
| old_key_final_index_vocab = list(vocab_data.keys())[final_index] | |
| old_key_final_index_vocab_min2 = list(vocab_data.keys())[final_index - 1] | |
| old_key_final_index_tokenizer_merges = tokenizer_data['model']['merges'][mergeslength - 1] | |
| print(f"old_key_final_index_tokenizer = {old_key_final_index_tokenizer}") | |
| print(f"old_key_final_index_vocab = {old_key_final_index_vocab}") | |
| print(f"old_key_final_index_vocab_min2 = {old_key_final_index_vocab_min2}") | |
| print(f"old_key_final_index_tokenizer_merges = {old_key_final_index_tokenizer_merges}") | |
| #replace old key with new key | |
| tokenizer_data['model']['vocab']['<|endoftext|>'] = tokenizer_data['model']['vocab'][old_key_final_index_tokenizer] | |
| vocab_data[eos] = vocab_data[old_key_final_index_vocab] | |
| #replace the final merges idx with vocab_data - 1 | |
| tokenizer_data['model']['merges'] = tokenizer_data['model']['merges'][: mergeslength - 1] | |
| #delete old key | |
| del tokenizer_data['model']['vocab'][old_key_final_index_tokenizer] | |
| del vocab_data[old_key_final_index_vocab] | |
| #check updated key | |
| old_key_final_index_tokenizer = list(tokenizer_data['model']['vocab'].keys())[final_index] | |
| old_key_final_index_vocab = list(vocab_data.keys())[final_index] | |
| old_key_final_index_tokenizer_merges = tokenizer_data['model']['merges'][mergeslength - 2] | |
| print(len(tokenizer_data['model']['merges'])) | |
| print() | |
| print(f"updated old_key_final_index_tokenizer = {old_key_final_index_tokenizer}") | |
| print(f"updated old_key_final_index_vocab = {old_key_final_index_vocab}") | |
| print(f"updated old_key_final_index_tokenizer_merges = {old_key_final_index_tokenizer_merges}") | |
| with open(tokenizer_path, "w")as f: | |
| json.dump(tokenizer_data, f) | |
| with open(vocab_path, "w")as f: | |
| json.dump(vocab_data, f) | |
| with open('merges.txt') as f: | |
| lines = f.readlines() | |
| with open("merges.txt", "w") as f: | |
| for i in range(len(lines) - 1): | |
| f.write(lines[i]) | |
| with open('merges.txt') as f: | |
| newlines = f.readlines() | |
| print(f"newlines[len(newlines) - 1] = {newlines[len(newlines) - 1]}") | |