ccm commited on
Commit
326fe51
·
verified ·
1 Parent(s): d5f3fea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -19
app.py CHANGED
@@ -36,7 +36,7 @@ import gradio # Interface handling
36
  import spaces # For GPU
37
  import langchain_community.vectorstores # Vectorstore for publications
38
  import langchain_huggingface # Embeddings
39
- import llama_cpp
40
 
41
  # The number of publications to retrieve for the prompt
42
  PUBLICATIONS_TO_RETRIEVE = 5
@@ -67,15 +67,8 @@ publication_vectorstore = langchain_community.vectorstores.FAISS.load_local(
67
  )
68
 
69
  # Create the callable LLM
70
- # llm = transformers.pipeline(
71
- # task="text-generation", model="Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4", device="cuda"
72
- # )
73
- llm = llama_cpp.Llama.from_pretrained(
74
- repo_id="bartowski/Qwen2.5-7B-Instruct-GGUF",
75
- filename="Qwen2.5-7B-Instruct-Q4_K_M.gguf",
76
- n_gpu_layers=-1,
77
- n_ctx=2048,
78
- verbose=True
79
  )
80
 
81
 
@@ -122,15 +115,13 @@ def reply(message: str, history: list[str]) -> str:
122
  str: The generated response from the language model.
123
  """
124
 
125
- # return llm(
126
- # preprocess(message),
127
- # max_new_tokens=512,
128
- # return_full_text=False,
129
- # )[
130
- # 0
131
- # ]["generated_text"]
132
-
133
- return llm(preprocess(message))["choices"][0]["text"]
134
 
135
  # Example Queries for Interface
136
  EXAMPLE_QUERIES = [
 
36
  import spaces # For GPU
37
  import langchain_community.vectorstores # Vectorstore for publications
38
  import langchain_huggingface # Embeddings
39
+ import transformers
40
 
41
  # The number of publications to retrieve for the prompt
42
  PUBLICATIONS_TO_RETRIEVE = 5
 
67
  )
68
 
69
  # Create the callable LLM
70
+ llm = transformers.pipeline(
71
+ task="text-generation", model="Qwen/Qwen2.5-7B-Instruct-GPTQ-Int4", device="cuda"
 
 
 
 
 
 
 
72
  )
73
 
74
 
 
115
  str: The generated response from the language model.
116
  """
117
 
118
+ return llm(
119
+ preprocess(message),
120
+ max_new_tokens=512,
121
+ return_full_text=False,
122
+ )[
123
+ 0
124
+ ]["generated_text"]
 
 
125
 
126
  # Example Queries for Interface
127
  EXAMPLE_QUERIES = [