cigol123 commited on
Commit
fa18beb
·
verified ·
1 Parent(s): 52edec5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -4,32 +4,48 @@ from llama_cpp import Llama
4
  llm = Llama(
5
  model_path="yugogpt-q4_0.gguf",
6
  n_ctx=2048,
7
- n_threads=4
 
 
 
8
  )
9
 
10
  def chat(message, history):
11
- # Enhanced prompt template for more detailed responses
12
- prompt = f"""USER: {message}
13
- ASSISTANT: Let me provide you with a comprehensive and thoughtful response.
14
-
 
 
15
  """
16
 
17
  response = llm(
18
- prompt,
19
- max_tokens=1024, # Increased token limit
20
- temperature=0.8, # Slightly increased creativity
21
- stop=["USER:"], # Only stop at new user input
22
- repeat_penalty=1.2, # Reduce repetition
23
- top_p=0.95 # Maintain focus while allowing creativity
 
24
  )
25
 
26
  return response['choices'][0]['text']
27
 
28
  demo = gr.ChatInterface(
29
  fn=chat,
30
- title="YugoGPT Chat",
31
- description="Ask me anything - I'll provide detailed and thoughtful responses."
 
 
 
 
 
32
  )
33
 
34
  if __name__ == "__main__":
35
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
4
  llm = Llama(
5
  model_path="yugogpt-q4_0.gguf",
6
  n_ctx=2048,
7
+ n_threads=4,
8
+ n_batch=512,
9
+ use_mlock=True,
10
+ use_mmap=True
11
  )
12
 
13
  def chat(message, history):
14
+ # Enhanced system prompt for better responses
15
+ system_prompt = "You are a helpful, knowledgeable, and professional AI assistant. Provide detailed and thoughtful responses."
16
+
17
+ full_prompt = f"""SYSTEM: {system_prompt}
18
+ USER: {message}
19
+ ASSISTANT: Let me provide a comprehensive response.
20
  """
21
 
22
  response = llm(
23
+ full_prompt,
24
+ max_tokens=2048,
25
+ temperature=0.7,
26
+ top_p=0.95,
27
+ repeat_penalty=1.2,
28
+ top_k=40,
29
+ stop=["USER:", "\n\n"]
30
  )
31
 
32
  return response['choices'][0]['text']
33
 
34
  demo = gr.ChatInterface(
35
  fn=chat,
36
+ title="YugoGPT Professional Assistant",
37
+ description="I provide detailed and thoughtful responses to your questions.",
38
+ examples=[
39
+ "Explain quantum computing",
40
+ "What are the main principles of machine learning?",
41
+ "How does blockchain technology work?"
42
+ ]
43
  )
44
 
45
  if __name__ == "__main__":
46
+ demo.launch(
47
+ server_name="0.0.0.0",
48
+ server_port=7860,
49
+ share=False
50
+ )
51
+