Abhaykoul commited on
Commit
2878205
1 Parent(s): 35c626c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +33 -31
README.md CHANGED
@@ -36,41 +36,43 @@ HelpingAI-9B has achieved an impressive Emotional Quotient (EQ) of 89.23, surpas
36
 
37
  ## Usage code
38
  ```python
39
- from transformers import AutoModelForCausalLM, AutoTokenizer
40
  import torch
41
- device = "cuda" # the device to load the model onto
42
 
43
- model = AutoModelForCausalLM.from_pretrained(
44
- "OEvortex/HelpingAI-9B",
45
- torch_dtype='auto',
46
- device_map="auto"
47
- )
48
  tokenizer = AutoTokenizer.from_pretrained("OEvortex/HelpingAI-9B")
49
 
50
- prompt = "Express joy and excitement about visiting a new place"
51
- messages = [
52
- # {"role": "system", "content": "You are a helpful AI assistant."},
53
- {"role": "user", "content": prompt}
54
- ]
55
- text = tokenizer.apply_chat_template(
56
- messages,
57
- tokenize=False,
58
- add_generation_prompt=True
59
- )
60
- model_inputs = tokenizer([text], return_tensors="pt").to(device)
61
-
62
- generated_ids = model.generate(
63
- model_inputs.input_ids,
64
- max_new_tokens=1024,
65
- eos_token_id=tokenizer.eos_token_id,
66
- temperature=0.25,
67
- )
68
- generated_ids = [
69
- output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
70
- ]
71
-
72
- response = tokenizer.batch_decode(generated_ids)[0]
73
- print(response)
 
 
 
 
74
 
75
  ```
76
  *Directly using this model from GGUF*
 
36
 
37
  ## Usage code
38
  ```python
 
39
  import torch
40
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
41
 
42
+ # Let's bring in the big guns! Our super cool HelpingAI-9B model
43
+ model = AutoModelForCausalLM.from_pretrained("OEvortex/HelpingAI-9B").to("cuda")
44
+
45
+ # We also need the special HelpingAI translator to understand our chats
 
46
  tokenizer = AutoTokenizer.from_pretrained("OEvortex/HelpingAI-9B")
47
 
48
+ # This TextStreamer thingy is our secret weapon for super smooth conversation flow
49
+ streamer = TextStreamer(tokenizer)
50
+
51
+ # Now, here comes the magic! ✨ This is the basic template for our chat
52
+ prompt = """
53
+ <|im_start|>system: {system}
54
+ <|im_end|>
55
+ <|im_start|>user: {insaan}
56
+ <|im_end|>
57
+ <|im_start|>assistant:
58
+ """
59
+
60
+ # Okay, enough chit-chat, let's get down to business! Here's what will be our system prompt
61
+ system = "You are HelpingAI a emotional AI always answer my question in HelpingAI style"
62
+
63
+
64
+ # And the insaan is curious (like you!) insaan means human in hindi
65
+ insaan = "I'm excited because I just got accepted into my dream school! I wanted to share the good news with someone."
66
+
67
+ # Now we combine system and user messages into the template, like adding sprinkles to our conversation cupcake
68
+ prompt = prompt.format(system=system, insaan=insaan)
69
+
70
+ # Time to chat! We'll use the tokenizer to translate our text into a language the model understands
71
+ inputs = tokenizer(prompt, return_tensors="pt", return_attention_mask=False).to("cuda")
72
+
73
+ # Here comes the fun part! Let's unleash the power of HelpingAI-3B to generate some awesome text
74
+ generated_text = model.generate(**inputs, max_length=3084, top_p=0.95, do_sample=True, temperature=0.6, use_cache=True, streamer=streamer)
75
+
76
 
77
  ```
78
  *Directly using this model from GGUF*