Despite the extreme disparity in training volume (18B vs 2T+ tokens), Noeum-1-Nano-Base establishes strong baselines on standard zero-shot and few-shot tasks.
This model uses a custom architecture. You must set trust_remote_code=True to load it.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# Path to your base noeum model
5MODEL_PATH = "./base/Noeum-hf-base"
6DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
7
8
9def main():
10 print(f"--- Evaluating Base Model Noeum on {DEVICE} ---")
11
12 # 1. Load Resources
13 tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
14 if tokenizer.pad_token is None: tokenizer.pad_token = tokenizer.eos_token
15
16 model = AutoModelForCausalLM.from_pretrained(
17 MODEL_PATH,
18 trust_remote_code=True,
19 torch_dtype=torch.float16 if DEVICE == "cuda" else torch.float32
20 ).to(DEVICE)
21 model.eval()
22
23 # Helper function for generation
24 def run_test(test_name, prompt, max_new=50, temp=0.7):
25 print(f"\n=== {test_name} ===")
26 print(f"Input Pattern:\n{prompt.strip()}")
27 print("-" * 20)
28
29 inputs = tokenizer(prompt, return_tensors="pt").to(DEVICE)
30
31 with torch.no_grad():
32 output_ids = model.generate(
33 **inputs,
34 max_new_tokens=max_new,
35 do_sample=True,
36 temperature=temp,
37 top_p=0.9,
38 use_cache=False, # Essential for your MoE architecture compatibility
39 pad_token_id=tokenizer.pad_token_id,
40 eos_token_id=tokenizer.eos_token_id
41 )
42
43 # Decode only the NEW tokens to see exactly what the model added
44 new_tokens = output_ids[0][inputs.input_ids.shape[1]:]
45 output_text = tokenizer.decode(new_tokens, skip_special_tokens=True)
46 print(f"Model Completion:\n{output_text}")
47 print("=" * 30)
48
49 # ==============================================================================
50 # TEST 1: Few-Shot Knowledge
51 # Base models need examples to know they should answer, not ask more questions.
52 # ==============================================================================
53 few_shot_prompt = """
54Q: What is the capital of Germany?
55A: Berlin
56Q: What is the capital of Spain?
57A: Madrid
58Q: What is the capital of France?
59A:"""
60 run_test("Test 1: Few-Shot Knowledge", few_shot_prompt, max_new=10, temp=0.1)
61
62 # ==============================================================================
63 # TEST 2: Story Continuation
64 # Tests the model's ability to maintain narrative flow and grammar.
65 # ==============================================================================
66 story_prompt = "The spaceship landed silently on the unknown planet. The captain opened the hatch and saw"
67 run_test("Test 2: Creative Writing", story_prompt, max_new=60, temp=0.8)
68
69 # ==============================================================================
70 # TEST 3: Logic/Code Pattern
71 # Base models are often good at completing structured patterns or code.
72 # ==============================================================================
73 code_prompt = """
74def add(a, b):
75 return a + b
76
77def multiply(a, b):"""
78 run_test("Test 3: Code/Pattern Completion", code_prompt, max_new=30, temp=0.2)
79
80
81if __name__ == "__main__":
82 main()