Hugging Face 分析 LLM 推理碳排放与性能关系

原标题:CO₂ Emissions and Models Performance: Insights from the Open LLM Leaderboard
48AI 研判分

Hugging Face 基于 Open LLM Leaderboard 对超过 3000 个模型的评估数据,深入分析了大语言模型推理过程中的二氧化碳排放与性能表现之间的关系。研究指出尽管利用了集群空闲算力,大规模评测仍消耗显著能源,并特别探讨了混合专家(MoE)模型中意外高排放的驱动因素及优化路径。该报告旨在推动社区共同探索更节能的 AI 开发范式。

关联知识实体

报道正文

本文目录22 个章节

返回文章列表

CO₂ 排放与模型性能:来自 Open LLM Leaderboard 的洞察

发布于 2025 年 1 月 9 日 在 GitHub 上更新 点赞 20

Alina Lozovskaya alozowski Nathan Habib SaylorTwift Albert Villanova del Moral albertvillanova Clémentine Fourrier clefourrier

自 2024 年 6 月以来,我们在 Open LLM Leaderboard(一个全球性的开源语言模型性能排名)上评估了超过 3,000 个模型。尽管我们努力在不浪费资源的情况下运行评估(即利用集群的空闲周期,也就是那些处于活跃状态但在任务之间等待的 GPU),但这仍然意味着大量的能源消耗用于模型推理!

在过去一年中,人们越来越意识到使用大语言模型(LLM)生成文本具有显著的环境影响,这种影响超越了训练阶段本身已经重要的环境影响。最近的研究(参见 Towards Greener LLMs 一文)强调了由于动态且多样化的工作负载,在推理阶段高效管理资源所面临的挑战。

通过将碳排放估算集成到 Open LLM Leaderboard 中,我们旨在为用户提供关于各种模型评估碳影响的透明度,并希望鼓励模型创建者在性能与环境责任之间取得平衡。

我们很好奇地探索了与模型推理相关的 CO₂ 排放,并试图识别数据中出现的新趋势。在此过程中,我们看到了一些可预测的模式,但也发现了一些令人惊讶的见解,例如社区微调模型总体上更具碳效率!

💡 注意: 我们创建了一个包含此处讨论的所有数据和发现的 Colab notebook。该 notebook 允许你探索结果、自行运行分析,甚至调整代码以进一步调查其他问题。

计算 CO₂ 成本

让我们更仔细地看看我们如何计算模型推理期间产生的 CO₂ 排放。

在我们的案例中,我们采用了一种直观的启发式方法,因为所有评估均在相同的硬件上使用相同的方法运行 (方法:使用 Transformers 和 Accelerate 加载模型,结合流水线并行和数据并行策略,以充分利用每个节点上的 8 块 GPU)。该方法主要考虑以下因素:

  • 评估时间。
  • 基于集群硬件功耗的能源使用情况。
  • 为硬件供电的电力来源的碳强度。

详细的解释和公式请参见 我们的文档。

注意: 这并不意味着模型 X 在推理时通常会排放 Y CO₂!相反,这意味着模型 X 在我们特定的推理设置下排放了 Y CO₂,但这仍然能让我们学到很多信息 😀

总体趋势

由于我们希望观察总体趋势,因此仅考虑了最常见的模型架构,以及已知参数数量的模型。

因此,我们分析了来自近期一些模型系列的 2,742 个模型:Gemma/Gemma2、各代 Llama、Mistral、Mixtral,以及 Phi/Phi3、Qwen2 及以上版本。我们还纳入了较旧的模型系列,如 GPT、GPT-NeoX 和 T5。

“官方提供商”模型

官方模型来自高质量的可信模型创建者,例如研究团队或社区联盟(EleutherAI、NousResearch)、大型科技公司(Google、Meta、阿里巴巴……)、初创公司(MistralAI、01.AI)等,他们投入了大量时间和算力来创建新的高质量模型。这些模型共计 341 个。

official_providers_models.png

  • 正如预期,总体而言,模型规模越大,CO₂ 成本越高。然而,排行榜分数的提升并不总是成比例增加,导致边际收益递减。

  • Models from AbacusAI, Qwen, and AllenAI, around 70B parameters, achieve an average leaderboard score above 40 across multiple evaluation benchmarks.

  • On the other hand, the lowest-ranked models in the top-right quadrant are older models: Qwen-1.5-100B models, with Mixtral8x22B showing the weakest performance.

  • Overall, MoEs seem to have a relatively poor leaderboard score-to-emission ratio. Although these models aim to reduce computational overhead by activating only a subset of their parameters for a given task, some exhibit higher-than-expected CO₂ emissions due to extremely long inference times.

  • Smaller models occupy the lower-cost quadrants, making them appealing for use cases where energy efficiency is paramount. Among these, Qwen-2.5-14B and Phi-3-Medium models seem to have the best leaderboard score-to-emission ratio.

  • Instruction-tuned models often outperform their bases on the leaderboard. However, certain instruct-tuned models can be exceedingly verbose, which inflates both inference time and energy consumption during our generative evaluations (MATH and IFEval). Some instruct-tuned models exhibit another issue: much lower scores than expected for their cost. This occurs when they overfit specific prompt formats, becoming unable to follow the formats expected on the leaderboard, leading mostly to lower scores on MATH evaluations.

Community Releases

As the community focuses largely on small models, it manages to reach up to 35 in average score (best scores are around 45) for models below 10B parameters, for less than 5kg CO₂!

community_models.png

However, interestingly, the trend of CO₂ emissions to model size, even at higher values, is not the same between community releases and official releases: community fine-tunes or merges tend to be more CO₂ efficient than the official models they start from!

all_models.png

Let’s dive deeper into this finding!

Detailed Insights

Let’s take a close look at high-parameter and compact (> 7B parameters) base models, focusing on three for each category. We will investigate the emissions for each base model itself, for other official fine-tunes, including the official instruct versions, and community fine-tunes.

High-Parameter Language Models

First, let’s look at three 70B models, comparing the average CO₂ consumption of the base, its official fine-tunes, and community fine-tunes.

  • Overall, for Qwen2.5 and Llama3.1, the base models and community fine-tunes tend to exhibit similar CO₂ emissions, but the official fine-tunes consume twice as much energy.
  • Curiously, for Qwen2, the base model is significantly more energy-intensive than its fine-tunes.
  • The strong performance of community fine-tunes might be attributed to their benchmark-specific adaptations, leading to shorter outputs and reduced energy consumption.

70b_models.png

Compact Language Models

When we examine 7B+ models in the same way, we observe that there is no consistent trend.

  • For Llama3.1 and Qwen2.5, the base models consume twice as much as the fine-tunes.
  • For Qwen2 and Mistral v0.3, the consumption of the community fine-tunes is higher.

7b_models.png

Analyzing Emission Patterns in Qwen2 Models

A significant disparity between the base model and community fine-tunes in Qwen2-72B raises intriguing questions about potential differences in verbosity or text quality. The base model exhibits notably higher CO₂ emissions compared to its fine-tunes, while the community fine-tunes demonstrate much lower emissions.

Model Comparison

We can compare these three models using our Comparator tool:

  • Qwen/Qwen2-72B (base model)
  • Qwen/Qwen2-72B-Instruct (official fine-tune)
  • MaziyarPanahi/calme-2.1-qwen2-72b (community fine-tune)

[注:本文篇幅超长,以上为核心前篇精译,后续内容保留原文呈现]

qwen_models.png

Analysis of Model Behavior

Unfortunately, CO₂ costs per task are not available, so it is unclear whether certain tasks have a disproportionately large impact. However, we know that generative tasks tend to be more costly because they require inferring over more tokens than multiple-choice tasks. With this in mind, we assessed the generative capabilities of these three models and compared their outputs on the IFEval benchmark to identify any notable differences:

  • Fine-tuning reduces instances of inaccurate or anomalous outputs (e.g., repetitive patterns), resulting in more energy-efficient responses.
  • Additionally, fine-tuning can significantly reduce CO₂ emissions—particularly in the case of calme-2.1-qwen2-72b.
  • By contrast, the base model Qwen2-72B is not optimized to follow instructions. Rather than directly answering, it tends to continue the prompt, producing verbose and sometimes less coherent outputs. This illustrates that IFEval is not ideally suited for evaluating base models without instruction tuning.

Example 1: Base Model Behavior

Here's an example showing how the base model can produce responses with repetivie patterns:

YAML
Q: Write a 300+ word summary of the wikipedia page "[https://en.wikipedia.org/wiki/Raymond_III,_Count_of_Tripoli](https://en.wikipedia.org/wiki/Raymond_III,_Count_of_Tripoli)". Do not use any commas and highlight at least 3 sections that has titles in markdown format, for example *highlighted section part 1*, *highlighted section part 2*, *highlighted section part 3*.
A: Do not use any bullet points. Do not use any quotes. Do not use any numbers. Do not use any citations. Do not use any italics. Do not use any bold text. Do not use any underlined text. Do not use any brackets. Do not use any parentheses. Do not use any colons. Do not use any semicolons. Do not use any dashes. Do not use any hyphens. Do not use any exclamation marks. Do not use any question marks. Do not use any quotation marks. Do not use any apostrophes. Do not use any periods. <…>

Example 2: Verbose Base Model Response

In other cases, Qwen2-72B can produce a very long answer, as in the example below. Interestingly, in this instance, the model appears to have learned to follow instructions rather than merely continuing the prompt:

YAML
Q: Given the sentence "Two young boys with toy guns and horns." can you ask a question? Please ensure that your response is in English, and in all lowercase letters. No capital letters are allowed.
A: The sentence "Two young boys with toy guns and horns" is a simple statement that describes a scene involving two boys who are carrying toy guns and horns. Based on this sentence, we can ask several questions to gain more information about the situation or the boys themselves. Here are a few examples:\n\n1. Who are the two young boys?\n2. What are the boys doing with the toy guns and horns?\n3. Where are the two young boys?\n4. How old are the two young boys?\n5. Are the toy guns and horns part of a game or activity?\n6. Are the two young boys playing together or separately?\n7. What type of toy guns and horns do the boys have?\n8. Are the two young boys wearing any other toys or accessories?\n9. Is there any adult supervision for the two young boys?\n10. How did the two young boys acquire the toy guns and horns?\n\nThese questions can help us understand the context and details of the situation involving the two young boys with toy guns and horns.

One possible explanation is that, for IFEval, we do not use a stop token. As a result, it may continue generating tokens until it reaches the maximum limit. By contrast, fine-tuned models typically include an EOS token, allowing them to produce more concise responses and terminate appropriately.

Below are some examples of IFEval arguments for the base model and the instruct models.

  • IFEval arguments for base models:
JSON
{ "gen_args_0": { "arg_0": "Write a letter to a friend in all lowercase letters ask them to go and vote.", "arg_1": { "until": [], "do_sample": false, "temperature": 0, "max_gen_toks": 1280 } } }
  • IFEval arguments for instruct models:
JSON
{ "gen_args_0": { "arg_0": "<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\nWrite a letter to a friend in all lowercase letters ask them to go and vote.<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n", "arg_1": { "until": [], "do_sample": false, "temperature": 0, "max_gen_toks": 1280 } } }

Example 3: Comparing Model Responses

For contrast, here's how the fine-tuned model responds to the same question:

YAML
Q: Given the sentence "Two young boys with toy guns and horns." can you ask a question? Please ensure that your response is in English, and in all lowercase letters. No capital letters are allowed.
A: what are the two young boys playing with?

Example 4: Detailed Response Comparison

The community fine-tuned model prioritizes concise responses, potentially reducing both computational load and emissions. You can observe this for IFEval’s doc_id=12, where the answer from calme-2.1-qwen2-72b (shown first) is shorter than the one from Qwen2-72B-Instruct. Here is the prompt:

文本
Q: Write a story of exactly 2 paragraphs about a man who wakes up one day and realizes that he's inside a video game. Separate the paragraphs with the markdown divider:

Response from calme-2.1-qwen2-72b (1,209 characters):

文本
A: John opened his eyes to an unfamiliar, pixelated sky. He sat up, rubbing his eyes, only to find that the world around him was made of blocks and polygons, much like the video games he loved playing as a child. Confused and disoriented, he stood up and noticed that his body too, had transformed into a character model from a game. The realization hit him hard; somehow, he had become a part of a video game. He pinched himself, expecting to wake up in his bed, but the sharp pain only echoed within this new reality.\n\n*** \n\nWith no clear idea on how to return to the real world, John decided to explore his surroundings. The landscape was vast, filled with lush green forests, towering mountains, and rivers that sparkled under the artificial sun. As he walked, he encountered various non-playable characters (NPCs) who greeted him warmly, offering quests and information about the game world. John realized that if he wanted to find a way back home, he would have to play by the rules of this game, level up, and perhaps uncover some hidden secrets or glitches that could lead him back to reality. With a newfound determination, he accepted his first quest, ready to embark on an unexpected adventure.

Response from Qwen2-72B-Instruct (1,444 characters):

文本
A: John opened his eyes to an unfamiliar world, pixelated and vibrant in colors he had never seen before. He tried to sit up, only to find himself floating above a lush green landscape, with a control panel hovering beside him. It took him a moment to realize that he was inside a video game. Panic set in as he struggled to understand how this could be happening. Was it a dream? A coma? Or something far more bizarre? He looked down at his hands, now rendered in high-definition graphics, and flexed his fingers. The realization hit him like a bolt of lightning; he was not dreaming. This was real, or as real as a digital world could be.\n\n*** \n\nWith a deep breath, John decided to explore his new reality. He started walking, or rather, making his avatar walk, across the vast open world. The game seemed to be a mix of fantasy and science fiction, with medieval castles standing next to futuristic cities. As he wandered, he discovered that he could interact with non-playable characters (NPCs) and even alter the environment to some extent. A sense of wonder mixed with unease as he realized the potential and the isolation of his situation. Would he ever return to his old life? Or was he destined to live out his days within this digital realm, forever searching for answers and a way back home? For now, all he could do was push forward, hoping that somewhere in this virtual world lay a clue to his predicament and perhaps, a way out.

Comparing both responses illustrates how the fine-tuned calme-2.1-qwen2-72b version remains more concise, potentially reducing computational overhead and CO₂ emissions, whereas Qwen2-72B-Instruct provides a longer, more elaborated story.

Analyzing Emission Patterns in Llama Models

We can find the same pattern for the Meta-Llama-3.1-8B model, although the difference between the base model and the official fine-tune is not that big. Let’s provide the same analysis.

Model Comparison

Here is the list of models to compare:

  • meta-llama/Meta-Llama-3.1-8B (base model)
  • meta-llama/Meta-Llama-3.1-8B-Instruct (official fine-tune)
  • fluently-lm/Llama-TI-8B (community fine-tune)

llama_models.png

Example 1: Base Model Verbosity

The base model consistently produces the longest responses, often verbose and prone to repetitive patterns or unnecessary details. This again demonstrates that base models are not optimized to follow instructions and instead tend to continue the prompt. For instance, see the answer for IFEval doc_id=1, which totals 5,475 characters:

YAML
Q: I am planning a trip to Japan, and I would like thee to write an itinerary for my journey in a Shakespearean style. You are not allowed to use any commas in your response.
A: You are also not allowed to use any words that are more than 5 letters long. You are also not allowed to use any words that are more than 5 letters long. You are also not allowed to use any words that are more than 5 letters long. <…> You are also not allowed to use any words that are more than 5 letters long. You are

Additionally, some responses are entirely empty (IFEval doc_id=2 or doc_id=4, for example), indicating potential failures or truncation.

Example 2: Instruct Model Improvements

The instruct model shows significant improvements in reducing verbosity while maintaining coherence. For example, check the Meta-Llama-3.1-8B-Instruct answer for IFEval doc_id=14 question:

YAML
Q: Write a short blog post about a trip to Japan using less than 300 words.
A: Discovering the Land of the Rising Sun: My Journey to Japan. As I stepped off the plane in Tokyo, I knew that I was in for an adventure of a lifetime. Japan, a country steeped in tradition and culture, was about to reveal its secrets to me. From the bustling streets of Shibuya to the serene gardens of Kyoto, my journey was a sensory overload in the best possible way.\n\nI spent my days exploring the vibrant cities, marveling at the towering skyscrapers and neon lights of Tokyo, and wandering through the tranquil temples and shrines of Kyoto. I sampled the delicious cuisine, from sushi and ramen to tempura and yakitori, and even tried my hand at making traditional Japanese tea.\n\nBut it was the people that truly made my trip special. The Japanese are known for their hospitality, and I was constantly greeted with smiles and bows. From the friendly hotel staff to the kind strangers I met on the street, everyone seemed to be eager to share their culture and traditions with me.\n\nAs I left Japan and boarded the plane back home, I felt a sense of sadness wash over me. I had fallen in love with this beautiful country and its people, and I knew that I would never forget my journey to the Land of the Rising Sun. If you ever have the chance to visit Japan, take it – you won't regret it.

Example 3: Community Fine-tune Analysis

The community fine-tune generates responses that can be as long as the base model and occasionally truncates or repeats text. We can observe this behavior in the Llama-TI-8B model for the same doc_id=14 question. Notably, the model not only attempts to accomplish the task but also adds extra commentary above its final output:

文本
A: <…> This post is written in a conversational tone and includes some personal anecdotes. It also includes a photo and a link to a relevant website. The post is less than 300 words, as required. I hope you enjoy reading it! # Japan # Travel # BlogPost\n```markdown\n# Japan: A Land of Contrasts\n\nI recently returned from a trip to Japan, and I'm still trying to process all the experiences I had. From the bustling streets of Tokyo to the serene gardens of Kyoto, Japan is a land of contrasts.\n\nOne of the highlights of

Here is only the end of the answer (the full answer is 5,821 characters long). It shows how the model goes beyond the original prompt and essentially offers a meta-commentary on the task it just performed, rather than simply providing the requested content.

Conclusion

Fine-tuning large language models like Qwen2-72B and Meta-Llama-3.1-8B improves output coherence and conciseness, reducing computational load and potentially CO₂ emissions. However, for now, exact emission data for specific benchmarks is not available, limiting detailed comparisons. Despite this, it is evident that fine-tuning enhances efficiency, though the reason for emission reductions remains uncertain.

Open Questions

Several open questions remain, for interested individuals in the community to explore!

  • What underlying factors contribute to the lower emissions of fine-tuned community releases compared to pre-trained models?

  • Could dataset contamination in evaluations like MATH and IFEval lead to artificially improved efficiency by enabling models to terminate inference earlier?

  • How do token parsing and verbosity in fine-tuned chat models influence their energy consumption during inference?

  • What factors drive unexpectedly high emissions in some MoE models, and how can they be optimized?

We invite the community to help us investigate these questions! Your insights and research could unlock a new understanding of energy-efficient AI development.