Instructions to use readerbench/RoGPT2-large with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use readerbench/RoGPT2-large with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="readerbench/RoGPT2-large")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("readerbench/RoGPT2-large") model = AutoModelForCausalLM.from_pretrained("readerbench/RoGPT2-large", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use readerbench/RoGPT2-large with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "readerbench/RoGPT2-large" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "readerbench/RoGPT2-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/readerbench/RoGPT2-large
- SGLang
How to use readerbench/RoGPT2-large 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 "readerbench/RoGPT2-large" \ --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": "readerbench/RoGPT2-large", "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 "readerbench/RoGPT2-large" \ --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": "readerbench/RoGPT2-large", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use readerbench/RoGPT2-large with Docker Model Runner:
docker model run hf.co/readerbench/RoGPT2-large
ReaderBench commited on
Commit ·
0a955f1
1
Parent(s): e60b3cd
update how to use
Browse files
README.md
CHANGED
|
@@ -18,16 +18,16 @@ For code and evaluation check out [GitHub](https://github.com/readerbench/RoGPT2
|
|
| 18 |
|
| 19 |
```python
|
| 20 |
# TensorFlow
|
| 21 |
-
from transformers import AutoTokenizer,
|
| 22 |
|
| 23 |
tokenizer = AutoTokenizer.from_pretrained('readerbench/RoGPT2-large')
|
| 24 |
-
model =
|
| 25 |
inputs = tokenizer.encode("Este o zi de vara", return_tensors='tf')
|
| 26 |
text = model.generate(inputs, max_length=1024, no_repeat_ngram_size=2)
|
| 27 |
print(tokenizer.decode(text[0]))
|
| 28 |
|
| 29 |
# PyTorch
|
| 30 |
-
from transformers import AutoTokenizer,
|
| 31 |
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained('readerbench/RoGPT2-large')
|
| 33 |
model = AutoModelForCausalLM.from_pretrained('readerbench/RoGPT2-large')
|
|
|
|
| 18 |
|
| 19 |
```python
|
| 20 |
# TensorFlow
|
| 21 |
+
from transformers import AutoTokenizer, TFAutoModelForCausalLM
|
| 22 |
|
| 23 |
tokenizer = AutoTokenizer.from_pretrained('readerbench/RoGPT2-large')
|
| 24 |
+
model = TFAutoModelForCausalLM.from_pretrained('readerbench/RoGPT2-large')
|
| 25 |
inputs = tokenizer.encode("Este o zi de vara", return_tensors='tf')
|
| 26 |
text = model.generate(inputs, max_length=1024, no_repeat_ngram_size=2)
|
| 27 |
print(tokenizer.decode(text[0]))
|
| 28 |
|
| 29 |
# PyTorch
|
| 30 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 31 |
|
| 32 |
tokenizer = AutoTokenizer.from_pretrained('readerbench/RoGPT2-large')
|
| 33 |
model = AutoModelForCausalLM.from_pretrained('readerbench/RoGPT2-large')
|