abisee/cnn_dailymail
Viewer • Updated • 936k • 74.9k • 359
How to use minhtoan/gpt3-small-finetune-cnndaily-news with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="minhtoan/gpt3-small-finetune-cnndaily-news") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("minhtoan/gpt3-small-finetune-cnndaily-news")
model = AutoModelForCausalLM.from_pretrained("minhtoan/gpt3-small-finetune-cnndaily-news", device_map="auto")How to use minhtoan/gpt3-small-finetune-cnndaily-news with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "minhtoan/gpt3-small-finetune-cnndaily-news"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "minhtoan/gpt3-small-finetune-cnndaily-news",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/minhtoan/gpt3-small-finetune-cnndaily-news
How to use minhtoan/gpt3-small-finetune-cnndaily-news with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "minhtoan/gpt3-small-finetune-cnndaily-news" \
--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": "minhtoan/gpt3-small-finetune-cnndaily-news",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "minhtoan/gpt3-small-finetune-cnndaily-news" \
--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": "minhtoan/gpt3-small-finetune-cnndaily-news",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use minhtoan/gpt3-small-finetune-cnndaily-news with Docker Model Runner:
docker model run hf.co/minhtoan/gpt3-small-finetune-cnndaily-news
Pretrained GPT-3 small, continuing the development of GPT NEO, with architecture that purposefully mimics that of GPT-3, model was trained on CNN Daily Mail News dataset for text generation.
from transformers import GPT2Tokenizer, GPTNeoForCausalLM
tokenizer = GPT2Tokenizer.from_pretrained('minhtoan/gpt3-small-finetune-cnndaily-news')
model = GPTNeoForCausalLM.from_pretrained('minhtoan/gpt3-small-finetune-cnndaily-news')
text = "Ever noticed how plane seats appear to be getting smaller and smaller? "
input_ids = tokenizer.encode(text, return_tensors='pt')
max_length = 150
sample_outputs = model.generate(input_ids, do_sample=True, max_length=max_length,temperature = 0.8)
for i, sample_output in enumerate(sample_outputs):
print(">> Generated text {}\n\n{}".format(i+1, tokenizer.decode(sample_output.tolist())))
print('\n---')
Phan Minh Toan