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

keras
/
gpt2_medium_en

Text Generation
KerasHub
English
Model card Files Files and versions
xet
Community

Instructions to use keras/gpt2_medium_en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • KerasHub

    How to use keras/gpt2_medium_en with KerasHub:

    import keras_hub
    
    # Load CausalLM model (optional: use half precision for inference)
    causal_lm = keras_hub.models.CausalLM.from_preset("hf://keras/gpt2_medium_en", dtype="bfloat16")
    causal_lm.compile(sampler="greedy")  # (optional) specify a sampler
    
    # Generate text
    causal_lm.generate("Keras: deep learning for", max_length=64)
    
    import keras_hub
    
    # Create a Backbone model unspecialized for any task
    backbone = keras_hub.models.Backbone.from_preset("hf://keras/gpt2_medium_en")
    
  • Keras

    How to use keras/gpt2_medium_en with Keras:

    # Available backend options are: "jax", "torch", "tensorflow".
    import os
    os.environ["KERAS_BACKEND"] = "jax"
    
    import keras
    
    model = keras.saving.load_model("hf://keras/gpt2_medium_en")
    
  • Notebooks
  • Google Colab
  • Kaggle
gpt2_medium_en / assets /tokenizer
1.5 MB
Ctrl+K
Ctrl+K
  • 3 contributors
History: 1 commit
Divyasreepat's picture
Divyasreepat
Upload folder using huggingface_hub
2f5a6cb verified over 1 year ago
  • merges.txt
    456 kB
    Upload folder using huggingface_hub over 1 year ago
  • vocabulary.json
    1.04 MB
    Upload folder using huggingface_hub over 1 year ago