ThomasBlumet commited on
Commit
6a2a8e3
·
1 Parent(s): ddfa8fe

change max_length

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
6
  logger = logging.get_logger("transformers")
7
 
8
  # Load the model and tokenizer
9
- model_name = "TheBloke/zephyr-7B-beta-GPTQ" #"openai-community/gpt2"
10
  tokenizer = AutoTokenizer.from_pretrained(model_name)
11
  #model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
12
  model = AutoModelForCausalLM.from_pretrained(model_name)
@@ -14,7 +14,7 @@ model = AutoModelForCausalLM.from_pretrained(model_name)
14
  # Fonction pour générer du texte
15
  def generate_text(prompt):
16
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
17
- summary_ids = model.generate(inputs["input_ids"], max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
18
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
19
 
20
  # #for training the model after the data is collected
 
6
  logger = logging.get_logger("transformers")
7
 
8
  # Load the model and tokenizer
9
+ model_name = "TheBloke/zephyr-7B-beta-GPTQ" #"openai-community/gpt2" or "TheBloke/Mistral-7B-Instruct-v0.1-GPTQ"
10
  tokenizer = AutoTokenizer.from_pretrained(model_name)
11
  #model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
12
  model = AutoModelForCausalLM.from_pretrained(model_name)
 
14
  # Fonction pour générer du texte
15
  def generate_text(prompt):
16
  inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512, padding="max_length")
17
+ summary_ids = model.generate(inputs["input_ids"], max_length=512, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
18
  return tokenizer.decode(summary_ids[0], skip_special_tokens=True)
19
 
20
  # #for training the model after the data is collected