alx-d commited on
Commit
0802c48
·
verified ·
1 Parent(s): 4cbdaf1

Upload folder using huggingface_hub

Browse files
__pycache__/advanced_rag.cpython-311.pyc CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8f50eecfb78de9572a90521d5496aa1ac5e4f9119bf0856405d383227e0345a8
3
- size 114726
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d68b1e6a80f0f4ca6dd86ed864bf6a85ea9ab118f467cc5035c3e5dc5abe0c2b
3
+ size 129736
advanced_rag.py CHANGED
@@ -4,6 +4,7 @@ import datetime
4
  import functools
5
  import traceback
6
  from typing import List, Optional, Any, Dict, Tuple
 
7
  import csv
8
  import pandas as pd
9
  import tempfile
@@ -63,6 +64,102 @@ except Exception as e:
63
  # API Key Configuration
64
  NEBIUS_API_KEY = os.environ.get("NEBIUS_API_KEY", "")
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  # Add batch processing helper functions
67
  def generate_parameter_values(min_val, max_val, num_values):
68
  """Generate evenly spaced values between min and max"""
@@ -906,12 +1003,185 @@ class ElevatedRagChain:
906
  return input_data["question"]
907
 
908
  # Improve error handling in the ElevatedRagChain class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
909
  def create_llm_pipeline(self, max_tokens_override=None):
910
  from langchain.llms.base import LLM # Import LLM here so it's always defined
911
- from typing import Optional, List, Any
912
  from pydantic import PrivateAttr
913
 
914
- # Extract the model name without the flag emoji prefix
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
915
  clean_llm_choice = self.llm_choice.split(" ", 1)[-1] if " " in self.llm_choice else self.llm_choice
916
  normalized = clean_llm_choice.lower()
917
  print(f"Normalized model name: {normalized}")
@@ -1019,8 +1289,8 @@ class ElevatedRagChain:
1019
  debug_print(f"OpenAI {model} pipeline created successfully.")
1020
  return OpenAILLM()
1021
 
1022
- # Meta-Llama-3 model
1023
- elif "meta-llama" in normalized or "llama" in normalized:
1024
  debug_print("Creating remote Meta-Llama-3 pipeline via Hugging Face Inference API...")
1025
  from huggingface_hub import InferenceClient
1026
  repo_id = "meta-llama/Meta-Llama-3-8B-Instruct"
@@ -1132,81 +1402,6 @@ class ElevatedRagChain:
1132
  debug_print("Mistral API pipeline created successfully.")
1133
  return mistral_llm
1134
 
1135
- # Nebius models
1136
- elif self.llm_choice in ["🟦 GPT OSS 120b (Nebius)", "🟦 GPT OSS 20b (Nebius)", "🟦 Google Gemma 3 27b-Instruct (Nebius)",
1137
- "🟦 DeepSeek-R1-0528 (Nebius)", "🟦 DeepSeek-V3 (Nebius)", "🟦 Meta-Llama-3.1-70B-Instruct (Nebius)",
1138
- "🟦 Meta-Llama-3.1-405B-Instruct (Nebius)", "🟦 Qwen3-235B-A22B (Nebius)", "🟦 Qwen3-32B (Nebius)",
1139
- "🟦 Hermes 4 405B (Nebius)", "🟦 GLM-4.5 AIR (Nebius)"]:
1140
-
1141
- if not OPENAI_AVAILABLE:
1142
- raise ImportError("openai package is required for NEBIUS models.")
1143
-
1144
- # Map display names to backend names
1145
- nebius_model_mapping = {
1146
- "🟦 GPT OSS 120b (Nebius)": "openai/gpt-oss-120b",
1147
- "🟦 GPT OSS 20b (Nebius)": "openai/gpt-oss-20b",
1148
- "🟦 Google Gemma 3 27b-Instruct (Nebius)": "google/gemma-3-27b-it",
1149
- "🟦 DeepSeek-R1-0528 (Nebius)": "deepseek-ai/DeepSeek-R1-0528",
1150
- "🟦 DeepSeek-V3 (Nebius)": "deepseek-ai/DeepSeek-V3",
1151
- "🟦 Meta-Llama-3.1-70B-Instruct (Nebius)": "meta-llama/Meta-Llama-3.1-70B-Instruct",
1152
- "🟦 Meta-Llama-3.1-405B-Instruct (Nebius)": "meta-llama/Meta-Llama-3.1-405B-Instruct",
1153
- "🟦 Qwen3-235B-A22B (Nebius)": "Qwen/Qwen3-235B-A22B",
1154
- "🟦 Qwen3-32B (Nebius)": "Qwen/Qwen3-32B",
1155
- "🟦 Hermes 4 405B (Nebius)": "NousResearch/Hermes-4-405B",
1156
- "🟦 GLM-4.5 AIR (Nebius)": "zai-org/GLM-4.5-Air"
1157
- }
1158
-
1159
- backend_model = nebius_model_mapping[self.llm_choice]
1160
-
1161
- class NebiusLLM(LLM):
1162
- model: str
1163
- temperature: float = 0.5
1164
- top_p: float = 0.95
1165
- top_k: int = 50
1166
- max_tokens: int = 3000
1167
- _client: Any = PrivateAttr()
1168
-
1169
- def __init__(self, model: str, temperature: float = 0.5, top_p: float = 0.95, top_k: int = 50, max_tokens: int = 3000, **kwargs: Any):
1170
- if not OPENAI_AVAILABLE:
1171
- raise ImportError("openai package is required for NEBIUS models.")
1172
- super().__init__(**kwargs)
1173
- api_key = NEBIUS_API_KEY or os.environ.get("NEBIUS_API_KEY")
1174
- if not api_key:
1175
- raise ValueError("Please set the NEBIUS_API_KEY either in the code or as an environment variable.")
1176
- self.model = model
1177
- self.temperature = temperature
1178
- self.top_p = top_p
1179
- self.top_k = top_k
1180
- self.max_tokens = max_tokens
1181
- # Use object.__setattr__ to bypass Pydantic field validation
1182
- object.__setattr__(self, "_client", OpenAI(base_url="https://api.studio.nebius.com/v1/", api_key=api_key))
1183
-
1184
- @property
1185
- def _llm_type(self) -> str:
1186
- return "nebius_llm"
1187
-
1188
- def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
1189
- try:
1190
- completion = self._client.chat.completions.create(
1191
- model=self.model,
1192
- messages=[{"role": "user", "content": prompt}],
1193
- temperature=self.temperature,
1194
- top_p=self.top_p,
1195
- max_tokens=self.max_tokens
1196
- )
1197
- return completion.choices[0].message.content if hasattr(completion.choices[0].message, 'content') else str(completion.choices[0].message)
1198
- except Exception as e:
1199
- return f"Error from Nebius: {str(e)}"
1200
-
1201
- @property
1202
- def _identifying_params(self) -> dict:
1203
- return {"model": self.model, "temperature": self.temperature, "top_p": self.top_p}
1204
-
1205
- debug_print(f"Creating Nebius LLM for model: {backend_model}")
1206
- nebius_llm = NebiusLLM(model=backend_model, temperature=self.temperature, top_p=self.top_p, top_k=self.top_k, max_tokens=self.max_tokens)
1207
- debug_print("Nebius API pipeline created successfully.")
1208
- return nebius_llm
1209
-
1210
  else:
1211
  raise ValueError(f"Unsupported model choice: {self.llm_choice}")
1212
 
@@ -2374,48 +2569,35 @@ def create_csv_from_batch_results(results: List[Dict], job_id: str,
2374
 
2375
  # Extract short names for filename
2376
  def get_short_name(full_name, prefix_length=2):
2377
- """Extract short name from full model name"""
2378
  if not full_name:
2379
  return "unknown"
 
2380
  # Remove emojis and get the actual model name
2381
  clean_name = full_name.split(" ", 1)[-1] if " " in full_name else full_name
2382
 
2383
  # Remove parentheses and replace with underscores, also clean other special characters
2384
  clean_name = clean_name.replace("(", "_").replace(")", "").replace(" ", "_").replace(",", "").replace("-", "_")
2385
 
2386
- # For embedding models, extract the unique suffix part
2387
  if "sentence_transformers/" in clean_name:
2388
- # Extract the part after "sentence_transformers/"
2389
  suffix = clean_name.replace("sentence_transformers/", "")
2390
- # Take the last part after the last underscore for uniqueness
2391
- if "_" in suffix:
2392
- parts = suffix.split("_")
2393
- # Take the last 2-3 parts to ensure uniqueness
2394
- if len(parts) >= 2:
2395
- return "_".join(parts[-2:])
2396
- else:
2397
- return suffix
2398
- else:
2399
- return suffix
2400
  else:
2401
- # For other models, use a cleaner approach
2402
- # Remove common prefixes and take meaningful parts
2403
  if "Nebius" in clean_name:
2404
- # For Nebius models, extract the model name part
2405
  parts = clean_name.split("_")
2406
- # Filter out common words and take meaningful parts
2407
- meaningful_parts = [p for p in parts if p not in ["Nebius", "the", "and", "or", "of", "in", "on", "at", "to", "for", "with", "by"]]
2408
  if meaningful_parts:
2409
- return "_".join(meaningful_parts[-2:]) if len(meaningful_parts) >= 2 else meaningful_parts[0]
2410
  else:
2411
  return clean_name
2412
  else:
2413
- # For other models, take first and last parts
2414
- parts = clean_name.split("_")
2415
- if len(parts) >= 2:
2416
- return "_".join([parts[0], parts[-1]])
2417
- else:
2418
- return clean_name
2419
 
2420
  def get_param_variation_name(param_configs):
2421
  """Get the parameter that was varied"""
 
4
  import functools
5
  import traceback
6
  from typing import List, Optional, Any, Dict, Tuple
7
+ from pydantic import Field
8
  import csv
9
  import pandas as pd
10
  import tempfile
 
64
  # API Key Configuration
65
  NEBIUS_API_KEY = os.environ.get("NEBIUS_API_KEY", "")
66
 
67
+ # Define NebiusLLM class at module level to avoid pickle issues
68
+ class NebiusLLM(LLM):
69
+ """Nebius LLM wrapper with proper response validation."""
70
+
71
+ model: str = Field(..., description="The model name to use")
72
+ api_key: str = Field(..., description="API key for Nebius")
73
+ base_url: str = "https://api.studio.nebius.com/v1"
74
+ max_tokens: int = 2048
75
+ temperature: float = 0.7
76
+ top_p: float = 0.95
77
+ top_k: int = 50
78
+
79
+ def __init__(self, **data):
80
+ super().__init__(**data)
81
+ if not self.model:
82
+ raise ValueError("Model name cannot be empty")
83
+
84
+ @property
85
+ def _llm_type(self) -> str:
86
+ return "nebius"
87
+
88
+ def _call(
89
+ self,
90
+ prompt: str,
91
+ stop: Optional[List[str]] = None,
92
+ run_manager: Optional[Any] = None,
93
+ **kwargs: Any,
94
+ ) -> str:
95
+ """Call the Nebius API and return the response."""
96
+
97
+ try:
98
+ from openai import OpenAI
99
+
100
+ debug_print(f"Nebius API call: model={self.model}, max_tokens={self.max_tokens}")
101
+
102
+ # Create OpenAI client with Nebius base URL
103
+ client = OpenAI(base_url=self.base_url, api_key=self.api_key)
104
+
105
+ completion = client.chat.completions.create(
106
+ model=self.model,
107
+ messages=[{"role": "user", "content": prompt}],
108
+ temperature=self.temperature,
109
+ top_p=self.top_p,
110
+ max_tokens=self.max_tokens
111
+ )
112
+
113
+ # Extract the text content with proper validation
114
+ if completion.choices and len(completion.choices) > 0:
115
+ choice = completion.choices[0]
116
+
117
+ # Handle different response formats
118
+ if hasattr(choice.message, 'content') and choice.message.content:
119
+ text = choice.message.content
120
+ elif hasattr(choice, 'text'):
121
+ text = choice.text
122
+ else:
123
+ debug_print(f"WARNING: Unexpected response format: {choice}")
124
+ text = str(choice.message) if hasattr(choice, 'message') else str(choice)
125
+
126
+ # Validate that we got actual text
127
+ if text is None:
128
+ debug_print(f"WARNING: Received None text from API response")
129
+ return "I apologize, but I received an empty response. Please try rephrasing your question."
130
+
131
+ if not isinstance(text, str):
132
+ text = str(text)
133
+
134
+ if not text.strip():
135
+ debug_print(f"WARNING: Received empty text from API")
136
+ return "I apologize, but I received an empty response. Please try rephrasing your question."
137
+
138
+ return text.strip()
139
+ else:
140
+ debug_print(f"WARNING: No choices in API response")
141
+ return "I apologize, but I didn't receive a valid response. Please try again."
142
+
143
+ except ImportError:
144
+ error_msg = "OpenAI package is required for Nebius models. Please install it with: pip install openai"
145
+ debug_print(error_msg)
146
+ return error_msg
147
+ except Exception as e:
148
+ error_msg = f"Error calling Nebius API: {str(e)}"
149
+ debug_print(error_msg)
150
+ return f"API error: {str(e)}"
151
+
152
+ @property
153
+ def _identifying_params(self) -> Dict[str, Any]:
154
+ """Return identifying parameters."""
155
+ return {
156
+ "model": self.model,
157
+ "temperature": self.temperature,
158
+ "top_p": self.top_p,
159
+ "top_k": self.top_k,
160
+ "max_tokens": self.max_tokens,
161
+ }
162
+
163
  # Add batch processing helper functions
164
  def generate_parameter_values(min_val, max_val, num_values):
165
  """Generate evenly spaced values between min and max"""
 
1003
  return input_data["question"]
1004
 
1005
  # Improve error handling in the ElevatedRagChain class
1006
+ def calculate_safe_max_tokens(self, backend_model, prompt_text="", max_tokens_override=None):
1007
+ """Calculate safe max_tokens based on model context limits and input length."""
1008
+
1009
+ # Model context limits (total tokens including input + output) - from Nebius documentation
1010
+ nebius_context_limits = {
1011
+ "openai/gpt-oss-120b": 131000,
1012
+ "openai/gpt-oss-20b": 131000,
1013
+ "google/gemma-3-27b-it": 131000,
1014
+ "deepseek-ai/DeepSeek-R1-0528": 164000,
1015
+ "deepseek-ai/DeepSeek-V3": 128000,
1016
+ "llama-3.1-70b-instruct": 128000,
1017
+ "Meta-Llama-3.1-405B-Instruct": 128000,
1018
+ "Qwen/Qwen3-235B-A22B": 262000,
1019
+ "Qwen/Qwen3-32B": 41000, # Correct limit: 41K context
1020
+ "NousResearch/Hermes-4-405B": 128000,
1021
+ "zai-org/GLM-4.5-Air": 128000
1022
+ }
1023
+
1024
+ context_limit = nebius_context_limits.get(backend_model, 32768)
1025
+
1026
+ # Better token estimation
1027
+ def estimate_tokens(text):
1028
+ """Rough token estimation: 1 token ≈ 3.5-4 characters for most models."""
1029
+ if not text:
1030
+ return 0
1031
+ # More conservative estimate
1032
+ return int(len(str(text)) / 3.5)
1033
+
1034
+ # Estimate input tokens from various sources
1035
+ input_tokens = 0
1036
+
1037
+ # Add tokens from retrieved documents
1038
+ if hasattr(self, 'retrieved_docs') and self.retrieved_docs:
1039
+ docs_text = ' '.join([doc.page_content for doc in self.retrieved_docs])
1040
+ input_tokens += estimate_tokens(docs_text)
1041
+
1042
+ # Add tokens from prompt/query
1043
+ input_tokens += estimate_tokens(prompt_text)
1044
+
1045
+ # Add tokens from system prompts and formatting (rough estimate)
1046
+ input_tokens += 500 # Buffer for system messages, formatting, etc.
1047
+
1048
+ # Calculate safe max_tokens
1049
+ available_tokens = context_limit - input_tokens
1050
+
1051
+ # Apply user override if provided, but cap it at available tokens
1052
+ if max_tokens_override:
1053
+ requested_tokens = min(max_tokens_override, available_tokens - 100) # 100 token safety buffer
1054
+ else:
1055
+ # Default to 25% of available tokens, capped at reasonable limits
1056
+ requested_tokens = min(
1057
+ int(available_tokens * 0.25), # 25% of available space
1058
+ 8192 # Reasonable upper limit for generation
1059
+ )
1060
+
1061
+ # Ensure minimum viable response length
1062
+ safe_max_tokens = max(512, requested_tokens)
1063
+
1064
+ debug_print(f"Token calculation for {backend_model}:")
1065
+ debug_print(f" Context limit: {context_limit}")
1066
+ debug_print(f" Estimated input tokens: {input_tokens}")
1067
+ debug_print(f" Available tokens: {available_tokens}")
1068
+ debug_print(f" Safe max_tokens: {safe_max_tokens}")
1069
+
1070
+ if safe_max_tokens <= 512:
1071
+ raise ValueError(f"Input too long for model {backend_model}. Input: {input_tokens} tokens, Context limit: {context_limit}")
1072
+
1073
+ return safe_max_tokens
1074
+
1075
  def create_llm_pipeline(self, max_tokens_override=None):
1076
  from langchain.llms.base import LLM # Import LLM here so it's always defined
1077
+ from typing import Optional, List, Any, Dict
1078
  from pydantic import PrivateAttr
1079
 
1080
+ # Check for Nebius models FIRST (before any normalization)
1081
+ debug_print(f"Checking for Nebius model: {self.llm_choice}")
1082
+ print(f"DEBUG: Checking for Nebius model: {self.llm_choice}")
1083
+ if self.llm_choice in ["🟦 GPT OSS 120b (Nebius)", "🟦 GPT OSS 20b (Nebius)", "🟦 Google Gemma 3 27b-Instruct (Nebius)",
1084
+ "🟦 DeepSeek-R1-0528 (Nebius)", "🟦 DeepSeek-V3 (Nebius)", "🟦 Meta-Llama-3.1-70B-Instruct (Nebius)",
1085
+ "🟦 Meta-Llama-3.1-405B-Instruct (Nebius)", "🟦 Qwen3-235B-A22B (Nebius)", "🟦 Qwen3-32B (Nebius)",
1086
+ "🟦 Hermes 4 405B (Nebius)", "🟦 GLM-4.5 AIR (Nebius)"]:
1087
+ debug_print(f"Found Nebius model: {self.llm_choice}")
1088
+ print(f"DEBUG: Found Nebius model: {self.llm_choice}")
1089
+
1090
+ if not OPENAI_AVAILABLE:
1091
+ raise ImportError("openai package is required for NEBIUS models.")
1092
+
1093
+ # Map display names to backend names
1094
+ nebius_model_mapping = {
1095
+ "🟦 GPT OSS 120b (Nebius)": "openai/gpt-oss-120b",
1096
+ "🟦 GPT OSS 20b (Nebius)": "openai/gpt-oss-20b",
1097
+ "🟦 Google Gemma 3 27b-Instruct (Nebius)": "google/gemma-3-27b-it",
1098
+ "🟦 DeepSeek-R1-0528 (Nebius)": "deepseek-ai/DeepSeek-R1-0528",
1099
+ "🟦 DeepSeek-V3 (Nebius)": "deepseek-ai/DeepSeek-V3",
1100
+ "🟦 Meta-Llama-3.1-70B-Instruct (Nebius)": "llama-3.1-70b-instruct",
1101
+ "🟦 Meta-Llama-3.1-405B-Instruct (Nebius)": "Meta-Llama-3.1-405B-Instruct",
1102
+ "🟦 Qwen3-235B-A22B (Nebius)": "Qwen/Qwen3-235B-A22B",
1103
+ "🟦 Qwen3-32B (Nebius)": "Qwen/Qwen3-32B",
1104
+ "🟦 Hermes 4 405B (Nebius)": "NousResearch/Hermes-4-405B",
1105
+ "🟦 GLM-4.5 AIR (Nebius)": "zai-org/GLM-4.5-Air"
1106
+ }
1107
+
1108
+ # Set appropriate token limits for Nebius models
1109
+ # These are MAXIMUM GENERATION tokens, not total context length
1110
+ nebius_token_limits = {
1111
+ "openai/gpt-oss-120b": 8192, # Conservative limit
1112
+ "openai/gpt-oss-20b": 8192, # Conservative limit
1113
+ "google/gemma-3-27b-it": 4096, # Conservative for 8K context
1114
+ "deepseek-ai/DeepSeek-R1-0528": 8192,
1115
+ "deepseek-ai/DeepSeek-V3": 16384,
1116
+ "meta-llama/Meta-Llama-3.1-70B-Instruct": 32768,
1117
+ "meta-llama/Meta-Llama-3.1-405B-Instruct": 32768,
1118
+ "Qwen/Qwen3-235B-A22B": 8192,
1119
+ "Qwen/Qwen3-32B": 8192, # Reduced from 32768 - model has 40K total context
1120
+ "NousResearch/Hermes-4-405B": 32768,
1121
+ "zai-org/GLM-4.5-Air": 16384
1122
+ }
1123
+
1124
+ # Model context limits (total tokens including input + output) - from Nebius documentation
1125
+ nebius_context_limits = {
1126
+ "openai/gpt-oss-120b": 131000,
1127
+ "openai/gpt-oss-20b": 131000,
1128
+ "google/gemma-3-27b-it": 131000,
1129
+ "deepseek-ai/DeepSeek-R1-0528": 164000,
1130
+ "deepseek-ai/DeepSeek-V3": 128000,
1131
+ "meta-llama/Meta-Llama-3.1-70B-Instruct": 128000,
1132
+ "meta-llama/Meta-Llama-3.1-405B-Instruct": 128000,
1133
+ "Qwen/Qwen3-235B-A22B": 262000,
1134
+ "Qwen/Qwen3-32B": 41000, # Correct limit: 41K context
1135
+ "NousResearch/Hermes-4-405B": 128000,
1136
+ "zai-org/GLM-4.5-Air": 128000
1137
+ }
1138
+
1139
+ backend_model = nebius_model_mapping[self.llm_choice]
1140
+
1141
+ # Calculate safe max_tokens based on context limit
1142
+ context_limit = nebius_context_limits.get(backend_model, 32768)
1143
+
1144
+ # Calculate safe max_tokens dynamically
1145
+ try:
1146
+ # Get current prompt if available
1147
+ current_prompt = getattr(self, 'current_query', '')
1148
+ max_tokens = self.calculate_safe_max_tokens(
1149
+ backend_model,
1150
+ current_prompt,
1151
+ max_tokens_override
1152
+ )
1153
+ except ValueError as e:
1154
+ debug_print(f"Token calculation error: {str(e)}")
1155
+ # Fallback to model-specific token limits
1156
+ max_tokens = nebius_token_limits.get(backend_model, 2048)
1157
+
1158
+ debug_print(f"Creating Nebius LLM for model: {backend_model} with max_tokens: {max_tokens}")
1159
+ print(f"DEBUG: Creating Nebius LLM for model: {backend_model} with max_tokens: {max_tokens}")
1160
+
1161
+
1162
+ try:
1163
+ api_key = NEBIUS_API_KEY or os.environ.get("NEBIUS_API_KEY")
1164
+ if not api_key:
1165
+ raise ValueError("Please set the NEBIUS_API_KEY either in the code or as an environment variable.")
1166
+
1167
+ nebius_llm = NebiusLLM(
1168
+ model=backend_model,
1169
+ api_key=api_key,
1170
+ temperature=self.temperature,
1171
+ top_p=self.top_p,
1172
+ top_k=self.top_k,
1173
+ max_tokens=max_tokens
1174
+ )
1175
+ debug_print("Nebius API pipeline created successfully.")
1176
+ print(f"DEBUG: Nebius API pipeline created successfully for {self.llm_choice}")
1177
+ return nebius_llm
1178
+ except Exception as e:
1179
+ error_msg = f"Failed to create Nebius LLM: {str(e)}"
1180
+ debug_print(error_msg)
1181
+ print(f"DEBUG: {error_msg}")
1182
+ raise ValueError(error_msg)
1183
+
1184
+ # Extract the model name without the flag emoji prefix (for non-Nebius models)
1185
  clean_llm_choice = self.llm_choice.split(" ", 1)[-1] if " " in self.llm_choice else self.llm_choice
1186
  normalized = clean_llm_choice.lower()
1187
  print(f"Normalized model name: {normalized}")
 
1289
  debug_print(f"OpenAI {model} pipeline created successfully.")
1290
  return OpenAILLM()
1291
 
1292
+ # Meta-Llama-3 model (but not Nebius models)
1293
+ elif ("meta-llama" in normalized or "llama" in normalized) and "nebius" not in normalized:
1294
  debug_print("Creating remote Meta-Llama-3 pipeline via Hugging Face Inference API...")
1295
  from huggingface_hub import InferenceClient
1296
  repo_id = "meta-llama/Meta-Llama-3-8B-Instruct"
 
1402
  debug_print("Mistral API pipeline created successfully.")
1403
  return mistral_llm
1404
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1405
  else:
1406
  raise ValueError(f"Unsupported model choice: {self.llm_choice}")
1407
 
 
2569
 
2570
  # Extract short names for filename
2571
  def get_short_name(full_name, prefix_length=2):
2572
+ """Extract complete name from full model name for better clarity"""
2573
  if not full_name:
2574
  return "unknown"
2575
+
2576
  # Remove emojis and get the actual model name
2577
  clean_name = full_name.split(" ", 1)[-1] if " " in full_name else full_name
2578
 
2579
  # Remove parentheses and replace with underscores, also clean other special characters
2580
  clean_name = clean_name.replace("(", "_").replace(")", "").replace(" ", "_").replace(",", "").replace("-", "_")
2581
 
2582
+ # For embedding models, return the complete suffix after sentence_transformers/
2583
  if "sentence_transformers/" in clean_name:
2584
+ # Extract the complete part after "sentence_transformers/"
2585
  suffix = clean_name.replace("sentence_transformers/", "")
2586
+ return suffix
 
 
 
 
 
 
 
 
 
2587
  else:
2588
+ # For other models, return the complete cleaned name
 
2589
  if "Nebius" in clean_name:
2590
+ # For Nebius models, return the complete model name without common words
2591
  parts = clean_name.split("_")
2592
+ # Filter out only the most common words but keep the model name complete
2593
+ meaningful_parts = [p for p in parts if p not in ["Nebius"]]
2594
  if meaningful_parts:
2595
+ return "_".join(meaningful_parts)
2596
  else:
2597
  return clean_name
2598
  else:
2599
+ # For other models, return the complete cleaned name
2600
+ return clean_name
 
 
 
 
2601
 
2602
  def get_param_variation_name(param_configs):
2603
  """Get the parameter that was varied"""
batch_all_MiniLM_L6_v2__384_dim_fast_GPT_OSS_120b__const_20250917_224047.csv ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Temperature,Top-p,Top-k,BM25 Weight,Model,Main Answer,Input Tokens,Output Tokens,Conversation History,Progress,Elapsed Time (s)
2
+ 0.5,0.95,50,0.6,🟦 GPT OSS 120b (Nebius),"**Key Concepts that Function as Criteria for Holding an Agent Accountable**
3
+
4
+ | # | Concept (English term) | How the text employs the term as a gate‑keeper for accountability | Why it qualifies as a “criterion” |
5
+ |---|------------------------|-------------------------------------------------------------------|---------------------------------|
6
+ | 1 | **Voluntary Action** | The work repeatedly stresses that “Moral Choice is plainly voluntary” (Chapter IV) and that “voluntary” is the broader category that includes moral choice. Actions that are not voluntary are excluded from blame. | If an act is classified as voluntary, the agent is deemed capable of owning the act; otherwise the agent is excused. |
7
+ | 2 | **Involuntary Action** | Involuntary actions are split into “compulsion” (external force) and “ignorance” (lack of self‑caused knowledge) (Chapter III‑IV). The author notes that “the man who acts by compulsion … is not blamed” and that ignorance “is not self‑caused” can mitigate responsibility. | The presence of involuntariness removes or reduces accountability, making it a decisive test. |
8
+ | 3 | **Moral Choice (Deliberate Selection)** | Defined as “the object of Moral Choice is … that which after Deliberation has been preferred to something else” (Chapter VII). The text treats Moral Choice as the *starting‑point* of moral agency. | Only actions that arise from a genuine Moral Choice are subject to evaluation; the existence of such a choice signals full responsibility. |
9
+ | 4 | **Knowledge (True Opinion)** | The treatise distinguishes “true conclusions and right moral choice” from false ones (Chapter VIII) and links knowledge to the “right movement of the Will.” It also says that “the man who knows … is simply entitled to the designations who abides or not by the true opinion.” | Possessing correct knowledge about the relevant facts and principles is required for being answerable; ignorance of self‑caused facts can excuse. |
10
+ | 5 | **Self‑Control (Perfected Self‑Mastery)** | Extensive discussion of “Self‑Control” and “Imperfect Self‑Control” (multiple chapters). The author states that “Self‑Control is a good state and the Imperfection of it a bad one” and that the “man of Self‑Control … abides by his resolutions.” | The capacity to regulate passions determines whether an agent can be held to his own resolutions; lack of self‑control can explain failure to act responsibly. |
11
+ | 6 | **Passion (Lust, Anger, Fear)** | Passions are repeatedly presented as forces that can “prevent his acting in accordance with Right Reason” (Chapter VIII) and as “the irrational feelings … must be avoided.” The text contrasts actions “from Lust” with those “from Moral Choice.” | When an action is driven primarily by an uncontrolled passion, the agent’s responsibility is attenuated; the presence or absence of passion is a diagnostic factor. |
12
+ | 7 | **Deliberation (Practical Reasoning)** | The author notes that “Deliberation has for its object whatever may be done through one’s own instrumentality” (Chapter VII) and that “the mean state … is according to the dictates of Right Reason.” Deliberation is required before Moral Choice can be formed. | An agent who has deliberated correctly is fully accountable; failure to deliberate (or deliberation based on false premises) reduces responsibility. |
13
+ | 8 | **Remorse / Moral Awareness after the Act** | The text says that the “Imperfect Self‑Control … is almost made up of remorse” (Chapter VIII) and that “the man of Imperfect Self‑Control … is blamed, not as an error merely but also as being a vice.” | The presence of genuine remorse signals that the agent recognized the moral quality of the act, reinforcing responsibility; lack of remorse can indicate diminished culpability. |
14
+ | 9 | **Justice vs. Injustice (Proportional Equality)** | Justice is defined as “the moral state … in virtue of which the just man … makes division … proportionably equal” (Chapter VIII). Injustice is “both excess and defect because it aims at producing excess and defect.” | An action judged as just or unjust, according to proportional equality, is a benchmark for assessing whether the agent acted responsibly. |
15
+ | 10 | **Equity (Fair Adjustment of the Law)** | The treatise treats the “Equitable” as “Just but better than one form of Just” (Chapter XVI) and links it to “the tendency to choose and carry out these principles” rather than “press the letter of the law on the worse side.” | When an agent’s conduct aligns with equitable judgment rather than strict literalism, the agent is considered to have exercised the higher standard of responsibility. |
16
+
17
+ **Why these ten were selected**
18
+
19
+ - Each term appears **explicitly** in the source material and is **thematically linked** to the question of when an agent can be praised or blamed.
20
+ - The concepts together **cover the full spectrum** of the treatise’s analysis: the *ontological status* of the act (voluntary vs. involuntary), the *cognitive pre‑conditions* (knowledge, deliberation), the *affective conditions* (passion, self‑control, remorse), and the *normative evaluation* (justice, equity).
21
+ - By citing the **specific passages** where the author uses the term, the list demonstrates that the criteria are not modern inventions but are rooted in the historical philosophical discussion presented in the document.",N/A,N/A,0,Query 1/1,0.00
batch_all_MiniLM_L6_v2__384_dim_fast_Meta_Llama_3.1_405B_Instruct__const_20250917_223651.csv ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Temperature,Top-p,Top-k,BM25 Weight,Model,Main Answer,Input Tokens,Output Tokens,Conversation History,Progress,Elapsed Time (s)
2
+ 0.5,0.95,50,0.6,🟦 Meta-Llama-3.1-405B-Instruct (Nebius),"Based on the uploaded document, which appears to be a translation of Aristotle's Nicomachean Ethics, I have identified the following 10 prominent concepts that describe criteria for moral responsibility:
3
+
4
+ 1. **Voluntariness**: Aristotle emphasizes the importance of voluntariness in moral actions, stating that ""the voluntary is that which is done with knowledge"" (Book III, Chapter 1). This concept is crucial in determining moral responsibility, as it implies that individuals can only be held accountable for actions they perform knowingly and intentionally.
5
+
6
+ 2. **Deliberation**: Aristotle discusses the role of deliberation in moral decision-making, arguing that ""we deliberate not about ends, but about means"" (Book III, Chapter 3). This concept highlights the importance of rational consideration in moral actions, which is essential for moral responsibility.
7
+
8
+ 3. **Choice**: Aristotle distinguishes between voluntary actions and choices, stating that ""choice is a deliberate desire of things in our own power"" (Book III, Chapter 3). This concept emphasizes the importance of intentional decision-making in moral actions, which is a key criterion for moral responsibility.
9
+
10
+ 4. **Knowledge**: Aristotle stresses the importance of knowledge in moral actions, arguing that ""the voluntary is that which is done with knowledge"" (Book III, Chapter 1). This concept is essential for moral responsibility, as individuals can only be held accountable for actions they perform with full knowledge of the circumstances.
11
+
12
+ 5. **Intention**: Aristotle discusses the role of intention in moral actions, stating that ""the intention is the principle of the action"" (Book III, Chapter 5). This concept highlights the importance of an individual's goals and motivations in determining moral responsibility.
13
+
14
+ 6. **Self-Control**: Aristotle emphasizes the importance of self-control in moral actions, arguing that ""the man of perfected self-mastery is he who can do what he should do without being affected by passion"" (Book II, Chapter 3). This concept is crucial for moral responsibility, as individuals must be able to regulate their emotions and desires to make moral decisions.
15
+
16
+ 7. **Rationality**: Aristotle discusses the role of rationality in moral decision-making, arguing that ""the rational part of the soul is the principle of the virtues"" (Book I, Chapter 7). This concept highlights the importance of rational consideration in moral actions, which is essential for moral responsibility.
17
+
18
+ 8. **Habit**: Aristotle emphasizes the importance of habit in moral development, arguing that ""we are what we repeatedly do"" (Book II, Chapter 1). This concept highlights the importance of consistent behavior in shaping moral character, which is essential for moral responsibility.
19
+
20
+ 9. **Pleasure and Pain**: Aristotle discusses the role of pleasure and pain in moral decision-making, arguing that ""pleasure and pain are the test of the moral character"" (Book II, Chapter 3). This concept highlights the importance of emotional regulation in moral actions, which is essential for moral responsibility.
21
+
22
+ 10. **Character**: Aristotle emphasizes the importance of character in moral decision-making, arguing that ""the character is the principle of the action"" (Book III, Chapter 5). This concept highlights the importance of an individual's moral disposition in determining moral responsibility.
23
+
24
+ These concepts were selected based on their prominence in the text and their relevance to moral responsibility. Aristotle's Nicomachean Ethics provides a comprehensive framework for understanding moral responsibility, and these concepts are central to his theory.",N/A,N/A,0,Query 1/1,0.00
batch_all_MiniLM_L6_v2__384_dim_fast_Meta_Llama_3.1_70B_Instruct__const_20250917_223512.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Temperature,Top-p,Top-k,BM25 Weight,Model,Main Answer,Input Tokens,Output Tokens,Conversation History,Progress,Elapsed Time (s)
2
+ 0.5,0.95,50,0.6,🟦 Meta-Llama-3.1-70B-Instruct (Nebius),API error: Error code: 404 - {'detail': 'The model `meta-llama/Meta-Llama-3.1-70B-Instruct` does not exist.'},N/A,N/A,0,Query 1/1,0.00
batch_dim_fast_20b__const_20250917_213830.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Temperature,Top-p,Top-k,BM25 Weight,Model,Main Answer,Input Tokens,Output Tokens,Conversation History,Progress,Elapsed Time (s)
2
+ 0.5,0.95,50,0.6,Unknown,"Error: 1 validation error for Generation
3
+ text
4
+ none is not an allowed value (type=type_error.none.not_allowed)",N/A,N/A,0,Query 1/1,0.00