Really-Amazing commited on
Commit
2e33bb4
·
verified ·
1 Parent(s): 96bec5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -5,31 +5,30 @@ from nanochat.checkpoint_manager import load_model
5
  from nanochat.tokenizer import get_tokenizer
6
 
7
  MODEL_PATH = "model_000971.pt"
8
- META_PATH = "meta_000971.json"
9
 
10
  print("Waking up the toddler (NanoChat-ClimbMix-D12)...")
11
 
12
- # 1. Load the tokenizer and model first
13
- tokenizer = get_tokenizer(META_PATH)
 
 
14
  model, _ = load_model(MODEL_PATH, device="cpu")
15
 
16
- # 2. Pass the objects to the Engine
17
  engine = Engine(model=model, tokenizer=tokenizer)
18
 
19
  def chat_fn(message, history):
20
- # Based on your engine.py, it expects a list of tokens or a string?
21
- # Usually, generate handles the string-to-token conversion.
22
  response = engine.generate(message, max_tokens=300, temperature=0.85)
23
  return response
24
 
25
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
26
  gr.Markdown("# 🧸 NanoChat-ClimbMix-D12 – The Confident Toddler LLM")
27
- gr.Markdown("Inspired by Andrej Karpathy's nanochat. Currently in 'Preschool Phase'!")
28
-
29
  gr.ChatInterface(
30
  fn=chat_fn,
31
  title="Chat with the Toddler",
32
- examples=["Why is the sky blue?", "Tell me a joke."],
33
  )
34
 
35
  if __name__ == "__main__":
 
5
  from nanochat.tokenizer import get_tokenizer
6
 
7
  MODEL_PATH = "model_000971.pt"
8
+ # META_PATH is not needed for the tokenizer call based on your error
9
 
10
  print("Waking up the toddler (NanoChat-ClimbMix-D12)...")
11
 
12
+ # 1. Load the tokenizer (no arguments needed!)
13
+ tokenizer = get_tokenizer()
14
+
15
+ # 2. Load the model
16
  model, _ = load_model(MODEL_PATH, device="cpu")
17
 
18
+ # 3. Pass the objects to the Engine
19
  engine = Engine(model=model, tokenizer=tokenizer)
20
 
21
  def chat_fn(message, history):
22
+ # Your engine.py uses 'max_tokens' based on the previous grep
 
23
  response = engine.generate(message, max_tokens=300, temperature=0.85)
24
  return response
25
 
26
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue")) as demo:
27
  gr.Markdown("# 🧸 NanoChat-ClimbMix-D12 – The Confident Toddler LLM")
 
 
28
  gr.ChatInterface(
29
  fn=chat_fn,
30
  title="Chat with the Toddler",
31
+ examples=["Why is the sky blue?", "Explain UPI in one sentence."],
32
  )
33
 
34
  if __name__ == "__main__":