Instructions to use jed351/gpt2_tiny_zh-hk-shikoto with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jed351/gpt2_tiny_zh-hk-shikoto with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jed351/gpt2_tiny_zh-hk-shikoto")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jed351/gpt2_tiny_zh-hk-shikoto") model = AutoModelForCausalLM.from_pretrained("jed351/gpt2_tiny_zh-hk-shikoto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jed351/gpt2_tiny_zh-hk-shikoto with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jed351/gpt2_tiny_zh-hk-shikoto" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jed351/gpt2_tiny_zh-hk-shikoto", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jed351/gpt2_tiny_zh-hk-shikoto
- SGLang
How to use jed351/gpt2_tiny_zh-hk-shikoto 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 "jed351/gpt2_tiny_zh-hk-shikoto" \ --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": "jed351/gpt2_tiny_zh-hk-shikoto", "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 "jed351/gpt2_tiny_zh-hk-shikoto" \ --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": "jed351/gpt2_tiny_zh-hk-shikoto", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jed351/gpt2_tiny_zh-hk-shikoto with Docker Model Runner:
docker model run hf.co/jed351/gpt2_tiny_zh-hk-shikoto
gpt2-shikoto
This model was trained on a dataset I obtained from an online novel site. Please be aware that the stories (training data) might contain inappropriate content. This model is intended for research purposes only.
The base model can be found here, which was obtained by patching a GPT2 Chinese model and its tokenizer with Cantonese characters. Refer to the base model for info on the patching process.
Training procedure
Please refer to the script provided by Huggingface.
The model was trained for 400,000 steps on 2 NVIDIA Quadro RTX6000 for around 15 hours at the Research Computing Services of Imperial College London.
Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 20
- eval_batch_size: 20
- seed: 42
- distributed_type: multi-GPU
- num_devices: 2
- total_train_batch_size: 40
- total_eval_batch_size: 40
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- training_steps: 400000
- mixed_precision_training: Native AMP
Training results
How to use it?
from transformers import AutoTokenizer
from transformers import TextGenerationPipeline, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("jed351/gpt2-tiny-zh-hk")
model = AutoModelForCausalLM.from_pretrained("jed351/gpt2_tiny_zh-hk-shikoto")
# try messing around with the parameters
generator = TextGenerationPipeline(model, tokenizer,
max_new_tokens=200,
no_repeat_ngram_size=3) #, device=0) #if you have a GPU
input_string = "your input"
output = generator(input_string)
string = output[0]['generated_text'].replace(' ', '')
print(string)
Framework versions
- Transformers 4.26.0.dev0
- Pytorch 1.13.1
- Datasets 2.8.0
- Tokenizers 0.13.2
- Downloads last month
- 7
Dataset used to train jed351/gpt2_tiny_zh-hk-shikoto
Evaluation results
- Accuracy on jed351/shikoto_zh_hkself-reported0.374