Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,14 @@ body::before {
|
|
| 37 |
|
| 38 |
#keras.config.set_floatx("bfloat16") uncomment to run at half precision.
|
| 39 |
gemma_lm = keras_nlp.models.CausalLM.from_preset("hf://sultan-hassan/CosmoGemma_2b_en")
|
| 40 |
-
chat = utils.ChatState(gemma_lm) # adding a chat helper to manage the conversation state (modified version from https://github.com/google-gemini/gemma-cookbook/blob/main/Gemma/Keras_Gemma_2_Quickstart_Chat.ipynb)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
def launch(message):
|
| 43 |
|
|
@@ -52,13 +59,14 @@ def launch(message):
|
|
| 52 |
ind = out.index('\n\nResponse:\n') + len('\n\nResponse:\n')
|
| 53 |
return out[ind:]
|
| 54 |
|
| 55 |
-
# This is to convert QA system to a chatbot
|
| 56 |
#chat_history = chat.send_message(message) + "\n\n##### History #####\n\n" + chat.get_history()
|
| 57 |
#return chat_history
|
| 58 |
|
| 59 |
iface = gr.Interface(launch,
|
| 60 |
inputs="text",
|
| 61 |
outputs="text",
|
|
|
|
| 62 |
css=css,
|
| 63 |
title="Hey I am CosmoGemma 👋 I can answer cosmology questions from astroph.CO research articles. Try me :)",
|
| 64 |
description="Gemma_2b_en fine-tuned on QA pairs (~3.5k) generated from Cosmology and Nongalactic Astrophysics articles (arXiv astro-ph.CO) from 2018-2022 and tested on QA pairs (~1k) generated from 2023 articles, scoring over 75% accuracy.")
|
|
|
|
| 37 |
|
| 38 |
#keras.config.set_floatx("bfloat16") uncomment to run at half precision.
|
| 39 |
gemma_lm = keras_nlp.models.CausalLM.from_preset("hf://sultan-hassan/CosmoGemma_2b_en")
|
| 40 |
+
#chat = utils.ChatState(gemma_lm) # adding a chat helper to manage the conversation state (modified version from https://github.com/google-gemini/gemma-cookbook/blob/main/Gemma/Keras_Gemma_2_Quickstart_Chat.ipynb)
|
| 41 |
+
|
| 42 |
+
examples = [
|
| 43 |
+
'What are some common methods for model selection in astrophysics?',
|
| 44 |
+
'Please list two interesting projects to work on to advance cosmology?',
|
| 45 |
+
'What is the primary reason for the decline in the number density of luminous quasars at redshifts greater than 5?',
|
| 46 |
+
'What is the primary goal of calibrating subgrid feedback models in cosmological simulations?',
|
| 47 |
+
]
|
| 48 |
|
| 49 |
def launch(message):
|
| 50 |
|
|
|
|
| 59 |
ind = out.index('\n\nResponse:\n') + len('\n\nResponse:\n')
|
| 60 |
return out[ind:]
|
| 61 |
|
| 62 |
+
# This is to convert QA system to a chatbot by adding history to prompt
|
| 63 |
#chat_history = chat.send_message(message) + "\n\n##### History #####\n\n" + chat.get_history()
|
| 64 |
#return chat_history
|
| 65 |
|
| 66 |
iface = gr.Interface(launch,
|
| 67 |
inputs="text",
|
| 68 |
outputs="text",
|
| 69 |
+
examples=examples,
|
| 70 |
css=css,
|
| 71 |
title="Hey I am CosmoGemma 👋 I can answer cosmology questions from astroph.CO research articles. Try me :)",
|
| 72 |
description="Gemma_2b_en fine-tuned on QA pairs (~3.5k) generated from Cosmology and Nongalactic Astrophysics articles (arXiv astro-ph.CO) from 2018-2022 and tested on QA pairs (~1k) generated from 2023 articles, scoring over 75% accuracy.")
|