-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_usage.py
More file actions
40 lines (31 loc) · 1.12 KB
/
example_usage.py
File metadata and controls
40 lines (31 loc) · 1.12 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
#!/usr/bin/env python3
"""Example script for chatting with Terry."""
from tools.inference import ModelInference
def main():
print("=== Terry Inference Example ===\n")
model = ModelInference(checkpoint_path="releases/terry_tinyllm_5000.pt", device="auto")
prompts = [
"hi terry",
"what do you think about rain on the window",
"help me make a tiny plan for today",
"tell me a small story",
]
for index, prompt in enumerate(prompts, start=1):
print(f"\n--- Prompt {index}: {prompt} ---")
reply = model.generate(prompt, temperature=0.8)
print(f"Terry: {reply}")
print("\nEnter prompts to chat with Terry. Type 'quit' to exit.")
while True:
user_input = input("\nYou: ").strip()
if user_input.lower() == "quit":
print("Goodbye!")
break
if not user_input:
continue
try:
reply = model.generate(user_input, temperature=0.8)
print(f"Terry: {reply}")
except Exception as exc:
print(f"Error during generation: {exc}")
if __name__ == "__main__":
main()