dynamic-learning-model 1.4__tar.gz → 1.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 1.4
3
+ Version: 1.5.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -48,8 +48,11 @@ Whether you're building a student support bot, a domain-specific assistant, or a
48
48
 
49
49
  **REQUIRED PARAMETERS**:
50
50
  * The constructor requires passing in two parameters:
51
- - Bot Mode: 't' = training, 'c' = commercial, 'e' = experimental
52
- - Empty SQL Database for training the bot with queries
51
+ - Bot Mode:
52
+ - 'learn' = Enables training using the memory model. The bot can be updated with new information,
53
+ - 'recall' = The bot uses the memory model in read-only mode (no training),
54
+ - 'compute' = Activates the computation model for processing and solving queries algorithmically (no training)
55
+ - Empty SQL Database for training the bot with queries and for the memory model
53
56
  * The ask() method also requires passing in two parameters:
54
57
  - Query: "What is the definition of FAFSA" (as an example)
55
58
  - Display Thought: "True" to allow the bot's Chain of Thought to be displayed, or else "False"
@@ -61,32 +64,32 @@ pip install dynamic-learning-model
61
64
  ```
62
65
  * ***Python 3.12 or higher is required to use this bot in your program***
63
66
 
64
- (Experimental 'e' mode [computation queries])
67
+ ('learn' mode [training queries])
68
+ * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
65
69
  ```python
66
70
  from dlm import DLM
67
71
 
68
- computation_bot = DLM("e", "college_knowledge.db")
72
+ training_bot = DLM("learn", "college_knowledge.db")
69
73
 
70
- computation_bot.ask("Compute the following: 5 * 5 * 5 + 5 / 5", True)
74
+ training_bot.ask("What is FAFSA in college?", True)
71
75
  ```
72
76
 
73
- (Training 't' mode [training queries])
74
- * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
77
+ ('recall' mode [deployment/production use after training])
75
78
  ```python
76
79
  from dlm import DLM
77
80
 
78
- training_bot = DLM("t", "college_knowledge.db")
81
+ commercial_bot = DLM("recall", "college_knowledge.db")
79
82
 
80
- training_bot.ask("What is FAFSA in college?", True)
83
+ commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
81
84
  ```
82
85
 
83
- (Commercial 'c' mode [deployment/production use after training])
86
+ ('compute' mode [computation queries])
84
87
  ```python
85
88
  from dlm import DLM
86
89
 
87
- commercial_bot = DLM("c", "college_knowledge.db")
90
+ computation_bot = DLM("compute", "college_knowledge.db")
88
91
 
89
- commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
92
+ computation_bot.ask("Tell me the result for the following: 5 * 5 * 5 + 5 / 5", True)
90
93
  ```
91
94
 
92
95
  **HIGH-LEVEL PIPELINE VISUALS**:
@@ -18,8 +18,11 @@ Whether you're building a student support bot, a domain-specific assistant, or a
18
18
 
19
19
  **REQUIRED PARAMETERS**:
20
20
  * The constructor requires passing in two parameters:
21
- - Bot Mode: 't' = training, 'c' = commercial, 'e' = experimental
22
- - Empty SQL Database for training the bot with queries
21
+ - Bot Mode:
22
+ - 'learn' = Enables training using the memory model. The bot can be updated with new information,
23
+ - 'recall' = The bot uses the memory model in read-only mode (no training),
24
+ - 'compute' = Activates the computation model for processing and solving queries algorithmically (no training)
25
+ - Empty SQL Database for training the bot with queries and for the memory model
23
26
  * The ask() method also requires passing in two parameters:
24
27
  - Query: "What is the definition of FAFSA" (as an example)
25
28
  - Display Thought: "True" to allow the bot's Chain of Thought to be displayed, or else "False"
@@ -31,32 +34,32 @@ pip install dynamic-learning-model
31
34
  ```
32
35
  * ***Python 3.12 or higher is required to use this bot in your program***
33
36
 
34
- (Experimental 'e' mode [computation queries])
37
+ ('learn' mode [training queries])
38
+ * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
35
39
  ```python
36
40
  from dlm import DLM
37
41
 
38
- computation_bot = DLM("e", "college_knowledge.db")
42
+ training_bot = DLM("learn", "college_knowledge.db")
39
43
 
40
- computation_bot.ask("Compute the following: 5 * 5 * 5 + 5 / 5", True)
44
+ training_bot.ask("What is FAFSA in college?", True)
41
45
  ```
42
46
 
43
- (Training 't' mode [training queries])
44
- * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
47
+ ('recall' mode [deployment/production use after training])
45
48
  ```python
46
49
  from dlm import DLM
47
50
 
48
- training_bot = DLM("t", "college_knowledge.db")
51
+ commercial_bot = DLM("recall", "college_knowledge.db")
49
52
 
50
- training_bot.ask("What is FAFSA in college?", True)
53
+ commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
51
54
  ```
52
55
 
53
- (Commercial 'c' mode [deployment/production use after training])
56
+ ('compute' mode [computation queries])
54
57
  ```python
55
58
  from dlm import DLM
56
59
 
57
- commercial_bot = DLM("c", "college_knowledge.db")
60
+ computation_bot = DLM("compute", "college_knowledge.db")
58
61
 
59
- commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
62
+ computation_bot.ask("Tell me the result for the following: 5 * 5 * 5 + 5 / 5", True)
60
63
  ```
61
64
 
62
65
  **HIGH-LEVEL PIPELINE VISUALS**:
@@ -12,7 +12,6 @@ from better_profanity import profanity
12
12
  from nltk.corpus import names
13
13
  from word2number import w2n
14
14
 
15
-
16
15
  class DLM:
17
16
  __filename = None # knowledge-base (SQL)
18
17
  __query = None # user-inputted query
@@ -21,7 +20,7 @@ class DLM:
21
20
  __nlp = None # Spacy NLP analysis
22
21
  __tone = None # sentimental tone of user query
23
22
  __trainingPwd = "371507" # password to enter training mode
24
- __mode = None # either "training", "commercial", or "experimental"
23
+ __mode = None # either "learn", "recall", or "compute"
25
24
  __unsure_while_thinking = False # if uncertain while thinking, then it will let the user know that
26
25
  __nlp_similarity_value = None # saves the similarity value by doing SpaCy calculation (for debugging)
27
26
  __special_stripped_query = None # saves query without any special words for reduced interference while vector calculating
@@ -342,9 +341,9 @@ class DLM:
342
341
 
343
342
  Parameters:
344
343
  mode (str): The access mode. Options:
345
- 't' for Training mode (to train the bot with queries),
346
- 'c' for Commercial mode (to use it in your deployment/production program),
347
- 'e' for Experimental mode (for arithmetic or conversion queries).
344
+ 'learn' for training mode (to train the bot with queries),
345
+ 'recall' for recalling learned queries (to use it in your deployment/production program),
346
+ 'compute' for mathematical queries (for arithmetic or conversion queries).
348
347
  db_filename (str): The SQLite database file used to train and retrieve
349
348
  question-answer-category triples.
350
349
 
@@ -365,26 +364,25 @@ class DLM:
365
364
 
366
365
  def __login_verification(self, mode): # no return, void
367
366
  """
368
- Verify and initialize the selected access mode (Training, Commercial, or Experimental).
367
+ Verify and initialize the selected access mode (Learn, Recall, or Compute).
369
368
 
370
369
  Parameters:
371
- mode (str): The access mode. Options are:
372
- 't' - Training mode (requires password and shows training guidelines)
373
- 'c' - Commercial mode (no training features, read-only usage)
374
- 'e' - Experimental mode (enables reasoning features, no DB writes)
375
-
370
+ mode (str): The access mode. Options:
371
+ 'learn' for training mode (to train the bot with queries),
372
+ 'recall' for recalling learned queries (to use it in your deployment/production program),
373
+ 'compute' for mathematical queries (for arithmetic or conversion queries).
376
374
  Behavior:
377
- - If mode is 't', prompts for a password and displays mandatory training instructions.
378
- - If mode is 'c', enters Commercial mode without training privileges.
379
- - If mode is 'e', proceeds with Experimental mode with reasoning capabilities.
375
+ - If mode is 'learn', prompts for a password and displays mandatory training instructions.
376
+ - If mode is 'recall', enters deployment mode without training privileges.
377
+ - If mode is 'compute', proceeds with computation model with reasoning capabilities.
380
378
  """
381
- if mode.lower() == "t":
382
- password = input("Enter the password to enter Training Mode: ")
379
+ if mode.lower() == "learn":
380
+ password = input("Enter the password to enter Learn Mode: ")
383
381
  while password != self.__trainingPwd:
384
382
  password = input(
385
- "Password is incorrect, try again or type 'stop' to enter in commercial mode instead: ")
383
+ "Password is incorrect, try again or type 'stop' to enter in recall mode instead: ")
386
384
  if password.lower() == "stop":
387
- self.__mode = "commercial"
385
+ self.__mode = "recall"
388
386
  print("\n")
389
387
  break
390
388
  if password == self.__trainingPwd:
@@ -407,14 +405,14 @@ class DLM:
407
405
  while confirmation.lower() != "y": # trainers must understand the instructions above
408
406
  confirmation = input(
409
407
  "You cannot proceed to train without understanding the instructions aforementioned. Type 'Y' to continue: ")
410
- self.__mode = "training"
408
+ self.__mode = "learn"
411
409
  print("\n")
412
410
  self.__loadingAnimation("Logging in as Trainer", 0.6)
413
411
  print("\n")
414
- elif mode.lower() == "c":
415
- self.__mode = "commercial"
412
+ elif mode.lower() == "recall":
413
+ self.__mode = "recall"
416
414
  else:
417
- self.__mode = "experimental"
415
+ self.__mode = "compute"
418
416
 
419
417
  def __create_table_if_missing(self): # no return, void
420
418
  """
@@ -535,7 +533,7 @@ class DLM:
535
533
  - Tokenizes the input into words.
536
534
  - Removes filler words unless:
537
535
  - It's the first word and part of the exception list.
538
- - The current mode is 'experimental' and the word is a computation keyword.
536
+ - The current mode is 'compute' and the word is a computation keyword.
539
537
  - Preserves word order while removing duplicates.
540
538
  - Joins the remaining words back into a single filtered string.
541
539
  """
@@ -553,12 +551,12 @@ class DLM:
553
551
 
554
552
  # otherwise, only keep non-fillers
555
553
  else:
556
- # In experimental mode, keep any computation keyword even if it's also a filler
554
+ # In compute mode, keep any computation keyword even if it's also a filler
557
555
  is_computation_kw = any(word_lowered == kw.lower()
558
556
  for kws in self.__computation_identifiers.values()
559
557
  for kw in kws)
560
558
 
561
- if word_lowered not in self.__filler_words or (self.__mode == "experimental" and is_computation_kw):
559
+ if word_lowered not in self.__filler_words or (self.__mode == "compute" and is_computation_kw):
562
560
  filtered_words.append(word)
563
561
 
564
562
  # remove duplicates while preserving order (numbers excluded)
@@ -634,7 +632,7 @@ class DLM:
634
632
  height_value_index = None
635
633
  other_values = []
636
634
  object_intel = []
637
- common_endings = ["ular", "ish", "al"] # some people might say "squarish" or "rectangular" etc
635
+ common_endings = ["ular", "ish", "al"] # some people might say "squarish" or "rectangular" etc
638
636
 
639
637
  tokens = filtered_query.split()
640
638
  lower_tokens = [t.lower() for t in tokens]
@@ -714,39 +712,45 @@ class DLM:
714
712
  break
715
713
  if end_check:
716
714
  break
717
-
715
+
718
716
  # if allowed, display the inner thought process
719
717
  obj_name = object_intel[1]
720
718
  if display_thought:
721
719
  self.__loadingAnimation(f"It seems that the user wants to compute the {' of a '.join(object_intel)}", 0.5)
722
720
  if height_value is not None:
723
- self.__loadingAnimation(f"* The user has mentioned that the height of the {obj_name} object is {height_value}", 0.4)
721
+ self.__loadingAnimation(
722
+ f"* The user has mentioned that the height of the {obj_name} object is {height_value}", 0.4)
724
723
  else:
725
- self.__loadingAnimation(f"* The {object_intel[1]} object has no height associated with it, so moving on", 0.4)
724
+ self.__loadingAnimation(
725
+ f"* The {object_intel[1]} object has no height associated with it, so moving on", 0.4)
726
726
  if len(other_values) > 0:
727
- self.__loadingAnimation(f"* Additional numerical values associated with the dimensions of the {obj_name} object is {' and '.join(str(v) for v in other_values)}", 0.4)
727
+ self.__loadingAnimation(
728
+ f"* Additional numerical values associated with the dimensions of the {obj_name} object is {' and '.join(str(v) for v in other_values)}",
729
+ 0.4)
728
730
  else:
729
- self.__loadingAnimation(f"* No additional numerical values associated with the dimensions of the {obj_name} were given",0.4)
731
+ self.__loadingAnimation(
732
+ f"* No additional numerical values associated with the dimensions of the {obj_name} were given",
733
+ 0.4)
730
734
 
731
735
  # Now iterate through the geometric identifier list, find the correct object, and then find its formula, then plug compute
732
736
  formula = self.__geometric_calculation_identifiers[obj_name]["formula"]
733
737
  params = self.__geometric_calculation_identifiers[obj_name]["params"]
734
738
 
735
- formula_inputs = {} # all data gathered to compute geometry
736
-
739
+ formula_inputs = {} # all data gathered to compute geometry
740
+
737
741
  # gather and plug in values into the formula
738
742
  try:
739
743
  if "height" in params:
740
744
  formula_inputs["height"] = height_value
741
-
742
- value_idx = 0 # count how many values to be added in formula_inputs
745
+
746
+ value_idx = 0 # count how many values to be added in formula_inputs
743
747
  for param in params:
744
748
  if param == "height":
745
749
  continue # already added
746
- elif param == "other": # two consecutive numbers to append
750
+ elif param == "other": # two consecutive numbers to append
747
751
  formula_inputs["other"] = other_values[value_idx:value_idx + 2]
748
752
  value_idx += 2
749
- else: # only one number to append
753
+ else: # only one number to append
750
754
  formula_inputs[param] = other_values[value_idx]
751
755
  value_idx += 1
752
756
 
@@ -756,12 +760,13 @@ class DLM:
756
760
 
757
761
  except Exception as e:
758
762
  if display_thought:
759
- print(f"{'\033[33m'}Unable to compute the {object_intel[0]} of the {obj_name} due to missing or mismatched values{'\033[0m'}")
763
+ print(
764
+ f"{'\033[33m'}Unable to compute the {object_intel[0]} of the {obj_name} due to missing or mismatched values{'\033[0m'}")
760
765
  else:
761
- print(f"{'\033[34m'}Unable to compute the {object_intel[0]} of the {obj_name} due to missing or mismatched values{'\033[0m'}")
766
+ print(
767
+ f"{'\033[34m'}Unable to compute the {object_intel[0]} of the {obj_name} due to missing or mismatched values{'\033[0m'}")
762
768
  return None
763
769
 
764
-
765
770
  def __perform_advanced_CoT(self, filtered_query, display_thought): # no return, void
766
771
  """
767
772
  Perform advanced Chain-of-Thought (CoT) reasoning to solve arithmetic or unit conversion problems.
@@ -798,7 +803,8 @@ class DLM:
798
803
  print(
799
804
  f"{'\033[33m'}I am presented with a more involved query asking me to do some form of computation{'\033[0m'}")
800
805
  self.__loadingAnimation("Let me think about this carefully and break it down so that I can solve it", 0.8)
801
- self.__loadingAnimation(f"I’ve trimmed away any extra words so I’m focusing on \"{filtered_query}\" now", 0.8)
806
+ self.__loadingAnimation(f"I’ve trimmed away any extra words so I’m focusing on \"{filtered_query}\" now",
807
+ 0.8)
802
808
 
803
809
  # Have the bot pick out names mentioned (in order) using SpaCy and NLTK (for maximum coverage)
804
810
  for ent in doc.ents:
@@ -830,10 +836,12 @@ class DLM:
830
836
  words = filtered_query.lower().split()
831
837
  geometric_ans = None
832
838
  # checks if the query contains shapes or object to perform possibly formula calculation
833
- geometric_calc = any(difflib.get_close_matches(word, self.__geometric_calculation_identifiers.keys(), n=1, cutoff=0.70) for word in words)
839
+ geometric_calc = any(
840
+ difflib.get_close_matches(word, self.__geometric_calculation_identifiers.keys(), n=1, cutoff=0.70) for word
841
+ in words)
834
842
  is_geometric_query = False
835
843
 
836
- geo_types = set() # currently supported types of geometric calculations
844
+ geo_types = set() # currently supported types of geometric calculations
837
845
 
838
846
  for t in self.__geometric_calculation_identifiers:
839
847
  shape = self.__geometric_calculation_identifiers[t]["keywords"]
@@ -842,7 +850,7 @@ class DLM:
842
850
  geometric_ans = self.__geometric_calculation(filtered_query, display_thought)
843
851
  if geometric_ans is not None:
844
852
  is_geometric_query = True
845
- else: # Not geometric, so have the bot find all operand indicating keywords
853
+ else: # Not geometric, so have the bot find all operand indicating keywords
846
854
  found_operand = False
847
855
  for fq in filtered_query.split():
848
856
  fq_l = fq.lower()
@@ -992,22 +1000,33 @@ class DLM:
992
1000
  operands_mentioned = [op for op in operands_mentioned if op != '=']
993
1001
 
994
1002
  # verify and possibly print thoughts
995
- if (not is_geometric_query) and (any(not lst for lst in (num_mentioned, operands_mentioned)) or ('=' not in operands_mentioned and num_mentioned.__len__() < 2)): # don't compute if parts are missing
996
- print(f"{self.__loadingAnimation('Hmm', 0.8) or '' if display_thought else ''}{'\033[34m'}It looks like some essential details are missing, so I can’t complete this calculation right now.{'\033[0m'}")
997
- print(f"\033[34mIf you are asking a geometric query, try including geometric identifiers like \"{'\", \"'.join(geo_types)}\" in your query.\033[0m")
998
- print(f"\033[34mCurrently, I can only compute those identifiers aforementioned, but more geometric features are coming soon!\033[0m")
1003
+ if (not is_geometric_query) and (any(not lst for lst in (num_mentioned, operands_mentioned)) or (
1004
+ '=' not in operands_mentioned and num_mentioned.__len__() < 2)): # don't compute if parts are missing
1005
+ print(
1006
+ f"{self.__loadingAnimation('Hmm', 0.8) or '' if display_thought else ''}{'\033[34m'}It looks like some essential details are missing, so I can’t complete this calculation right now.{'\033[0m'}")
1007
+ print(
1008
+ f"\033[34mIf you are asking a geometric query, try including geometric identifiers like \"{'\", \"'.join(geo_types)}\" in your query.\033[0m")
1009
+ print(
1010
+ f"\033[34mCurrently, I can only compute those identifiers aforementioned, but more geometric features are coming soon!\033[0m")
999
1011
  else: # else, the bot needs to explain what it has tokenized
1000
1012
  if display_thought:
1001
- self.__loadingAnimation(f"1.) I see {', '.join(persons_mentioned) if persons_mentioned.__len__() >= 1 else 'no one'} mentioned as a person name; "
1013
+ self.__loadingAnimation(
1014
+ f"1.) I see {', '.join(persons_mentioned) if persons_mentioned.__len__() >= 1 else 'no one'} mentioned as a person name; "
1002
1015
  f"{'they’re likely key to this problem' if persons_mentioned.__len__() >= 1 else 'moving on'}", 0.2)
1003
- self.__loadingAnimation(f"2.) Moreover, I see {', '.join(items_mentioned) if items_mentioned.__len__() >= 1 else 'no items'} mentioned as proper nouns; "
1016
+ self.__loadingAnimation(
1017
+ f"2.) Moreover, I see {', '.join(items_mentioned) if items_mentioned.__len__() >= 1 else 'no items'} mentioned as proper nouns; "
1004
1018
  f"{'this might be a key thing to this problem' if items_mentioned.__len__() >= 1 else 'moving on'}",
1005
1019
  0.2)
1006
1020
  if is_geometric_query:
1007
- self.__loadingAnimation(f"3.) This is a geometric problem and I have already computed the answer", 0.2)
1021
+ self.__loadingAnimation(f"3.) This is a geometric problem and I have already computed the answer",
1022
+ 0.2)
1008
1023
  else:
1009
- self.__loadingAnimation(f"3.) I’ve also identified the numbers {' and '.join(num_mentioned)} that I need to compute with", 0.2)
1010
- self.__loadingAnimation(f"4.) I see the keywords \"{'\" and \"'.join(keywords_mentioned)}\", meaning I need to perform a \"{'\" and \"'.join(operands_mentioned)}\" operation for this query; I’ll use that to guide my calculation", 0.2)
1024
+ self.__loadingAnimation(
1025
+ f"3.) I’ve also identified the numbers {' and '.join(num_mentioned)} that I need to compute with",
1026
+ 0.2)
1027
+ self.__loadingAnimation(
1028
+ f"4.) I see the keywords \"{'\" and \"'.join(keywords_mentioned)}\", meaning I need to perform a \"{'\" and \"'.join(operands_mentioned)}\" operation for this query; I’ll use that to guide my calculation",
1029
+ 0.2)
1011
1030
  self.__loadingAnimation("Now I have the parts, so let me put it all together and solve", 0.3)
1012
1031
 
1013
1032
  # Finally compute it and then give the response (if there is any)
@@ -1172,7 +1191,7 @@ class DLM:
1172
1191
 
1173
1192
  Behavior:
1174
1193
  - Outputs step-by-step reasoning in a conversational format (e.g., interpreting the question's structure and tone).
1175
- - In experimental mode, calls advanced reasoning (e.g., math parsing or CoT decomposition).
1194
+ - In compute mode, calls advanced reasoning (e.g., math parsing or CoT decomposition).
1176
1195
  - Identifies the question's tone, topic, and potential intent based on interrogative words and SpaCy similarity.
1177
1196
  - Displays confidence based on similarity metrics and sets flags for uncertain answers.
1178
1197
  - Uses colorized terminal output and a loading animation to simulate reflective thought.
@@ -1188,7 +1207,7 @@ class DLM:
1188
1207
  if self.__tone != "":
1189
1208
  print(
1190
1209
  f"{'\033[33m'}Right off the bat, the user seems quite {sentiment_tone[0]} or {sentiment_tone[1]} by their query tone. Hopefully I won't disappoint!{'\033[0m'}")
1191
- if self.__mode == "experimental":
1210
+ if self.__mode == "compute":
1192
1211
  self.__perform_advanced_CoT(filtered_query, display_thought)
1193
1212
  else:
1194
1213
  interrogative_start = filtered_query.split()[0]
@@ -1243,7 +1262,7 @@ class DLM:
1243
1262
  f"Additionally, doing a more in-depth vector NLP analysis resulted in {int(self.__nlp_similarity_value * 100)}% similarity. Although there are room for error, we will see.{'\033[0m'}")
1244
1263
  self.__loadingAnimation("Let me recall that answer", 0.8)
1245
1264
  print("\n")
1246
- elif self.__mode == "experimental":
1265
+ elif self.__mode == "compute":
1247
1266
  self.__perform_advanced_CoT(filtered_query, display_thought)
1248
1267
 
1249
1268
  def __generate_response(self, best_match_answer, best_match_question): # no return, void
@@ -1526,8 +1545,8 @@ class DLM:
1526
1545
  - Detects tone, filters input, searches knowledge base.
1527
1546
  - Performs Chain-of-Thought (CoT) while recalling learnt answer.
1528
1547
  - If match is found, generates a response.
1529
- - If in training mode and answer is incorrect or not found, prompts user to teach the bot.
1530
- - In experimental mode, performs reasoning or arithmetic without using database.
1548
+ - If in learning mode and answer is incorrect or not found, prompts user to teach the bot.
1549
+ - In compute mode, performs reasoning or arithmetic without using database.
1531
1550
  """
1532
1551
  self.__query = query
1533
1552
  while self.__query is None or self.__query == "":
@@ -1536,7 +1555,7 @@ class DLM:
1536
1555
  self.__set_sentiment_tone(self.__query) # sets global variable sentiment tone
1537
1556
 
1538
1557
  # storing the user-query (filtered, lower-case, no punctuation)
1539
- if self.__mode == "experimental":
1558
+ if self.__mode == "compute":
1540
1559
  # We want to keep the following
1541
1560
  keep = {".", "+", "-", "*", "/", "="}
1542
1561
  to_remove = "".join(ch for ch in string.punctuation if ch not in keep)
@@ -1584,13 +1603,13 @@ class DLM:
1584
1603
  display_thought)
1585
1604
 
1586
1605
  # accept a match if highest_similarity is 65% or more, or if semantic similarity is recognized
1587
- if self.__mode != "experimental":
1606
+ if self.__mode != "compute":
1588
1607
  if (not self.__unsure_while_thinking) and ((highest_similarity >= 0.65) or (
1589
1608
  best_match_answer and self.__semantic_similarity(self.__special_stripped_query,
1590
1609
  best_match_question))):
1591
1610
  self.__unsure_while_thinking = False # reset this back to default for next iteration
1592
1611
  self.__generate_response(best_match_answer, best_match_question)
1593
- if self.__mode == "training":
1612
+ if self.__mode == "learn":
1594
1613
  self.__expectation = input("Is this what you expected (Y/N): ")
1595
1614
 
1596
1615
  while not self.__expectation: # if nothing entered, ask until question answered
@@ -1603,7 +1622,7 @@ class DLM:
1603
1622
  return
1604
1623
 
1605
1624
  # only executes if training option is TRUE
1606
- if self.__mode == "training":
1625
+ if self.__mode == "learn":
1607
1626
  self.__expectation = input(
1608
1627
  "I'm not sure. Train me with the expected response: ") # train DLM with answer
1609
1628
  while not self.__expectation:
@@ -1621,5 +1640,5 @@ class DLM:
1621
1640
  self.__learn(self.__expectation,
1622
1641
  self.__category) # learn this new question and answer pair and add to knowledgebase
1623
1642
  print("I learned something new!") # confirmation that it went through the whole process
1624
- else: # only executes when in commercial mode and bot cannot find the answer
1643
+ else: # only executes when in recall mode and bot cannot find the answer
1625
1644
  print(f"{'\033[34m'}{random.choice(self.__fallback_responses)}{'\033[0m'}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamic-learning-model
3
- Version: 1.4
3
+ Version: 1.5.1
4
4
  Summary: A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.
5
5
  Home-page: https://github.com/VigneshT24/Dynamic_Learning_Model
6
6
  Author: Vignesh Thondikulam
@@ -48,8 +48,11 @@ Whether you're building a student support bot, a domain-specific assistant, or a
48
48
 
49
49
  **REQUIRED PARAMETERS**:
50
50
  * The constructor requires passing in two parameters:
51
- - Bot Mode: 't' = training, 'c' = commercial, 'e' = experimental
52
- - Empty SQL Database for training the bot with queries
51
+ - Bot Mode:
52
+ - 'learn' = Enables training using the memory model. The bot can be updated with new information,
53
+ - 'recall' = The bot uses the memory model in read-only mode (no training),
54
+ - 'compute' = Activates the computation model for processing and solving queries algorithmically (no training)
55
+ - Empty SQL Database for training the bot with queries and for the memory model
53
56
  * The ask() method also requires passing in two parameters:
54
57
  - Query: "What is the definition of FAFSA" (as an example)
55
58
  - Display Thought: "True" to allow the bot's Chain of Thought to be displayed, or else "False"
@@ -61,32 +64,32 @@ pip install dynamic-learning-model
61
64
  ```
62
65
  * ***Python 3.12 or higher is required to use this bot in your program***
63
66
 
64
- (Experimental 'e' mode [computation queries])
67
+ ('learn' mode [training queries])
68
+ * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
65
69
  ```python
66
70
  from dlm import DLM
67
71
 
68
- computation_bot = DLM("e", "college_knowledge.db")
72
+ training_bot = DLM("learn", "college_knowledge.db")
69
73
 
70
- computation_bot.ask("Compute the following: 5 * 5 * 5 + 5 / 5", True)
74
+ training_bot.ask("What is FAFSA in college?", True)
71
75
  ```
72
76
 
73
- (Training 't' mode [training queries])
74
- * You can find the training password in the ```__trainingPwd``` variable defined within the DLM.py file
77
+ ('recall' mode [deployment/production use after training])
75
78
  ```python
76
79
  from dlm import DLM
77
80
 
78
- training_bot = DLM("t", "college_knowledge.db")
81
+ commercial_bot = DLM("recall", "college_knowledge.db")
79
82
 
80
- training_bot.ask("What is FAFSA in college?", True)
83
+ commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
81
84
  ```
82
85
 
83
- (Commercial 'c' mode [deployment/production use after training])
86
+ ('compute' mode [computation queries])
84
87
  ```python
85
88
  from dlm import DLM
86
89
 
87
- commercial_bot = DLM("c", "college_knowledge.db")
90
+ computation_bot = DLM("compute", "college_knowledge.db")
88
91
 
89
- commercial_bot.ask("What is the difference between FAFSA and CADAA in California?", False)
92
+ computation_bot.ask("Tell me the result for the following: 5 * 5 * 5 + 5 / 5", True)
90
93
  ```
91
94
 
92
95
  **HIGH-LEVEL PIPELINE VISUALS**:
@@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as f:
5
5
 
6
6
  setup(
7
7
  name='dynamic-learning-model',
8
- version='1.4',
8
+ version='1.5.1',
9
9
  author='Vignesh Thondikulam',
10
10
  author_email='vignesh.tho2006@gmail.com',
11
11
  description='A Dynamic Learning Model for processing NLP queries using hybrid AI and reasoning.',