Instructions to use yujiepan/opt-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/opt-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yujiepan/opt-tiny-random")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yujiepan/opt-tiny-random") model = AutoModelForCausalLM.from_pretrained("yujiepan/opt-tiny-random") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use yujiepan/opt-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/opt-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/opt-tiny-random", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/yujiepan/opt-tiny-random
- SGLang
How to use yujiepan/opt-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/opt-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/opt-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/opt-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/opt-tiny-random", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use yujiepan/opt-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/opt-tiny-random
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pipeline_tag: text-generation
|
| 3 |
+
inference: true
|
| 4 |
+
widget:
|
| 5 |
+
- text: 'Hello!'
|
| 6 |
+
example_title: Hello world
|
| 7 |
+
group: Python
|
| 8 |
+
library_name: transformers
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
This model is randomly initialized, using the config from [facebook/opt-30b](https://huggingface.co/facebook/opt-30b) but with smaller size.
|
| 12 |
+
Note the model is in float16.
|
| 13 |
+
|
| 14 |
+
Codes:
|
| 15 |
+
```python
|
| 16 |
+
import torch
|
| 17 |
+
import transformers
|
| 18 |
+
import os
|
| 19 |
+
from optimum.intel.openvino import OVModelForCausalLM
|
| 20 |
+
|
| 21 |
+
save_path = '/tmp/yujiepan/opt-tiny-random'
|
| 22 |
+
repo_id = 'yujiepan/opt-tiny-random'
|
| 23 |
+
|
| 24 |
+
config = transformers.AutoConfig.from_pretrained('facebook/opt-30b')
|
| 25 |
+
config.ffn_dim = 32
|
| 26 |
+
config.hidden_size = 8
|
| 27 |
+
config.num_attention_heads = 2
|
| 28 |
+
config.num_hidden_layers = 2
|
| 29 |
+
config.word_embed_proj_dim = 8
|
| 30 |
+
|
| 31 |
+
model = transformers.AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16)
|
| 32 |
+
model = model.half()
|
| 33 |
+
model.save_pretrained(save_path)
|
| 34 |
+
|
| 35 |
+
tokenizer = transformers.AutoTokenizer.from_pretrained('facebook/opt-30b')
|
| 36 |
+
tokenizer.save_pretrained(save_path)
|
| 37 |
+
|
| 38 |
+
ovmodel = OVModelForCausalLM.from_pretrained(save_path, export=True)
|
| 39 |
+
ovmodel = ovmodel.half()
|
| 40 |
+
ovmodel.save_pretrained(save_path)
|
| 41 |
+
|
| 42 |
+
os.system(f'ls -alh {save_path}')
|
| 43 |
+
|
| 44 |
+
from huggingface_hub import create_repo, upload_folder
|
| 45 |
+
create_repo(repo_id, exist_ok=True)
|
| 46 |
+
upload_folder(repo_id=repo_id, folder_path=save_path)
|
| 47 |
+
```
|