Instructions to use nnpy/opt-350m-instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nnpy/opt-350m-instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nnpy/opt-350m-instruct")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nnpy/opt-350m-instruct") model = AutoModelForCausalLM.from_pretrained("nnpy/opt-350m-instruct") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nnpy/opt-350m-instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nnpy/opt-350m-instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nnpy/opt-350m-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/nnpy/opt-350m-instruct
- SGLang
How to use nnpy/opt-350m-instruct 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 "nnpy/opt-350m-instruct" \ --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": "nnpy/opt-350m-instruct", "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 "nnpy/opt-350m-instruct" \ --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": "nnpy/opt-350m-instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use nnpy/opt-350m-instruct with Docker Model Runner:
docker model run hf.co/nnpy/opt-350m-instruct
Commit ·
c77d8d4
1
Parent(s): 746c8a9
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- openchat/openchat_sharegpt4_dataset
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
## Usage
|
| 8 |
+
```
|
| 9 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 10 |
+
tok = AutoTokenizer.from_pretrained('facebook/opt-350m')
|
| 11 |
+
model = AutoModelForCausalLM.from_pretrained('prasanna2003/opt-350m-instruct')
|
| 12 |
+
|
| 13 |
+
system_message = "You are AI language model helps the human."
|
| 14 |
+
input_prompt = "Define data science."
|
| 15 |
+
|
| 16 |
+
prompt = '<system>' + system_message + '<human>' + input_prompt + '<assistant>'
|
| 17 |
+
prompt = tokenizer(prompt, return_tensors='pt')
|
| 18 |
+
out = model.generate(**prompt, max_length=120)
|
| 19 |
+
print(tok.decode(out[0]))
|
| 20 |
+
```
|