-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
42 lines (34 loc) · 1.1 KB
/
example.py
File metadata and controls
42 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""
Simple example script to run Grok-Mini V2
"""
from grok_mini import GrokMiniV2, generate, config
def main():
print("=" * 60)
print("Grok-Mini V2 Example")
print("=" * 60)
# Initialize model
print(f"\nInitializing model on {config.device}...")
model = GrokMiniV2().to(config.device).to(config.dtype)
param_count = sum(p.numel() for p in model.parameters()) / 1e6
print(f"Model loaded successfully!")
print(f"Parameters: {param_count:.1f}M")
print(f"Device: {config.device}")
print(f"Dtype: {config.dtype}")
# Test text generation
print("\n" + "=" * 60)
print("Text Generation Test")
print("=" * 60)
prompts = [
"What is artificial intelligence?",
"Explain machine learning in simple terms:",
"The future of AI is"
]
for prompt in prompts:
print(f"\nPrompt: {prompt}")
print("-" * 40)
response = generate(model, prompt, max_new_tokens=50, temperature=0.7)
print(f"Response: {response}")
print()
if __name__ == "__main__":
main()