Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small updates to llama model class #70

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions eureka_ml_insights/configs/model_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@
},
)

AIF_NT_LLAMA3_2_90B_VISION_INSTRUCT_CONFIG = ModelConfig(
LlamaServerlessAzureRestEndpointModel,
{
"url": "https://Llama-3-2-90B-Vision-Instruct-ev.eastus2.models.ai.azure.com/chat/completions",
"secret_key_params": {
"key_name": "aif-nt-meta-llama-3-2-90b-Instruct-1",
"local_keys_path": "keys/aifeval-vault-azure-net.json",
},
},
)

AIF_NT_LLAMA3_2_90B_VISION_INSTRUCT_CONFIG_2 = ModelConfig(
LlamaServerlessAzureRestEndpointModel,
{
"url": "https://Llama-3-2-90B-Vision-Instruct-2.eastus2.models.ai.azure.com/chat/completions",
"secret_key_params": {
"key_name": "aif-nt-meta-llama-3-2-90b-Instruct-2",
"local_keys_path": "keys/aifeval-vault-azure-net.json",
},
},
)

# Mistral Endpoints
AIF_NT_MISTRAL_LARGE_2_2407_CONFIG = ModelConfig(
MistralServerlessAzureRestEndpointModel,
Expand Down
2 changes: 2 additions & 0 deletions eureka_ml_insights/data_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .aime_utils import AIMEExtractAnswer
from .data import (
AzureDataReader,
AzureJsonReader,
Expand Down Expand Up @@ -41,6 +42,7 @@
)

__all__ = [
AIMEExtractAnswer,
JsonLinesWriter,
JsonReader,
HFJsonReader,
Expand Down
56 changes: 28 additions & 28 deletions eureka_ml_insights/data_utils/aime_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase


@dataclass
Expand All @@ -12,32 +12,32 @@ class AIMEExtractAnswer(DFTransformBase):
model_answer_column: str

def transform(self, df: pd.DataFrame) -> pd.DataFrame:
df[self.model_answer_column] = df[self.model_output_column].apply(parse_output_answer)
df[self.model_answer_column] = df[self.model_output_column].apply(self.parse_output_answer)
return df


def parse_output_answer(response):
"""
Parse the input string to extract answer of a given AIME question.
Parameters:
response (str): Input string containing answer X in the form of "Final Answer: X".
Returns:
numerical_value (float): A numeric value representing the model's answer.
"""
numerical_value = None

# Try to find an answer in the "Final Answer: X" format
match = re.search(r"Final Answer:\s*([\$]?-?[\d,]+(?:\.\d+)?%?)", response)
if match:
answer_str = match.group(1)
# Remove $ and commas, handle percentages for numerical comparison
answer_str = answer_str.replace("$", "").replace(",", "")
if answer_str.endswith("%"):
numerical_value = float(answer_str[:-1]) / 100 # Convert percentage to decimal
else:
try:
numerical_value = float(answer_str)
except ValueError as e:
numerical_value = None

return numerical_value
@staticmethod
def parse_output_answer(response):
"""
Parse the input string to extract answer of a given AIME question.
Parameters:
response (str): Input string containing answer X in the form of "Final Answer: X".
Returns:
numerical_value (float): A numeric value representing the model's answer.
"""
numerical_value = None

# Try to find an answer in the "Final Answer: X" format
match = re.search(r"Final Answer:\s*([\$]?-?[\d,]+(?:\.\d+)?%?)", response)
if match:
answer_str = match.group(1)
# Remove $ and commas, handle percentages for numerical comparison
answer_str = answer_str.replace("$", "").replace(",", "")
if answer_str.endswith("%"):
numerical_value = float(answer_str[:-1]) / 100 # Convert percentage to decimal
else:
try:
numerical_value = float(answer_str)
except ValueError as e:
numerical_value = None

return numerical_value
2 changes: 1 addition & 1 deletion eureka_ml_insights/data_utils/dna_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion eureka_ml_insights/data_utils/flenqa_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion eureka_ml_insights/data_utils/kitab_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion eureka_ml_insights/data_utils/mmmu_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase

MMMUCategories = {
"Art and Design": ["Art", "Art_Theory", "Design", "Music"],
Expand Down
5 changes: 1 addition & 4 deletions eureka_ml_insights/data_utils/spatial_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

import pandas as pd

from eureka_ml_insights.data_utils.transform import (
DFTransformBase,
MultiColumnTransform,
)
from .transform import DFTransformBase, MultiColumnTransform


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion eureka_ml_insights/data_utils/toxigen_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pandas as pd

from eureka_ml_insights.data_utils import DFTransformBase
from .transform import DFTransformBase

delimiters = [
"Toxic score",
Expand Down
Loading
Loading