Rulga commited on
Commit
72f65c8
·
1 Parent(s): 1502cbe

Refactor model configuration to include detailed information for each model in the settings

Browse files
Files changed (2) hide show
  1. app.py +5 -134
  2. config/settings.py +88 -2
app.py CHANGED
@@ -14,7 +14,8 @@ from config.settings import (
14
  DATASET_ID,
15
  CHAT_HISTORY_PATH,
16
  VECTOR_STORE_PATH,
17
- DEFAULT_MODEL
 
18
  )
19
  from src.knowledge_base.vector_store import create_vector_store, load_vector_store
20
  from web.training_interface import (
@@ -38,138 +39,8 @@ if not HF_TOKEN:
38
  raise ValueError("HUGGINGFACE_TOKEN not found in environment variables")
39
 
40
  # Enhanced model details for UI
41
- # Enhanced model details for UI
42
- MODEL_DETAILS = {
43
- "llama-7b": {
44
- "full_name": "Meta Llama 2 7B Chat",
45
- "capabilities": [
46
- "Multilingual support ",
47
- "Good performance on legal texts",
48
- "Free model with open license",
49
- "Can run on computers with 16GB+ RAM"
50
- ],
51
- "limitations": [
52
- "Limited knowledge of specific legal terminology",
53
- "May provide incorrect answers to complex legal questions",
54
- "Knowledge is limited to training data"
55
- ],
56
- "use_cases": [
57
- "Legal document analysis",
58
- "Answering general legal questions",
59
- "Searching through legal knowledge base",
60
- "Assistance in document drafting"
61
- ],
62
- "documentation": "https://huggingface.co/meta-llama/Llama-2-7b-chat-hf"
63
- },
64
- "zephyr-7b": {
65
- "full_name": "HuggingFaceH4 Zephyr 7B Beta",
66
- "capabilities": [
67
- "High performance on instruction-following tasks",
68
- "Good response accuracy",
69
- "Advanced reasoning capabilities",
70
- "Excellent text generation quality"
71
- ],
72
- "limitations": [
73
- "May require paid API for usage",
74
- "Limited support for languages other than English",
75
- "Less optimization for legal topics compared to specialized models"
76
- ],
77
- "use_cases": [
78
- "Complex legal reasoning",
79
- "Case analysis",
80
- "Legal research",
81
- "Structured legal text generation"
82
- ],
83
- "documentation": "https://huggingface.co/HuggingFaceH4/zephyr-7b-beta"
84
- },
85
- "mistral-7b": {
86
- "full_name": "Mistral 7B Instruct v0.2",
87
- "capabilities": [
88
- "Strong multilingual support",
89
- "Superior instruction following ability",
90
- "Fast inference speed",
91
- "Excellent reasoning capabilities",
92
- "Free for commercial use"
93
- ],
94
- "limitations": [
95
- "May have limited knowledge of specialized legal terminology",
96
- "Less exposure to legal domain than specialized models",
97
- "Knowledge cutoff before latest legal developments"
98
- ],
99
- "use_cases": [
100
- "Multilingual legal assistance",
101
- "Cross-border legal questions",
102
- "Clear explanations of complex legal topics",
103
- "Serving international clients in their native language"
104
- ],
105
- "documentation": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2"
106
- },
107
- "xglm-7.5b": {
108
- "full_name": "Meta XGLM 7.5B",
109
- "capabilities": [
110
- "Specialized for multilingual generation",
111
- "Support for 30+ languages",
112
- "Strong cross-lingual transfer abilities",
113
- "Consistent performance across diverse languages"
114
- ],
115
- "limitations": [
116
- "Less instruction-tuned than dedicated chat models",
117
- "May require more specific prompting",
118
- "Not specifically optimized for legal domain",
119
- "Slightly larger model requiring more GPU memory"
120
- ],
121
- "use_cases": [
122
- "International legal assistance in native languages",
123
- "Complex multilingual documentation",
124
- "Serving clients from diverse linguistic backgrounds",
125
- "Translation and summarization of legal concepts across languages"
126
- ],
127
- "documentation": "https://huggingface.co/facebook/xglm-7.5B"
128
- }
129
- }
130
  # MODEL_DETAILS = {
131
- # "llama-7b": {
132
- # "full_name": "Meta Llama 2 7B Chat",
133
- # "capabilities": [
134
- # "Multilingual support ",
135
- # "Good performance on legal texts",
136
- # "Free model with open license",
137
- # "Can run on computers with 16GB+ RAM"
138
- # ],
139
- # "limitations": [
140
- # "Limited knowledge of specific legal terminology",
141
- # "May provide incorrect answers to complex legal questions",
142
- # "Knowledge is limited to training data"
143
- # ],
144
- # "use_cases": [
145
- # "Legal document analysis",
146
- # "Answering general legal questions",
147
- # "Searching through legal knowledge base",
148
- # "Assistance in document drafting"
149
- # ],
150
- # "documentation": "https://huggingface.co/meta-llama/Llama-2-7b-chat-hf"
151
- # },
152
- # "zephyr-7b": {
153
- # "full_name": "HuggingFaceH4 Zephyr 7B Beta",
154
- # "capabilities": [
155
- # "High performance on instruction-following tasks",
156
- # "Good response accuracy",
157
- # "Advanced reasoning capabilities",
158
- # "Excellent text generation quality"
159
- # ],
160
- # "limitations": [
161
- # "May require paid API for usage",
162
- # "Limited support for languages other than English",
163
- # "Less optimization for legal topics compared to specialized models"
164
- # ],
165
- # "use_cases": [
166
- # "Complex legal reasoning",
167
- # "Case analysis",
168
- # "Legal research",
169
- # "Structured legal text generation"
170
- # ],
171
- # "documentation": "https://huggingface.co/HuggingFaceH4/zephyr-7b-beta"
172
- # }
173
  # }
174
 
175
  # Path for user preferences file
@@ -570,10 +441,10 @@ def update_model_info(model_key):
570
 
571
  def get_model_details_html(model_key):
572
  """Get detailed HTML for model information panel"""
573
- if model_key not in MODEL_DETAILS:
574
  return "<p>Model information not available</p>"
575
 
576
- details = MODEL_DETAILS[model_key]
577
 
578
  html = f"""
579
  <div style="padding: 15px; border: 1px solid #ccc; border-radius: 5px; margin-top: 10px;">
 
14
  DATASET_ID,
15
  CHAT_HISTORY_PATH,
16
  VECTOR_STORE_PATH,
17
+ DEFAULT_MODEL,
18
+ API_CONFIG
19
  )
20
  from src.knowledge_base.vector_store import create_vector_store, load_vector_store
21
  from web.training_interface import (
 
39
  raise ValueError("HUGGINGFACE_TOKEN not found in environment variables")
40
 
41
  # Enhanced model details for UI
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  # MODEL_DETAILS = {
43
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  # }
45
 
46
  # Path for user preferences file
 
441
 
442
  def get_model_details_html(model_key):
443
  """Get detailed HTML for model information panel"""
444
+ if model_key not in MODELS or 'details' not in MODELS[model_key]:
445
  return "<p>Model information not available</p>"
446
 
447
+ details = MODELS[model_key]['details']
448
 
449
  html = f"""
450
  <div style="padding: 15px; border: 1px solid #ccc; border-radius: 5px; margin-top: 10px;">
config/settings.py CHANGED
@@ -32,7 +32,7 @@ os.makedirs(MODEL_PATH, exist_ok=True)
32
  os.makedirs(TRAINING_OUTPUT_DIR, exist_ok=True)
33
  MODELS_REGISTRY_PATH = os.path.join(MODEL_PATH, "registry.json")
34
 
35
- # Models configuration
36
  MODELS = {
37
  "zephyr-7b": {
38
  "id": "HuggingFaceH4/zephyr-7b-beta",
@@ -54,6 +54,27 @@ MODELS = {
54
  "lora_dropout": 0.05,
55
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
56
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
  },
59
  "llama-7b": {
@@ -76,6 +97,27 @@ MODELS = {
76
  "lora_dropout": 0.05,
77
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
78
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
  },
81
  "mistral-7b": {
@@ -98,6 +140,28 @@ MODELS = {
98
  "lora_dropout": 0.05,
99
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
100
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
  },
103
  "xglm-7.5b": {
@@ -120,6 +184,28 @@ MODELS = {
120
  "lora_dropout": 0.05,
121
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
  }
125
  }
@@ -136,4 +222,4 @@ ACTIVE_MODEL = MODELS[DEFAULT_MODEL]
136
  EMBEDDING_MODEL = "intfloat/multilingual-e5-large"
137
 
138
  # Request settings
139
- USER_AGENT = "Status-Law-Assistant/1.0"
 
32
  os.makedirs(TRAINING_OUTPUT_DIR, exist_ok=True)
33
  MODELS_REGISTRY_PATH = os.path.join(MODEL_PATH, "registry.json")
34
 
35
+ # Models configuration with detailed information
36
  MODELS = {
37
  "zephyr-7b": {
38
  "id": "HuggingFaceH4/zephyr-7b-beta",
 
54
  "lora_dropout": 0.05,
55
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
56
  }
57
+ },
58
+ "details": {
59
+ "full_name": "HuggingFaceH4 Zephyr 7B Beta",
60
+ "capabilities": [
61
+ "High performance on instruction-following tasks",
62
+ "Good response accuracy",
63
+ "Advanced reasoning capabilities",
64
+ "Excellent text generation quality"
65
+ ],
66
+ "limitations": [
67
+ "May require paid API for usage",
68
+ "Limited support for languages other than English",
69
+ "Less optimization for legal topics compared to specialized models"
70
+ ],
71
+ "use_cases": [
72
+ "Complex legal reasoning",
73
+ "Case analysis",
74
+ "Legal research",
75
+ "Structured legal text generation"
76
+ ],
77
+ "documentation": "https://huggingface.co/HuggingFaceH4/zephyr-7b-beta"
78
  }
79
  },
80
  "llama-7b": {
 
97
  "lora_dropout": 0.05,
98
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
99
  }
100
+ },
101
+ "details": {
102
+ "full_name": "Meta Llama 2 7B Chat",
103
+ "capabilities": [
104
+ "Multilingual support ",
105
+ "Good performance on legal texts",
106
+ "Free model with open license",
107
+ "Can run on computers with 16GB+ RAM"
108
+ ],
109
+ "limitations": [
110
+ "Limited knowledge of specific legal terminology",
111
+ "May provide incorrect answers to complex legal questions",
112
+ "Knowledge is limited to training data"
113
+ ],
114
+ "use_cases": [
115
+ "Legal document analysis",
116
+ "Answering general legal questions",
117
+ "Searching through legal knowledge base",
118
+ "Assistance in document drafting"
119
+ ],
120
+ "documentation": "https://huggingface.co/meta-llama/Llama-2-7b-chat-hf"
121
  }
122
  },
123
  "mistral-7b": {
 
140
  "lora_dropout": 0.05,
141
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
142
  }
143
+ },
144
+ "details": {
145
+ "full_name": "Mistral 7B Instruct v0.2",
146
+ "capabilities": [
147
+ "Strong multilingual support",
148
+ "Superior instruction following ability",
149
+ "Fast inference speed",
150
+ "Excellent reasoning capabilities",
151
+ "Free for commercial use"
152
+ ],
153
+ "limitations": [
154
+ "May have limited knowledge of specialized legal terminology",
155
+ "Less exposure to legal domain than specialized models",
156
+ "Knowledge cutoff before latest legal developments"
157
+ ],
158
+ "use_cases": [
159
+ "Multilingual legal assistance",
160
+ "Cross-border legal questions",
161
+ "Clear explanations of complex legal topics",
162
+ "Serving international clients in their native language"
163
+ ],
164
+ "documentation": "https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2"
165
  }
166
  },
167
  "xglm-7.5b": {
 
184
  "lora_dropout": 0.05,
185
  "target_modules": ["q_proj", "v_proj", "k_proj", "o_proj"]
186
  }
187
+ },
188
+ "details": {
189
+ "full_name": "Meta XGLM 7.5B",
190
+ "capabilities": [
191
+ "Specialized for multilingual generation",
192
+ "Support for 30+ languages",
193
+ "Strong cross-lingual transfer abilities",
194
+ "Consistent performance across diverse languages"
195
+ ],
196
+ "limitations": [
197
+ "Less instruction-tuned than dedicated chat models",
198
+ "May require more specific prompting",
199
+ "Not specifically optimized for legal domain",
200
+ "Slightly larger model requiring more GPU memory"
201
+ ],
202
+ "use_cases": [
203
+ "International legal assistance in native languages",
204
+ "Complex multilingual documentation",
205
+ "Serving clients from diverse linguistic backgrounds",
206
+ "Translation and summarization of legal concepts across languages"
207
+ ],
208
+ "documentation": "https://huggingface.co/facebook/xglm-7.5B"
209
  }
210
  }
211
  }
 
222
  EMBEDDING_MODEL = "intfloat/multilingual-e5-large"
223
 
224
  # Request settings
225
+ USER_AGENT = "Status-Law-Assistant/1.0"