Instructions to use yujiepan/gptj-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/gptj-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yujiepan/gptj-tiny-random")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yujiepan/gptj-tiny-random") model = AutoModelForCausalLM.from_pretrained("yujiepan/gptj-tiny-random") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use yujiepan/gptj-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/gptj-tiny-random" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/gptj-tiny-random", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yujiepan/gptj-tiny-random
- SGLang
How to use yujiepan/gptj-tiny-random 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 "yujiepan/gptj-tiny-random" \ --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": "yujiepan/gptj-tiny-random", "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 "yujiepan/gptj-tiny-random" \ --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": "yujiepan/gptj-tiny-random", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yujiepan/gptj-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/gptj-tiny-random
Update README.md
Browse files
README.md
CHANGED
|
@@ -13,6 +13,7 @@ Note the model is in float16.
|
|
| 13 |
|
| 14 |
Codes:
|
| 15 |
```python
|
|
|
|
| 16 |
from huggingface_hub import create_repo, upload_folder
|
| 17 |
import torch
|
| 18 |
import transformers
|
|
@@ -23,14 +24,18 @@ save_path = '/tmp/yujiepan/gptj-tiny-random'
|
|
| 23 |
repo_id = 'yujiepan/gptj-tiny-random'
|
| 24 |
|
| 25 |
config = transformers.AutoConfig.from_pretrained(model_id)
|
| 26 |
-
config.hidden_size =
|
| 27 |
-
config.n_embd =
|
| 28 |
config.num_attention_heads = 2
|
| 29 |
config.n_head = 2
|
|
|
|
|
|
|
| 30 |
config.n_layer = 2
|
|
|
|
| 31 |
print(config)
|
| 32 |
|
| 33 |
model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
|
|
|
|
| 34 |
model.save_pretrained(save_path)
|
| 35 |
|
| 36 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
|
|
@@ -38,11 +43,9 @@ tokenizer.save_pretrained(save_path)
|
|
| 38 |
|
| 39 |
# from optimum.intel.openvino import OVModelForCausalLM
|
| 40 |
# ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
|
| 41 |
-
# ovmodel = ovmodel.half()
|
| 42 |
# ovmodel.save_pretrained(save_path)
|
| 43 |
|
| 44 |
os.system(f'ls -alh {save_path}')
|
| 45 |
-
|
| 46 |
create_repo(repo_id, exist_ok=True)
|
| 47 |
upload_folder(repo_id=repo_id, folder_path=save_path)
|
| 48 |
```
|
|
|
|
| 13 |
|
| 14 |
Codes:
|
| 15 |
```python
|
| 16 |
+
from transformers import pipeline
|
| 17 |
from huggingface_hub import create_repo, upload_folder
|
| 18 |
import torch
|
| 19 |
import transformers
|
|
|
|
| 24 |
repo_id = 'yujiepan/gptj-tiny-random'
|
| 25 |
|
| 26 |
config = transformers.AutoConfig.from_pretrained(model_id)
|
| 27 |
+
config.hidden_size = 16
|
| 28 |
+
config.n_embd = 16
|
| 29 |
config.num_attention_heads = 2
|
| 30 |
config.n_head = 2
|
| 31 |
+
config.rotary_dim = 4
|
| 32 |
+
config.num_hidden_layers = 2
|
| 33 |
config.n_layer = 2
|
| 34 |
+
config.torch_dtype = torch.float16
|
| 35 |
print(config)
|
| 36 |
|
| 37 |
model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
|
| 38 |
+
model = model.half()
|
| 39 |
model.save_pretrained(save_path)
|
| 40 |
|
| 41 |
tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
|
|
|
|
| 43 |
|
| 44 |
# from optimum.intel.openvino import OVModelForCausalLM
|
| 45 |
# ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
|
|
|
|
| 46 |
# ovmodel.save_pretrained(save_path)
|
| 47 |
|
| 48 |
os.system(f'ls -alh {save_path}')
|
|
|
|
| 49 |
create_repo(repo_id, exist_ok=True)
|
| 50 |
upload_folder(repo_id=repo_id, folder_path=save_path)
|
| 51 |
```
|