Neon-AI commited on
Commit
e581288
·
verified ·
1 Parent(s): 45ba9ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import streamlit as st
2
  import torch
3
  import threading
 
4
  from peft import PeftModel
5
  from transformers import (
6
  AutoModelForCausalLM,
@@ -10,7 +11,7 @@ from transformers import (
10
 
11
  # ---------------- CONFIG ----------------
12
  MODEL_ID = "Neon-AI/Niche"
13
- MAX_NEW_TOKENS = 16384
14
  TEMPERATURE = 0.7
15
  TOP_P = 0.9
16
  # ----------------------------------------
@@ -32,16 +33,19 @@ def load_model():
32
  device_map=None
33
  )
34
 
35
- # If LoRA adapters exist, this will load them
36
  try:
37
  model = PeftModel.from_pretrained(base_model, MODEL_ID)
38
  except Exception:
39
- model = base_model # fallback if no LoRA
40
 
41
  model.to("cpu")
42
  model.eval()
43
  return tokenizer, model
44
 
 
 
 
45
  # -------- SESSION STATE --------
46
  if "history" not in st.session_state:
47
  st.session_state.history = []
@@ -53,18 +57,18 @@ if st.button("Send") and prompt.strip():
53
  st.session_state.history.append(("You", prompt))
54
 
55
  system_instructions = (
56
- "You are Niche, a concise and intelligent AI. "
57
- "Answer directly and naturally. "
58
- "Do not use greetings, pleasantries, or offers of help. "
59
- "Respond only with the requested information or explanation. "
60
- "Keep responses short, clear, and focused. "
61
- "Your owner is Neon. Mention Neon only if explicitly asked."
62
- "Neon is a man the pronoun sghould always be 'him'"
63
  )
64
 
65
  chat = [
66
- {"role": "system", "content": system_instructions},
67
- {"role": "user", "content": prompt}
68
  ]
69
 
70
  inputs = tokenizer.apply_chat_template(
 
1
  import streamlit as st
2
  import torch
3
  import threading
4
+
5
  from peft import PeftModel
6
  from transformers import (
7
  AutoModelForCausalLM,
 
11
 
12
  # ---------------- CONFIG ----------------
13
  MODEL_ID = "Neon-AI/Niche"
14
+ MAX_NEW_TOKENS = 512
15
  TEMPERATURE = 0.7
16
  TOP_P = 0.9
17
  # ----------------------------------------
 
33
  device_map=None
34
  )
35
 
36
+ # Load LoRA if present
37
  try:
38
  model = PeftModel.from_pretrained(base_model, MODEL_ID)
39
  except Exception:
40
+ model = base_model
41
 
42
  model.to("cpu")
43
  model.eval()
44
  return tokenizer, model
45
 
46
+
47
+ tokenizer, model = load_model()
48
+
49
  # -------- SESSION STATE --------
50
  if "history" not in st.session_state:
51
  st.session_state.history = []
 
57
  st.session_state.history.append(("You", prompt))
58
 
59
  system_instructions = (
60
+ "You are Niche, a concise and intelligent AI. "
61
+ "Answer directly and naturally. "
62
+ "Do not use greetings, pleasantries, or offers of help. "
63
+ "Respond only with the requested information or explanation. "
64
+ "Keep responses short, clear, and focused. "
65
+ "Your owner is Neon. Mention Neon only if explicitly asked. "
66
+ "Neon is a man; always use 'him'."
67
  )
68
 
69
  chat = [
70
+ {"role": "system", "content": system_instructions},
71
+ {"role": "user", "content": prompt}
72
  ]
73
 
74
  inputs = tokenizer.apply_chat_template(