Lazarus is a next-generation small LLM based on
gpt2-medium, distilled from LLaMA 3 3B using the
vicgalle/alpaca-gpt4 dataset.
Lazarus demonstrates exceptional performance for its size, especially in question understanding and step-by-step reasoning — outperforming many small LLMs. Larger versions are in development.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4print("CUDA Available:", torch.cuda.is_available())
5
6model_name = "Aclevo/AclevoGPT-100M-Instruct"
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(model_name)
9model.eval()
10
11device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
12model.to(device)
13
14system_prompt = (
15 "Your name is Lazarus. You are an intelligent AI assistant. You help users with whatever they need. "
16 "You always think before answering, and explain your reasoning out loud step by step.\n"
17)
18
19chat_history = []
20
21def chat():
22 print("Chatting with GPT-2 (type 'exit' to quit)\n")
23
24 while True:
25 user_input = input("You: ")
26 if user_input.lower() == "exit":
27 break
28
29 chat_history.append(f"You: {user_input}")
30 recent_history = chat_history[-6:]
31 full_prompt = system_prompt + "\n".join(recent_history) + "\nAI:"
32
33 inputs = tokenizer(full_prompt, return_tensors="pt", truncation=True).to(device)
34
35 with torch.no_grad():
36 outputs = model.generate(
37 **inputs,
38 max_length=inputs["input_ids"].shape[1] + 150,
39 pad_token_id=tokenizer.eos_token_id,
40 do_sample=True,
41 top_k=100,
42 top_p=0.92,
43 temperature=0.7,
44 eos_token_id=tokenizer.eos_token_id
45 )
46
47 response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
48 response = response.strip()
49
50 bad_responses = {"I hope that", "I don't know", "", "I'm excited"}
51 if response in bad_responses:
52 print("AI: [Regenerating due to low-quality response]")
53 continue
54
55 print(f"AI: {response}")
56 chat_history.append(f"AI: {response}")
57
58if __name__ == "__main__":
59 chat()