Tijmen2 commited on
Commit
a05c286
·
verified ·
1 Parent(s): 9b19735

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -2,6 +2,7 @@ from threading import Thread
2
  import gradio as gr
3
  import random
4
  import torch
 
5
  from transformers import (
6
  AutoModelForCausalLM,
7
  AutoTokenizer,
@@ -10,8 +11,8 @@ from transformers import (
10
  )
11
 
12
  # Constants for the model and configuration
13
- MODEL_ID = "universeTBD/astrollama"
14
- WINDOW_SIZE = 4096
15
  DEVICE = "cuda"
16
 
17
  # Load model configuration, tokenizer, and model
@@ -35,7 +36,6 @@ GREETING_MESSAGES = [
35
  "The universe awaits! I'm AstroSage. What astronomical wonders shall we discuss?",
36
  ]
37
 
38
-
39
  def generate_text(prompt: str, history: list, max_new_tokens=512, temperature=0.7, top_p=0.95, top_k=50):
40
  """
41
  Generate a response using the transformer model.
@@ -86,7 +86,7 @@ def user(user_message, history):
86
  history = []
87
  return "", history + [{"role": "user", "content": user_message}]
88
 
89
-
90
  def bot(history):
91
  """
92
  Generate the bot's response based on the history.
 
2
  import gradio as gr
3
  import random
4
  import torch
5
+ import spaces
6
  from transformers import (
7
  AutoModelForCausalLM,
8
  AutoTokenizer,
 
11
  )
12
 
13
  # Constants for the model and configuration
14
+ MODEL_ID = "AstroMLab/AstroSage-8B"
15
+ WINDOW_SIZE = 2048
16
  DEVICE = "cuda"
17
 
18
  # Load model configuration, tokenizer, and model
 
36
  "The universe awaits! I'm AstroSage. What astronomical wonders shall we discuss?",
37
  ]
38
 
 
39
  def generate_text(prompt: str, history: list, max_new_tokens=512, temperature=0.7, top_p=0.95, top_k=50):
40
  """
41
  Generate a response using the transformer model.
 
86
  history = []
87
  return "", history + [{"role": "user", "content": user_message}]
88
 
89
+ @spaces.GPU
90
  def bot(history):
91
  """
92
  Generate the bot's response based on the history.