Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets new
  • Docs
  • Enterprise
  • Pricing
    • Website
      • Tasks
      • HuggingChat
      • Collections
      • Languages
      • Organizations
    • Community
      • Blog
      • Posts
      • Daily Papers
      • Learn
      • Discord
      • Forum
      • GitHub
    • Solutions
      • Team & Enterprise
      • Hugging Face PRO
      • Enterprise Support
      • Inference Providers
      • Inference Endpoints
      • Storage Buckets

  • Log In
  • Sign Up

sxx123
/
gpt2-medium

Text Generation
Transformers
PyTorch
google-tensorflow TensorFlow
JAX
Rust
Safetensors
English
gpt2
text-generation-inference
Model card Files Files and versions
xet
Community

Instructions to use sxx123/gpt2-medium with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • Transformers

    How to use sxx123/gpt2-medium with Transformers:

    # Use a pipeline as a high-level helper
    from transformers import pipeline
    
    pipe = pipeline("text-generation", model="sxx123/gpt2-medium")
    # Load model directly
    from transformers import AutoTokenizer, AutoModelForCausalLM
    
    tokenizer = AutoTokenizer.from_pretrained("sxx123/gpt2-medium")
    model = AutoModelForCausalLM.from_pretrained("sxx123/gpt2-medium")
  • Notebooks
  • Google Colab
  • Kaggle
  • Local Apps Settings
  • vLLM

    How to use sxx123/gpt2-medium with vLLM:

    Install from pip and serve model
    # Install vLLM from pip:
    pip install vllm
    # Start the vLLM server:
    vllm serve "sxx123/gpt2-medium"
    # Call the server using curl (OpenAI-compatible API):
    curl -X POST "http://localhost:8000/v1/completions" \
    	-H "Content-Type: application/json" \
    	--data '{
    		"model": "sxx123/gpt2-medium",
    		"prompt": "Once upon a time,",
    		"max_tokens": 512,
    		"temperature": 0.5
    	}'
    Use Docker
    docker model run hf.co/sxx123/gpt2-medium
  • SGLang

    How to use sxx123/gpt2-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 "sxx123/gpt2-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": "sxx123/gpt2-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 "sxx123/gpt2-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": "sxx123/gpt2-medium",
    		"prompt": "Once upon a time,",
    		"max_tokens": 512,
    		"temperature": 0.5
    	}'
  • Docker Model Runner

    How to use sxx123/gpt2-medium with Docker Model Runner:

    docker model run hf.co/sxx123/gpt2-medium
gpt2-medium
7.61 GB
Ctrl+K
Ctrl+K
  • 1 contributor
History: 18 commits
sxx123's picture
sxx123
Update config.json
8e5864c almost 3 years ago
  • .gitattributes
    206 Bytes
    Upload tf_model.h5 almost 3 years ago
  • README.md
    11.9 kB
    Upload README.md almost 3 years ago
  • config.json
    719 Bytes
    Update config.json almost 3 years ago
  • flax_model.msgpack
    1.42 GB
    xet
    Upload flax_model.msgpack almost 3 years ago
  • generation_config.json
    124 Bytes
    Upload generation_config.json almost 3 years ago
  • generation_config_for_text_generation.json
    165 Bytes
    Upload generation_config_for_text_generation.json almost 3 years ago
  • gitattributes.txt
    445 Bytes
    Upload gitattributes.txt almost 3 years ago
  • merges.txt
    456 kB
    Upload merges.txt almost 3 years ago
  • model.safetensors
    1.52 GB
    xet
    Upload model.safetensors almost 3 years ago
  • pytorch_model.bin

    Detected Pickle imports (3)

    • "torch._utils._rebuild_tensor_v2",
    • "torch.FloatStorage",
    • "collections.OrderedDict"

    What is a pickle import?

    1.52 GB
    xet
    Upload pytorch_model.bin almost 3 years ago
  • rust_model.ot
    1.73 GB
    xet
    Upload rust_model.ot almost 3 years ago
  • tf_model.h5
    1.42 GB
    xet
    Upload tf_model.h5 almost 3 years ago
  • tokenizer.json
    1.36 MB
    Upload tokenizer.json almost 3 years ago
  • vocab.json
    1.04 MB
    Upload vocab.json almost 3 years ago