Instructions to use hinttt/gpt2-imdb-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasHub
How to use hinttt/gpt2-imdb-finetuned with KerasHub:
import keras_hub # Load CausalLM model (optional: use half precision for inference) causal_lm = keras_hub.models.CausalLM.from_preset("hf://hinttt/gpt2-imdb-finetuned", 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://hinttt/gpt2-imdb-finetuned") - Keras
How to use hinttt/gpt2-imdb-finetuned with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://hinttt/gpt2-imdb-finetuned") - Notebooks
- Google Colab
- Kaggle
GPT-2 Movie Review Generator
Performance Metrics
- Training Loss: 1.0200 (after 1 epoch)
- Hardware: Google Colab GPU/TPU
Example Generation
Prompt: This movie was
Output:
one of the first I saw in theaters and I was so excited to see it again...
How to use
import keras_hub
model = keras_hub.models.CausalLM.from_preset("hf://hinttt/gpt2-imdb-finetuned")
output = model.generate("This movie was", max_length=100)
- Downloads last month
- 3