From 4be7c5b11cc2808f18fe439c466741ed57a6d519 Mon Sep 17 00:00:00 2001 From: anthonypizzolato-abacus Date: Fri, 7 Aug 2026 18:08:08 +0000 Subject: [PATCH] Add Muse Spark 1.2 to live bench runs --- lcb_runner/lm_styles.py | 8 ++++ lcb_runner/prompts/code_generation.py | 2 +- lcb_runner/runner/meta_runner.py | 69 +++++++++++++++++++++++++++ lcb_runner/runner/runner_utils.py | 4 ++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 lcb_runner/runner/meta_runner.py diff --git a/lcb_runner/lm_styles.py b/lcb_runner/lm_styles.py index 66988366..a0112b0c 100644 --- a/lcb_runner/lm_styles.py +++ b/lcb_runner/lm_styles.py @@ -12,6 +12,7 @@ class LMStyle(Enum): CohereCommand = "CohereCommand" DataBricks = "DataBricks" DeepSeekAPI = "DeepSeekAPI" + MetaAPI = "MetaAPI" GenericBase = "GenericBase" @@ -173,6 +174,13 @@ def __hash__(self) -> int: datetime(2023, 8, 1), link="https://huggingface.co/deepseek-ai/DeepSeek-V2", ), + LanguageModel( + "muse-spark-1.2", + "MuseSpark-1.2", + LMStyle.MetaAPI, + datetime(2026, 8, 5), + link="https://developer.meta.com/ai/models/muse-spark/", + ), LanguageModel( "codellama/CodeLlama-70b-hf", "CodeLlama-70b-Base", diff --git a/lcb_runner/prompts/code_generation.py b/lcb_runner/prompts/code_generation.py index 020d4617..6695783b 100644 --- a/lcb_runner/prompts/code_generation.py +++ b/lcb_runner/prompts/code_generation.py @@ -206,7 +206,7 @@ def get_example_prompt(example): def format_prompt_generation( question: CodeGenerationProblem, LanguageModelStyle: LMStyle ) -> str: - if LanguageModelStyle in [LMStyle.OpenAIChat, LMStyle.DeepSeekAPI]: + if LanguageModelStyle in [LMStyle.OpenAIChat, LMStyle.DeepSeekAPI, LMStyle.MetaAPI]: chat_messages = [ { "role": "system", diff --git a/lcb_runner/runner/meta_runner.py b/lcb_runner/runner/meta_runner.py new file mode 100644 index 00000000..7f0cd343 --- /dev/null +++ b/lcb_runner/runner/meta_runner.py @@ -0,0 +1,69 @@ +import os +from time import sleep + +try: + import openai + from openai import OpenAI +except ImportError as e: + pass + +from lcb_runner.runner.base_runner import BaseRunner + + +class MetaRunner(BaseRunner): + client = OpenAI( + api_key=os.getenv("META_API"), base_url="https://api.meta.ai" + ) + + def __init__(self, args, model): + super().__init__(args, model) + self.client_kwargs: dict[str | str] = { + "model": args.model, + "temperature": args.temperature, + "max_tokens": args.max_tokens, + "top_p": args.top_p, + "frequency_penalty": 0, + "presence_penalty": 0, + "n": 1, + "timeout": args.openai_timeout, + # "stop": args.stop, --> stop is only used for base models currently + } + + def _run_single(self, prompt: list[dict[str, str]]) -> list[str]: + assert isinstance(prompt, list) + + def __run_single(counter): + try: + response = self.client.chat.completions.create( + messages=prompt, + **self.client_kwargs, + ) + content = response.choices[0].message.content + return content + except ( + openai.APIError, + openai.RateLimitError, + openai.InternalServerError, + openai.OpenAIError, + openai.APIStatusError, + openai.APITimeoutError, + openai.InternalServerError, + openai.APIConnectionError, + ) as e: + print("Exception: ", repr(e)) + print("Sleeping for 30 seconds...") + print("Consider reducing the number of parallel processes.") + sleep(30) + return MetaRunner._run_single(prompt) + except Exception as e: + print(f"Failed to run the model for {prompt}!") + print("Exception: ", repr(e)) + raise e + + outputs = [] + try: + for _ in range(self.args.n): + outputs.append(__run_single(10)) + except Exception as e: + raise e + return outputs diff --git a/lcb_runner/runner/runner_utils.py b/lcb_runner/runner/runner_utils.py index a6aa6ee2..088b5829 100644 --- a/lcb_runner/runner/runner_utils.py +++ b/lcb_runner/runner/runner_utils.py @@ -30,6 +30,10 @@ def build_runner(args, model: LanguageModel): from lcb_runner.runner.deepseek_runner import DeepSeekRunner return DeepSeekRunner(args, model) + if model.model_style == LMStyle.MetaAPI: + from lcb_runner.runner.meta_runner import MetaRunner + + return MetaRunner(args, model) elif model.model_style in []: raise NotImplementedError( f"Runner for language model style {model.model_style} not implemented yet"