import torch

from mteb.models import ModelMeta
from mteb.models.instruct_wrapper import InstructSentenceTransformerModel
from mteb.models.model_meta import ScoringFunction
from mteb.types import PromptType

F2LLM_CITATION = """@article{2025F2LLM,
    title={F2LLM Technical Report: Matching SOTA Embedding Performance with 6 Million Open-Source Data},
    author={Ziyin Zhang and Zihan Liao and Hang Yu and Peng Di and Rui Wang},
    journal={CoRR},
    volume={abs/2510.02294},
    year={2025},
    url={https://doi.org/10.48550/arXiv.2510.02294},
    doi={10.48550/ARXIV.2510.02294},
    eprinttype={arXiv},
    eprint={2510.02294}
}"""

training_datasets = {
    "MSMARCO",
    "ArguAna",
    "SNLI",
    "MNLI",
    "ANLI",
    "PAQ",
    "SQuAD",
    "StackExchange",
    "NQ",
    "HotpotQA",
    "FEVER",
    "ELI5",
    "FiQA2018",
    "BioASQ",
    "NFCorpus",
    "MIRACLRetrieval",
    "MrTidyRetrieval",
    "SciFact",
    "TriviaQA",
    "COLIEE",
    "PubMedQA",
    "S2ORC",
    "AmazonQA",
    "SPECTER",
    "XSum",
    "CNNDM",
    "SentenceCompression",
    "StackExchangeDupQuestions",
    "QQP",
    "StackOverflowDupQuestions",
    "STS12",
    "STS22",
    "STSBenchmark",
    "AmazonCounterfactualClassification",
    "AmazonPolarityClassification",
    "ImdbClassification",
    "ToxicConversationsClassification",
    "CoLA",
    "AmazonReviewClassification",
    "Banking77Classification",
    "EmotionClassification",
    "MTOPIntentClassification",
    "MTOPDomainClassification",
    "MassiveScenarioClassification",
    "MassiveIntentClassification",
    "TweetSentimentExtractionClassification",
    "ArxivClusteringP2P",
    "ArxivClusteringS2S",
    "BiorxivClusteringP2P",
    "BiorxivClusteringS2S",
    "MedrxivClusteringP2P",
    "MedrxivClusteringS2S",
    "RedditClustering",
    "RedditClusteringP2P",
    "StackExchangeClustering",
    "StackExchangeClusteringP2P",
    "TwentyNewsgroupsClustering",
}

f2llmv2_training_datasets = training_datasets.union(
    {
        "Waimai",
        "NordicClassification",
        "SIB200",
        "MLSUMClustering",
        "BactrianXLanguageClassification",
        "BactrianXTranslation",
        "Europarl",
        "XCodeEvalTranslation",
        "TNews",
        "THUCNews",
        "CSL",
        "CEDR",
        "RuSentimentClustering",
        "WebFAQ",
        "MMARCO",
        "MLDR",
        "MKQA",
        "MLSUMRetrieval",
        "Aya",
        "MURI",
        "UNPC",
        "XNLI",
        "PawsX",
        "CodeSearchNet",
        "CodeSearchNetCCR",
        "CosQA",
        "SyntheticText2SQL",
        "CodeFeedbackMT",
        "CodeFeedbackST",
        "StackOverflowQA",
        "OpenCodeGeneticInstruct",
        "OpenCodeReasoning2",
        "XCodeEvalCodeToCode",
        "XCodeEvalNLToCode",
        "ProCQA",
        "ParaCrawl",
        "NaturalReasoning",
        "MultiAlpaca",
        "COIG",
        "OASST2",
        "WildChat",
        "M2Lingual",
        "InfinityInstruct",
        "cMedQAv2",
        "MedInstruct",
        "HuatuoKGQA",
        "HuatuoEncQA",
        "CLIRMatrix",
        "BQ",
        "YahooAnswers",
        "DuReader",
        "T2Ranking",
        "GooAQ",
        "MedicalQARu",
        "MEDI2",
        "OpenOrca",
        "MedicalInstruction",
        "MultiCPRMedical",
        "MultiCPRECom",
        "HealthCareMagic",
        "OCNLI",
        "ESCI",
        "CORD19",
        "CMCQA",
        "CMNLI",
        "DBPedia",
        "FEVERNL",
        "HotpotQANL",
        "KoAlpaca",
        "KoAlpacaRealQA",
        "KoMagpie",
        "Lawzhidao",
        "LCQMC",
        "QBQTC",
        "LCSTS",
        "LLMRetrievalData",
        "MailruQA",
        "MedicalFlashcards",
        "MedMCQA",
        "MedQA",
        "MedQuAD",
        "MSciNLI",
        "NordicRetrieval",
        "NordicSTS",
        "NordicTextMatching",
        "ParSQuAD",
        "PersianQA",
        "PQuAD",
        "RefGPT",
        "RuInstruct",
        "SiberianDataset",
        "SimCLUE",
        "webMedQA",
        "WikiOmnia",
        "MQA",
    }
)

c2llm_training_datasets = {
    "CodeSearchNet",
    "CodeSearchNetRetrieval",
    "CodeSearchNetCCRetrieval",
    "CodeEditSearchRetrieval",
    "CodeFeedbackMT",
    "CodeFeedbackST",
    "CodeTransOceanContest",
    "CodeTransOceanDL",
    "COIRCodeSearchNetRetrieval",
    "CosQA",
    "StackOverflowQA",
    "SyntheticText2SQL",
    "AdvTrain",
}

prompts_dict = {
    "AmazonCounterfactualClassification": "Classify a given Amazon customer review text as either counterfactual or not counterfactual.",
    "Banking77Classification": "Given an online banking query, find the corresponding intents.",
    "ImdbClassification": "Classify the sentiment expressed in the given movie review text from the IMDB dataset.",
    "MTOPDomainClassification": "Classify the intent domain of the given utterance in task-oriented conversation.",
    "MassiveIntentClassification": "Given a user utterance as query, find the user intents.",
    "MassiveScenarioClassification": "Given a user utterance as query, find the user scenarios.",
    "ToxicConversationsClassification": "Classify the given comments as either toxic or not toxic.",
    "TweetSentimentExtractionClassification": "Classify the sentiment of a given tweet as either positive, negative, or neutral",
    "ArXivHierarchicalClusteringP2P": "Identify the main and secondary category of arXiv papers based on the titles and abstracts.",
    "ArXivHierarchicalClusteringS2S": "Identify the main and secondary category of arXiv papers based on the titles.",
    "BiorxivClusteringP2P.v2": "Identify the main category of bioRxiv papers based on the titles and abstracts.",
    "MedrxivClusteringP2P.v2": "Identify the main category of medRxiv papers based on the titles and abstracts.",
    "MedrxivClusteringS2S.v2": "Identify the main category of medRxiv papers based on the titles.",
    "StackExchangeClustering.v2": "Identify the topic or theme of StackExchange posts based on the titles.",
    "StackExchangeClusteringP2P.v2": "Identify the topic or theme of StackExchange posts based on the given paragraphs.",
    "TwentyNewsgroupsClustering.v2": "Identify the topic or theme of the given news articles.",
    "SprintDuplicateQuestions": "Retrieve duplicate questions from Sprint forum.",
    "TwitterSemEval2015": "Retrieve tweets that are semantically similar to the given tweet.",
    "TwitterURLCorpus": "Retrieve tweets that are semantically similar to the given tweet.",
    "AskUbuntuDupQuestions": "Retrieve duplicate questions from AskUbuntu forum.",
    "MindSmallReranking": "Retrieve relevant news articles based on user browsing history.",
    "ArguAna": "Given a claim, find documents that refute the claim.",
    "CQADupstackGamingRetrieval": "Given a question, retrieve questions that are semantically equivalent.",
    "CQADupstackUnixRetrieval": "Given a question, retrieve questions that are semantically equivalent.",
    "ClimateFEVERHardNegatives": "Given a claim about climate change, retrieve documents that support or refute the claim.",
    "FEVERHardNegatives": "Given a claim, retrieve documents that support or refute the claim.",
    "FiQA2018": "Given a financial question, retrieve passages that answer the question.",
    "HotpotQAHardNegatives": "Given a multi-hop question, retrieve passages that answer the question.",
    "SCIDOCS": "Given a scientific paper title, retrieve paper abstracts that are cited by the given paper.",
    "TRECCOVID": "Given a query on COVID-19, retrieve documents that answer the query.",
    "Touche2020Retrieval.v3": "Given a question, retrieve passages that answer the question.",
    "BIOSSES": "Retrieve semantically similar text.",
    "SICK-R": "Retrieve semantically similar text.",
    "STS12": "Retrieve semantically similar text.",
    "STS13": "Retrieve semantically similar text.",
    "STS14": "Retrieve semantically similar text.",
    "STS15": "Retrieve semantically similar text.",
    "STS17": "Retrieve semantically similar text.",
    "STS22.v2": "Retrieve semantically similar text.",
    "STSBenchmark": "Retrieve semantically similar text.",
    "SummEvalSummarization.v2": "Given a news summary, retrieve other semantically similar summaries.",
}

f2llmv2_prompts_dict = prompts_dict.copy()
f2llmv2_prompts_dict.update(
    {
        "STS": "Retrieve semantically similar text.",
        "BitextMining": "Retrieve translations of the following text.",
        "Classification": "Classify the topic of the given text.",
        "MultilabelClassification": "Classify the topic of the given text.",
        "Clustering": "Classify the topic of the given text.",
        "PairClassification": "Retrieve semantically entailed text.",
        "query": "Given a question, retrieve passages that can help answer the question.",
        "document": "",
        "BulgarianStoreReviewSentimentClassfication": "Classify the sentiment of the given text.",
        "CzechProductReviewSentimentClassification": "Classify the sentiment of the given text.",
        "FinancialPhrasebankClassification": "Classify the sentiment of the given text.",
        "PoemSentimentClassification": "Classify the sentiment of the given text.",
        "EstonianValenceClassification": "Classify the sentiment of the given text.",
        "FilipinoShopeeReviewsClassification": "Classify the sentiment of the given text.",
        "SentimentAnalysisHindi": "Classify the sentiment of the given text.",
        "KurdishSentimentClassification": "Classify the sentiment of the given text.",
        "MacedonianTweetSentimentClassification": "Classify the sentiment of the given text.",
        "AfriSentiClassification": "Classify the sentiment of the given text.",
        "CataloniaTweetClassification": "Classify the sentiment of the given text.",
        "MultiHateClassification": "Classify the sentiment of the given text.",
        "NusaParagraphEmotionClassification": "Classify the sentiment of the given text.",
        "NusaX-senti": "Classify the sentiment of the given text.",
        "SwissJudgementClassification": "Classify the sentiment of the given text.",
        "PolEmo2.0-OUT": "Classify the sentiment of the given text.",
        "CSFDSKMovieReviewSentimentClassification": "Classify the sentiment of the given text.",
        "SlovakMovieReviewSentimentClassification": "Classify the sentiment of the given text.",
        "CyrillicTurkicLangClassification": "Classify the text into its language.",
        "IndicLangClassification": "Classify the text into its language.",
        "NordicLangClassification": "Classify the text into its language.",
        "ScalaClassification": "Classify the given sentence as linguistically acceptable or not acceptable.",
        "DalajClassification": "Classify the given sentence as linguistically acceptable or not acceptable.",
        "IndonesianIdClickbaitClassification": "Classify the given text as either clickbait or not clickbait.",
        "KorSarcasmClassification": "Classify the given text as either sarcasm or not sarcasm.",
        "PAC": "Classify the given clause as either abusive or not abusive.",
        "WikiCitiesClustering": "Classify the following city description by country.",
        "ArmenianParaphrasePC": "Retrieve paraphrases of the given sentence.",
        "OpusparcusPC": "Retrieve paraphrases of the given sentence.",
        "PawsXPairClassification": "Retrieve paraphrases of the given sentence.",
        "PpcPC": "Retrieve paraphrases of the given sentence.",
        "KorHateSpeechMLClassification": "Classify the sentiment of the given text.",
        "CEDRClassification": "Classify the emotion expressed in the given comment into: joy, sadness, surprise, fear, and anger.",
        "AppsRetrieval": "Retrieve the most relevant code snippet for the given query.",
        "CodeEditSearchRetrieval": "Retrieve the most relevant code edit.",
        "CodeFeedbackMT": "Retrieve the most relevant response for the given query.",
        "CodeFeedbackST": "Retrieve the most relevant response for the given query.",
        "CodeSearchNetCCRetrieval": "Retrieve the most relevant code snippet for the given code snippet.",
        "CodeSearchNetRetrieval": "Retrieve the most relevant code snippet for the given query.",
        "CodeTransOceanContest": "Retrieve similar code to the given source code.",
        "CodeTransOceanDL": "Retrieve similar code to the given source code.",
        "CosQA": "Retrieve the most relevant code snippet for the given query.",
        "COIRCodeSearchNetRetrieval": "Retrieve the most relevant code summary for the given code snippet.",
        "StackOverflowQA": "Retrieve the most relevant response for the given query.",
        "SyntheticText2SQL": "Retrieve the most relevant sql code snippet for the given query.",
        "AILAStatutes": "Identify the most relevant statutes for the given situation.",
        "LegalBenchCorporateLobbying": "Given a bill title, retrieve the corresponding bill summary.",
        "CovidRetrieval": "Given a query on COVID-19, retrieve documents that answer the query.",
        "WebLINXCandidatesReranking": "Given a web navigation step, retrieve relevant elements.",
        "NFCorpus": "Given a question, retrieve passages that answer the question.",
        "TRECCOVID-PL": "Given a query on COVID-19, retrieve documents that answer the query.",
        "SciFact": "Given a scientific claim, retrieve passages that support or refute the claim.",
        "SciFact-PL": "Given a scientific claim, retrieve passages that support or refute the claim.",
        "CmedqaRetrieval": "Given a question, retrieve passages that answer the question.",
        "CMedQAv2-reranking": "Given a question, retrieve passages that answer the question.",
        "AngryTweetsClassification": "Classify the sentiment of the given text.",
        "DanishPoliticalCommentsClassification": "Classify the sentiment of the given text.",
        "DKHateClassification": "Classify the given comments as either offensive or not offensive.",
        "LccSentimentClassification": "Classify the sentiment of the given text.",
        "NoRecClassification": "Classify the sentiment of the given text.",
        "NorwegianParliamentClassification": "Classify the sentiment of the given text.",
        "SwedishSentimentClassification": "Classify the sentiment of the given text.",
        "SweRecClassification": "Classify the sentiment of the given text.",
        "DanFeverRetrieval": "Given a claim, retrieve documents that support or refute the claim.",
        "SNLRetrieval": "Given a summary, retrieve the original article.",
        "SwednRetrieval": "Given a summary, retrieve the original article.",
        "TV2Nordretrieval": "Given a news summary, retrieve the original article.",
        "BengaliSentimentAnalysis": "Classify the sentiment of the given text.",
        "HindiDiscourseClassification": "Classify the given text into one of the five discourse modes: argumentative, narrative, descriptive, dialogic, and informative.",
        "MTOPIntentClassification": "Classify the intent of the given utterance in task-oriented conversation.",
        "TweetSentimentClassification": "Classify the sentiment of the given text.",
        "UrduRomanSentimentClassification": "Classify the sentiment of the given text as either positive, negative, or neutral.",
        "AmazonReviewsClassification": "Classify the given Amazon review into its appropriate rating category.",
        "BlurbsClusteringP2P": "Classify the given book title and blurb into its genre.",
        "BlurbsClusteringS2S": "Classify the given book title into its genre.",
        "FalseFriendsGermanEnglish": "Retrieve translations of the following text.",
        "XMarket": "Given a product name search, retrieve the corresponding product description.",
        "GerDaLIR": "Retrieve documents that are referenced by the given text.",
        "MLSUMClusteringP2P": "Classify the topic of the given news article.",
        "SummEvalFr": "Given a news summary, retrieve other semantically similar summaries.",
        "AllegroReviews": "Classify the sentiment of the given text.",
        "CBD": "Classify the given text as either cyberbullying or not.",
        "PolEmo2.0-IN": "Classify the sentiment of the given text.",
        "PSC": "Retrieve semantically similar text.",
        "EcomRetrieval": "Given a product name query, retrieve the corresponding product description.",
        "MedicalRetrieval": "Retrieve the most relevant response for the given query.",
        "VideoRetrieval": "Given a video search query, retrieve the titles of relevant videos.",
        "CMedQAv1-reranking": "Retrieve the most relevant response for the given query.",
        "Waimai": "Classify the sentiment of the given review as either positive or negative.",
        "OnlineShopping": "Classify the sentiment of the given review as either positive or negative.",
        "JDReview": "Classify the sentiment of the given review as either positive or negative.",
        "MultilingualSentiment": "Classify the sentiment of the given review as either positive, negative, or neutral.",
        "ToxicChatClassification": "Classify the given text as either toxic or not toxic.",
        "JapaneseSentimentClassification": "Classify the sentiment of the given text.",
        "WRIMEClassification": "Classify the sentiment of the given text.",
        "NLPJournalTitleAbsRetrieval.V2": "Given a paper's title, retrieve the corresponding abstract.",
        "NLPJournalTitleIntroRetrieval.V2": "Given a paper's title, retrieve the corresponding introduction.",
        "NLPJournalAbsIntroRetrieval.V2": "Given a paper's abstract, retrieve the corresponding introduction.",
        "NLPJournalAbsArticleRetrieval.V2": "Given a paper's abstract, retrieve the corresponding paper.",
        "ESCIReranking": "Given a product name query, retrieve the corresponding product description.",
        "DutchBookReviewSentimentClassification.v2": "Classify the sentiment of the given text.",
        "VaccinChatNLClassification": "Classify the intent of the given utterance.",
        "DutchColaClassification": "Classify the given sentence as linguistically acceptable or not acceptable.",
        "DutchGovernmentBiasClassification": "Classify the given government document as biased or unbiased.",
        "DutchSarcasticHeadlinesClassification": "Classify the given newspaper headline as sarcastic or not sarcastic.",
        "XLWICNLPairClassification": "Retrieve semantically similar text.",
        "CovidDisinformationNLMultiLabelClassification": "Classify the given social media post related to COVID-19 into its misinformation category.",
        "VABBClusteringS2S": "Identify the main category of the given paper based on the title.",
        "VABBClusteringP2P": "Identify the main category of the given paper based on the title and abstract.",
        "ArguAna-NL.v2": "Given a claim, find documents that refute the claim.",
        "SCIDOCS-NL.v2": "Given a scientific paper title, retrieve paper abstracts that are cited by the given paper.",
        "SciFact-NL.v2": "Given a scientific claim, retrieve passages that support or refute the claim.",
        "DutchNewsArticlesRetrieval": "Given a news title, retrieve the original article.",
        "OpenTenderRetrieval": "Given a title, retrieve the corresponding article.",
        "VABBRetrieval": "Given a paper's title, retrieve the corresponding abstract.",
        "GeoreviewClassification": "Classify the given review into its appropriate rating category.",
        "InappropriatenessClassification": "Classify the given message as either sensitive topic or not.",
        "KinopoiskClassification": "Classify the sentiment of the given movie review.",
        "RuReviewsClassification": "Classify the sentiment of the given review as either positive, negative, or neutral.",
        "RuSciBenchGRNTIClassification": "Identify the main category of the given paper based on the title and abstract.",
        "RuSciBenchOECDClassification": "Identify the main category of the given paper based on the title and abstract.",
        "GeoreviewClusteringP2P": "Identify the organization category based on the given review.",
        "RuSciBenchGRNTIClusteringP2P": "Identify the main category of the given paper based on the title and abstract.",
        "RuSciBenchOECDClusteringP2P": "Identify the main category of the given paper based on the title and abstract.",
        "SensitiveTopicsClassification": "Classify the given text into sensitive topics.",
        "RiaNewsRetrievalHardNegatives.v2": "Given a news title, retrieve the original article.",
        "PersianFoodSentimentClassification": "Classify the sentiment of the given text as either positive or negative.",
        "SynPerChatbotConvSAClassification": "Classify the sentiment of the given text.",
        "SynPerChatbotConvSAToneChatbotClassification": "Classify the sentiment of the given text.",
        "SynPerChatbotConvSAToneUserClassification": "Classify the sentiment of the given text.",
        "SynPerChatbotSatisfactionLevelClassification": "Classify the satisfaction level of the given text.",
        "SynPerTextToneClassification.v3": "Classify the tone of the given text.",
        "DeepSentiPers.v2": "Classify the sentiment of the given text.",
        "PersianTextEmotion.v2": "Classify the emotion expressed in the given text into: joy, sadness, surprise, fear, anger, and love.",
        "StyleClassification": "Classify the style of the given text as either formal or informal.",
        "PerShopDomainClassification": "Classify the domain of the given utterance in shopping dialogue.",
        "PerShopIntentClassification": "Classify the intent of the given utterance in shopping dialogue.",
        "SynPerChatbotRAGFAQPC": "Retrieve the most relevant response for the given query.",
        "FarsiParaphraseDetection": "Retrieve semantically similar text.",
        "SynPerTextKeywordsPC": "Identify keywords in the given text.",
        "SynPerQAPC": "Retrieve the most relevant response for the given query.",
        "ParsinluQueryParaphPC": "Retrieve semantically similar text.",
        "SynPerChatbotRAGFAQRetrieval": "Retrieve the most relevant response for the given query.",
        "HotpotQA-FaHardNegatives": "Given a multi-hop question, retrieve passages that answer the question.",
        "ArguAna-Fa.v2": "Given a claim, find documents that refute the claim.",
        "QuoraRetrieval-Fa.v2": "Retrieve questions that are semantically equivalent to the given one.",
        "SCIDOCS-Fa.v2": "Given a scientific paper title, retrieve paper abstracts that are cited by the given paper.",
        "SciFact-Fa.v2": "Given a scientific claim, retrieve passages that support or refute the claim.",
        "TRECCOVID-Fa.v2": "Given a query on COVID-19, retrieve documents that answer the query.",
        "FEVER-FaHardNegatives": "Given a claim, retrieve documents that support or refute the claim.",
        "SAMSumFa": "Retrieve the most relevant summary for the given conversation.",
        "SynPerChatbotSumSRetrieval": "Retrieve the most relevant summary for the given conversation.",
        "SynPerChatbotRAGSumSRetrieval": "Retrieve the most relevant summary for the given conversation.",
        "ArguAna-VN": "Given a claim, find documents that refute the claim.",
        "SciFact-VN": "Given a scientific claim, retrieve passages that support or refute the claim.",
        "ClimateFEVER-VN": "Given a claim about climate change, retrieve documents that support or refute the claim.",
        "FEVER-VN": "Given a claim, retrieve documents that support or refute the claim.",
        "DBPedia-VN": "Given a query, retrieve relevant entity descriptions.",
        "HotpotQA-VN": "Given a multi-hop question, retrieve passages that answer the question.",
        "TRECCOVID-VN": "Given a query on COVID-19, retrieve documents that answer the query.",
        "SCIDOCS-VN": "Given a scientific paper title, retrieve paper abstracts that are cited by the given paper.",
        "Quora-VN": "Retrieve questions that are semantically equivalent to the given one.",
        "CQADupstackAndroid-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackGis-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackMathematica-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackPhysics-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackProgrammers-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackStats-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackTex-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackUnix-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackWebmasters-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "CQADupstackWordpress-VN": "Given a question, retrieve questions that are semantically equivalent.",
        "Banking77VNClassification": "Given an online banking query, find the corresponding intents.",
        "EmotionVNClassification": "Classify the emotion expressed in the given Twitter message into one of the six emotions: anger, fear, joy, love, sadness, and surprise.",
        "AmazonCounterfactualVNClassification": "Classify a given Amazon customer review text as either counterfactual or not counterfactual.",
        "MTOPDomainVNClassification": "Classify the intent domain of the given utterance in task-oriented conversation.",
        "TweetSentimentExtractionVNClassification": "Classify the sentiment of a given tweet as either positive, negative, or neutral",
        "ToxicConversationsVNClassification": "Classify the given comments as either toxic or not toxic.",
        "ImdbVNClassification": "Classify the sentiment expressed in the given movie review text from the IMDB dataset.",
        "MTOPIntentVNClassification": "Classify the intent of the given utterance in task-oriented conversation.",
        "MassiveScenarioVNClassification": "Given a user utterance as query, find the user scenarios.",
        "MassiveIntentVNClassification": "Given a user utterance as query, find the user intents.",
        "AmazonReviewsVNClassification": "Classify the given Amazon review into its appropriate rating category.",
        "AmazonPolarityVNClassification": "Classify the given Amazon review as either positive or negative.",
        "SprintDuplicateQuestions-VN": "Retrieve duplicate questions from Sprint forum.",
        "TwitterSemEval2015-VN": "Retrieve tweets that are semantically similar to the given tweet.",
        "TwitterURLCorpus-VN": "Retrieve tweets that are semantically similar to the given tweet.",
        "TwentyNewsgroupsClustering-VN": "Identify the topic or theme of the given news articles.",
        "RedditClusteringP2P-VN": "Identify the topic or theme of Reddit posts based on the titles and posts.",
        "StackExchangeClusteringP2P-VN": "Identify the topic or theme of StackExchange posts based on the given titles and paragraphs.",
        "StackExchangeClustering-VN": "Identify the topic or theme of StackExchange posts based on the titles.",
        "RedditClustering-VN": "Identify the topic or theme of Reddit posts based on the titles.",
        "SciDocsRR-VN": "Given a title of a scientific paper, retrieve the titles of other relevant papers.",
        "AskUbuntuDupQuestions-VN": "Retrieve duplicate questions from AskUbuntu forum.",
        "StackOverflowDupQuestions-VN": "Retrieve duplicate questions from StackOverflow forum.",
    }
)


c2llm_prompts_dict = {
    "CodeEditSearchRetrieval": {
        "query": "Retrieve the diff code that relevant the following query:\n",
        "document": "Retrieved Answer:",
    },
    "CodeSearchNetRetrieval": {
        "query": "Retrieve the code that solves the following query:\n",
        "document": "Retrieved Answer:",
    },
    "AppsRetrieval": {
        "query": "Given a problem description from a programming contest, retrieve code examples that can assist in solving it.\n",
        "document": "Retrieved Answer:",
    },
    "CodeFeedbackMT": {
        "query": "Given a multi-turn conversation history that includes both text and code, retrieve relevant multi-modal answers composed of text and code that address the ongoing discussion.\n",
        "document": "Retrieved Answer:",
    },
    "CodeFeedbackST": {
        "query": "Given a single-turn question composed of text and code, retrieve suitable answers that also mix text and code to provide helpful feedback.\n",
        "document": "Retrieved Answer:",
    },
    "CodeSearchNetCCRetrieval": {
        "query": "Given an initial code segment, retrieve the subsequent segment that continues the code.\n",
        "document": "Retrieved Answer:",
    },
    "CodeTransOceanContest": {
        "query": "Given a Python code snippet, retrieve its semantically equivalent version written in C++.\n",
        "document": "Retrieved Answer:",
    },
    "CodeTransOceanDL": {
        "query": "Given a Python code snippet, retrieve its semantically equivalent version written in C++.\n",
        "document": "Retrieved Answer:",
    },
    "COIRCodeSearchNetRetrieval": {
        "query": "Given a code snippet, retrieve its corresponding document string that summarizes its functionality.\n",
        "document": "Retrieved Answer:",
    },
    "CosQA": {
        "query": "Given a query from a web search, retrieve code that is helpful in addressing the query.\n",
        "document": "Retrieved Answer:",
    },
    "StackOverflowQA": {
        "query": "Given a question combining text and code, retrieve relevant answers that also contain both text and code snippets and can address the question.\n",
        "document": "Retrieved Answer:",
    },
    "SyntheticText2SQL": {
        "query": "Given a natural language question, retrieve SQL queries that serve as appropriate responses.\n",
        "document": "Retrieved Answer:",
    },
}

c2llm_languages = [
    "eng-Latn",
    "zho-Hans",
    "python-Code",
    "javascript-Code",
    "go-Code",
    "ruby-Code",
    "java-Code",
    "php-Code",
]

f2llmv2_languages = [
    "python-Code",
    "php-Code",
    "java-Code",
    "c++-Code",
    "go-Code",
    "javascript-Code",
    "c#-Code",
    "ruby-Code",
    "c-Code",
    "rust-Code",
    "sql-Code",
    "eng-Latn",
    "zho-Hans",
    "rus-Cyrl",
    "spa-Latn",
    "fra-Latn",
    "deu-Latn",
    "ara-Arab",
    "nld-Latn",
    "vie-Latn",
    "hin-Deva",
    "kor-Hang",
    "jpn-Jpan",
    "ita-Latn",
    "ind-Latn",
    "por-Latn",
    "pol-Latn",
    "tur-Latn",
    "dan-Latn",
    "tha-Thai",
    "swe-Latn",
    "fas-Arab",
    "ukr-Cyrl",
    "ces-Latn",
    "nor-Latn",
    "ell-Grek",
    "cat-Latn",
    "ron-Latn",
    "fin-Latn",
    "bul-Cyrl",
    "tgl-Latn",
    "glg-Latn",
    "mya-Mymr",
    "hye-Armn",
    "khm-Khmr",
    "nep-Deva",
    "hun-Latn",
    "eus-Latn",
    "heb-Hebr",
    "lao-Laoo",
    "swa-Latn",
    "azj-Latn",
    "lav-Latn",
    "sin-Sinh",
    "slk-Latn",
    "tgk-Cyrl",
    "est-Latn",
    "lit-Latn",
    "msa-Latn",
    "hrv-Latn",
    "isl-Latn",
    "slv-Latn",
    "srp-Cyrl",
    "urd-Arab",
    "ben-Beng",
    "aze-Latn",
    "afr-Latn",
    "tam-Taml",
    "kat-Geor",
    "tel-Telu",
    "mal-Mlym",
    "mon-Cyrl",
    "nno-Latn",
    "kaz-Cyrl",
    "cym-Latn",
    "mar-Deva",
    "sqi-Latn",
    "nob-Latn",
    "pus-Arab",
    "mkd-Cyrl",
    "ceb-Latn",
    "jav-Latn",
    "war-Latn",
    "kan-Knda",
    "epo-Latn",
    "lat-Latn",
    "guj-Gujr",
    "uzb-Latn",
    "amh-Ethi",
    "oci-Latn",
    "bel-Cyrl",
    "azb-Arab",
]


c2llm_loader_kwargs = dict(
    trust_remote_code=True,
    prompts_dict=c2llm_prompts_dict,
    apply_instruction_to_passages=True,
    max_seq_length=2048,
    padding_side="left",
)


def instruction_template(
    instruction: str, prompt_type: PromptType | None = None
) -> str:
    if not instruction or prompt_type == PromptType.document:
        return ""
    if isinstance(instruction, dict):
        if prompt_type is None:
            instruction = "Given a web search query, retrieve relevant passages that answer the query"
        else:
            instruction = instruction[prompt_type]
    return f"Instruct: {instruction}\nQuery: "


F2LLM_0B6 = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template=instruction_template,
        prompts_dict=prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
    ),
    name="codefuse-ai/F2LLM-0.6B",
    model_type=["dense"],
    languages=["eng-Latn"],
    open_weights=True,
    revision="36416618b83d4bd84a8ca30c2ee01ed518f9f2e7",
    release_date="2025-09-18",
    n_parameters=596049920,
    n_embedding_parameters=155582464,
    memory_usage_mb=1137,
    embed_dim=1024,
    license="apache-2.0",
    max_tokens=8192,
    reference="https://huggingface.co/codefuse-ai/F2LLM-0.6B",
    similarity_fn_name="cosine",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    use_instructions=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM",
    training_datasets=training_datasets,
    citation=F2LLM_CITATION,
)

F2LLM_1B7 = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template=instruction_template,
        prompts_dict=prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
    ),
    name="codefuse-ai/F2LLM-1.7B",
    model_type=["dense"],
    languages=["eng-Latn"],
    open_weights=True,
    revision="fdce0e09655f42cea26f7f66f5a70cd4507ea45c",
    release_date="2025-09-18",
    n_parameters=1_720_574_976,
    n_embedding_parameters=311164928,
    memory_usage_mb=3282,
    embed_dim=2048,
    license="apache-2.0",
    max_tokens=8192,
    reference="https://huggingface.co/codefuse-ai/F2LLM-1.7B",
    similarity_fn_name="cosine",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    use_instructions=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM",
    training_datasets=training_datasets,
    citation=F2LLM_CITATION,
)

F2LLM_4B = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template=instruction_template,
        prompts_dict=prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
    ),
    name="codefuse-ai/F2LLM-4B",
    model_type=["dense"],
    languages=["eng-Latn"],
    open_weights=True,
    revision="9fe95901ed2b6b59dd7673d6e93c9d76766a1e25",
    release_date="2025-09-18",
    n_parameters=4022468096,
    n_embedding_parameters=388956160,
    memory_usage_mb=7672,
    embed_dim=2560,
    license="apache-2.0",
    max_tokens=8192,
    reference="https://huggingface.co/codefuse-ai/F2LLM-4B",
    similarity_fn_name="cosine",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    use_instructions=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM",
    training_datasets=training_datasets,
    citation=F2LLM_CITATION,
)

C2LLM_0B5 = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=c2llm_loader_kwargs,
    name="codefuse-ai/C2LLM-0.5B",
    revision="f08c18be03de42c6e388948a1804d4b271a953a2",
    release_date="2025-12-22",
    languages=c2llm_languages,
    n_parameters=497252096,
    n_embedding_parameters=136134656,
    memory_usage_mb=948.0,
    max_tokens=32768,
    embed_dim=896,
    license="apache-2.0",
    open_weights=True,
    public_training_code=None,
    public_training_data=None,
    framework=["PyTorch", "Sentence Transformers", "Transformers", "safetensors"],
    reference="https://huggingface.co/codefuse-ai/C2LLM-0.5B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=c2llm_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    is_cross_encoder=None,
    citation=None,
    contacts=None,
)

C2LLM_7B = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=c2llm_loader_kwargs,
    name="codefuse-ai/C2LLM-7B",
    revision="c1dc16d6d64eb962c783bfb36a6d9c2f24a86dca",
    release_date="2025-12-22",
    languages=c2llm_languages,
    n_parameters=7667028992,
    n_embedding_parameters=544997376,
    memory_usage_mb=14624.0,
    max_tokens=32768,
    embed_dim=3584,
    license="apache-2.0",
    open_weights=True,
    public_training_code=None,
    public_training_data=None,
    framework=["PyTorch", "Sentence Transformers", "Transformers", "safetensors"],
    reference="https://huggingface.co/codefuse-ai/C2LLM-7B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=c2llm_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    is_cross_encoder=None,
    citation=None,
    contacts=None,
)

F2LLM_v2_80M = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-80M",
    revision="35baae5091e26211dbe628f1723448c146fafdf2",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=80084288,
    n_active_parameters_override=None,
    n_embedding_parameters=48534080,
    memory_usage_mb=305,
    max_tokens=40960,
    embed_dim=320,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-80M",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_160M = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-160M",
    revision="9eb35007d12e8624e6bf3e9e35d2255b5269597f",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=159185024,
    n_active_parameters_override=None,
    n_embedding_parameters=97068160,
    memory_usage_mb=607,
    max_tokens=40960,
    embed_dim=640,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-160M",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_330M = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-330M",
    revision="b0e8e19bdf603b9826422852572c0d18d482c414",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=334349184,
    n_active_parameters_override=None,
    n_embedding_parameters=135895424,
    memory_usage_mb=1275,
    max_tokens=40960,
    embed_dim=896,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-330M",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_0B6 = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-0.6B",
    revision="54b4e2dc74e01be7126d4cf5f016af6b21edc563",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=596049920,
    n_active_parameters_override=None,
    n_embedding_parameters=155309056,
    memory_usage_mb=2274,
    max_tokens=40960,
    embed_dim=1024,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-0.6B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_1B7 = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-1.7B",
    revision="3766d46e7a68545ed6190c15330983f9b39ab718",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=1720574976,
    n_active_parameters_override=None,
    n_embedding_parameters=310618112,
    memory_usage_mb=6563,
    max_tokens=40960,
    embed_dim=2048,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-1.7B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_4B = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-4B",
    revision="e04d1a04f4a0e154bf43969d3dcc596bbd92b1f8",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=4022468096,
    n_active_parameters_override=None,
    n_embedding_parameters=388272640,
    memory_usage_mb=15344,
    max_tokens=40960,
    embed_dim=2560,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-4B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_8B = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-8B",
    revision="5ac7d57351026337281e8e6a23e05cce16e79415",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=7568405504,
    n_active_parameters_override=None,
    n_embedding_parameters=621236224,
    memory_usage_mb=28871,
    max_tokens=40960,
    embed_dim=4096,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-8B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)

F2LLM_v2_14B = ModelMeta(
    loader=InstructSentenceTransformerModel,
    loader_kwargs=dict(
        instruction_template="Instruct: {instruction}\nQuery: ",
        prompts_dict=f2llmv2_prompts_dict,
        apply_instruction_to_passages=False,
        add_eos_token=True,
        max_seq_length=8192,
        model_kwargs={
            "attn_implementation": "flash_attention_2",
            "torch_dtype": torch.bfloat16,
        },
    ),
    name="codefuse-ai/F2LLM-v2-14B",
    revision="e42037a37e12999db44ce8e1a0e63c366c273f6a",
    release_date="2026-03-09",
    languages=f2llmv2_languages,
    n_parameters=13990394880,
    n_active_parameters_override=None,
    n_embedding_parameters=776545280,
    memory_usage_mb=53369,
    max_tokens=40960,
    embed_dim=5120,
    license="apache-2.0",
    open_weights=True,
    public_training_code="https://github.com/codefuse-ai/F2LLM",
    public_training_data="https://huggingface.co/datasets/codefuse-ai/F2LLM-v2",
    framework=["Sentence Transformers", "PyTorch", "safetensors", "Transformers"],
    reference="https://huggingface.co/codefuse-ai/F2LLM-v2-14B",
    similarity_fn_name=ScoringFunction.COSINE,
    use_instructions=True,
    training_datasets=f2llmv2_training_datasets,
    adapted_from=None,
    superseded_by=None,
    modalities=["text"],
    model_type=["dense"],
    citation=None,
    contacts=None,
)
