mychen76 commited on
Commit
63cfc66
·
verified ·
1 Parent(s): c72a78e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -1
README.md CHANGED
@@ -11,7 +11,7 @@ tags:
11
 
12
  <!-- Provide a quick summary of what the model is/does. -->
13
  # Intuitive Thinker
14
- Improve small size LLM reasoning by employs system of thinking mental models by structured Chain-of-Thoughts process and thoughtful reflection prior to responding to user queries.
15
 
16
  ***Problem:*** <br/>
17
  smaller-sized transformer models exhibit inferior reasoning capabilities compared to their larger counterparts, whose advanced reasoning abilities stem from broader connection networks that facilitate cross-domain inference.
@@ -36,6 +36,90 @@ https://huggingface.co/mychen76/Llama-3.1_Intuitive-Thinker
36
  Quantized: mychen76/Llama-3.1_Intuitive-Thinker_8B_2309_GGUF
37
  https://huggingface.co/mychen76/Llama-3.1_Intuitive-Thinker_8B_2309_GGUF
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  ***Ollama.com*** <br/>
40
  https://ollama.com/mychen76/llama3.1-intuitive-thinker
41
 
@@ -47,6 +131,7 @@ For direct easy to use each mental model has been package on own model package.
47
  4. Iceberg Mental Model: [mychen76/llama3.1-intuitive-thinker:iceberg-mental-model.q5]
48
  5. Second Order Thinking: [mychen76/llama3.1-intuitive-thinker:second-order-thinking.q5]
49
 
 
50
  ### Samples
51
 
52
  ***Sample: Chain-of-Thoughts***
 
11
 
12
  <!-- Provide a quick summary of what the model is/does. -->
13
  # Intuitive Thinker
14
+ Attempt to improve small size LLM reasoning by employs system of thinking mental models by structured Chain-of-Thoughts process and thoughtful reflection prior to responding to user queries.
15
 
16
  ***Problem:*** <br/>
17
  smaller-sized transformer models exhibit inferior reasoning capabilities compared to their larger counterparts, whose advanced reasoning abilities stem from broader connection networks that facilitate cross-domain inference.
 
36
  Quantized: mychen76/Llama-3.1_Intuitive-Thinker_8B_2309_GGUF
37
  https://huggingface.co/mychen76/Llama-3.1_Intuitive-Thinker_8B_2309_GGUF
38
 
39
+ ***HF Usage*** <br/>
40
+ ```python
41
+ from intuitive_thinker.mental_model import MentalModel
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
43
+ import torch
44
+ import json
45
+
46
+ question="count number of r in word strawberry?"
47
+
48
+ ## format question using mental model template
49
+ mental_model = MentalModel(MentalModel.CHAIN_OF_THOUGHTS)
50
+ prompt = json.loads(mental_model(question))
51
+
52
+ bnb_config = BitsAndBytesConfig(
53
+ load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype="float16", bnb_4bit_use_double_quant=True
54
+ )
55
+
56
+ # Prepare the input as before
57
+ messages = [
58
+ {"role": "system", "content": prompt['system_message']},
59
+ {"role": "user", "content": prompt['user_input'] }
60
+ ]
61
+
62
+ hf_model_id = "mychen76/Llama-3.1_Intuitive-Thinker"
63
+
64
+ # 1: Load the model and tokenizer
65
+ model = AutoModelForCausalLM.from_pretrained(hf_model_id, device_map="auto", quantization_config=bnb_config, torch_dtype=torch.bfloat16)
66
+ tokenizer = AutoTokenizer.from_pretrained(hf_model_id)
67
+
68
+ # 2: Apply the chat template
69
+ formatted_chat = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
70
+ #print("Formatted chat:\n", formatted_chat)
71
+
72
+ # 3: Tokenize the chat (This can be combined with the previous step using tokenize=True)
73
+ inputs = tokenizer(formatted_chat, return_tensors="pt", add_special_tokens=False)
74
+ # Move the tokenized inputs to the same device the model is on (GPU/CPU)
75
+ inputs = {key: tensor.to(model.device) for key, tensor in inputs.items()}
76
+ #print("Tokenized inputs:\n", inputs)
77
+
78
+ # 4: Generate text from the model
79
+ outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
80
+ #print("Generated tokens:\n", outputs)
81
+
82
+ # 5: Decode the output back to a string
83
+ decoded_output = tokenizer.decode(outputs[0][inputs['input_ids'].size(1):], skip_special_tokens=True)
84
+ print("Decoded output:\n", decoded_output)
85
+ ```
86
+ result
87
+ ```bash
88
+ Decoded output:
89
+ <thinking>
90
+ a. Briefly analyze the question and outline our approach:
91
+ The question asks for the count of the letter 'r' in the word'strawberry'. This is a simple text analysis task that requires examining the word for the target letter.
92
+
93
+ b. Present a clear plan of steps to solve the problem:
94
+ 1. Write out the word'strawberry' in its full form.
95
+ 2. Count the occurrences of the letter 'r' in the word.
96
+ 3. Provide the final count as the answer.
97
+
98
+ c. Use a "Chain of Thought" reasoning process:
99
+ 1. Start by writing out the word: s-t-r-a-w-b-e-r-r-y
100
+ 2. Now, count the 'r's: r (1), r (2), r (3)
101
+ 3. We have found all 'r's in the word.
102
+
103
+ <reflection>
104
+ a. Review our reasoning:
105
+ We have broken down the task into simple steps and followed through with the counting process.
106
+
107
+ b. Check for potential errors or oversights:
108
+ - We have accounted for all letters in the word.
109
+ - We have specifically targeted the letter 'r' for counting.
110
+ - We have counted each occurrence of 'r' correctly.
111
+
112
+ c. Confirm our conclusion:
113
+ Yes, our conclusion is correct. The word'strawberry' contains 3 occurrences of the letter 'r'.
114
+
115
+ </reflection>
116
+ </thinking>
117
+
118
+ <output>
119
+ The word'strawberry' contains 3 occurrences of the letter 'r'.
120
+ </output>
121
+ ```
122
+
123
  ***Ollama.com*** <br/>
124
  https://ollama.com/mychen76/llama3.1-intuitive-thinker
125
 
 
131
  4. Iceberg Mental Model: [mychen76/llama3.1-intuitive-thinker:iceberg-mental-model.q5]
132
  5. Second Order Thinking: [mychen76/llama3.1-intuitive-thinker:second-order-thinking.q5]
133
 
134
+
135
  ### Samples
136
 
137
  ***Sample: Chain-of-Thoughts***