GPT2
Collection
GPT-2 fine-tunes: arxiv, exomachina, and ArtPrompter. • 3 items • Updated
How to use pearsonkyle/gpt2-arxiv with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="pearsonkyle/gpt2-arxiv") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("pearsonkyle/gpt2-arxiv")
model = AutoModelForCausalLM.from_pretrained("pearsonkyle/gpt2-arxiv", device_map="auto")How to use pearsonkyle/gpt2-arxiv with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "pearsonkyle/gpt2-arxiv"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "pearsonkyle/gpt2-arxiv",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/pearsonkyle/gpt2-arxiv
How to use pearsonkyle/gpt2-arxiv with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "pearsonkyle/gpt2-arxiv" \
--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": "pearsonkyle/gpt2-arxiv",
"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 "pearsonkyle/gpt2-arxiv" \
--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": "pearsonkyle/gpt2-arxiv",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use pearsonkyle/gpt2-arxiv with Docker Model Runner:
docker model run hf.co/pearsonkyle/gpt2-arxiv
A gpt2 powered predictive keyboard trained on ~1.6M manuscript abstracts from the ArXiv. This model uses https://www.kaggle.com/datasets/Cornell-University/arxiv
from transformers import pipeline
from transformers import GPT2TokenizerFast
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
llm = pipeline('text-generation',model='pearsonkyle/gpt2-arxiv', tokenizer=tokenizer)
texts = llm("Directly imaged exoplanets probe",
max_length=50, do_sample=True, num_return_sequences=5,
penalty_alpha=0.65, top_k=40, repetition_penalty=1.25,
temperature=0.95)
for i in range(5):
print(texts[i]['generated_text']+'\n')
that large, deciduous forest fires are composed of mostly dry, unprocessed material that is distributed in a nearly patchy fashion. The distributions of these fires are correlated with temperature, and also with vegetation...the atmospheres of giant planets. The detection of such planets requires high-quality imaging with high contrast and angular resolution, as well asthe planetary conditions including atmospheric temperature and cloud properties, which is essential for understanding how the planet interacts with the atmosphere and how it affects the climate. The primary science objective of this paper is to develop a methodology that can be applied to any kind of observation and measurement data, and to provide a framework that enables the detection and characterization of the atmospheres of exoplanetsGPT-2: 12-layer, 768-hidden, 12-heads, 117M parameters
Coming soon...
Be careful when generating a lot of text or when changing the sampling mode of the language model. It can sometimes produce things that are not truthful, e.g.,
~49 hours on a 3090 training for 1.25M iterations
The following hyperparameters were used during training: