Instructions to use zhuimengshaonian/gpt2-ancient-medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zhuimengshaonian/gpt2-ancient-medium with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zhuimengshaonian/gpt2-ancient-medium")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zhuimengshaonian/gpt2-ancient-medium") model = AutoModelForCausalLM.from_pretrained("zhuimengshaonian/gpt2-ancient-medium") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zhuimengshaonian/gpt2-ancient-medium with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zhuimengshaonian/gpt2-ancient-medium" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zhuimengshaonian/gpt2-ancient-medium", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/zhuimengshaonian/gpt2-ancient-medium
- SGLang
How to use zhuimengshaonian/gpt2-ancient-medium 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 "zhuimengshaonian/gpt2-ancient-medium" \ --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": "zhuimengshaonian/gpt2-ancient-medium", "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 "zhuimengshaonian/gpt2-ancient-medium" \ --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": "zhuimengshaonian/gpt2-ancient-medium", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use zhuimengshaonian/gpt2-ancient-medium with Docker Model Runner:
docker model run hf.co/zhuimengshaonian/gpt2-ancient-medium
YAML Metadata Error:"widget" must be an array
Chinese Ancient GPT2 Model
Model description
The model is used to generate ancient Chinese.The model uses the frame of GPT2-medium. We trained on 4 P100 for about 8 days.(batch size = 4, steps = 1M)
How to use
You can use the model directly with a pipeline for text generation:
from transformers import BertTokenizer, GPT2LMHeadModel, TextGenerationPipeline
tokenizer = BertTokenizer.from_pretrained("zhuimengshaonian/gpt2-ancient-medium")
model = GPT2LMHeadModel.from_pretrained("zhuimengshaonian/gpt2-ancient-medum")
text_generator = TextGenerationPipeline(model, tokenizer)
text_generator("[CLS]当是时", max_length=100, do_sample=True)
- Downloads last month
- 7