alexkueck commited on
Commit
ced6d3a
1 Parent(s): 33355f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -5
app.py CHANGED
@@ -270,7 +270,7 @@ def create_assistant_suche(prompt):
270
  #########################################################
271
  #Funktion wird direkt aufgerufen aus der GUI - von hier muss auch die Rückmeldung kommen....
272
  #man kann einen Text-Prompt eingeben (mit oder ohne RAG), dazu ein Image hochladen, ein Bild zu einem reinen textprompt erzeugen lassen
273
- def generate_auswahl(prompt_in, file, file_history, chatbot, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
274
  global splittet, db
275
  #wenn RAG angeschaltet - Vektorstore initialisieren
276
  #aber nur, wenn es noch nicht geshehen ist (splittet = False)
@@ -294,7 +294,7 @@ def generate_auswahl(prompt_in, file, file_history, chatbot, history, rag_option
294
  #kein Bild hochgeladen -> auf Text antworten...
295
  status = "Antwort der KI ..."
296
  if (file == None and file_history == None):
297
- result, status = generate_text(prompt, chatbot, history, rag_option, model_option, openai_api_key, db, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,)
298
  history = history + [[prompt, result]]
299
  else:
300
  #Es wurde ein File neu angehängt -> wenn prompt dazu, das Bild analysieren
@@ -398,7 +398,7 @@ def generate_text_zu_doc(file, prompt, k, rag_option, chatbot, history, db):
398
  ####################################################
399
  #aus einem Text-Prompt die Antwort von KI bekommen
400
  #mit oder ohne RAG möglich
401
- def generate_text (prompt, chatbot, history, rag_option, model_option, openai_api_key, db, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,):
402
  global splittet
403
  suche_im_Netz="Antwort der KI ..."
404
  print("Text pur..............................")
@@ -434,7 +434,7 @@ def generate_text (prompt, chatbot, history, rag_option, model_option, openai_ap
434
  else:
435
  #oder an Hugging Face --------------------------
436
  print("HF Anfrage.......................")
437
- model_kwargs={"temperature": 0.5, "max_length": 128, "num_return_sequences": 2}
438
  llm = HuggingFaceHub(repo_id=repo_id, model_kwargs=model_kwargs)
439
  #llm = HuggingFaceChain(model=MODEL_NAME_HF, model_kwargs={"temperature": 0.5, "max_length": 128})
440
  #llm = HuggingFaceHub(url_??? = "https://wdgsjd6zf201mufn.us-east-1.aws.endpoints.huggingface.cloud", model_kwargs={"temperature": 0.5, "max_length": 64})
@@ -563,6 +563,15 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
563
  label="Top-p",
564
  visible=False,
565
  )
 
 
 
 
 
 
 
 
 
566
  temperature = gr.Slider(
567
  minimum=0.1,
568
  maximum=2.0,
@@ -651,7 +660,8 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
651
  temperature,
652
  max_length_tokens,
653
  max_context_length_tokens,
654
- repetition_penalty
 
655
  ],
656
  outputs=[chatbot, history, attached_file, attached_file_history, status_display],
657
  show_progress=True,
 
270
  #########################################################
271
  #Funktion wird direkt aufgerufen aus der GUI - von hier muss auch die Rückmeldung kommen....
272
  #man kann einen Text-Prompt eingeben (mit oder ohne RAG), dazu ein Image hochladen, ein Bild zu einem reinen textprompt erzeugen lassen
273
+ def generate_auswahl(prompt_in, file, file_history, chatbot, history, rag_option, model_option, openai_api_key, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,top_k=35):
274
  global splittet, db
275
  #wenn RAG angeschaltet - Vektorstore initialisieren
276
  #aber nur, wenn es noch nicht geshehen ist (splittet = False)
 
294
  #kein Bild hochgeladen -> auf Text antworten...
295
  status = "Antwort der KI ..."
296
  if (file == None and file_history == None):
297
+ result, status = generate_text(prompt, chatbot, history, rag_option, model_option, openai_api_key, db, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,, top_k=35)
298
  history = history + [[prompt, result]]
299
  else:
300
  #Es wurde ein File neu angehängt -> wenn prompt dazu, das Bild analysieren
 
398
  ####################################################
399
  #aus einem Text-Prompt die Antwort von KI bekommen
400
  #mit oder ohne RAG möglich
401
+ def generate_text (prompt, chatbot, history, rag_option, model_option, openai_api_key, db, k=3, top_p=0.6, temperature=0.5, max_new_tokens=4048, max_context_length_tokens=2048, repetition_penalty=1.3,, top_k=35):
402
  global splittet
403
  suche_im_Netz="Antwort der KI ..."
404
  print("Text pur..............................")
 
434
  else:
435
  #oder an Hugging Face --------------------------
436
  print("HF Anfrage.......................")
437
+ model_kwargs={"temperature": 0.5, "max_length": 512, "num_return_sequences": 1, "top_k": top_k, "top_p": top_p, "repetition_penalty": repetition_penalty}
438
  llm = HuggingFaceHub(repo_id=repo_id, model_kwargs=model_kwargs)
439
  #llm = HuggingFaceChain(model=MODEL_NAME_HF, model_kwargs={"temperature": 0.5, "max_length": 128})
440
  #llm = HuggingFaceHub(url_??? = "https://wdgsjd6zf201mufn.us-east-1.aws.endpoints.huggingface.cloud", model_kwargs={"temperature": 0.5, "max_length": 64})
 
563
  label="Top-p",
564
  visible=False,
565
  )
566
+ top_k = gr.Slider(
567
+ minimum=1,
568
+ maximum=100,
569
+ value=35,
570
+ step=1,
571
+ interactive=True,
572
+ label="Top-k",
573
+ visible=False,
574
+ )
575
  temperature = gr.Slider(
576
  minimum=0.1,
577
  maximum=2.0,
 
660
  temperature,
661
  max_length_tokens,
662
  max_context_length_tokens,
663
+ repetition_penalty,
664
+ top_k
665
  ],
666
  outputs=[chatbot, history, attached_file, attached_file_history, status_display],
667
  show_progress=True,