Views
No views yet
microsoft/phi-4 specialized in logical analysis within the paradigm of Aristotelian/scholastic logic. It's like the last one with Gemma, but better, I think.1# --- STATELESS CHATBOT ---
2# Each query is treated as a fresh, independent task.
3
4import transformers
5import torch
6
7# 1. Load the pipeline
8hub_model_id = "Berthi-Rohar/ScholasticLogicAI-Gemma3-12B-PT"
9print(f"Loading model: {hub_model_id}")
10pipe = transformers.pipeline(
11 "text-generation",
12 model=hub_model_id,
13 model_kwargs={"torch_dtype": torch.bfloat16, "device_map": "auto"},
14)
15tokenizer = pipe.tokenizer
16print("✅ Model loaded successfully")
17
18# 2. The Stateless Chat Loop
19def run_stateless_chat():
20 print("\n" + "="*50)
21 print("🤖 Machinula Syllogistica (STATELESS MODE)")
22 print(" (Each query is a fresh start. No memory.)")
23 print("="*50)
24
25 while True:
26 user_input = input("\nYou: ")
27 if user_input.lower() in ["quit", "exit"]:
28 print("🤖 Goodbye!")
29 break
30
31 conversation_history = [{"role": "user", "content": user_input}]
32
33 # This part remains the same
34 prompt = tokenizer.apply_chat_template(conversation_history, tokenize=False, add_generation_prompt=True)
35
36 outputs = pipe(
37 prompt,
38 max_new_tokens=1024,
39 do_sample=False,
40 # NEW: This is the key change to stop the prompt from being repeated
41 return_full_text=False,
42 eos_token_id=tokenizer.eos_token_id,
43 )
44
45 # CHANGED: The post-processing is now much simpler
46 model_response = outputs[0]['generated_text'].replace("<|end|>", "").strip()
47
48 print(f"\n🤖 Machinula Syllogistica:\n{model_response}")
49
50# 3. Start the chat
51run_stateless_chat()