aliabd HF staff commited on
Commit
7e2a384
1 Parent(s): bb7ae26

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,12 +1,12 @@
1
  # URL: https://huggingface.co/spaces/gradio/text_generation
2
  # imports
3
  import gradio as gr
4
- from transformers import AutoTokenizer, AutoModelForCausalLM
5
  import torch
6
 
7
  # loading the model
8
- tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B")
9
- model = AutoModelForCausalLM.from_pretrained("EleutherAI/gpt-j-6B")
10
 
11
  # defining the core function
12
  def generate(text):
@@ -15,9 +15,8 @@ def generate(text):
15
  return result[0]["generated_text"]
16
 
17
 
18
- # defining title, description and examples
19
- title = "Text Generation with GPT-J-6B"
20
- description = "This demo generates text using GPT-J 6B: a transformer model trained using Ben Wang's Mesh Transformer JAX."
21
  examples = [
22
  ["The Moon's orbit around Earth has"],
23
  ["The smooth Borealis basin in the Northern Hemisphere covers 40%"],
 
1
  # URL: https://huggingface.co/spaces/gradio/text_generation
2
  # imports
3
  import gradio as gr
4
+ from transformers import GPT2Tokenizer, TFGPT2Model
5
  import torch
6
 
7
  # loading the model
8
+ tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
9
+ model = TFGPT2Model.from_pretrained('gpt2')
10
 
11
  # defining the core function
12
  def generate(text):
 
15
  return result[0]["generated_text"]
16
 
17
 
18
+ # defining title and examples
19
+ title = "Text Generation with GPT-2"
 
20
  examples = [
21
  ["The Moon's orbit around Earth has"],
22
  ["The smooth Borealis basin in the Northern Hemisphere covers 40%"],