Update inference.py
Browse files- inference.py +17 -0
inference.py
CHANGED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.text.all import load_learner
|
2 |
+
|
3 |
+
def chat_with_model():
|
4 |
+
learn = load_learner('model.pkl')
|
5 |
+
context = "Hey"
|
6 |
+
while True:
|
7 |
+
print(f"You: {context}")
|
8 |
+
generated = learn.predict(context, 200, temperature=0.9)
|
9 |
+
print(f"Bot: {generated}\n")
|
10 |
+
|
11 |
+
user_input = input("You: ")
|
12 |
+
if user_input.strip().lower() in ["quit", "exit", "stop"]:
|
13 |
+
break
|
14 |
+
context = user_input
|
15 |
+
|
16 |
+
if __name__ == "__main__":
|
17 |
+
chat_with_model()
|