riotu-lab commited on
Commit
618d911
1 Parent(s): a3871d3

Update app

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -2,9 +2,9 @@ import gradio as gr
2
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
 
4
  # Define the function to handle text generation
5
- def generate_text(model_name, text, num_beams, max_length, top_p, temperature, repetition_penalty, no_repeat_ngram_size):
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(model_name)
8
 
9
  # Initialize pipeline with explicit model and tokenizer
10
  pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
@@ -32,7 +32,8 @@ inputs_component = [
32
  gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Top p"),
33
  gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Temperature"),
34
  gr.Slider(minimum=1.0, maximum=5.0, step=0.5, label="Repetition Penalty"),
35
- gr.Slider(minimum=2, maximum=5, step=1, label="No Repeat Ngram Size")
 
36
  ]
37
 
38
  # Setup the interface with live=False to require button press
 
2
  from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
 
4
  # Define the function to handle text generation
5
+ def generate_text(model_name, text, num_beams, max_length, top_p, temperature, repetition_penalty, no_repeat_ngram_size, token):
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=token)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name, use_auth_token=token)
8
 
9
  # Initialize pipeline with explicit model and tokenizer
10
  pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
 
32
  gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Top p"),
33
  gr.Slider(minimum=0.1, maximum=1.0, step=0.1, label="Temperature"),
34
  gr.Slider(minimum=1.0, maximum=5.0, step=0.5, label="Repetition Penalty"),
35
+ gr.Slider(minimum=2, maximum=5, step=1, label="No Repeat Ngram Size"),
36
+ gr.Textbox(placeholder="Enter your Hugging Face token here...", label="Hugging Face Token", type="password")
37
  ]
38
 
39
  # Setup the interface with live=False to require button press