Instructions to use nlpcloud/instruct-gpt-j-fp16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nlpcloud/instruct-gpt-j-fp16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nlpcloud/instruct-gpt-j-fp16")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nlpcloud/instruct-gpt-j-fp16") model = AutoModelForCausalLM.from_pretrained("nlpcloud/instruct-gpt-j-fp16") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nlpcloud/instruct-gpt-j-fp16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nlpcloud/instruct-gpt-j-fp16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nlpcloud/instruct-gpt-j-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nlpcloud/instruct-gpt-j-fp16
- SGLang
How to use nlpcloud/instruct-gpt-j-fp16 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 "nlpcloud/instruct-gpt-j-fp16" \ --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": "nlpcloud/instruct-gpt-j-fp16", "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 "nlpcloud/instruct-gpt-j-fp16" \ --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": "nlpcloud/instruct-gpt-j-fp16", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nlpcloud/instruct-gpt-j-fp16 with Docker Model Runner:
docker model run hf.co/nlpcloud/instruct-gpt-j-fp16
Awesome. Request for training script.
This is awesome. Thanks for providing this model. I was looking for such a model that is trained on instructions and this works very good. Is it possible to provide the original training script? or at least the data preprocessing scripts (involving split to chunks, converting to tokens etc..). So that I can fine tune this model in the same way for my use cases.
Thanks, great to see it's useful!
Here is the dataset I used: https://huggingface.co/datasets/nlpcloud/instructions-dataset-adapted-from-stanford-alpaca-for-gpt-j
Here's the repo I used for the fine-tuning: https://github.com/kingoflolz/mesh-transformer-jax. I used 5 epochs, and apart from that I kept the default parameters in the repo.
Thanks for your reply. Much appreciated. Could you please answer few more questions for me? While training, did you freeze any layers? and what kind of hardware/software config is used (like GPU VRAM, CPU Memory etc..)
I've initially trained base GPT-J model in fp-16 by freezing all layers and unfreezing top n layers, which provided decent results for my use case and data, but unable to train entire model on a single GPU with 24GB VRAM. Looking into AWS sagemaker SMP.
You're welcome.
No I did not freeze any layer. I fine-tuned the model on a TPU v3-8 , and followed this guide: https://github.com/kingoflolz/mesh-transformer-jax/blob/master/howto_finetune.md
The fine-tuning took around one hour.