ccm commited on
Commit
316ac93
·
verified ·
1 Parent(s): 1d48be6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -21,7 +21,7 @@ PUBLICATIONS_TO_RETRIEVE = 10
21
 
22
 
23
  def embedding(
24
- device: str = "mps", normalize_embeddings: bool = False
25
  ) -> langchain_huggingface.HuggingFaceEmbeddings:
26
  """Loads embedding model with specified device and normalization."""
27
  return langchain_huggingface.HuggingFaceEmbeddings(
@@ -70,16 +70,18 @@ def preprocess(query: str, k: int) -> str:
70
 
71
 
72
  @spaces.GPU
73
- def reply(message: str) -> str:
74
  """
75
  Generates a response to the user’s message.
76
  """
77
  # Preprocess message
78
 
79
- pipe = transformers.pipeline("text-generation", model="Qwen/Qwen2.5-7B-Instruct")
 
 
80
 
81
  message = preprocess(message, PUBLICATIONS_TO_RETRIEVE)
82
- return pipe(message, max_new_tokens=512, device="mps")[0]["generated_text"]
83
 
84
 
85
  # Example Queries for Interface
 
21
 
22
 
23
  def embedding(
24
+ device: str = "cuda", normalize_embeddings: bool = False
25
  ) -> langchain_huggingface.HuggingFaceEmbeddings:
26
  """Loads embedding model with specified device and normalization."""
27
  return langchain_huggingface.HuggingFaceEmbeddings(
 
70
 
71
 
72
  @spaces.GPU
73
+ def reply(message: str, history: list[str]) -> str:
74
  """
75
  Generates a response to the user’s message.
76
  """
77
  # Preprocess message
78
 
79
+ pipe = transformers.pipeline(
80
+ "text-generation", model="Qwen/Qwen2.5-7B-Instruct", device="cuda"
81
+ )
82
 
83
  message = preprocess(message, PUBLICATIONS_TO_RETRIEVE)
84
+ return pipe(message, max_new_tokens=512)[0]["generated_text"]
85
 
86
 
87
  # Example Queries for Interface