Instructions to use EleutherAI/gpt-j-6b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use EleutherAI/gpt-j-6b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="EleutherAI/gpt-j-6b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6b") model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-j-6b") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use EleutherAI/gpt-j-6b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "EleutherAI/gpt-j-6b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "EleutherAI/gpt-j-6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/EleutherAI/gpt-j-6b
- SGLang
How to use EleutherAI/gpt-j-6b 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 "EleutherAI/gpt-j-6b" \ --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": "EleutherAI/gpt-j-6b", "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 "EleutherAI/gpt-j-6b" \ --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": "EleutherAI/gpt-j-6b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use EleutherAI/gpt-j-6b with Docker Model Runner:
docker model run hf.co/EleutherAI/gpt-j-6b
ValueError: Attempting to unscale FP16 gradients.
Hi I am getting this error when I am trying to fine-tune gpt-j-6b on custom data? Any one has any idea on this?
This happens when I call my trainer.train() to fine-tune the model
```
ValueError Traceback (most recent call last)
/tmp/ipykernel_7169/3756176484.py in
46
47 # Fine-tune the model
---> 48 trainer.train()
/opt/conda/lib/python3.8/site-packages/transformers/trainer.py in train(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)
1631 self._inner_training_loop, self._train_batch_size, args.auto_find_batch_size
1632 )
-> 1633 return inner_training_loop(
1634 args=args,
1635 resume_from_checkpoint=resume_from_checkpoint,
/opt/conda/lib/python3.8/site-packages/transformers/trainer.py in inner_training_loop(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)
1933 xm.all_reduce("sum", gradients, scale=1.0 / xm.xrt_world_size())
1934 # AMP: gradients need unscaling
-> 1935 self.scaler.unscale(self.optimizer)
1936
1937 if is_sagemaker_mp_enabled() and args.fp16:
/opt/conda/lib/python3.8/site-packages/torch/cuda/amp/grad_scaler.py in unscale_(self, optimizer)
282 found_inf = torch.full((1,), 0.0, dtype=torch.float32, device=self._scale.device)
283
--> 284 optimizer_state["found_inf_per_device"] = self.unscale_grads(optimizer, inv_scale, found_inf, False)
285 optimizer_state["stage"] = OptState.UNSCALED
286
/opt/conda/lib/python3.8/site-packages/torch/cuda/amp/grad_scaler.py in unscale_grads(self, optimizer, inv_scale, found_inf, allow_fp16)
210 continue
211 if (not allow_fp16) and param.grad.dtype == torch.float16:
--> 212 raise ValueError("Attempting to unscale FP16 gradients.")
213 if param.grad.is_sparse:
214 # is_coalesced() == False means the sparse grad has values with duplicate indices.
ValueError: Attempting to unscale FP16 gradients.
```