Upload 3 files
Browse files- config.json +79 -17
- config.py +43 -50
- model_manager.py +4 -21
config.json
CHANGED
|
@@ -10,7 +10,74 @@
|
|
| 10 |
"DATASET_PATHS": {
|
| 11 |
"general": ["data/general.json"],
|
| 12 |
"programming_software_dev": ["data/programming_software_dev.json"],
|
| 13 |
-
"other_information": ["data/other_information.json"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
},
|
| 15 |
"LAZY_LOADING_ENABLED": true,
|
| 16 |
"MAX_INITIAL_SPECIALIZATIONS": 2,
|
|
@@ -20,23 +87,18 @@
|
|
| 20 |
"INPUT_SIZE": 768,
|
| 21 |
"OUTPUT_SIZE": 768,
|
| 22 |
"SPECIALIZATIONS": [
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
"
|
| 28 |
-
"
|
| 29 |
-
"
|
| 30 |
-
"
|
| 31 |
-
"industrial_engineering",
|
| 32 |
-
"science_engineering",
|
| 33 |
"mathematics",
|
| 34 |
-
"
|
| 35 |
-
"
|
| 36 |
-
"
|
| 37 |
-
"cyber_security",
|
| 38 |
-
"business_legal_finance",
|
| 39 |
-
"other_information"
|
| 40 |
],
|
| 41 |
"PREPROCESSING": {
|
| 42 |
"LOWERCASE": true,
|
|
|
|
| 10 |
"DATASET_PATHS": {
|
| 11 |
"general": ["data/general.json"],
|
| 12 |
"programming_software_dev": ["data/programming_software_dev.json"],
|
| 13 |
+
"other_information": ["data/other_information.json"],
|
| 14 |
+
"python": [
|
| 15 |
+
"data/python_mbpp.json",
|
| 16 |
+
"data/python_programming.json",
|
| 17 |
+
"data/python_transformer_model.json"
|
| 18 |
+
],
|
| 19 |
+
"rust": [
|
| 20 |
+
"data/rust_ai_language_model.json",
|
| 21 |
+
"data/rust_blockchain.json",
|
| 22 |
+
"data/rust_mbrp.json",
|
| 23 |
+
"data/rust_programming.json"
|
| 24 |
+
],
|
| 25 |
+
"solidity": ["data/solidity_programming.json"],
|
| 26 |
+
"computer": [
|
| 27 |
+
"data/computer_advanced_debugging.json",
|
| 28 |
+
"data/computer_agenticAI.json",
|
| 29 |
+
"data/computer_architecture.json",
|
| 30 |
+
"data/computer_cloud_security.json",
|
| 31 |
+
"data/computer_cloudCI-CD.json",
|
| 32 |
+
"data/computer_creativity.json",
|
| 33 |
+
"data/computer_crossplatform.json",
|
| 34 |
+
"data/computer_cybersecurity.json",
|
| 35 |
+
"data/computer_error_handling_examples.json",
|
| 36 |
+
"data/computer_gitInstruct.json"
|
| 37 |
+
],
|
| 38 |
+
"cpp": [
|
| 39 |
+
"data/cpp_ai_language_model.json",
|
| 40 |
+
"data/cpp_blockchain.json",
|
| 41 |
+
"data/cpp_mbcppp.json",
|
| 42 |
+
"data/cpp_programming.json"
|
| 43 |
+
],
|
| 44 |
+
"go": [
|
| 45 |
+
"data/golang_ai_language_model.json",
|
| 46 |
+
"data/golang_mbgp.json",
|
| 47 |
+
"data/golang_programming.json"
|
| 48 |
+
],
|
| 49 |
+
"java": [
|
| 50 |
+
"data/java_ai_language_model.json",
|
| 51 |
+
"data/java_blockchain.json",
|
| 52 |
+
"data/java_mbjp.json",
|
| 53 |
+
"data/java_programming.json",
|
| 54 |
+
"data/java_transformer_language_model.json"
|
| 55 |
+
],
|
| 56 |
+
"javascript": [
|
| 57 |
+
"data/javascript_chatbot.json",
|
| 58 |
+
"data/javascript_n_Typescript_backend.json",
|
| 59 |
+
"data/javascript_n_Typescript_frontend.json",
|
| 60 |
+
"data/javascript_n_Typescript_programming.json"
|
| 61 |
+
],
|
| 62 |
+
"mathematics": [
|
| 63 |
+
"data/mathematics.json",
|
| 64 |
+
"data/mathematics_training.json"
|
| 65 |
+
],
|
| 66 |
+
"nim": [
|
| 67 |
+
"data/nim_ai_language_model.json",
|
| 68 |
+
"data/nim_blockchain.json",
|
| 69 |
+
"data/nim_chatbot.json",
|
| 70 |
+
"data/nim_conversation.json",
|
| 71 |
+
"data/nim_mbnp.json",
|
| 72 |
+
"data/nim_programming.json"
|
| 73 |
+
],
|
| 74 |
+
"other_information": ["data/other_information.json"],
|
| 75 |
+
"physics": [
|
| 76 |
+
"data/physics_n_engineering.json",
|
| 77 |
+
"data/physics_n_engineering_applied.json",
|
| 78 |
+
"data/project_structure.json",
|
| 79 |
+
"data/python_chatbot_guide.json"
|
| 80 |
+
]
|
| 81 |
},
|
| 82 |
"LAZY_LOADING_ENABLED": true,
|
| 83 |
"MAX_INITIAL_SPECIALIZATIONS": 2,
|
|
|
|
| 87 |
"INPUT_SIZE": 768,
|
| 88 |
"OUTPUT_SIZE": 768,
|
| 89 |
"SPECIALIZATIONS": [
|
| 90 |
+
"python",
|
| 91 |
+
"rust",
|
| 92 |
+
"solidity",
|
| 93 |
+
"computer",
|
| 94 |
+
"cpp",
|
| 95 |
+
"go",
|
| 96 |
+
"java",
|
| 97 |
+
"javascript",
|
|
|
|
|
|
|
| 98 |
"mathematics",
|
| 99 |
+
"nim",
|
| 100 |
+
"other_information",
|
| 101 |
+
"physics"
|
|
|
|
|
|
|
|
|
|
| 102 |
],
|
| 103 |
"PREPROCESSING": {
|
| 104 |
"LOWERCASE": true,
|
config.py
CHANGED
|
@@ -94,99 +94,92 @@ HIDDEN_SIZE = 768 # Hidden layer size
|
|
| 94 |
|
| 95 |
# Add SPECIALIZATIONS list
|
| 96 |
SPECIALIZATIONS = [
|
| 97 |
-
"cpp",
|
| 98 |
-
"java",
|
| 99 |
-
"go",
|
| 100 |
-
"javascript",
|
| 101 |
-
"nim",
|
| 102 |
"python",
|
| 103 |
"rust",
|
| 104 |
"solidity",
|
| 105 |
"computer",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
"mathematics",
|
| 107 |
-
"
|
| 108 |
-
"other_information"
|
|
|
|
| 109 |
]
|
| 110 |
|
| 111 |
-
# Define DATASET_PATHS so that each specialization
|
| 112 |
DATASET_PATHS = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
"computer": [
|
| 114 |
str(DATA_DIR / "data" / "computer_advanced_debugging.json"),
|
| 115 |
str(DATA_DIR / "data" / "computer_agenticAI.json"),
|
| 116 |
str(DATA_DIR / "data" / "computer_architecture.json"),
|
| 117 |
str(DATA_DIR / "data" / "computer_cloud_security.json"),
|
|
|
|
| 118 |
str(DATA_DIR / "data" / "computer_creativity.json"),
|
| 119 |
str(DATA_DIR / "data" / "computer_crossplatform.json"),
|
| 120 |
str(DATA_DIR / "data" / "computer_cybersecurity.json"),
|
| 121 |
str(DATA_DIR / "data" / "computer_error_handling_examples.json"),
|
| 122 |
str(DATA_DIR / "data" / "computer_gitInstruct.json")
|
| 123 |
],
|
| 124 |
-
|
| 125 |
"cpp": [
|
| 126 |
-
str(DATA_DIR / "data" / "
|
| 127 |
str(DATA_DIR / "data" / "cpp_blockchain.json"),
|
| 128 |
str(DATA_DIR / "data" / "cpp_mbcppp.json"),
|
| 129 |
str(DATA_DIR / "data" / "cpp_programming.json")
|
| 130 |
],
|
| 131 |
-
|
| 132 |
-
"java": [
|
| 133 |
-
str(DATA_DIR / "data" / "java_ai_language_model.json"),
|
| 134 |
-
str(DATA_DIR / "data" / "java_blockchain.json"),
|
| 135 |
-
str(DATA_DIR / "data" / "java_mbjp.json"),
|
| 136 |
-
str(DATA_DIR / "data" / "java_transformer_language_model.json"),
|
| 137 |
-
],
|
| 138 |
-
|
| 139 |
"go": [
|
| 140 |
str(DATA_DIR / "data" / "golang_ai_language_model.json"),
|
| 141 |
str(DATA_DIR / "data" / "golang_mbgp.json"),
|
| 142 |
str(DATA_DIR / "data" / "golang_programming.json")
|
| 143 |
],
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
"javascript": [
|
| 146 |
str(DATA_DIR / "data" / "javascript_chatbot.json"),
|
| 147 |
-
str(DATA_DIR / "data" / "javascript_n_Typescript_frontend.json"),
|
| 148 |
str(DATA_DIR / "data" / "javascript_n_Typescript_backend.json"),
|
| 149 |
-
str(DATA_DIR / "data" / "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
],
|
| 151 |
-
|
| 152 |
"nim": [
|
| 153 |
str(DATA_DIR / "data" / "nim_ai_language_model.json"),
|
| 154 |
str(DATA_DIR / "data" / "nim_blockchain.json"),
|
| 155 |
str(DATA_DIR / "data" / "nim_chatbot.json"),
|
|
|
|
| 156 |
str(DATA_DIR / "data" / "nim_mbnp.json"),
|
| 157 |
str(DATA_DIR / "data" / "nim_programming.json")
|
| 158 |
],
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
str(DATA_DIR / "data" / "python_chatbot_guide.json"),
|
| 162 |
-
str(DATA_DIR / "data" / "python_mbpp.json"),
|
| 163 |
-
str(DATA_DIR / "data" / "python_programming.json"),
|
| 164 |
-
str(DATA_DIR / "data" / "python_transformer_model.json")
|
| 165 |
-
],
|
| 166 |
-
|
| 167 |
-
"rust": [
|
| 168 |
-
str(DATA_DIR / "data" / "rust_ai_language_model.json"),
|
| 169 |
-
str(DATA_DIR / "data" / "rust_blockchain.json"),
|
| 170 |
-
str(DATA_DIR / "data" / "rust_mbrp.json"),
|
| 171 |
-
str(DATA_DIR / "data" / "rust_programming.json")
|
| 172 |
-
],
|
| 173 |
-
|
| 174 |
-
"solidity": [
|
| 175 |
-
str(DATA_DIR / "data" / "solidity_programming.json")
|
| 176 |
-
],
|
| 177 |
-
|
| 178 |
-
"mathematics": [
|
| 179 |
-
str(DATA_DIR / "data" / "mathematics.json"),
|
| 180 |
-
str(DATA_DIR / "data" / "mathematics_training.json")
|
| 181 |
],
|
| 182 |
-
|
| 183 |
"physics": [
|
| 184 |
str(DATA_DIR / "data" / "physics_n_engineering.json"),
|
| 185 |
-
str(DATA_DIR / "data" / "physics_n_engineering_applied.json")
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
"other_information": [
|
| 189 |
-
str(DATA_DIR / "data" / "other_information.json")
|
| 190 |
]
|
| 191 |
}
|
| 192 |
|
|
|
|
| 94 |
|
| 95 |
# Add SPECIALIZATIONS list
|
| 96 |
SPECIALIZATIONS = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
"python",
|
| 98 |
"rust",
|
| 99 |
"solidity",
|
| 100 |
"computer",
|
| 101 |
+
"cpp",
|
| 102 |
+
"go",
|
| 103 |
+
"java",
|
| 104 |
+
"javascript",
|
| 105 |
"mathematics",
|
| 106 |
+
"nim",
|
| 107 |
+
"other_information",
|
| 108 |
+
"physics"
|
| 109 |
]
|
| 110 |
|
| 111 |
+
# Define DATASET_PATHS so that each specialization maps to its JSON files
|
| 112 |
DATASET_PATHS = {
|
| 113 |
+
"python": [
|
| 114 |
+
str(DATA_DIR / "data" / "python_mbpp.json"),
|
| 115 |
+
str(DATA_DIR / "data" / "python_programming.json"),
|
| 116 |
+
str(DATA_DIR / "data" / "python_transformer_model.json")
|
| 117 |
+
],
|
| 118 |
+
"rust": [
|
| 119 |
+
str(DATA_DIR / "data" / "rust_ai_language_model.json"),
|
| 120 |
+
str(DATA_DIR / "data" / "rust_blockchain.json"),
|
| 121 |
+
str(DATA_DIR / "data" / "rust_mbrp.json"),
|
| 122 |
+
str(DATA_DIR / "data" / "rust_programming.json")
|
| 123 |
+
],
|
| 124 |
+
"solidity": [
|
| 125 |
+
str(DATA_DIR / "data" / "solidity_programming.json")
|
| 126 |
+
],
|
| 127 |
"computer": [
|
| 128 |
str(DATA_DIR / "data" / "computer_advanced_debugging.json"),
|
| 129 |
str(DATA_DIR / "data" / "computer_agenticAI.json"),
|
| 130 |
str(DATA_DIR / "data" / "computer_architecture.json"),
|
| 131 |
str(DATA_DIR / "data" / "computer_cloud_security.json"),
|
| 132 |
+
str(DATA_DIR / "data" / "computer_cloudCI-CD.json"),
|
| 133 |
str(DATA_DIR / "data" / "computer_creativity.json"),
|
| 134 |
str(DATA_DIR / "data" / "computer_crossplatform.json"),
|
| 135 |
str(DATA_DIR / "data" / "computer_cybersecurity.json"),
|
| 136 |
str(DATA_DIR / "data" / "computer_error_handling_examples.json"),
|
| 137 |
str(DATA_DIR / "data" / "computer_gitInstruct.json")
|
| 138 |
],
|
|
|
|
| 139 |
"cpp": [
|
| 140 |
+
str(DATA_DIR / "data" / "cpp_ai_language_model.json"),
|
| 141 |
str(DATA_DIR / "data" / "cpp_blockchain.json"),
|
| 142 |
str(DATA_DIR / "data" / "cpp_mbcppp.json"),
|
| 143 |
str(DATA_DIR / "data" / "cpp_programming.json")
|
| 144 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
"go": [
|
| 146 |
str(DATA_DIR / "data" / "golang_ai_language_model.json"),
|
| 147 |
str(DATA_DIR / "data" / "golang_mbgp.json"),
|
| 148 |
str(DATA_DIR / "data" / "golang_programming.json")
|
| 149 |
],
|
| 150 |
+
"java": [
|
| 151 |
+
str(DATA_DIR / "data" / "java_ai_language_model.json"),
|
| 152 |
+
str(DATA_DIR / "data" / "java_blockchain.json"),
|
| 153 |
+
str(DATA_DIR / "data" / "java_mbjp.json"),
|
| 154 |
+
str(DATA_DIR / "data" / "java_programming.json"),
|
| 155 |
+
str(DATA_DIR / "data" / "java_transformer_language_model.json")
|
| 156 |
+
],
|
| 157 |
"javascript": [
|
| 158 |
str(DATA_DIR / "data" / "javascript_chatbot.json"),
|
|
|
|
| 159 |
str(DATA_DIR / "data" / "javascript_n_Typescript_backend.json"),
|
| 160 |
+
str(DATA_DIR / "data" / "javascript_n_Typescript_frontend.json"),
|
| 161 |
+
str(DATA_DIR / "data" / "javascript_n_Typescript_programming.json")
|
| 162 |
+
],
|
| 163 |
+
"mathematics": [
|
| 164 |
+
str(DATA_DIR / "data" / "mathematics.json"),
|
| 165 |
+
str(DATA_DIR / "data" / "mathematics_training.json")
|
| 166 |
],
|
|
|
|
| 167 |
"nim": [
|
| 168 |
str(DATA_DIR / "data" / "nim_ai_language_model.json"),
|
| 169 |
str(DATA_DIR / "data" / "nim_blockchain.json"),
|
| 170 |
str(DATA_DIR / "data" / "nim_chatbot.json"),
|
| 171 |
+
str(DATA_DIR / "data" / "nim_conversation.json"),
|
| 172 |
str(DATA_DIR / "data" / "nim_mbnp.json"),
|
| 173 |
str(DATA_DIR / "data" / "nim_programming.json")
|
| 174 |
],
|
| 175 |
+
"other_information": [
|
| 176 |
+
str(DATA_DIR / "data" / "other_information.json")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
],
|
|
|
|
| 178 |
"physics": [
|
| 179 |
str(DATA_DIR / "data" / "physics_n_engineering.json"),
|
| 180 |
+
str(DATA_DIR / "data" / "physics_n_engineering_applied.json"),
|
| 181 |
+
str(DATA_DIR / "data" / "project_structure.json"),
|
| 182 |
+
str(DATA_DIR / "data" / "python_chatbot_guide.json")
|
|
|
|
|
|
|
| 183 |
]
|
| 184 |
}
|
| 185 |
|
model_manager.py
CHANGED
|
@@ -3,16 +3,13 @@ from pathlib import Path
|
|
| 3 |
from threading import Lock
|
| 4 |
from collections import OrderedDict
|
| 5 |
from nltk.stem import WordNetLemmatizer
|
| 6 |
-
from typing import List, Dict, Any, Tuple, Optional
|
| 7 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 8 |
from config import app_config
|
| 9 |
from dataset import TensorDataset
|
| 10 |
from utils.transformer_utils import get_sentence_transformer
|
| 11 |
from utils.smartHybridAttention import SmartHybridAttention, get_hybrid_attention_config
|
| 12 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 13 |
-
|
| 14 |
-
if TYPE_CHECKING:
|
| 15 |
-
from service_registry import registry
|
| 16 |
from service_registry import registry, MODEL, TOKENIZER, MODEL_MANAGER, COMMUNICATOR
|
| 17 |
|
| 18 |
logger = logging.getLogger(__name__)
|
|
@@ -236,22 +233,8 @@ class ModelManager:
|
|
| 236 |
}
|
| 237 |
|
| 238 |
def _load_models(self):
|
| 239 |
-
"""Load
|
| 240 |
-
|
| 241 |
-
"mbpp",
|
| 242 |
-
"programming_software_dev",
|
| 243 |
-
"machine_learning_ai_data_science",
|
| 244 |
-
"industrial_engineering",
|
| 245 |
-
"science_engineering",
|
| 246 |
-
"mathematics",
|
| 247 |
-
"healthcare_and_lifesciences",
|
| 248 |
-
"chemistry",
|
| 249 |
-
"hardware_devops_cloud",
|
| 250 |
-
"cyber_security",
|
| 251 |
-
"business_legal_finance",
|
| 252 |
-
"other_information"
|
| 253 |
-
]
|
| 254 |
-
initial = ["general", "programming_software_dev"]
|
| 255 |
data_dir = os.environ.get("TLM_DATA_DIR", "/tmp/tlm_data")
|
| 256 |
os.makedirs(data_dir, exist_ok=True)
|
| 257 |
|
|
@@ -264,7 +247,7 @@ class ModelManager:
|
|
| 264 |
logger.error(f"Failed to load model for '{spec}'", exc_info=True)
|
| 265 |
raise
|
| 266 |
|
| 267 |
-
logger.info(f"{len(self.models)} models loaded at startup (of {len(
|
| 268 |
|
| 269 |
def get_or_create_model(self, specialization: str) -> Any:
|
| 270 |
"""Get an existing model or create it on demand if not already loaded"""
|
|
|
|
| 3 |
from threading import Lock
|
| 4 |
from collections import OrderedDict
|
| 5 |
from nltk.stem import WordNetLemmatizer
|
| 6 |
+
from typing import List, Dict, Any, Tuple, Optional
|
| 7 |
from sklearn.metrics.pairwise import cosine_similarity
|
| 8 |
from config import app_config
|
| 9 |
from dataset import TensorDataset
|
| 10 |
from utils.transformer_utils import get_sentence_transformer
|
| 11 |
from utils.smartHybridAttention import SmartHybridAttention, get_hybrid_attention_config
|
| 12 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
| 13 |
from service_registry import registry, MODEL, TOKENIZER, MODEL_MANAGER, COMMUNICATOR
|
| 14 |
|
| 15 |
logger = logging.getLogger(__name__)
|
|
|
|
| 233 |
}
|
| 234 |
|
| 235 |
def _load_models(self):
|
| 236 |
+
"""Load initial specializations—now pulled from config.DATASET_PATHS keys."""
|
| 237 |
+
initial = ["general"] # only preload the 'general' specialization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
data_dir = os.environ.get("TLM_DATA_DIR", "/tmp/tlm_data")
|
| 239 |
os.makedirs(data_dir, exist_ok=True)
|
| 240 |
|
|
|
|
| 247 |
logger.error(f"Failed to load model for '{spec}'", exc_info=True)
|
| 248 |
raise
|
| 249 |
|
| 250 |
+
logger.info(f"{len(self.models)} models loaded at startup (of {len(self.specializations)} total)")
|
| 251 |
|
| 252 |
def get_or_create_model(self, specialization: str) -> Any:
|
| 253 |
"""Get an existing model or create it on demand if not already loaded"""
|