thefutureofai commited on
Commit
90066b9
·
verified ·
1 Parent(s): 0cf6b11

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +69 -3
README.md CHANGED
@@ -1,3 +1,69 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ Instruction-tuned model finetuned on WizardLMTeam/WizardLM_evol_instruct_V2_196k
5
+
6
+ ## 🚀 Usage
7
+
8
+ You can interact with Lazarus using the script below:
9
+
10
+ ```python
11
+ from transformers import AutoTokenizer, AutoModelForCausalLM
12
+ import torch
13
+
14
+ print("CUDA Available:", torch.cuda.is_available())
15
+
16
+ model_name = "Aclevo/Lazarus-Instruct"
17
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
18
+ model = AutoModelForCausalLM.from_pretrained(model_name)
19
+ model.eval()
20
+
21
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
22
+ model.to(device)
23
+
24
+ system_prompt = (
25
+ "Your name is Lazarus. You are an intelligent AI assistant. You help users with whatever they need. "
26
+ "You always think before answering, and explain your reasoning out loud step by step.\n"
27
+ )
28
+
29
+ chat_history = []
30
+
31
+ def chat():
32
+ print("Chatting with GPT-2 (type 'exit' to quit)\n")
33
+
34
+ while True:
35
+ user_input = input("You: ")
36
+ if user_input.lower() == "exit":
37
+ break
38
+
39
+ chat_history.append(f"You: {user_input}")
40
+ recent_history = chat_history[-6:]
41
+ full_prompt = system_prompt + "\n".join(recent_history) + "\nAI:"
42
+
43
+ inputs = tokenizer(full_prompt, return_tensors="pt", truncation=True).to(device)
44
+
45
+ with torch.no_grad():
46
+ outputs = model.generate(
47
+ **inputs,
48
+ max_length=inputs["input_ids"].shape[1] + 150,
49
+ pad_token_id=tokenizer.eos_token_id,
50
+ do_sample=True,
51
+ top_k=100,
52
+ top_p=0.92,
53
+ temperature=0.7,
54
+ eos_token_id=tokenizer.eos_token_id
55
+ )
56
+
57
+ response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
58
+ response = response.strip()
59
+
60
+ bad_responses = {"I hope that", "I don't know", "", "I'm excited"}
61
+ if response in bad_responses:
62
+ print("AI: [Regenerating due to low-quality response]")
63
+ continue
64
+
65
+ print(f"AI: {response}")
66
+ chat_history.append(f"AI: {response}")
67
+
68
+ if __name__ == "__main__":
69
+ chat()