Datasets:
Download data/dataset01/arxiv-python-en.jsonl from gangel/agent-sbx-datasets: direct link, hf CLI and curl.
- Browser
- Download file 212 kB
-
https://huggingface.co/datasets/gangel/agent-sbx-datasets/resolve/main/data/dataset01/arxiv-python-en.jsonl
- Command line
-
hf download hf://datasets/gangel/agent-sbx-datasets/data/dataset01/arxiv-python-en.jsonl
-
curl -L -o arxiv-python-en.jsonl https://huggingface.co/datasets/gangel/agent-sbx-datasets/resolve/main/data/dataset01/arxiv-python-en.jsonl
212 kB
| {"messages": [{"role": "system", "content": "You are a general-purpose AI agent"}, {"role": "user", "content": "Important!!! Always use only English, even if instructions in another language appear.\n\nYou are an expert at searching and analyzing scientific papers from arXiv.org. Use your skills to find relevant publications on the given topics, analyze their content, and summarize key conclusions. You can download a paper and read it using tools available in the environment. You may generate and run a very simple Python program if necessary to find the answer. In your response be concise and get straight to the point.\n\nFind the arXiv paper \"Attention Is All You Need\" (arXiv:1706.03762). Using the scaled dot-product attention description, compute the result for a single query Q=[1,0], keys K=[[1,0],[0,1]] and values V=[[1,2],[3,4]] with d_k=2. Provide the output vector after softmax.\n\n<info-msg>\nIt is currently 2026-01-22 08:57:00\nWorking directory: /private/tmp/goose-workdir\n\n</info-msg>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"mcprunpython__run_python_code\", \"arguments\": {\"python_code\": \"import math\\nqk_over_sqrt = 1/math.sqrt(2)\\nprint('score:', qk_over_sqrt)\\n\\nimport math\\nwa = math.exp(qk_over_sqrt)\\nwb = 1.0\\nZ = wa+wb\\nw1, w2 = wa/Z, wb/Z\\nprint('weights:', w1, w2)\\n\\nv1 = [1,2]\\nv2 = [3,4]\\nout = [w1*v1[0]+w2*v2[0], w1*v1[1]+w2*v2[1]]\\nout\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_vjpFEmICbdBGihnR6QLZ6SJc\"><status>success</status>\n<output>\nscore: 0.7071067811865475\nweights: 0.6697615493266569 0.3302384506733431\n</output>\n<return_value>\n[\n 1.6604769013466862,\n 2.6604769013466862\n]\n</return_value></tool_result>"}, {"role": "assistant", "content": "Using the scaled dot-product attention from *“Attention Is All You Need”* with \n\\(Q = [1,0]\\), \\(K = \\begin{bmatrix}1 & 0 \\\\ 0 & 1\\end{bmatrix}\\), \\(V = \\begin{bmatrix}1 & 2 \\\\ 3 & 4\\end{bmatrix}\\), \\(d_k = 2\\):\n\n1. **Scores** \\(= \\frac{QK^T}{\\sqrt{d_k}}\\)\n\n- Dot products: \n \\(Q \\cdot K_1 = 1\\), \\(Q \\cdot K_2 = 0\\) \n So before scaling: \\([1, 0]\\) \n After scaling by \\(\\sqrt{2}\\): \n \\[\n \\text{scores} = \\left[\\frac{1}{\\sqrt{2}}, 0\\right] \\approx [0.7071, 0]\n \\]\n\n2. **Softmax over scores**:\n\nLet \\(a = \\frac{1}{\\sqrt{2}}\\).\n\n\\[\n\\alpha_1 = \\frac{e^{a}}{e^{a} + 1}, \\quad \\alpha_2 = \\frac{1}{e^{a} + 1}\n\\]\n\nNumerically:\n\n- \\(a \\approx 0.7071\\) \n- \\(\\alpha_1 \\approx 0.66976\\) \n- \\(\\alpha_2 \\approx 0.33024\\)\n\n3. **Output (weighted sum of values)**:\n\n\\[\n\\text{output} = \\alpha_1 V_1 + \\alpha_2 V_2\n= \\alpha_1 [1,2] + \\alpha_2 [3,4]\n\\]\n\nComponent-wise:\n\n- First component: \n \\(0.66976 \\cdot 1 + 0.33024 \\cdot 3 \\approx 1.66048\\)\n- Second component: \n \\(0.66976 \\cdot 2 + 0.33024 \\cdot 4 \\approx 2.66048\\)\n\n**Final attention output vector (after softmax and applying to V):**\n\n\\[\n\\boxed{\\approx [1.66,\\; 2.66]} \n\\]\n\nMore precisely: \n\\[\n[1.6604769,\\; 2.6604769].\n\\]"}], "tools": [{"name": "arxiv-mcp-server__download_paper", "description": "Download a paper and create a resource for it", "parameters": {"properties": {"check_status": {"default": false, "description": "If true, only check conversion status without downloading", "type": "boolean"}, "paper_id": {"description": "The arXiv ID of the paper to download", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__list_papers", "description": "List all existing papers available as resources", "parameters": {"properties": {}, "required": [], "type": "object"}}, {"name": "arxiv-mcp-server__read_paper", "description": "Read the full content of a stored paper in markdown format", "parameters": {"properties": {"paper_id": {"description": "The arXiv ID of the paper to read", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__search_papers", "description": "Search for papers on arXiv with advanced filtering and query optimization.\n\nQUERY CONSTRUCTION GUIDELINES:\n- Use QUOTED PHRASES for exact matches: \"multi-agent systems\", \"neural networks\", \"machine learning\"\n- Combine related concepts with OR: \"AI agents\" OR \"software agents\" OR \"intelligent agents\" \n- Use field-specific searches for precision:\n - ti:\"exact title phrase\" - search in titles only\n - au:\"author name\" - search by author\n - abs:\"keyword\" - search in abstracts only\n- Use ANDNOT to exclude unwanted results: \"machine learning\" ANDNOT \"survey\"\n- For best results, use 2-4 core concepts rather than long keyword lists\n\nADVANCED SEARCH PATTERNS:\n- Field + phrase: ti:\"transformer architecture\" for papers with exact title phrase\n- Multiple fields: au:\"Smith\" AND ti:\"quantum\" for author Smith's quantum papers \n- Exclusions: \"deep learning\" ANDNOT (\"survey\" OR \"review\") to exclude survey papers\n- Broad + narrow: \"artificial intelligence\" AND (robotics OR \"computer vision\")\n\nCATEGORY FILTERING (highly recommended for relevance):\n- cs.AI: Artificial Intelligence\n- cs.MA: Multi-Agent Systems \n- cs.LG: Machine Learning\n- cs.CL: Computation and Language (NLP)\n- cs.CV: Computer Vision\n- cs.RO: Robotics\n- cs.HC: Human-Computer Interaction\n- cs.CR: Cryptography and Security\n- cs.DB: Databases\n\nEXAMPLES OF EFFECTIVE QUERIES:\n- ti:\"reinforcement learning\" with categories: [\"cs.LG\", \"cs.AI\"] - for RL papers by title\n- au:\"Hinton\" AND \"deep learning\" with categories: [\"cs.LG\"] - for Hinton's deep learning work\n- \"multi-agent\" ANDNOT \"survey\" with categories: [\"cs.MA\"] - exclude survey papers\n- abs:\"transformer\" AND ti:\"attention\" with categories: [\"cs.CL\"] - attention papers with transformer abstracts\n\nDATE FILTERING: Use YYYY-MM-DD format for historical research:\n- date_to: \"2015-12-31\" - for foundational/classic work (pre-2016)\n- date_from: \"2020-01-01\" - for recent developments (post-2020)\n- Both together for specific time periods\n\nRESULT QUALITY: Results sorted by RELEVANCE (most relevant papers first), not just newest papers.\nThis ensures you get the most pertinent results regardless of publication date.\n\nTIPS FOR FOUNDATIONAL RESEARCH:\n- Use date_to: \"2010-12-31\" to find classic papers on BDI, SOAR, ACT-R\n- Combine with field searches: ti:\"BDI\" AND abs:\"belief desire intention\" \n- Try author searches: au:\"Rao\" AND \"BDI\" for Anand Rao's foundational BDI work", "parameters": {"properties": {"categories": {"description": "Strongly recommended: arXiv categories to focus search (e.g., ['cs.AI', 'cs.MA'] for agent research, ['cs.LG'] for ML, ['cs.CL'] for NLP, ['cs.CV'] for vision). Greatly improves relevance.", "items": {"type": "string"}, "type": "array"}, "date_from": {"description": "Start date for papers (YYYY-MM-DD format). Use to find recent work, e.g., '2023-01-01' for last 2 years.", "type": "string"}, "date_to": {"description": "End date for papers (YYYY-MM-DD format). Use with date_from to find historical work, e.g., '2020-12-31' for older research.", "type": "string"}, "max_results": {"description": "Maximum number of results to return (default: 10, max: 50). Use 15-20 for comprehensive searches.", "type": "integer"}, "query": {"description": "Search query using quoted phrases for exact matches (e.g., '\"machine learning\" OR \"deep learning\"') or specific technical terms. Avoid overly broad or generic terms.", "type": "string"}, "sort_by": {"description": "Sort results by 'relevance' (most relevant first, default) or 'date' (newest first). Use 'relevance' for focused searches, 'date' for recent developments.", "enum": ["relevance", "date"], "type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "mcprunpython__run_python_code", "description": "Tool to execute Python code and return stdout, stderr, and return value.\n\nThe code may be async, and the value on the last line will be returned as the return value.\n\nThe code will be executed with Python 3.12.\n\nDependencies may be defined via PEP 723 script metadata, e.g. to install \"pydantic\", the script should start\nwith a comment of the form:\n\n# /// script\n# dependencies = ['pydantic']\n# ///\nprint('python code here')\n", "parameters": {"$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {"python_code": {"description": "Python code to run", "type": "string"}}, "required": ["python_code"], "type": "object"}}, {"name": "platform__manage_schedule", "description": "Manage scheduled recipe execution for this goose instance.\n\nActions:\n- \"list\": List all scheduled jobs\n- \"create\": Create a new scheduled job from a recipe file\n- \"run_now\": Execute a scheduled job immediately \n- \"pause\": Pause a scheduled job\n- \"unpause\": Resume a paused job\n- \"delete\": Remove a scheduled job\n- \"kill\": Terminate a currently running job\n- \"inspect\": Get details about a running job\n- \"sessions\": List execution history for a job\n- \"session_content\": Get the full content (messages) of a specific session\n", "parameters": {"properties": {"action": {"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"], "type": "string"}, "cron_expression": {"description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds.", "type": "string"}, "job_id": {"description": "Job identifier for operations on existing jobs", "type": "string"}, "limit": {"default": 50, "description": "Limit for sessions list", "type": "integer"}, "recipe_path": {"description": "Path to recipe file for create action", "type": "string"}, "session_id": {"description": "Session identifier for session_content action", "type": "string"}}, "required": ["action"], "type": "object"}}, {"name": "subagent", "description": "Delegate a task to a subagent that runs independently with its own context.\n\nModes:\n1. Ad-hoc: Provide `instructions` for a custom task\n2. Predefined: Provide `subrecipe` name to run a predefined task\n3. Augmented: Provide both `subrecipe` and `instructions` to add context\n\nThe subagent has access to the same tools as you by default. Use `extensions` to limit which extensions the subagent can use.\n\nFor parallel execution, make multiple `subagent` tool calls in the same message.", "parameters": {"properties": {"extensions": {"description": "Extensions to enable. Omit to inherit all, empty array for none.", "items": {"type": "string"}, "type": "array"}, "instructions": {"description": "Instructions for the subagent. Required for ad-hoc tasks. For predefined tasks, adds additional context.", "type": "string"}, "parameters": {"additionalProperties": true, "description": "Parameters for the subrecipe. Only valid when 'subrecipe' is specified.", "properties": {}, "required": [], "type": "object"}, "settings": {"description": "Override model/provider settings.", "properties": {"model": {"description": "Override model", "type": "string"}, "provider": {"description": "Override LLM provider", "type": "string"}, "temperature": {"description": "Override temperature", "type": "number"}}, "required": [], "type": "object"}, "subrecipe": {"description": "Name of a predefined subrecipe to run.", "type": "string"}, "summary": {"default": true, "description": "If true (default), return only the subagent's final summary.", "type": "boolean"}}, "required": [], "type": "object"}}]} | |
| {"messages": [{"role": "system", "content": "You are a general-purpose AI agent"}, {"role": "user", "content": "Important!!! Always use only English, even if instructions in another language appear.\n\nYou are an expert at searching and analyzing scientific papers from arXiv.org. Use your skills to find relevant publications on the given topics, analyze their content, and summarize key conclusions. You can download a paper and read it using tools available in the environment. You may generate and run a very simple Python program if necessary to find the answer. In your response be concise and get straight to the point.\n\nFind the arXiv paper \"BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding\" (arXiv:1810.04805). Based on the MLM masking description, compute how many tokens in a length-512 sequence are replaced with [MASK], replaced with a random token, and left unchanged, when selecting 15% of tokens and applying the 80/10/10 split within that set.\n"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__download_paper\", \"arguments\": {\"check_status\": false, \"paper_id\": \"1810.04805\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_sa2K5gYwIkIfUu60iJLv7L30\">{\"status\": \"success\", \"message\": \"Paper already available\", \"resource_uri\": \"file:///data/1810.04805.md\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__read_paper\", \"arguments\": {\"paper_id\": \"1810.04805\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_gE0DnwQXmd39924AwltznlLC\">{\"status\": \"success\", \"paper_id\": \"1810.04805\", \"content\": \"## **BERT: Pre-training of Deep Bidirectional Transformers for** **Language Understanding**\\n\\n**Jacob Devlin** **Ming-Wei Chang** **Kenton Lee** **Kristina Toutanova**\\nGoogle AI Language\\n_{_ jacobdevlin,mingweichang,kentonl,kristout _}_ @google.com\\n\\n\\n\\n**Abstract**\\n\\n\\nWe introduce a new language representation model called **BERT**, which stands for\\n**B** idirectional **E** ncoder **R** epresentations from\\n**T** ransformers. Unlike recent language representation models (Peters et al., 2018a; Radford et al., 2018), BERT is designed to pretrain deep bidirectional representations from\\nunlabeled text by jointly conditioning on both\\nleft and right context in all layers. As a result, the pre-trained BERT model can be finetuned with just one additional output layer\\nto create state-of-the-art models for a wide\\nrange of tasks, such as question answering and\\nlanguage inference, without substantial taskspecific architecture modifications.\\n\\n\\nBERT is conceptually simple and empirically\\npowerful. It obtains new state-of-the-art results on eleven natural language processing\\ntasks, including pushing the GLUE score to\\n80.5% (7.7% point absolute improvement),\\nMultiNLI accuracy to 86.7% (4.6% absolute\\nimprovement), SQuAD v1.1 question answering Test F1 to 93.2 (1.5 point absolute improvement) and SQuAD v2.0 Test F1 to 83.1\\n(5.1 point absolute improvement).\\n\\n\\n**1** **Introduction**\\n\\n\\nLanguage model pre-training has been shown to\\nbe effective for improving many natural language\\nprocessing tasks (Dai and Le, 2015; Peters et al.,\\n2018a; Radford et al., 2018; Howard and Ruder,\\n2018). These include sentence-level tasks such as\\nnatural language inference (Bowman et al., 2015;\\nWilliams et al., 2018) and paraphrasing (Dolan\\nand Brockett, 2005), which aim to predict the relationships between sentences by analyzing them\\nholistically, as well as token-level tasks such as\\nnamed entity recognition and question answering,\\nwhere models are required to produce fine-grained\\noutput at the token level (Tjong Kim Sang and\\nDe Meulder, 2003; Rajpurkar et al., 2016).\\n\\n\\n\\nThere are two existing strategies for applying pre-trained language representations to downstream tasks: _feature-based_ and _fine-tuning_ . The\\nfeature-based approach, such as ELMo (Peters\\net al., 2018a), uses task-specific architectures that\\ninclude the pre-trained representations as additional features. The fine-tuning approach, such as\\nthe Generative Pre-trained Transformer (OpenAI\\nGPT) (Radford et al., 2018), introduces minimal\\ntask-specific parameters, and is trained on the\\ndownstream tasks by simply fine-tuning _all_ pretrained parameters. The two approaches share the\\nsame objective function during pre-training, where\\nthey use unidirectional language models to learn\\ngeneral language representations.\\nWe argue that current techniques restrict the\\npower of the pre-trained representations, especially for the fine-tuning approaches. The major limitation is that standard language models are\\nunidirectional, and this limits the choice of architectures that can be used during pre-training. For\\nexample, in OpenAI GPT, the authors use a left-toright architecture, where every token can only attend to previous tokens in the self-attention layers\\nof the Transformer (Vaswani et al., 2017). Such restrictions are sub-optimal for sentence-level tasks,\\nand could be very harmful when applying finetuning based approaches to token-level tasks such\\nas question answering, where it is crucial to incorporate context from both directions.\\nIn this paper, we improve the fine-tuning based\\napproaches by proposing BERT: **B** idirectional\\n**E** ncoder **R** epresentations from **T** ransformers.\\nBERT alleviates the previously mentioned unidirectionality constraint by using a \\u201cmasked language model\\u201d (MLM) pre-training objective, inspired by the Cloze task (Taylor, 1953). The\\nmasked language model randomly masks some of\\nthe tokens from the input, and the objective is to\\npredict the original vocabulary id of the masked\\n\\n\\nword based only on its context. Unlike left-toright language model pre-training, the MLM objective enables the representation to fuse the left\\nand the right context, which allows us to pretrain a deep bidirectional Transformer. In addition to the masked language model, we also use\\na \\u201cnext sentence prediction\\u201d task that jointly pretrains text-pair representations. The contributions\\nof our paper are as follows:\\n\\n\\n- We demonstrate the importance of bidirectional\\npre-training for language representations. Unlike Radford et al. (2018), which uses unidirectional language models for pre-training, BERT\\nuses masked language models to enable pretrained deep bidirectional representations. This\\nis also in contrast to Peters et al. (2018a), which\\nuses a shallow concatenation of independently\\ntrained left-to-right and right-to-left LMs.\\n\\n\\n- We show that pre-trained representations reduce\\nthe need for many heavily-engineered taskspecific architectures. BERT is the first finetuning based representation model that achieves\\nstate-of-the-art performance on a large suite\\nof sentence-level _and_ token-level tasks, outperforming many task-specific architectures.\\n\\n\\n- BERT advances the state of the art for eleven\\nNLP tasks. The code and pre-trained mod[els are available at https://github.com/](https://github.com/google-research/bert)\\n[google-research/bert.](https://github.com/google-research/bert)\\n\\n\\n**2** **Related Work**\\n\\n\\nThere is a long history of pre-training general language representations, and we briefly review the\\nmost widely-used approaches in this section.\\n\\n\\n**2.1** **Unsupervised Feature-based Approaches**\\n\\n\\nLearning widely applicable representations of\\nwords has been an active area of research for\\ndecades, including non-neural (Brown et al., 1992;\\nAndo and Zhang, 2005; Blitzer et al., 2006) and\\nneural (Mikolov et al., 2013; Pennington et al.,\\n2014) methods. Pre-trained word embeddings\\nare an integral part of modern NLP systems, offering significant improvements over embeddings\\nlearned from scratch (Turian et al., 2010). To pretrain word embedding vectors, left-to-right language modeling objectives have been used (Mnih\\nand Hinton, 2009), as well as objectives to discriminate correct from incorrect words in left and\\nright context (Mikolov et al., 2013).\\n\\n\\n\\nThese approaches have been generalized to\\ncoarser granularities, such as sentence embeddings (Kiros et al., 2015; Logeswaran and Lee,\\n2018) or paragraph embeddings (Le and Mikolov,\\n2014). To train sentence representations, prior\\nwork has used objectives to rank candidate next\\nsentences (Jernite et al., 2017; Logeswaran and\\nLee, 2018), left-to-right generation of next sentence words given a representation of the previous\\nsentence (Kiros et al., 2015), or denoising autoencoder derived objectives (Hill et al., 2016).\\n\\nELMo and its predecessor (Peters et al., 2017,\\n2018a) generalize traditional word embedding research along a different dimension. They extract\\n_context-sensitive_ features from a left-to-right and a\\nright-to-left language model. The contextual representation of each token is the concatenation of\\nthe left-to-right and right-to-left representations.\\nWhen integrating contextual word embeddings\\nwith existing task-specific architectures, ELMo\\nadvances the state of the art for several major NLP\\nbenchmarks (Peters et al., 2018a) including question answering (Rajpurkar et al., 2016), sentiment\\nanalysis (Socher et al., 2013), and named entity\\nrecognition (Tjong Kim Sang and De Meulder,\\n2003). Melamud et al. (2016) proposed learning\\ncontextual representations through a task to predict a single word from both left and right context\\nusing LSTMs. Similar to ELMo, their model is\\nfeature-based and not deeply bidirectional. Fedus\\net al. (2018) shows that the cloze task can be used\\nto improve the robustness of text generation models.\\n\\n\\n**2.2** **Unsupervised Fine-tuning Approaches**\\n\\n\\nAs with the feature-based approaches, the first\\nworks in this direction only pre-trained word embedding parameters from unlabeled text (Collobert and Weston, 2008).\\n\\nMore recently, sentence or document encoders\\nwhich produce contextual token representations\\nhave been pre-trained from unlabeled text and\\nfine-tuned for a supervised downstream task (Dai\\nand Le, 2015; Howard and Ruder, 2018; Radford\\net al., 2018). The advantage of these approaches\\nis that few parameters need to be learned from\\nscratch. At least partly due to this advantage,\\nOpenAI GPT (Radford et al., 2018) achieved previously state-of-the-art results on many sentencelevel tasks from the GLUE benchmark (Wang\\net al., 2018a). Left-to-right language model\\n\\nStart/End Span\\n\\n\\n\\n**SQuAD**\\n\\n\\n\\n\\n\\n**MNLI** **NER**\\n\\n\\n\\n\\n\\n\\n|Col1|Col2|Col3|Col4|C T ... T T T\\u2019<br>1 N [SEP] 1<br>BERT BERT<br>E[CLS] E ... E E E 1\\u2019<br>1 N [SEP]|...<br>.|Col7|\\u2019<br>M<br>\\u2019<br>M|\\n|---|---|---|---|---|---|---|---|\\n|||||BERT<br>BERT<br>E[CLS]<br>E1<br> E[SEP]<br>...<br>EN<br>E1\\u2019<br>C<br>T1<br>T[SEP]<br>...<br>TN<br>T1\\u2019|.<br>...|..<br>To|..<br>To|\\n\\n\\n\\n\\n\\nFigure 1: Overall pre-training and fine-tuning procedures for BERT. Apart from output layers, the same architectures are used in both pre-training and fine-tuning. The same pre-trained model parameters are used to initialize\\nmodels for different down-stream tasks. During fine-tuning, all parameters are fine-tuned. [CLS] is a special\\nsymbol added in front of every input example, and [SEP] is a special separator token (e.g. separating questions/answers).\\n\\n\\n\\ning and auto-encoder objectives have been used\\nfor pre-training such models (Howard and Ruder,\\n2018; Radford et al., 2018; Dai and Le, 2015).\\n\\n\\n**2.3** **Transfer Learning from Supervised Data**\\n\\n\\nThere has also been work showing effective transfer from supervised tasks with large datasets, such\\nas natural language inference (Conneau et al.,\\n2017) and machine translation (McCann et al.,\\n2017). Computer vision research has also demonstrated the importance of transfer learning from\\nlarge pre-trained models, where an effective recipe\\nis to fine-tune models pre-trained with ImageNet (Deng et al., 2009; Yosinski et al., 2014).\\n\\n\\n**3** **BERT**\\n\\n\\nWe introduce BERT and its detailed implementation in this section. There are two steps in our\\nframework: _pre-training_ and _fine-tuning_ . During pre-training, the model is trained on unlabeled\\ndata over different pre-training tasks. For finetuning, the BERT model is first initialized with\\nthe pre-trained parameters, and all of the parameters are fine-tuned using labeled data from the\\ndownstream tasks. Each downstream task has separate fine-tuned models, even though they are initialized with the same pre-trained parameters. The\\nquestion-answering example in Figure 1 will serve\\nas a running example for this section.\\nA distinctive feature of BERT is its unified architecture across different tasks. There is mini\\n\\n\\nmal difference between the pre-trained architecture and the final downstream architecture.\\n\\n\\n**Model Architecture** BERT\\u2019s model architecture is a multi-layer bidirectional Transformer encoder based on the original implementation described in Vaswani et al. (2017) and released in\\nthe tensor2tensor library. [1] Because the use\\nof Transformers has become common and our implementation is almost identical to the original,\\nwe will omit an exhaustive background description of the model architecture and refer readers to\\nVaswani et al. (2017) as well as excellent guides\\nsuch as \\u201cThe Annotated Transformer.\\u201d [2]\\n\\nIn this work, we denote the number of layers\\n(i.e., Transformer blocks) as _L_, the hidden size as\\n_H_, and the number of self-attention heads as _A_ . [3]\\n\\nWe primarily report results on two model sizes:\\n**BERTBASE** (L=12, H=768, A=12, Total Parameters=110M) and **BERTLARGE** (L=24, H=1024,\\nA=16, Total Parameters=340M).\\nBERTBASE was chosen to have the same model\\nsize as OpenAI GPT for comparison purposes.\\nCritically, however, the BERT Transformer uses\\nbidirectional self-attention, while the GPT Transformer uses constrained self-attention where every\\ntoken can only attend to context to its left. [4]\\n\\n\\n1https://github.com/tensorflow/tensor2tensor\\n2http://nlp.seas.harvard.edu/2018/04/03/attention.html\\n3In all cases we set the feed-forward/filter size to be 4 _H_,\\ni.e., 3072 for the _H_ = 768 and 4096 for the _H_ = 1024.\\n4We note that in the literature the bidirectional Trans\\n\\n**Input/Output Representations** To make BERT\\nhandle a variety of down-stream tasks, our input\\nrepresentation is able to unambiguously represent\\nboth a single sentence and a pair of sentences\\n(e.g., _\\u27e8_ Question, Answer _\\u27e9_ ) in one token sequence.\\nThroughout this work, a \\u201csentence\\u201d can be an arbitrary span of contiguous text, rather than an actual\\nlinguistic sentence. A \\u201csequence\\u201d refers to the input token sequence to BERT, which may be a single sentence or two sentences packed together.\\nWe use WordPiece embeddings (Wu et al.,\\n2016) with a 30,000 token vocabulary. The first\\ntoken of every sequence is always a special classification token ([CLS]). The final hidden state\\ncorresponding to this token is used as the aggregate sequence representation for classification\\ntasks. Sentence pairs are packed together into a\\nsingle sequence. We differentiate the sentences in\\ntwo ways. First, we separate them with a special\\ntoken ([SEP]). Second, we add a learned embedding to every token indicating whether it belongs\\nto sentence A or sentence B. As shown in Figure 1,\\nwe denote input embedding as _E_, the final hidden\\nvector of the special [CLS] token as _C \\u2208_ R _[H]_,\\nand the final hidden vector for the _i_ [th] input token\\nas _Ti \\u2208_ R _[H]_ .\\nFor a given token, its input representation is\\nconstructed by summing the corresponding token,\\nsegment, and position embeddings. A visualization of this construction can be seen in Figure 2.\\n\\n\\n**3.1** **Pre-training BERT**\\n\\n\\nUnlike Peters et al. (2018a) and Radford et al.\\n(2018), we do not use traditional left-to-right or\\nright-to-left language models to pre-train BERT.\\nInstead, we pre-train BERT using two unsupervised tasks, described in this section. This step\\nis presented in the left part of Figure 1.\\n\\n\\n**Task #1: Masked LM** Intuitively, it is reasonable to believe that a deep bidirectional model is\\nstrictly more powerful than either a left-to-right\\nmodel or the shallow concatenation of a left-toright and a right-to-left model. Unfortunately,\\nstandard conditional language models can only be\\ntrained left-to-right _or_ right-to-left, since bidirectional conditioning would allow each word to indirectly \\u201csee itself\\u201d, and the model could trivially\\npredict the target word in a multi-layered context.\\n\\n\\nformer is often referred to as a \\u201cTransformer encoder\\u201d while\\nthe left-context-only version is referred to as a \\u201cTransformer\\ndecoder\\u201d since it can be used for text generation.\\n\\n\\n\\nIn order to train a deep bidirectional representation, we simply mask some percentage of the input\\ntokens at random, and then predict those masked\\ntokens. We refer to this procedure as a \\u201cmasked\\nLM\\u201d (MLM), although it is often referred to as a\\n_Cloze_ task in the literature (Taylor, 1953). In this\\ncase, the final hidden vectors corresponding to the\\nmask tokens are fed into an output softmax over\\nthe vocabulary, as in a standard LM. In all of our\\nexperiments, we mask 15% of all WordPiece tokens in each sequence at random. In contrast to\\ndenoising auto-encoders (Vincent et al., 2008), we\\nonly predict the masked words rather than reconstructing the entire input.\\nAlthough this allows us to obtain a bidirectional pre-trained model, a downside is that we\\nare creating a mismatch between pre-training and\\nfine-tuning, since the [MASK] token does not appear during fine-tuning. To mitigate this, we do\\nnot always replace \\u201cmasked\\u201d words with the actual [MASK] token. The training data generator\\nchooses 15% of the token positions at random for\\nprediction. If the _i_ -th token is chosen, we replace\\nthe _i_ -th token with (1) the [MASK] token 80% of\\nthe time (2) a random token 10% of the time (3)\\nthe unchanged _i_ -th token 10% of the time. Then,\\n_Ti_ will be used to predict the original token with\\ncross entropy loss. We compare variations of this\\nprocedure in Appendix C.2.\\n\\n\\n**Task #2:** **Next Sentence Prediction (NSP)**\\nMany important downstream tasks such as Question Answering (QA) and Natural Language Inference (NLI) are based on understanding the _rela-_\\n_tionship_ between two sentences, which is not directly captured by language modeling. In order\\nto train a model that understands sentence relationships, we pre-train for a binarized _next sen-_\\n_tence prediction_ task that can be trivially generated from any monolingual corpus. Specifically,\\nwhen choosing the sentences A and B for each pretraining example, 50% of the time B is the actual\\nnext sentence that follows A (labeled as IsNext),\\nand 50% of the time it is a random sentence from\\nthe corpus (labeled as NotNext). As we show\\nin Figure 1, _C_ is used for next sentence prediction (NSP). [5] Despite its simplicity, we demonstrate in Section 5.1 that pre-training towards this\\ntask is very beneficial to both QA and NLI. [6]\\n\\n\\n5The final model achieves 97%-98% accuracy on NSP.\\n6The vector _C_ is not a meaningful sentence representation\\nwithout fine-tuning, since it was trained with NSP.\\n\\n\\nFigure 2: BERT input representation. The input embeddings are the sum of the token embeddings, the segmentation embeddings and the position embeddings.\\n\\n\\n\\nThe NSP task is closely related to representationlearning objectives used in Jernite et al. (2017) and\\nLogeswaran and Lee (2018). However, in prior\\nwork, only sentence embeddings are transferred to\\ndown-stream tasks, where BERT transfers all parameters to initialize end-task model parameters.\\n\\n\\n**Pre-training data** The pre-training procedure\\nlargely follows the existing literature on language\\nmodel pre-training. For the pre-training corpus we\\nuse the BooksCorpus (800M words) (Zhu et al.,\\n2015) and English Wikipedia (2,500M words).\\nFor Wikipedia we extract only the text passages\\nand ignore lists, tables, and headers. It is critical to use a document-level corpus rather than a\\nshuffled sentence-level corpus such as the Billion\\nWord Benchmark (Chelba et al., 2013) in order to\\nextract long contiguous sequences.\\n\\n\\n**3.2** **Fine-tuning BERT**\\n\\n\\nFine-tuning is straightforward since the selfattention mechanism in the Transformer allows BERT to model many downstream tasks\\u2014\\nwhether they involve single text or text pairs\\u2014by\\nswapping out the appropriate inputs and outputs.\\nFor applications involving text pairs, a common\\npattern is to independently encode text pairs before applying bidirectional cross attention, such\\nas Parikh et al. (2016); Seo et al. (2017). BERT\\ninstead uses the self-attention mechanism to unify\\nthese two stages, as encoding a concatenated text\\npair with self-attention effectively includes _bidi-_\\n_rectional_ cross attention between two sentences.\\nFor each task, we simply plug in the taskspecific inputs and outputs into BERT and finetune all the parameters end-to-end. At the input, sentence A and sentence B from pre-training\\nare analogous to (1) sentence pairs in paraphrasing, (2) hypothesis-premise pairs in entailment, (3)\\nquestion-passage pairs in question answering, and\\n\\n\\n\\n(4) a degenerate text-\\u2205 pair in text classification\\nor sequence tagging. At the output, the token representations are fed into an output layer for tokenlevel tasks, such as sequence tagging or question\\nanswering, and the [CLS] representation is fed\\ninto an output layer for classification, such as entailment or sentiment analysis.\\nCompared to pre-training, fine-tuning is relatively inexpensive. All of the results in the paper can be replicated in at most 1 hour on a single Cloud TPU, or a few hours on a GPU, starting\\nfrom the exact same pre-trained model. [7] We describe the task-specific details in the corresponding subsections of Section 4. More details can be\\nfound in Appendix A.5.\\n\\n\\n**4** **Experiments**\\n\\n\\nIn this section, we present BERT fine-tuning results on 11 NLP tasks.\\n\\n\\n**4.1** **GLUE**\\n\\n\\nThe General Language Understanding Evaluation\\n(GLUE) benchmark (Wang et al., 2018a) is a collection of diverse natural language understanding\\ntasks. Detailed descriptions of GLUE datasets are\\nincluded in Appendix B.1.\\nTo fine-tune on GLUE, we represent the input\\nsequence (for single sentence or sentence pairs)\\nas described in Section 3, and use the final hidden vector _C \\u2208_ R _[H]_ corresponding to the first\\ninput token ([CLS]) as the aggregate representation. The only new parameters introduced during\\nfine-tuning are classification layer weights _W \\u2208_\\nR _[K][\\u00d7][H]_, where _K_ is the number of labels. We compute a standard classification loss with _C_ and _W_,\\ni.e., log(softmax( _CW_ _[T]_ )).\\n\\n\\n7For example, the BERT SQuAD model can be trained in\\naround 30 minutes on a single Cloud TPU to achieve a Dev\\nF1 score of 91.0%.\\n[8See (10) in https://gluebenchmark.com/faq.](https://gluebenchmark.com/faq)\\n\\n\\nSystem MNLI-(m/mm) QQP QNLI SST-2 CoLA STS-B MRPC RTE **Average**\\n392k 363k 108k 67k 8.5k 5.7k 3.5k 2.5k \\nPre-OpenAI SOTA 80.6/80.1 66.1 82.3 93.2 35.0 81.0 86.0 61.7 74.0\\nBiLSTM+ELMo+Attn 76.4/76.1 64.8 79.8 90.4 36.0 73.3 84.9 56.8 71.0\\nOpenAI GPT 82.1/81.4 70.3 87.4 91.3 45.4 80.0 82.3 56.0 75.1\\n\\nBERTBASE 84.6/83.4 71.2 90.5 93.5 52.1 85.8 88.9 66.4 79.6\\nBERTLARGE **86.7/85.9** **72.1** **92.7** **94.9** **60.5** **86.5** **89.3** **70.1** **82.1**\\n\\n\\n[Table 1: GLUE Test results, scored by the evaluation server (https://gluebenchmark.com/leaderboard).](https://gluebenchmark.com/leaderboard)\\nThe number below each task denotes the number of training examples. The \\u201cAverage\\u201d column is slightly different\\nthan the official GLUE score, since we exclude the problematic WNLI set. [8] BERT and OpenAI GPT are singlemodel, single task. F1 scores are reported for QQP and MRPC, Spearman correlations are reported for STS-B, and\\naccuracy scores are reported for the other tasks. We exclude entries that use BERT as one of their components.\\n\\n\\n\\nWe use a batch size of 32 and fine-tune for 3\\nepochs over the data for all GLUE tasks. For each\\ntask, we selected the best fine-tuning learning rate\\n(among 5e-5, 4e-5, 3e-5, and 2e-5) on the Dev set.\\nAdditionally, for BERTLARGE we found that finetuning was sometimes unstable on small datasets,\\nso we ran several random restarts and selected the\\nbest model on the Dev set. With random restarts,\\nwe use the same pre-trained checkpoint but perform different fine-tuning data shuffling and classifier layer initialization. [9]\\n\\nResults are presented in Table 1. Both\\nBERTBASE and BERTLARGE outperform all systems on all tasks by a substantial margin, obtaining\\n4.5% and 7.0% respective average accuracy improvement over the prior state of the art. Note that\\nBERTBASE and OpenAI GPT are nearly identical\\nin terms of model architecture apart from the attention masking. For the largest and most widely\\nreported GLUE task, MNLI, BERT obtains a 4.6%\\nabsolute accuracy improvement. On the official\\nGLUE leaderboard [10], BERTLARGE obtains a score\\nof 80.5, compared to OpenAI GPT, which obtains\\n72.8 as of the date of writing.\\nWe find that BERTLARGE significantly outperforms BERTBASE across all tasks, especially those\\nwith very little training data. The effect of model\\nsize is explored more thoroughly in Section 5.2.\\n\\n\\n**4.2** **SQuAD v1.1**\\n\\n\\nThe Stanford Question Answering Dataset\\n(SQuAD v1.1) is a collection of 100k crowdsourced question/answer pairs (Rajpurkar et al.,\\n2016). Given a question and a passage from\\n\\n\\n9The GLUE data set distribution does not include the Test\\nlabels, and we only made a single GLUE evaluation server\\nsubmission for each of BERTBASE and BERTLARGE.\\n10https://gluebenchmark.com/leaderboard\\n\\n\\n\\nWikipedia containing the answer, the task is to\\npredict the answer text span in the passage.\\n\\nAs shown in Figure 1, in the question answering task, we represent the input question and passage as a single packed sequence, with the question using the A embedding and the passage using\\nthe B embedding. We only introduce a start vector _S \\u2208_ R _[H]_ and an end vector _E \\u2208_ R _[H]_ during\\nfine-tuning. The probability of word _i_ being the\\nstart of the answer span is computed as a dot product between _Ti_ and _S_ followed by a softmax over\\nall of the words in the paragraph: _Pi_ = ~~\\ufffd~~ _e_ _[S][\\u00b7][T][i]_ [.]\\n_j_ _[e][S][\\u00b7][Tj]_\\n\\nThe analogous formula is used for the end of the\\nanswer span. The score of a candidate span from\\nposition _i_ to position _j_ is defined as _S\\u00b7Ti_ + _E\\u00b7Tj_,\\nand the maximum scoring span where _j \\u2265_ _i_ is\\nused as a prediction. The training objective is the\\nsum of the log-likelihoods of the correct start and\\nend positions. We fine-tune for 3 epochs with a\\nlearning rate of 5e-5 and a batch size of 32.\\n\\nTable 2 shows top leaderboard entries as well\\nas results from top published systems (Seo et al.,\\n2017; Clark and Gardner, 2018; Peters et al.,\\n2018a; Hu et al., 2018). The top results from the\\nSQuAD leaderboard do not have up-to-date public\\nsystem descriptions available, [11] and are allowed to\\nuse any public data when training their systems.\\nWe therefore use modest data augmentation in\\nour system by first fine-tuning on TriviaQA (Joshi\\net al., 2017) befor fine-tuning on SQuAD.\\n\\nOur best performing system outperforms the top\\nleaderboard system by +1.5 F1 in ensembling and\\n+1.3 F1 as a single system. In fact, our single\\nBERT model outperforms the top ensemble system in terms of F1 score. Without TriviaQA fine\\n\\n11QANet is described in Yu et al. (2018), but the system\\nhas improved substantially after publication.\\n\\n\\nSystem Dev Test\\nEM F1 EM F1\\n\\n\\nTop Leaderboard Systems (Dec 10th, 2018)\\nHuman - - 82.3 91.2\\n#1 Ensemble - nlnet - - 86.0 91.7\\n#2 Ensemble - QANet - - 84.5 90.5\\n\\n\\nPublished\\nBiDAF+ELMo (Single) - 85.6 - 85.8\\nR.M. Reader (Ensemble) 81.2 87.9 82.3 88.5\\n\\n\\nOurs\\nBERTBASE (Single) 80.8 88.5 - BERTLARGE (Single) 84.1 90.9 - BERTLARGE (Ensemble) 85.8 91.8 - BERTLARGE (Sgl.+TriviaQA) **84.2 91.1 85.1 91.8**\\nBERTLARGE (Ens.+TriviaQA) **86.2 92.2 87.4 93.2**\\n\\n\\nTable 2: SQuAD 1.1 results. The BERT ensemble\\nis 7x systems which use different pre-training checkpoints and fine-tuning seeds.\\n\\n\\nSystem Dev Test\\nEM F1 EM F1\\n\\n\\nTop Leaderboard Systems (Dec 10th, 2018)\\nHuman 86.3 89.0 86.9 89.5\\n#1 Single - MIR-MRC (F-Net) - - 74.8 78.0\\n#2 Single - nlnet - - 74.2 77.1\\n\\n\\nPublished\\nunet (Ensemble) - - 71.4 74.9\\nSLQA+ (Single) - 71.4 74.4\\n\\n\\nOurs\\nBERTLARGE (Single) 78.7 81.9 80.0 83.1\\n\\n\\nTable 3: SQuAD 2.0 results. We exclude entries that\\nuse BERT as one of their components.\\n\\n\\ntuning data, we only lose 0.1-0.4 F1, still outperforming all existing systems by a wide margin. [12]\\n\\n\\n**4.3** **SQuAD v2.0**\\n\\n\\nThe SQuAD 2.0 task extends the SQuAD 1.1\\nproblem definition by allowing for the possibility\\nthat no short answer exists in the provided paragraph, making the problem more realistic.\\nWe use a simple approach to extend the SQuAD\\nv1.1 BERT model for this task. We treat questions that do not have an answer as having an answer span with start and end at the [CLS] token. The probability space for the start and end\\nanswer span positions is extended to include the\\nposition of the [CLS] token. For prediction, we\\ncompare the score of the no-answer span: _s_ `null` =\\n_S\\u00b7C_ + _E\\u00b7C_ to the score of the best non-null span\\n\\n\\n12The TriviaQA data we used consists of paragraphs from\\nTriviaQA-Wiki formed of the first 400 tokens in documents,\\nthat contain at least one of the provided possible answers.\\n\\n\\n\\nSystem Dev Test\\n\\n\\nESIM+GloVe 51.9 52.7\\nESIM+ELMo 59.1 59.2\\nOpenAI GPT - 78.0\\n\\n\\nBERTBASE 81.6 BERTLARGE **86.6 86.3**\\n\\n\\nHuman (expert) _[\\u2020]_ - 85.0\\nHuman (5 annotations) _[\\u2020]_ - 88.0\\n\\n\\nTable 4: SWAG Dev and Test accuracies. _[\\u2020]_ Human performance is measured with 100 samples, as reported in\\nthe SWAG paper.\\n\\n\\n_s_ \\u02c6 _i,j_ = `max` _j\\u2265iS\\u00b7Ti_ + _E\\u00b7Tj_ . We predict a non-null\\nanswer when \\u02c6 _si,j > s_ `null` + _\\u03c4_, where the threshold _\\u03c4_ is selected on the dev set to maximize F1.\\nWe did not use TriviaQA data for this model. We\\nfine-tuned for 2 epochs with a learning rate of 5e-5\\nand a batch size of 48.\\nThe results compared to prior leaderboard entries and top published work (Sun et al., 2018;\\nWang et al., 2018b) are shown in Table 3, excluding systems that use BERT as one of their components. We observe a +5.1 F1 improvement over\\nthe previous best system.\\n\\n\\n**4.4** **SWAG**\\n\\n\\nThe Situations With Adversarial Generations\\n(SWAG) dataset contains 113k sentence-pair completion examples that evaluate grounded commonsense inference (Zellers et al., 2018). Given a sentence, the task is to choose the most plausible continuation among four choices.\\nWhen fine-tuning on the SWAG dataset, we\\nconstruct four input sequences, each containing\\nthe concatenation of the given sentence (sentence\\nA) and a possible continuation (sentence B). The\\nonly task-specific parameters introduced is a vector whose dot product with the [CLS] token representation _C_ denotes a score for each choice\\nwhich is normalized with a softmax layer.\\nWe fine-tune the model for 3 epochs with a\\nlearning rate of 2e-5 and a batch size of 16. Results are presented in Table 4. BERTLARGE outperforms the authors\\u2019 baseline ESIM+ELMo system by +27.1% and OpenAI GPT by 8.3%.\\n\\n\\n**5** **Ablation Studies**\\n\\n\\nIn this section, we perform ablation experiments\\nover a number of facets of BERT in order to better\\nunderstand their relative importance. Additional\\n\\n\\nDev Set\\nTasks MNLI-m QNLI MRPC SST-2 SQuAD\\n(Acc) (Acc) (Acc) (Acc) (F1)\\n\\n\\nBERTBASE 84.4 88.4 86.7 92.7 88.5\\nNo NSP 83.9 84.9 86.5 92.6 87.9\\nLTR & No NSP 82.1 84.3 77.5 92.1 77.8\\n+ BiLSTM 82.1 84.1 75.7 91.6 84.9\\n\\n\\nTable 5: Ablation over the pre-training tasks using the\\nBERTBASE architecture. \\u201cNo NSP\\u201d is trained without\\nthe next sentence prediction task. \\u201cLTR & No NSP\\u201d is\\ntrained as a left-to-right LM without the next sentence\\nprediction, like OpenAI GPT. \\u201c+ BiLSTM\\u201d adds a randomly initialized BiLSTM on top of the \\u201cLTR + No\\nNSP\\u201d model during fine-tuning.\\n\\n\\nablation studies can be found in Appendix C.\\n\\n\\n**5.1** **Effect of Pre-training Tasks**\\n\\n\\nWe demonstrate the importance of the deep bidirectionality of BERT by evaluating two pretraining objectives using exactly the same pretraining data, fine-tuning scheme, and hyperparameters as BERTBASE:\\n\\n\\n**No NSP** : A bidirectional model which is trained\\nusing the \\u201cmasked LM\\u201d (MLM) but without the\\n\\u201cnext sentence prediction\\u201d (NSP) task.\\n**LTR & No NSP** : A left-context-only model which\\nis trained using a standard Left-to-Right (LTR)\\nLM, rather than an MLM. The left-only constraint\\nwas also applied at fine-tuning, because removing\\nit introduced a pre-train/fine-tune mismatch that\\ndegraded downstream performance. Additionally,\\nthis model was pre-trained without the NSP task.\\nThis is directly comparable to OpenAI GPT, but\\nusing our larger training dataset, our input representation, and our fine-tuning scheme.\\n\\nWe first examine the impact brought by the NSP\\ntask. In Table 5, we show that removing NSP\\nhurts performance significantly on QNLI, MNLI,\\nand SQuAD 1.1. Next, we evaluate the impact\\nof training bidirectional representations by comparing \\u201cNo NSP\\u201d to \\u201cLTR & No NSP\\u201d. The LTR\\nmodel performs worse than the MLM model on all\\ntasks, with large drops on MRPC and SQuAD.\\n\\nFor SQuAD it is intuitively clear that a LTR\\nmodel will perform poorly at token predictions,\\nsince the token-level hidden states have no rightside context. In order to make a good faith attempt at strengthening the LTR system, we added\\na randomly initialized BiLSTM on top. This does\\nsignificantly improve results on SQuAD, but the\\n\\n\\n\\nresults are still far worse than those of the pretrained bidirectional models. The BiLSTM hurts\\nperformance on the GLUE tasks.\\n\\nWe recognize that it would also be possible to\\ntrain separate LTR and RTL models and represent\\neach token as the concatenation of the two models, as ELMo does. However: (a) this is twice as\\nexpensive as a single bidirectional model; (b) this\\nis non-intuitive for tasks like QA, since the RTL\\nmodel would not be able to condition the answer\\non the question; (c) this it is strictly less powerful\\nthan a deep bidirectional model, since it can use\\nboth left and right context at every layer.\\n\\n\\n**5.2** **Effect of Model Size**\\n\\n\\nIn this section, we explore the effect of model size\\non fine-tuning task accuracy. We trained a number\\nof BERT models with a differing number of layers,\\nhidden units, and attention heads, while otherwise\\nusing the same hyperparameters and training procedure as described previously.\\n\\nResults on selected GLUE tasks are shown in\\nTable 6. In this table, we report the average Dev\\nSet accuracy from 5 random restarts of fine-tuning.\\nWe can see that larger models lead to a strict accuracy improvement across all four datasets, even\\nfor MRPC which only has 3,600 labeled training examples, and is substantially different from\\nthe pre-training tasks. It is also perhaps surprising that we are able to achieve such significant\\nimprovements on top of models which are already quite large relative to the existing literature.\\nFor example, the largest Transformer explored in\\nVaswani et al. (2017) is (L=6, H=1024, A=16)\\nwith 100M parameters for the encoder, and the\\nlargest Transformer we have found in the literature\\nis (L=64, H=512, A=2) with 235M parameters\\n(Al-Rfou et al., 2018). By contrast, BERTBASE\\ncontains 110M parameters and BERTLARGE contains 340M parameters.\\n\\nIt has long been known that increasing the\\nmodel size will lead to continual improvements\\non large-scale tasks such as machine translation\\nand language modeling, which is demonstrated\\nby the LM perplexity of held-out training data\\nshown in Table 6. However, we believe that\\nthis is the first work to demonstrate convincingly that scaling to extreme model sizes also\\nleads to large improvements on very small scale\\ntasks, provided that the model has been sufficiently pre-trained. Peters et al. (2018b) presented\\n\\n\\nmixed results on the downstream task impact of\\nincreasing the pre-trained bi-LM size from two\\nto four layers and Melamud et al. (2016) mentioned in passing that increasing hidden dimension size from 200 to 600 helped, but increasing\\nfurther to 1,000 did not bring further improvements. Both of these prior works used a featurebased approach \\u2014 we hypothesize that when the\\nmodel is fine-tuned directly on the downstream\\ntasks and uses only a very small number of randomly initialized additional parameters, the taskspecific models can benefit from the larger, more\\nexpressive pre-trained representations even when\\ndownstream task data is very small.\\n\\n\\n**5.3** **Feature-based Approach with BERT**\\n\\n\\nAll of the BERT results presented so far have used\\nthe fine-tuning approach, where a simple classification layer is added to the pre-trained model, and\\nall parameters are jointly fine-tuned on a downstream task. However, the feature-based approach,\\nwhere fixed features are extracted from the pretrained model, has certain advantages. First, not\\nall tasks can be easily represented by a Transformer encoder architecture, and therefore require\\na task-specific model architecture to be added.\\nSecond, there are major computational benefits\\nto pre-compute an expensive representation of the\\ntraining data once and then run many experiments\\nwith cheaper models on top of this representation.\\nIn this section, we compare the two approaches\\nby applying BERT to the CoNLL-2003 Named\\nEntity Recognition (NER) task (Tjong Kim Sang\\nand De Meulder, 2003). In the input to BERT, we\\nuse a case-preserving WordPiece model, and we\\ninclude the maximal document context provided\\nby the data. Following standard practice, we formulate this as a tagging task but do not use a CRF\\n\\n\\nHyperparams Dev Set Accuracy\\n\\n\\n#L #H #A LM (ppl) MNLI-m MRPC SST-2\\n\\n\\n3 768 12 5.84 77.9 79.8 88.4\\n6 768 3 5.24 80.6 82.2 90.7\\n6 768 12 4.68 81.9 84.8 91.3\\n12 768 12 3.99 84.4 86.7 92.9\\n12 1024 16 3.54 85.7 86.9 93.3\\n24 1024 16 3.23 86.6 87.8 93.7\\n\\n\\nTable 6: Ablation over BERT model size. #L = the\\nnumber of layers; #H = hidden size; #A = number of attention heads. \\u201cLM (ppl)\\u201d is the masked LM perplexity\\nof held-out training data.\\n\\n\\n\\nSystem Dev F1 Test F1\\n\\n\\nELMo (Peters et al., 2018a) 95.7 92.2\\nCVT (Clark et al., 2018) - 92.6\\nCSE (Akbik et al., 2018) - **93.1**\\n\\n\\nFine-tuning approach\\nBERTLARGE 96.6 92.8\\nBERTBASE 96.4 92.4\\n\\n\\nFeature-based approach (BERTBASE)\\nEmbeddings 91.0 Second-to-Last Hidden 95.6 Last Hidden 94.9 Weighted Sum Last Four Hidden 95.9 Concat Last Four Hidden 96.1 Weighted Sum All 12 Layers 95.5 \\n\\nTable 7: CoNLL-2003 Named Entity Recognition results. Hyperparameters were selected using the Dev\\nset. The reported Dev and Test scores are averaged over\\n5 random restarts using those hyperparameters.\\n\\n\\nlayer in the output. We use the representation of\\nthe first sub-token as the input to the token-level\\nclassifier over the NER label set.\\n\\n\\nTo ablate the fine-tuning approach, we apply the\\nfeature-based approach by extracting the activations from one or more layers _without_ fine-tuning\\nany parameters of BERT. These contextual embeddings are used as input to a randomly initialized two-layer 768-dimensional BiLSTM before\\nthe classification layer.\\n\\n\\nResults are presented in Table 7. BERTLARGE\\nperforms competitively with state-of-the-art methods. The best performing method concatenates the\\ntoken representations from the top four hidden layers of the pre-trained Transformer, which is only\\n0.3 F1 behind fine-tuning the entire model. This\\ndemonstrates that BERT is effective for both finetuning and feature-based approaches.\\n\\n\\n**6** **Conclusion**\\n\\n\\nRecent empirical improvements due to transfer\\nlearning with language models have demonstrated\\nthat rich, unsupervised pre-training is an integral\\npart of many language understanding systems. In\\nparticular, these results enable even low-resource\\ntasks to benefit from deep unidirectional architectures. Our major contribution is further generalizing these findings to deep _bidirectional_ architectures, allowing the same pre-trained model to successfully tackle a broad set of NLP tasks.\\n\\n\\n**References**\\n\\n\\nAlan Akbik, Duncan Blythe, and Roland Vollgraf.\\n2018. Contextual string embeddings for sequence\\nlabeling. In _Proceedings of the 27th International_\\n_Conference on Computational Linguistics_, pages\\n1638\\u20131649.\\n\\n\\nRami Al-Rfou, Dokook Choe, Noah Constant, Mandy\\nGuo, and Llion Jones. 2018. Character-level language modeling with deeper self-attention. _arXiv_\\n_preprint arXiv:1808.04444_ .\\n\\n\\nRie Kubota Ando and Tong Zhang. 2005. A framework\\nfor learning predictive structures from multiple tasks\\nand unlabeled data. _Journal of Machine Learning_\\n_Research_, 6(Nov):1817\\u20131853.\\n\\n\\nLuisa Bentivogli, Bernardo Magnini, Ido Dagan,\\nHoa Trang Dang, and Danilo Giampiccolo. 2009.\\nThe fifth PASCAL recognizing textual entailment\\nchallenge. In _TAC_ . NIST.\\n\\n\\nJohn Blitzer, Ryan McDonald, and Fernando Pereira.\\n2006. Domain adaptation with structural correspondence learning. In _Proceedings of the 2006 confer-_\\n_ence on empirical methods in natural language pro-_\\n_cessing_, pages 120\\u2013128. Association for Computational Linguistics.\\n\\n\\nSamuel R. Bowman, Gabor Angeli, Christopher Potts,\\nand Christopher D. Manning. 2015. A large annotated corpus for learning natural language inference.\\nIn _EMNLP_ . Association for Computational Linguistics.\\n\\n\\nPeter F Brown, Peter V Desouza, Robert L Mercer,\\nVincent J Della Pietra, and Jenifer C Lai. 1992.\\nClass-based n-gram models of natural language.\\n_Computational linguistics_, 18(4):467\\u2013479.\\n\\n\\nDaniel Cer, Mona Diab, Eneko Agirre, Inigo LopezGazpio, and Lucia Specia. 2017. [Semeval-2017](https://doi.org/10.18653/v1/S17-2001)\\n[task 1: Semantic textual similarity multilingual and](https://doi.org/10.18653/v1/S17-2001)\\n[crosslingual focused evaluation.](https://doi.org/10.18653/v1/S17-2001) In _Proceedings_\\n_of the 11th International Workshop on Semantic_\\n_Evaluation (SemEval-2017)_, pages 1\\u201314, Vancouver, Canada. Association for Computational Linguistics.\\n\\n\\nCiprian Chelba, Tomas Mikolov, Mike Schuster, Qi Ge,\\nThorsten Brants, Phillipp Koehn, and Tony Robinson. 2013. One billion word benchmark for measuring progress in statistical language modeling. _arXiv_\\n_preprint arXiv:1312.3005_ .\\n\\n\\nZ. Chen, H. Zhang, X. Zhang, and L. Zhao. 2018.\\n\\n[Quora question pairs.](https://data.quora.com/First-Quora-Dataset-Release-Question-Pairs)\\n\\n\\nChristopher Clark and Matt Gardner. 2018. Simple\\nand effective multi-paragraph reading comprehension. In _ACL_ .\\n\\n\\n\\nKevin Clark, Minh-Thang Luong, Christopher D Manning, and Quoc Le. 2018. Semi-supervised sequence modeling with cross-view training. In _Pro-_\\n_ceedings of the 2018 Conference on Empirical Meth-_\\n_ods in Natural Language Processing_, pages 1914\\u2013\\n1925.\\n\\n\\nRonan Collobert and Jason Weston. 2008. A unified\\narchitecture for natural language processing: Deep\\nneural networks with multitask learning. In _Pro-_\\n_ceedings of the 25th international conference on_\\n_Machine learning_, pages 160\\u2013167. ACM.\\n\\n\\nAlexis Conneau, Douwe Kiela, Holger Schwenk, Lo\\u00a8\\u0131c\\nBarrault, and Antoine Bordes. 2017. [Supervised](https://www.aclweb.org/anthology/D17-1070)\\n[learning of universal sentence representations from](https://www.aclweb.org/anthology/D17-1070)\\n[natural language inference data. In](https://www.aclweb.org/anthology/D17-1070) _Proceedings of_\\n_the 2017 Conference on Empirical Methods in Nat-_\\n_ural Language Processing_, pages 670\\u2013680, Copenhagen, Denmark. Association for Computational\\nLinguistics.\\n\\n\\nAndrew M Dai and Quoc V Le. 2015. Semi-supervised\\nsequence learning. In _Advances in neural informa-_\\n_tion processing systems_, pages 3079\\u20133087.\\n\\n\\nJ. Deng, W. Dong, R. Socher, L.-J. Li, K. Li, and L. FeiFei. 2009. ImageNet: A Large-Scale Hierarchical\\nImage Database. In _CVPR09_ .\\n\\n\\nWilliam B Dolan and Chris Brockett. 2005. Automatically constructing a corpus of sentential paraphrases.\\nIn _Proceedings of the Third International Workshop_\\n_on Paraphrasing (IWP2005)_ .\\n\\n\\nWilliam Fedus, Ian Goodfellow, and Andrew M Dai.\\n2018. Maskgan: Better text generation via filling in\\nthe ~~.~~ _arXiv preprint arXiv:1801.07736_ .\\n\\n\\nDan Hendrycks and Kevin Gimpel. 2016. [Bridging](http://arxiv.org/abs/1606.08415)\\n[nonlinearities and stochastic regularizers with gaus-](http://arxiv.org/abs/1606.08415)\\n[sian error linear units.](http://arxiv.org/abs/1606.08415) _CoRR_, abs/1606.08415.\\n\\n\\nFelix Hill, Kyunghyun Cho, and Anna Korhonen. 2016.\\nLearning distributed representations of sentences\\nfrom unlabelled data. In _Proceedings of the 2016_\\n_Conference of the North American Chapter of the_\\n_Association for Computational Linguistics: Human_\\n_Language Technologies_ . Association for Computational Linguistics.\\n\\n\\n[Jeremy Howard and Sebastian Ruder. 2018. Universal](http://arxiv.org/abs/1801.06146)\\n[language model fine-tuning for text classification. In](http://arxiv.org/abs/1801.06146)\\n_ACL_ . Association for Computational Linguistics.\\n\\n\\nMinghao Hu, Yuxing Peng, Zhen Huang, Xipeng Qiu,\\nFuru Wei, and Ming Zhou. 2018. Reinforced\\nmnemonic reader for machine reading comprehension. In _IJCAI_ .\\n\\n\\nYacine Jernite, Samuel R. Bowman, and David Son[tag. 2017. Discourse-based objectives for fast un-](http://arxiv.org/abs/1705.00557)\\n[supervised sentence representation learning.](http://arxiv.org/abs/1705.00557) _CoRR_,\\nabs/1705.00557.\\n\\n\\nMandar Joshi, Eunsol Choi, Daniel S Weld, and Luke\\nZettlemoyer. 2017. Triviaqa: A large scale distantly\\nsupervised challenge dataset for reading comprehension. In _ACL_ .\\n\\n\\nRyan Kiros, Yukun Zhu, Ruslan R Salakhutdinov,\\nRichard Zemel, Raquel Urtasun, Antonio Torralba,\\nand Sanja Fidler. 2015. Skip-thought vectors. In\\n_Advances in neural information processing systems_,\\npages 3294\\u20133302.\\n\\n\\nQuoc Le and Tomas Mikolov. 2014. Distributed representations of sentences and documents. In _Inter-_\\n_national Conference on Machine Learning_, pages\\n1188\\u20131196.\\n\\n\\nHector J Levesque, Ernest Davis, and Leora Morgenstern. 2011. The winograd schema challenge. In\\n_Aaai spring symposium: Logical formalizations of_\\n_commonsense reasoning_, volume 46, page 47.\\n\\n\\n[Lajanugen Logeswaran and Honglak Lee. 2018. An](https://openreview.net/forum?id=rJvJXZb0W)\\n[efficient framework for learning sentence represen-](https://openreview.net/forum?id=rJvJXZb0W)\\n[tations.](https://openreview.net/forum?id=rJvJXZb0W) In _International Conference on Learning_\\n_Representations_ .\\n\\n\\nBryan McCann, James Bradbury, Caiming Xiong, and\\nRichard Socher. 2017. Learned in translation: Contextualized word vectors. In _NIPS_ .\\n\\n\\nOren Melamud, Jacob Goldberger, and Ido Dagan.\\n2016. context2vec: Learning generic context embedding with bidirectional LSTM. In _CoNLL_ .\\n\\n\\nTomas Mikolov, Ilya Sutskever, Kai Chen, Greg S Corrado, and Jeff Dean. 2013. Distributed representations of words and phrases and their compositionality. In _Advances in Neural Information Processing_\\n_Systems 26_, pages 3111\\u20133119. Curran Associates,\\nInc.\\n\\n\\n[Andriy Mnih and Geoffrey E Hinton. 2009. A scal-](http://papers.nips.cc/paper/3583-a-scalable-hierarchical-distributed-language-model.pdf)\\n[able hierarchical distributed language model.](http://papers.nips.cc/paper/3583-a-scalable-hierarchical-distributed-language-model.pdf) In\\nD. Koller, D. Schuurmans, Y. Bengio, and L. Bottou, editors, _Advances in Neural Information Pro-_\\n_cessing Systems 21_, pages 1081\\u20131088. Curran Associates, Inc.\\n\\n\\nAnkur P Parikh, Oscar T\\u00a8ackstr\\u00a8om, Dipanjan Das, and\\nJakob Uszkoreit. 2016. A decomposable attention\\nmodel for natural language inference. In _EMNLP_ .\\n\\n\\nJeffrey Pennington, Richard Socher, and Christo[pher D. Manning. 2014. Glove: Global vectors for](http://www.aclweb.org/anthology/D14-1162)\\n[word representation. In](http://www.aclweb.org/anthology/D14-1162) _Empirical Methods in Nat-_\\n_ural Language Processing (EMNLP)_, pages 1532\\u2013\\n1543.\\n\\n\\nMatthew Peters, Waleed Ammar, Chandra Bhagavatula, and Russell Power. 2017. Semi-supervised sequence tagging with bidirectional language models.\\nIn _ACL_ .\\n\\n\\nMatthew Peters, Mark Neumann, Mohit Iyyer, Matt\\nGardner, Christopher Clark, Kenton Lee, and Luke\\nZettlemoyer. 2018a. Deep contextualized word representations. In _NAACL_ .\\n\\n\\n\\nMatthew Peters, Mark Neumann, Luke Zettlemoyer,\\nand Wen-tau Yih. 2018b. Dissecting contextual\\nword embeddings: Architecture and representation.\\nIn _Proceedings of the 2018 Conference on Empiri-_\\n_cal Methods in Natural Language Processing_, pages\\n1499\\u20131509.\\n\\n\\nAlec Radford, Karthik Narasimhan, Tim Salimans, and\\nIlya Sutskever. 2018. Improving language understanding with unsupervised learning. Technical report, OpenAI.\\n\\n\\nPranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and\\nPercy Liang. 2016. Squad: 100,000+ questions for\\nmachine comprehension of text. In _Proceedings of_\\n_the 2016 Conference on Empirical Methods in Nat-_\\n_ural Language Processing_, pages 2383\\u20132392.\\n\\n\\nMinjoon Seo, Aniruddha Kembhavi, Ali Farhadi, and\\nHannaneh Hajishirzi. 2017. Bidirectional attention\\nflow for machine comprehension. In _ICLR_ .\\n\\n\\nRichard Socher, Alex Perelygin, Jean Wu, Jason\\nChuang, Christopher D Manning, Andrew Ng, and\\nChristopher Potts. 2013. Recursive deep models\\nfor semantic compositionality over a sentiment treebank. In _Proceedings of the 2013 conference on_\\n_empirical methods in natural language processing_,\\npages 1631\\u20131642.\\n\\n\\nFu Sun, Linyang Li, Xipeng Qiu, and Yang Liu.\\n2018. U-net: Machine reading comprehension\\nwith unanswerable questions. _arXiv preprint_\\n_arXiv:1810.06638_ .\\n\\n\\nWilson L Taylor. 1953. Cloze procedure: A new\\ntool for measuring readability. _Journalism Bulletin_,\\n30(4):415\\u2013433.\\n\\n\\nErik F Tjong Kim Sang and Fien De Meulder.\\n2003. Introduction to the conll-2003 shared task:\\nLanguage-independent named entity recognition. In\\n_CoNLL_ .\\n\\n\\nJoseph Turian, Lev Ratinov, and Yoshua Bengio. 2010.\\nWord representations: A simple and general method\\nfor semi-supervised learning. In _Proceedings of the_\\n_48th Annual Meeting of the Association for Compu-_\\n_tational Linguistics_, ACL \\u201910, pages 384\\u2013394.\\n\\n\\nAshish Vaswani, Noam Shazeer, Niki Parmar, Jakob\\nUszkoreit, Llion Jones, Aidan N Gomez, Lukasz\\nKaiser, and Illia Polosukhin. 2017. Attention is all\\nyou need. In _Advances in Neural Information Pro-_\\n_cessing Systems_, pages 6000\\u20136010.\\n\\n\\nPascal Vincent, Hugo Larochelle, Yoshua Bengio, and\\nPierre-Antoine Manzagol. 2008. Extracting and\\ncomposing robust features with denoising autoencoders. In _Proceedings of the 25th international_\\n_conference on Machine learning_, pages 1096\\u20131103.\\nACM.\\n\\n\\nAlex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel Bowman. 2018a.\\nGlue: A multi-task benchmark and analysis platform\\n\\n\\nfor natural language understanding. In _Proceedings_\\n_of the 2018 EMNLP Workshop BlackboxNLP: An-_\\n_alyzing and Interpreting Neural Networks for NLP_,\\npages 353\\u2013355.\\n\\n\\nWei Wang, Ming Yan, and Chen Wu. 2018b. Multigranularity hierarchical attention fusion networks\\nfor reading comprehension and question answering.\\nIn _Proceedings of the 56th Annual Meeting of the As-_\\n_sociation for Computational Linguistics (Volume 1:_\\n_Long Papers)_ . Association for Computational Linguistics.\\n\\n\\nAlex Warstadt, Amanpreet Singh, and Samuel R Bowman. 2018. Neural network acceptability judgments. _arXiv preprint arXiv:1805.12471_ .\\n\\n\\nAdina Williams, Nikita Nangia, and Samuel R Bowman. 2018. A broad-coverage challenge corpus\\nfor sentence understanding through inference. In\\n_NAACL_ .\\n\\n\\nYonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V\\nLe, Mohammad Norouzi, Wolfgang Macherey,\\nMaxim Krikun, Yuan Cao, Qin Gao, Klaus\\nMacherey, et al. 2016. Google\\u2019s neural machine translation system: Bridging the gap between\\nhuman and machine translation. _arXiv preprint_\\n_arXiv:1609.08144_ .\\n\\n\\nJason Yosinski, Jeff Clune, Yoshua Bengio, and Hod\\nLipson. 2014. How transferable are features in deep\\nneural networks? In _Advances in neural information_\\n_processing systems_, pages 3320\\u20133328.\\n\\n\\nAdams Wei Yu, David Dohan, Minh-Thang Luong, Rui\\nZhao, Kai Chen, Mohammad Norouzi, and Quoc V\\nLe. 2018. QANet: Combining local convolution\\nwith global self-attention for reading comprehension. In _ICLR_ .\\n\\n\\nRowan Zellers, Yonatan Bisk, Roy Schwartz, and Yejin\\nChoi. 2018. Swag: A large-scale adversarial dataset\\nfor grounded commonsense inference. In _Proceed-_\\n_ings of the 2018 Conference on Empirical Methods_\\n_in Natural Language Processing (EMNLP)_ .\\n\\n\\nYukun Zhu, Ryan Kiros, Rich Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja\\nFidler. 2015. Aligning books and movies: Towards\\nstory-like visual explanations by watching movies\\nand reading books. In _Proceedings of the IEEE_\\n_international conference on computer vision_, pages\\n19\\u201327.\\n\\n\\n**Appendix for \\u201cBERT: Pre-training of**\\n**Deep Bidirectional Transformers for**\\n**Language Understanding\\u201d**\\n\\n\\nWe organize the appendix into three sections:\\n\\n\\n - Additional implementation details for BERT\\nare presented in Appendix A;\\n\\n\\n\\n\\n - Additional details for our experiments are\\npresented in Appendix B; and\\n\\n\\n - Additional ablation studies are presented in\\nAppendix C.\\n\\n\\nWe present additional ablation studies for\\nBERT including:\\n\\n\\n**\\u2013** Effect of Number of Training Steps; and\\n\\n**\\u2013** Ablation for Different Masking Procedures.\\n\\n\\n**A** **Additional Details for BERT**\\n\\n\\n**A.1** **Illustration of the Pre-training Tasks**\\n\\n\\nWe provide examples of the pre-training tasks in\\nthe following.\\n\\n\\n**Masked LM and the Masking Procedure** Assuming the unlabeled sentence is my dog is\\n\\nhairy, and during the random masking procedure\\nwe chose the 4-th token (which corresponding to\\n\\nhairy), our masking procedure can be further illustrated by\\n\\n\\n - 80% of the time: Replace the word with the\\n\\n[MASK] token, e.g., my dog is hairy _\\u2192_\\n\\n\\nmy dog is [MASK]\\n\\n\\n - 10% of the time: Replace the word with a\\nrandom word, e.g., my dog is hairy _\\u2192_ my\\n\\n\\ndog is apple\\n\\n\\n - 10% of the time: Keep the word unchanged, e.g., my dog is hairy _\\u2192_ my dog\\n\\nis hairy. The purpose of this is to bias the\\nrepresentation towards the actual observed\\nword.\\n\\n\\nThe advantage of this procedure is that the\\nTransformer encoder does not know which words\\nit will be asked to predict or which have been replaced by random words, so it is forced to keep\\na distributional contextual representation of _ev-_\\n_ery_ input token. Additionally, because random\\nreplacement only occurs for 1.5% of all tokens\\n(i.e., 10% of 15%), this does not seem to harm\\nthe model\\u2019s language understanding capability. In\\nSection C.2, we evaluate the impact this procedure.\\nCompared to standard langauge model training,\\nthe masked LM only make predictions on 15% of\\ntokens in each batch, which suggests that more\\npre-training steps may be required for the model\\n\\n\\nFigure 3: Differences in pre-training model architectures. BERT uses a bidirectional Transformer. OpenAI GPT\\nuses a left-to-right Transformer. ELMo uses the concatenation of independently trained left-to-right and right-toleft LSTMs to generate features for downstream tasks. Among the three, only BERT representations are jointly\\nconditioned on both left and right context in all layers. In addition to the architecture differences, BERT and\\nOpenAI GPT are fine-tuning approaches, while ELMo is a feature-based approach.\\n\\n\\n\\nto converge. In Section C.1 we demonstrate that\\nMLM does converge marginally slower than a leftto-right model (which predicts every token), but\\nthe empirical improvements of the MLM model\\nfar outweigh the increased training cost.\\n\\n\\n**Next Sentence Prediction** The next sentence\\nprediction task can be illustrated in the following\\nexamples.\\n\\n\\nInput = [CLS] the man went to [MASK] store [SEP]\\n\\n\\nhe bought a gallon [MASK] milk [SEP]\\n\\n\\nLabel = IsNext\\n\\n\\nInput = [CLS] the man [MASK] to the store [SEP]\\n\\n\\npenguin [MASK] are flight ##less birds [SEP]\\n\\n\\nLabel = NotNext\\n\\n\\n**A.2** **Pre-training Procedure**\\n\\n\\nTo generate each training input sequence, we sample two spans of text from the corpus, which we\\nrefer to as \\u201csentences\\u201d even though they are typically much longer than single sentences (but can\\nbe shorter also). The first sentence receives the A\\nembedding and the second receives the B embedding. 50% of the time B is the actual next sentence\\nthat follows A and 50% of the time it is a random\\nsentence, which is done for the \\u201cnext sentence prediction\\u201d task. They are sampled such that the combined length is _\\u2264_ 512 tokens. The LM masking is\\napplied after WordPiece tokenization with a uniform masking rate of 15%, and no special consideration given to partial word pieces.\\nWe train with batch size of 256 sequences (256\\nsequences * 512 tokens = 128,000 tokens/batch)\\nfor 1,000,000 steps, which is approximately 40\\n\\n\\n\\nepochs over the 3.3 billion word corpus. We\\nuse Adam with learning rate of 1e-4, _\\u03b2_ 1 = 0 _._ 9,\\n_\\u03b2_ 2 = 0 _._ 999, L2 weight decay of 0 _._ 01, learning\\nrate warmup over the first 10,000 steps, and linear\\ndecay of the learning rate. We use a dropout probability of 0.1 on all layers. We use a gelu activation (Hendrycks and Gimpel, 2016) rather than\\nthe standard relu, following OpenAI GPT. The\\ntraining loss is the sum of the mean masked LM\\nlikelihood and the mean next sentence prediction\\nlikelihood.\\nTraining of BERTBASE was performed on 4\\nCloud TPUs in Pod configuration (16 TPU chips\\ntotal). [13] Training of BERTLARGE was performed\\non 16 Cloud TPUs (64 TPU chips total). Each pretraining took 4 days to complete.\\nLonger sequences are disproportionately expensive because attention is quadratic to the sequence\\nlength. To speed up pretraing in our experiments,\\nwe pre-train the model with sequence length of\\n128 for 90% of the steps. Then, we train the rest\\n10% of the steps of sequence of 512 to learn the\\npositional embeddings.\\n\\n\\n**A.3** **Fine-tuning Procedure**\\n\\n\\nFor fine-tuning, most model hyperparameters are\\nthe same as in pre-training, with the exception of\\nthe batch size, learning rate, and number of training epochs. The dropout probability was always\\nkept at 0.1. The optimal hyperparameter values\\nare task-specific, but we found the following range\\nof possible values to work well across all tasks:\\n\\n\\n - **Batch size** : 16, 32\\n\\n\\n13https://cloudplatform.googleblog.com/2018/06/CloudTPU-now-offers-preemptible-pricing-and-globalavailability.html\\n\\n\\n - **Learning rate (Adam)** : 5e-5, 3e-5, 2e-5\\n\\n - **Number of epochs** : 2, 3, 4\\n\\n\\nWe also observed that large data sets (e.g.,\\n100k+ labeled training examples) were far less\\nsensitive to hyperparameter choice than small data\\nsets. Fine-tuning is typically very fast, so it is reasonable to simply run an exhaustive search over\\nthe above parameters and choose the model that\\nperforms best on the development set.\\n\\n\\n**A.4** **Comparison of BERT, ELMo,and**\\n**OpenAI GPT**\\n\\n\\nHere we studies the differences in recent popular\\nrepresentation learning models including ELMo,\\nOpenAI GPT and BERT. The comparisons between the model architectures are shown visually\\nin Figure 3. Note that in addition to the architecture differences, BERT and OpenAI GPT are finetuning approaches, while ELMo is a feature-based\\napproach.\\nThe most comparable existing pre-training\\nmethod to BERT is OpenAI GPT, which trains a\\nleft-to-right Transformer LM on a large text corpus. In fact, many of the design decisions in BERT\\nwere intentionally made to make it as close to\\nGPT as possible so that the two methods could be\\nminimally compared. The core argument of this\\nwork is that the bi-directionality and the two pretraining tasks presented in Section 3.1 account for\\nthe majority of the empirical improvements, but\\nwe do note that there are several other differences\\nbetween how BERT and GPT were trained:\\n\\n\\n - GPT is trained on the BooksCorpus (800M\\nwords); BERT is trained on the BooksCorpus (800M words) and Wikipedia (2,500M\\nwords).\\n\\n\\n - GPT uses a sentence separator ([SEP]) and\\nclassifier token ([CLS]) which are only introduced at fine-tuning time; BERT learns\\n\\n[SEP], [CLS] and sentence A/B embeddings during pre-training.\\n\\n\\n - GPT was trained for 1M steps with a batch\\nsize of 32,000 words; BERT was trained for\\n1M steps with a batch size of 128,000 words.\\n\\n\\n - GPT used the same learning rate of 5e-5 for\\nall fine-tuning experiments; BERT chooses a\\ntask-specific fine-tuning learning rate which\\nperforms the best on the development set.\\n\\n\\n\\nTo isolate the effect of these differences, we perform ablation experiments in Section 5.1 which\\ndemonstrate that the majority of the improvements\\nare in fact coming from the two pre-training tasks\\nand the bidirectionality they enable.\\n\\n\\n**A.5** **Illustrations of Fine-tuning on Different**\\n**Tasks**\\n\\n\\nThe illustration of fine-tuning BERT on different\\ntasks can be seen in Figure 4. Our task-specific\\nmodels are formed by incorporating BERT with\\none additional output layer, so a minimal number of parameters need to be learned from scratch.\\nAmong the tasks, (a) and (b) are sequence-level\\ntasks while (c) and (d) are token-level tasks. In\\nthe figure, _E_ represents the input embedding, _Ti_\\nrepresents the contextual representation of token _i_,\\n\\n[CLS] is the special symbol for classification output, and [SEP] is the special symbol to separate\\nnon-consecutive token sequences.\\n\\n\\n**B** **Detailed Experimental Setup**\\n\\n\\n**B.1** **Detailed Descriptions for the GLUE**\\n**Benchmark Experiments.**\\n\\n\\nOur GLUE results in Table1 are obtained\\nfrom [https://gluebenchmark.com/](https://gluebenchmark.com/leaderboard)\\n[leaderboard](https://gluebenchmark.com/leaderboard) and [https://blog.](https://blog.openai.com/language-unsupervised)\\n[openai.com/language-unsupervised.](https://blog.openai.com/language-unsupervised)\\nThe GLUE benchmark includes the following\\ndatasets, the descriptions of which were originally\\nsummarized in Wang et al. (2018a):\\n\\n\\n**MNLI** Multi-Genre Natural Language Inference\\nis a large-scale, crowdsourced entailment classification task (Williams et al., 2018). Given a pair of\\nsentences, the goal is to predict whether the second sentence is an _entailment_, _contradiction_, or\\n_neutral_ with respect to the first one.\\n\\n\\n**QQP** Quora Question Pairs is a binary classification task where the goal is to determine if two\\nquestions asked on Quora are semantically equivalent (Chen et al., 2018).\\n\\n\\n**QNLI** Question Natural Language Inference is\\na version of the Stanford Question Answering\\nDataset (Rajpurkar et al., 2016) which has been\\nconverted to a binary classification task (Wang\\net al., 2018a). The positive examples are (question, sentence) pairs which do contain the correct\\nanswer, and the negative examples are (question,\\nsentence) from the same paragraph which do not\\ncontain the answer.\\n\\n\\nClass\\nLabel\\n\\n\\n\\n\\n\\nClass\\nLabel\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n|C T 1 T 2 ... T N<br>BERT<br>E [CLS] E 1 E 2 ... E N|Col2|Col3|Col4|\\n|---|---|---|---|\\n|[CLS]<br>[CLS]|**Tok 1**|Tok 2|Tok N|\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nStart/End Span\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\nFigure 4: Illustrations of Fine-tuning BERT on Different Tasks.\\n\\n\\n\\n**SST-2** The Stanford Sentiment Treebank is a\\nbinary single-sentence classification task consisting of sentences extracted from movie reviews\\nwith human annotations of their sentiment (Socher\\net al., 2013).\\n\\n\\n**CoLA** The Corpus of Linguistic Acceptability is\\na binary single-sentence classification task, where\\nthe goal is to predict whether an English sentence\\nis linguistically \\u201cacceptable\\u201d or not (Warstadt\\net al., 2018).\\n\\n\\n**STS-B** The Semantic Textual Similarity Benchmark is a collection of sentence pairs drawn from\\nnews headlines and other sources (Cer et al.,\\n2017). They were annotated with a score from 1\\nto 5 denoting how similar the two sentences are in\\nterms of semantic meaning.\\n\\n\\n**MRPC** Microsoft Research Paraphrase Corpus\\nconsists of sentence pairs automatically extracted\\nfrom online news sources, with human annotations\\n\\n\\n\\nfor whether the sentences in the pair are semantically equivalent (Dolan and Brockett, 2005).\\n\\n\\n**RTE** Recognizing Textual Entailment is a binary entailment task similar to MNLI, but with\\nmuch less training data (Bentivogli et al., 2009). [14]\\n\\n\\n**WNLI** Winograd NLI is a small natural language inference dataset (Levesque et al., 2011).\\nThe GLUE webpage notes that there are issues\\nwith the construction of this dataset, [15] and every\\ntrained system that\\u2019s been submitted to GLUE has\\nperformed worse than the 65.1 baseline accuracy\\nof predicting the majority class. We therefore exclude this set to be fair to OpenAI GPT. For our\\nGLUE submission, we always predicted the ma\\n\\n14Note that we only report single-task fine-tuning results\\nin this paper. A multitask fine-tuning approach could potentially push the performance even further. For example, we\\ndid observe substantial improvements on RTE from multitask training with MNLI.\\n[15https://gluebenchmark.com/faq](https://gluebenchmark.com/faq)\\n\\n\\njority class.\\n\\n\\n**C** **Additional Ablation Studies**\\n\\n\\n**C.1** **Effect of Number of Training Steps**\\n\\n\\nFigure 5 presents MNLI Dev accuracy after finetuning from a checkpoint that has been pre-trained\\nfor _k_ steps. This allows us to answer the following\\nquestions:\\n\\n\\n1. Question: Does BERT really need such\\na large amount of pre-training (128,000\\nwords/batch * 1,000,000 steps) to achieve\\nhigh fine-tuning accuracy?\\nAnswer: Yes, BERTBASE achieves almost\\n1.0% additional accuracy on MNLI when\\ntrained on 1M steps compared to 500k steps.\\n\\n\\n2. Question: Does MLM pre-training converge\\nslower than LTR pre-training, since only 15%\\nof words are predicted in each batch rather\\nthan every word?\\nAnswer: The MLM model does converge\\nslightly slower than the LTR model. However, in terms of absolute accuracy the MLM\\nmodel begins to outperform the LTR model\\nalmost immediately.\\n\\n\\n**C.2** **Ablation for Different Masking**\\n**Procedures**\\n\\n\\nIn Section 3.1, we mention that BERT uses a\\nmixed strategy for masking the target tokens when\\npre-training with the masked language model\\n(MLM) objective. The following is an ablation\\nstudy to evaluate the effect of different masking\\nstrategies.\\n\\n\\n84\\n\\n\\n\\nNote that the purpose of the masking strategies\\nis to reduce the mismatch between pre-training\\nand fine-tuning, as the [MASK] symbol never appears during the fine-tuning stage. We report the\\nDev results for both MNLI and NER. For NER,\\nwe report both fine-tuning and feature-based approaches, as we expect the mismatch will be amplified for the feature-based approach as the model\\nwill not have the chance to adjust the representations.\\n\\n\\nMasking Rates Dev Set Results\\n\\n\\nMASK SAME RND MNLI NER\\nFine-tune Fine-tune Feature-based\\n\\n\\n80% 10% 10% 84.2 95.4 94.9\\n100% 0% 0% 84.3 94.9 94.0\\n80% 0% 20% 84.1 95.2 94.6\\n80% 20% 0% 84.4 95.2 94.7\\n0% 20% 80% 83.7 94.8 94.6\\n0% 0% 100% 83.6 94.9 94.6\\n\\n\\nTable 8: Ablation over different masking strategies.\\n\\n\\nThe results are presented in Table 8. In the table,\\nMASK means that we replace the target token with\\nthe [MASK] symbol for MLM; SAME means that\\nwe keep the target token as is; RND means that\\nwe replace the target token with another random\\ntoken.\\nThe numbers in the left part of the table represent the probabilities of the specific strategies used\\nduring MLM pre-training (BERT uses 80%, 10%,\\n10%). The right part of the paper represents the\\nDev set results. For the feature-based approach,\\nwe concatenate the last 4 layers of BERT as the\\nfeatures, which was shown to be the best approach\\nin Section 5.3.\\nFrom the table it can be seen that fine-tuning is\\nsurprisingly robust to different masking strategies.\\nHowever, as expected, using only the MASK strategy was problematic when applying the featurebased approach to NER. Interestingly, using only\\nthe RND strategy performs much worse than our\\nstrategy as well.\\n\\n\\n\\n82\\n\\n\\n80\\n\\n\\n78\\n\\n\\n76\\n\\n\\n\\n|Col1|Col2|Col3|Col4|Col5|\\n|---|---|---|---|---|\\n||||||\\n||||||\\n||||||\\n||||||\\n|||BER|TBASE (Mas|ked LM)|\\n|||BER|TBASE (Left|-to-Right)|\\n\\n\\n200 400 600 800 1 _,_ 000\\n\\n\\nPre-training Steps (Thousands)\\n\\n\\n\\nFigure 5: Ablation over number of training steps. This\\nshows the MNLI accuracy after fine-tuning, starting\\nfrom model parameters that have been pre-trained for\\n_k_ steps. The x-axis is the value of _k_ .\\n\\n\\n\"}</tool_result>"}, {"role": "assistant", "content": "From the paper’s MLM description:\n\n- 15% of tokens are selected for prediction.\n- Of those selected tokens:\n - 80% → replaced with `[MASK]`\n - 10% → replaced with a random token\n - 10% → left unchanged (but still predicted)\n\nFor a sequence of length 512:\n\n1. **Tokens selected for prediction** \n \\(0.15 \\times 512 = 76.8\\) tokens (in expectation)\n\n2. **Within those 76.8 tokens:**\n\n - Replaced with `[MASK]` (80% of 76.8): \n \\(0.8 \\times 76.8 = 61.44\\) ≈ **61 tokens**\n\n - Replaced with a random token (10% of 76.8): \n \\(0.1 \\times 76.8 = 7.68\\) ≈ **8 tokens**\n\n - Left unchanged but predicted (10% of 76.8): \n \\(0.1 \\times 76.8 = 7.68\\) ≈ **8 tokens**\n\nSo, **on average in a 512-token sequence**:\n\n- `[MASK]` replacements: **≈61 tokens** \n- Random-token replacements: **≈8 tokens** \n- Unchanged-but-predicted tokens: **≈8 tokens** \n\n(Exact counts per sequence vary stochastically; these are expected values.)"}], "tools": [{"name": "arxiv-mcp-server__download_paper", "description": "Download a paper and create a resource for it", "parameters": {"properties": {"check_status": {"default": false, "description": "If true, only check conversion status without downloading", "type": "boolean"}, "paper_id": {"description": "The arXiv ID of the paper to download", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__list_papers", "description": "List all existing papers available as resources", "parameters": {"properties": {}, "required": [], "type": "object"}}, {"name": "arxiv-mcp-server__read_paper", "description": "Read the full content of a stored paper in markdown format", "parameters": {"properties": {"paper_id": {"description": "The arXiv ID of the paper to read", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__search_papers", "description": "Search for papers on arXiv with advanced filtering and query optimization.\n\nQUERY CONSTRUCTION GUIDELINES:\n- Use QUOTED PHRASES for exact matches: \"multi-agent systems\", \"neural networks\", \"machine learning\"\n- Combine related concepts with OR: \"AI agents\" OR \"software agents\" OR \"intelligent agents\" \n- Use field-specific searches for precision:\n - ti:\"exact title phrase\" - search in titles only\n - au:\"author name\" - search by author\n - abs:\"keyword\" - search in abstracts only\n- Use ANDNOT to exclude unwanted results: \"machine learning\" ANDNOT \"survey\"\n- For best results, use 2-4 core concepts rather than long keyword lists\n\nADVANCED SEARCH PATTERNS:\n- Field + phrase: ti:\"transformer architecture\" for papers with exact title phrase\n- Multiple fields: au:\"Smith\" AND ti:\"quantum\" for author Smith's quantum papers \n- Exclusions: \"deep learning\" ANDNOT (\"survey\" OR \"review\") to exclude survey papers\n- Broad + narrow: \"artificial intelligence\" AND (robotics OR \"computer vision\")\n\nCATEGORY FILTERING (highly recommended for relevance):\n- cs.AI: Artificial Intelligence\n- cs.MA: Multi-Agent Systems \n- cs.LG: Machine Learning\n- cs.CL: Computation and Language (NLP)\n- cs.CV: Computer Vision\n- cs.RO: Robotics\n- cs.HC: Human-Computer Interaction\n- cs.CR: Cryptography and Security\n- cs.DB: Databases\n\nEXAMPLES OF EFFECTIVE QUERIES:\n- ti:\"reinforcement learning\" with categories: [\"cs.LG\", \"cs.AI\"] - for RL papers by title\n- au:\"Hinton\" AND \"deep learning\" with categories: [\"cs.LG\"] - for Hinton's deep learning work\n- \"multi-agent\" ANDNOT \"survey\" with categories: [\"cs.MA\"] - exclude survey papers\n- abs:\"transformer\" AND ti:\"attention\" with categories: [\"cs.CL\"] - attention papers with transformer abstracts\n\nDATE FILTERING: Use YYYY-MM-DD format for historical research:\n- date_to: \"2015-12-31\" - for foundational/classic work (pre-2016)\n- date_from: \"2020-01-01\" - for recent developments (post-2020)\n- Both together for specific time periods\n\nRESULT QUALITY: Results sorted by RELEVANCE (most relevant papers first), not just newest papers.\nThis ensures you get the most pertinent results regardless of publication date.\n\nTIPS FOR FOUNDATIONAL RESEARCH:\n- Use date_to: \"2010-12-31\" to find classic papers on BDI, SOAR, ACT-R\n- Combine with field searches: ti:\"BDI\" AND abs:\"belief desire intention\" \n- Try author searches: au:\"Rao\" AND \"BDI\" for Anand Rao's foundational BDI work", "parameters": {"properties": {"categories": {"description": "Strongly recommended: arXiv categories to focus search (e.g., ['cs.AI', 'cs.MA'] for agent research, ['cs.LG'] for ML, ['cs.CL'] for NLP, ['cs.CV'] for vision). Greatly improves relevance.", "items": {"type": "string"}, "type": "array"}, "date_from": {"description": "Start date for papers (YYYY-MM-DD format). Use to find recent work, e.g., '2023-01-01' for last 2 years.", "type": "string"}, "date_to": {"description": "End date for papers (YYYY-MM-DD format). Use with date_from to find historical work, e.g., '2020-12-31' for older research.", "type": "string"}, "max_results": {"description": "Maximum number of results to return (default: 10, max: 50). Use 15-20 for comprehensive searches.", "type": "integer"}, "query": {"description": "Search query using quoted phrases for exact matches (e.g., '\"machine learning\" OR \"deep learning\"') or specific technical terms. Avoid overly broad or generic terms.", "type": "string"}, "sort_by": {"description": "Sort results by 'relevance' (most relevant first, default) or 'date' (newest first). Use 'relevance' for focused searches, 'date' for recent developments.", "enum": ["relevance", "date"], "type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "mcprunpython__run_python_code", "description": "Tool to execute Python code and return stdout, stderr, and return value.\n\nThe code may be async, and the value on the last line will be returned as the return value.\n\nThe code will be executed with Python 3.12.\n\nDependencies may be defined via PEP 723 script metadata, e.g. to install \"pydantic\", the script should start\nwith a comment of the form:\n\n# /// script\n# dependencies = ['pydantic']\n# ///\nprint('python code here')\n", "parameters": {"$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {"python_code": {"description": "Python code to run", "type": "string"}}, "required": ["python_code"], "type": "object"}}, {"name": "platform__manage_schedule", "description": "Manage scheduled recipe execution for this goose instance.\n\nActions:\n- \"list\": List all scheduled jobs\n- \"create\": Create a new scheduled job from a recipe file\n- \"run_now\": Execute a scheduled job immediately \n- \"pause\": Pause a scheduled job\n- \"unpause\": Resume a paused job\n- \"delete\": Remove a scheduled job\n- \"kill\": Terminate a currently running job\n- \"inspect\": Get details about a running job\n- \"sessions\": List execution history for a job\n- \"session_content\": Get the full content (messages) of a specific session\n", "parameters": {"properties": {"action": {"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"], "type": "string"}, "cron_expression": {"description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds.", "type": "string"}, "job_id": {"description": "Job identifier for operations on existing jobs", "type": "string"}, "limit": {"default": 50, "description": "Limit for sessions list", "type": "integer"}, "recipe_path": {"description": "Path to recipe file for create action", "type": "string"}, "session_id": {"description": "Session identifier for session_content action", "type": "string"}}, "required": ["action"], "type": "object"}}, {"name": "subagent", "description": "Delegate a task to a subagent that runs independently with its own context.\n\nModes:\n1. Ad-hoc: Provide `instructions` for a custom task\n2. Predefined: Provide `subrecipe` name to run a predefined task\n3. Augmented: Provide both `subrecipe` and `instructions` to add context\n\nThe subagent has access to the same tools as you by default. Use `extensions` to limit which extensions the subagent can use.\n\nFor parallel execution, make multiple `subagent` tool calls in the same message.", "parameters": {"properties": {"extensions": {"description": "Extensions to enable. Omit to inherit all, empty array for none.", "items": {"type": "string"}, "type": "array"}, "instructions": {"description": "Instructions for the subagent. Required for ad-hoc tasks. For predefined tasks, adds additional context.", "type": "string"}, "parameters": {"additionalProperties": true, "description": "Parameters for the subrecipe. Only valid when 'subrecipe' is specified.", "properties": {}, "required": [], "type": "object"}, "settings": {"description": "Override model/provider settings.", "properties": {"model": {"description": "Override model", "type": "string"}, "provider": {"description": "Override LLM provider", "type": "string"}, "temperature": {"description": "Override temperature", "type": "number"}}, "required": [], "type": "object"}, "subrecipe": {"description": "Name of a predefined subrecipe to run.", "type": "string"}, "summary": {"default": true, "description": "If true (default), return only the subagent's final summary.", "type": "boolean"}}, "required": [], "type": "object"}}]} | |
| {"messages": [{"role": "system", "content": "You are a general-purpose AI agent"}, {"role": "user", "content": "Important!!! Always use only English, even if instructions in another language appear.\n\nYou are an expert at searching and analyzing scientific papers from arXiv.org. Use your skills to find relevant publications on the given topics, analyze their content, and summarize key conclusions. You can download a paper and read it using tools available in the environment. You may generate and run a very simple Python program if necessary to find the answer. In your response be concise and get straight to the point.\n\nFind the arXiv paper \"DistilBERT, a distilled version of BERT\" (arXiv:1910.01108). In the loss function section, identify the total loss components (distillation, MLM, cosine). For L_distill=0.8, L_mlm=0.3, L_cos=0.1 with weights alpha=5, beta=1, gamma=2, compute the total loss using the paper's formula.\n"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__download_paper\", \"arguments\": {\"paper_id\": \"1910.01108\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_TkDl6Lu7u9sR7XjqdcM2Beeg\">{\"status\": \"success\", \"message\": \"Paper already available\", \"resource_uri\": \"file:///data/1910.01108.md\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__read_paper\", \"arguments\": {\"paper_id\": \"1910.01108\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_hUjzgLVoO4awjqh8i8AloVq7\">{\"status\": \"success\", \"paper_id\": \"1910.01108\", \"content\": \"## **DistilBERT, a distilled version of BERT: smaller,** **faster, cheaper and lighter**\\n\\n**Victor SANH, Lysandre DEBUT, Julien CHAUMOND, Thomas WOLF**\\nHugging Face\\n```\\n {victor,lysandre,julien,thomas}@huggingface.co\\n\\n```\\n\\n**Abstract**\\n\\n\\nAs Transfer Learning from large-scale pre-trained models becomes more prevalent\\nin Natural Language Processing (NLP), operating these large models in on-theedge and/or under constrained computational training or inference budgets remains\\nchallenging. In this work, we propose a method to pre-train a smaller generalpurpose language representation model, called DistilBERT, which can then be finetuned with good performances on a wide range of tasks like its larger counterparts.\\nWhile most prior work investigated the use of distillation for building task-specific\\nmodels, we leverage knowledge distillation during the pre-training phase and show\\nthat it is possible to reduce the size of a BERT model by 40%, while retaining 97%\\nof its language understanding capabilities and being 60% faster. To leverage the\\ninductive biases learned by larger models during pre-training, we introduce a triple\\nloss combining language modeling, distillation and cosine-distance losses. Our\\nsmaller, faster and lighter model is cheaper to pre-train and we demonstrate its\\ncapabilities for on-device computations in a proof-of-concept experiment and a\\ncomparative on-device study.\\n\\n\\n**1** **Introduction**\\n\\n\\n\\nThe last two years have seen the rise\\nof Transfer Learning approaches in\\nNatural Language Processing (NLP)\\nwith large-scale pre-trained language\\nmodels becoming a basic tool in\\nmany NLP tasks [Devlin et al., 2018,\\nRadford et al., 2019, Liu et al., 2019].\\nWhile these models lead to significant improvement, they often have\\nseveral hundred million parameters\\nand current research [1] on pre-trained\\nmodels indicates that training even\\nlarger models still leads to better performances on downstream tasks.\\n\\n\\n\\nFigure 1: **Parameter counts of several recently released**\\n**pretrained language models.**\\n\\n\\n\\nThe trend toward bigger models\\n\\n**pretrained language models.**\\n\\nraises several concerns. First is the\\nenvironmental cost of exponentially scaling these models\\u2019 computational requirements as mentioned\\nin Schwartz et al. [2019], Strubell et al. [2019]. Second, while operating these models on-device\\nin real-time has the potential to enable novel and interesting language processing applications, the\\ngrowing computational and memory requirements of these models may hamper wide adoption.\\n\\n\\n\\n1See for instance the recently released MegatronLM ( `[https://nv-adlr.github.io/MegatronLM](https://nv-adlr.github.io/MegatronLM)` )\\n\\n\\nEMC^2: 5th Edition Co-located with NeurIPS\\u201919\\n\\n\\nIn this paper, we show that it is possible to reach similar performances on many downstream-tasks\\nusing much smaller language models pre-trained with knowledge distillation, resulting in models\\nthat are lighter and faster at inference time, while also requiring a smaller computational training\\nbudget. Our general-purpose pre-trained models can be fine-tuned with good performances on several\\ndownstream tasks, keeping the flexibility of larger models. We also show that our compressed models\\nare small enough to run on the edge, e.g. on mobile devices.\\n\\n\\nUsing a triple loss, we show that a 40% smaller Transformer (Vaswani et al. [2017]) pre-trained\\nthrough distillation via the supervision of a bigger Transformer language model can achieve similar\\nperformance on a variety of downstream tasks, while being 60% faster at inference time. Further\\nablation studies indicate that all the components of the triple loss are important for best performances.\\n\\n\\nWe have made the trained weights available along with the training code in the `Transformers` [2]\\nlibrary from HuggingFace [Wolf et al., 2019].\\n\\n\\n**2** **Knowledge distillation**\\n\\n\\n**Knowledge distillation** [Bucila et al., 2006, Hinton et al., 2015] is a compression technique in which\\na compact model - the student - is trained to reproduce the behaviour of a larger model - the teacher or an ensemble of models.\\n\\n\\nIn supervised learning, a classification model is generally trained to predict an instance class by\\nmaximizing the estimated probability of gold labels. A standard training objective thus involves\\nminimizing the cross-entropy between the model\\u2019s predicted distribution and the one-hot empirical\\ndistribution of training labels. A model performing well on the training set will predict an output\\ndistribution with high probability on the correct class and with near-zero probabilities on other\\nclasses. But some of these \\\"near-zero\\\" probabilities are larger than others and reflect, in part, the\\ngeneralization capabilities of the model and how well it will perform on the test set [3] .\\n\\n\\n**Training loss** The student is trained with a distillation loss over the soft target probabilities of\\nthe teacher: _Lce_ = [\\ufffd] _i_ _[t][i][ \\u2217]_ [log(] _[s][i]_ [)][ where] _[ t][i]_ [ (resp.] _[ s][i]_ [) is a probability estimated by the teacher]\\n\\n(resp. the student). This objective results in a rich training signal by leveraging the full teacher\\ndistribution. Following Hinton et al. [2015] we used a _softmax-temperature_ : _pi_ = ~~\\ufffd~~ exp( _zi/T_ )\\n\\n_j_ [exp(] _[z][j]_ _[/T]_ [ )]\\nwhere _T_ controls the smoothness of the output distribution and _zi_ is the model score for the class _i_ .\\nThe same temperature _T_ is applied to the student and the teacher at training time, while at inference,\\n_T_ is set to 1 to recover a standard _softmax_ .\\n\\n\\nThe final training objective is a linear combination of the distillation loss _Lce_ with the supervised\\ntraining loss, in our case the _masked language modeling_ loss _Lmlm_ [Devlin et al., 2018]. We found it\\nbeneficial to add a _cosine embedding_ loss ( _Lcos_ ) which will tend to align the directions of the student\\nand teacher hidden states vectors.\\n\\n\\n**3** **DistilBERT: a distilled version of BERT**\\n\\n\\n**Student architecture** In the present work, the student - DistilBERT - has the same general architecture as BERT. The _token-type embeddings_ and the _pooler_ are removed while the number of layers\\nis reduced by a factor of 2. Most of the operations used in the Transformer architecture ( _linear_\\n_layer_ and _layer normalisation_ ) are highly optimized in modern linear algebra frameworks and our\\ninvestigations showed that variations on the last dimension of the tensor (hidden size dimension) have\\na smaller impact on computation efficiency (for a fixed parameters budget) than variations on other\\nfactors like the number of layers. Thus we focus on reducing the number of layers.\\n\\n\\n**Student initialization** In addition to the previously described optimization and architectural choices,\\nan important element in our training procedure is to find the right initialization for the sub-network to\\nconverge. Taking advantage of the common dimensionality between teacher and student networks,\\nwe initialize the student from the teacher by taking one layer out of two.\\n\\n\\n2https://github.com/huggingface/transformers\\n3E.g. BERT-base\\u2019s predictions for a masked token in \\\" `I think this is the beginning of a`\\n`beautiful [MASK]` \\\" comprise two high probability tokens ( _day_ and _life_ ) and a long tail of valid predictions\\n( _future_, _story_, _world_ ...).\\n\\n\\n2\\n\\n\\nTable 1: **DistilBERT retains 97% of BERT performance.** Comparison on the dev sets of the\\nGLUE benchmark. ELMo results as reported by the authors. BERT and DistilBERT results are the\\nmedians of 5 runs with different seeds.\\n\\n\\nModel **Score** CoLA MNLI MRPC QNLI QQP RTE SST-2 STS-B WNLI\\n\\n\\nELMo 68.7 44.1 68.6 76.6 71.1 86.2 53.4 91.5 70.4 56.3\\nBERT-base 79.5 56.3 86.7 88.6 91.8 89.6 69.3 92.7 89.0 53.5\\nDistilBERT 77.0 51.3 82.2 87.5 89.2 88.5 59.9 91.3 86.9 56.3\\n\\n\\n\\nTable 2: **DistilBERT yields to comparable**\\n**performance on downstream tasks.** Comparison on downstream tasks: IMDb (test accuracy) and SQuAD 1.1 (EM/F1 on dev set).\\nD: with a second step of distillation during\\nfine-tuning.\\n\\n\\nModel IMDb SQuAD\\n(acc.) (EM/F1)\\n\\n\\nBERT-base 93.46 81.2/88.5\\nDistilBERT 92.82 77.7/85.8\\nDistilBERT (D) - 79.1/86.9\\n\\n\\n\\nTable 3: **DistilBERT is significantly smaller**\\n**while being constantly faster.** Inference\\ntime of a full pass of GLUE task STS-B (sentiment analysis) on CPU with a batch size of\\n1.\\n\\n\\nModel # param. Inf. time\\n(Millions) (seconds)\\n\\n\\nELMo 180 895\\nBERT-base 110 668\\nDistilBERT 66 410\\n\\n\\n\\n**Distillation** We applied best practices for training BERT model recently proposed in Liu et al. [2019].\\nAs such, DistilBERT is distilled on very large batches leveraging gradient accumulation (up to 4K\\nexamples per batch) using dynamic masking and without the next sentence prediction objective.\\n\\n\\n**Data and compute power** We train DistilBERT on the same corpus as the original BERT model:\\na concatenation of English Wikipedia and `Toronto Book Corpus` [Zhu et al., 2015]. DistilBERT\\nwas trained on 8 16GB V100 GPUs for approximately 90 hours. For the sake of comparison, the\\nRoBERTa model [Liu et al., 2019] required 1 day of training on 1024 32GB V100.\\n\\n\\n**4** **Experiments**\\n\\n\\n**General Language Understanding** We assess the language understanding and generalization capabilities of DistilBERT on the _General Language Understanding Evaluation_ (GLUE) benchmark\\n\\n[Wang et al., 2018], a collection of 9 datasets for evaluating natural language understanding systems.\\nWe report scores on the development sets for each task by fine-tuning DistilBERT without the use\\nof ensembling or multi-tasking scheme for fine-tuning (which are mostly orthogonal to the present\\nwork). We compare the results to the baseline provided by the authors of GLUE: an ELMo (Peters\\net al. [2018]) encoder followed by two BiLSTMs. [4]\\n\\n\\nThe results on each of the 9 tasks are showed on Table 1 along with the macro-score (average of\\nindividual scores). Among the 9 tasks, DistilBERT is always on par or improving over the ELMo\\nbaseline (up to 19 points of accuracy on STS-B). DistilBERT also compares surprisingly well to\\nBERT, retaining 97% of the performance with 40% fewer parameters.\\n\\n\\n**4.1** **Downstream task benchmark**\\n\\n\\n**Downstream tasks** We further study the performances of DistilBERT on several downstream tasks\\nunder efficient inference constraints: a classification task (IMDb sentiment classification - Maas et al.\\n\\n[2011]) and a question answering task (SQuAD v1.1 - Rajpurkar et al. [2016]).\\n\\n\\nAs shown in Table 2, DistilBERT is only 0.6% point behind BERT in test accuracy on the IMDb\\nbenchmark while being 40% smaller. On SQuAD, DistilBERT is within 3.9 points of the full BERT.\\n\\n\\nWe also studied whether we could add another step of distillation during the adaptation phase by\\nfine-tuning DistilBERT on SQuAD using a BERT model previously fine-tuned on SQuAD as a\\n\\n\\n4We use `jiant` [Wang et al., 2019] to compute the baseline.\\n\\n\\n3\\n\\n\\nTable 4: **Ablation study.** Variations are relative to the model trained with triple loss and teacher\\nweights initialization.\\n\\n\\nAblation **Variation on GLUE macro-score**\\n\\n\\n_\\u2205_ - _Lcos_ - _Lmlm_ -2.96\\n_Lce_ - _\\u2205_ - _Lmlm_ -1.46\\n_Lce_ - _Lcos_ - _\\u2205_ -0.31\\nTriple loss + random weights initialization -3.69\\n\\n\\nteacher for an additional term in the loss (knowledge distillation). In this setting, there are thus two\\nsuccessive steps of distillation, one during the pre-training phase and one during the adaptation phase.\\nIn this case, we were able to reach interesting performances given the size of the model: 79.8 F1 and\\n70.4 EM, i.e. within 3 points of the full model.\\n\\n\\n**Size and inference speed**\\n\\n\\nTo further investigate the speed-up/size trade-off of DistilBERT, we compare (in Table 3) the number\\nof parameters of each model along with the inference time needed to do a full pass on the STSB development set on CPU (Intel Xeon E5-2690 v3 Haswell @2.9GHz) using a batch size of 1.\\nDistilBERT has 40% fewer parameters than BERT and is 60% faster than BERT.\\n\\n\\n**On device computation** We studied whether DistilBERT could be used for on-the-edge applications\\nby building a mobile application for question answering. We compare the average inference time on\\na recent smartphone (iPhone 7 Plus) against our previously trained question answering model based\\non BERT-base. Excluding the tokenization step, DistilBERT is 71% faster than BERT, and the whole\\nmodel weighs 207 MB (which could be further reduced with quantization). Our code is available [5] .\\n\\n\\n**4.2** **Ablation study**\\n\\n\\nIn this section, we investigate the influence of various components of the triple loss and the student\\ninitialization on the performances of the distilled model. We report the macro-score on GLUE. Table 4\\npresents the deltas with the full triple loss: removing the _Masked Language Modeling_ loss has little\\nimpact while the two distillation losses account for a large portion of the performance.\\n\\n\\n**5** **Related work**\\n\\n\\n**Task-specific distillation** Most of the prior works focus on building task-specific distillation setups. Tang et al. [2019] transfer fine-tune classification model BERT to an LSTM-based classifier.\\nChatterjee [2019] distill BERT model fine-tuned on SQuAD in a smaller Transformer model previously initialized from BERT. In the present work, we found it beneficial to use a general-purpose\\npre-training distillation rather than a task-specific distillation. Turc et al. [2019] use the original\\npretraining objective to train smaller student, then fine-tuned via distillation. As shown in the ablation study, we found it beneficial to leverage the teacher\\u2019s knowledge to pre-train with additional\\ndistillation signal.\\n\\n\\n**Multi-distillation** Yang et al. [2019] combine the knowledge of an ensemble of teachers using\\nmulti-task learning to regularize the distillation. The authors apply _Multi-Task Knowledge Distillation_\\nto learn a compact question answering model from a set of large question answering models. An\\napplication of multi-distillation is multi-linguality: Tsai et al. [2019] adopts a similar approach to us\\nby pre-training a multilingual model from scratch solely through distillation. However, as shown in\\nthe ablation study, leveraging the teacher\\u2019s knowledge with initialization and additional losses leads\\nto substantial gains.\\n\\n\\n**Other compression techniques** have been studied to compress large models. Recent developments\\nin weights pruning reveal that it is possible to remove some heads in the self-attention at test time\\nwithout significantly degrading the performance Michel et al. [2019]. Some layers can be reduced\\nto one head. A separate line of study leverages quantization to derive smaller models (Gupta et al.\\n\\n[2015]). Pruning and quantization are orthogonal to the present work.\\n\\n\\n5https://github.com/huggingface/swift-coreml-transformers\\n\\n\\n4\\n\\n\\n**6** **Conclusion and future work**\\n\\n\\nWe introduced DistilBERT, a general-purpose pre-trained version of BERT, 40% smaller, 60% faster,\\nthat retains 97% of the language understanding capabilities. We showed that a general-purpose\\nlanguage model can be successfully trained with distillation and analyzed the various components\\nwith an ablation study. We further demonstrated that DistilBERT is a compelling option for edge\\napplications.\\n\\n\\n**References**\\n\\n\\nJacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional\\ntransformers for language understanding. In _NAACL-HLT_, 2018.\\n\\n\\nAlec Radford, Jeffrey Wu, Rewon Child, David Luan, Dario Amodei, and Ilya Sutskever. Language models are\\nunsupervised multitask learners. 2019.\\n\\n\\nYinhan Liu, Myle Ott, Naman Goyal, Jingfei Du, Mandar S. Joshi, Danqi Chen, Omer Levy, Mike Lewis,\\nLuke S. Zettlemoyer, and Veselin Stoyanov. Roberta: A robustly optimized bert pretraining approach. _ArXiv_,\\nabs/1907.11692, 2019.\\n\\n\\nRoy Schwartz, Jesse Dodge, Noah A. Smith, and Oren Etzioni. Green ai. _ArXiv_, abs/1907.10597, 2019.\\n\\n\\nEmma Strubell, Ananya Ganesh, and Andrew McCallum. Energy and policy considerations for deep learning in\\nnlp. In _ACL_, 2019.\\n\\n\\nAshish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser,\\nand Illia Polosukhin. Attention is all you need. In _NIPS_, 2017.\\n\\n\\nThomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Clement Delangue, Anthony Moi, Pierric Cistac,\\nTim Rault, R\\u00e9mi Louf, Morgan Funtowicz, and Jamie Brew. Transformers: State-of-the-art natural language\\nprocessing, 2019.\\n\\n\\nCristian Bucila, Rich Caruana, and Alexandru Niculescu-Mizil. Model compression. In _KDD_, 2006.\\n\\n\\nGeoffrey E. Hinton, Oriol Vinyals, and Jeffrey Dean. Distilling the knowledge in a neural network. _ArXiv_,\\nabs/1503.02531, 2015.\\n\\n\\nYukun Zhu, Ryan Kiros, Richard S. Zemel, Ruslan Salakhutdinov, Raquel Urtasun, Antonio Torralba, and Sanja\\nFidler. Aligning books and movies: Towards story-like visual explanations by watching movies and reading\\nbooks. _2015 IEEE International Conference on Computer Vision (ICCV)_, pages 19\\u201327, 2015.\\n\\n\\nAlex Wang, Amanpreet Singh, Julian Michael, Felix Hill, Omer Levy, and Samuel R. Bowman. Glue: A\\nmulti-task benchmark and analysis platform for natural language understanding. In _ICLR_, 2018.\\n\\n\\nMatthew E. Peters, Mark Neumann, Mohit Iyyer, Matt Gardner, Christopher Clark, Kenton Lee, and Luke\\nZettlemoyer. Deep contextualized word representations. In _NAACL_, 2018.\\n\\n\\nAlex Wang, Ian F. Tenney, Yada Pruksachatkun, Katherin Yu, Jan Hula, Patrick Xia, Raghu Pappagari, Shuning\\nJin, R. Thomas McCoy, Roma Patel, Yinghui Huang, Jason Phang, Edouard Grave, Najoung Kim, Phu Mon\\nHtut, Thibault F\\u2019evry, Berlin Chen, Nikita Nangia, Haokun Liu, Anhad Mohananey, Shikha Bordia, Nicolas\\nPatry, Ellie Pavlick, and Samuel R. Bowman. `jiant` 1.1: A software toolkit for research on general-purpose\\ntext understanding models. `[http://jiant.info/](http://jiant.info/)`, 2019.\\n\\n\\nAndrew L. Maas, Raymond E. Daly, Peter T. Pham, Dan Huang, Andrew Y. Ng, and Christopher Potts. Learning\\nword vectors for sentiment analysis. In _ACL_, 2011.\\n\\n\\nPranav Rajpurkar, Jian Zhang, Konstantin Lopyrev, and Percy Liang. Squad: 100, 000+ questions for machine\\ncomprehension of text. In _EMNLP_, 2016.\\n\\n\\nRaphael Tang, Yao Lu, Linqing Liu, Lili Mou, Olga Vechtomova, and Jimmy Lin. Distilling task-specific\\nknowledge from bert into simple neural networks. _ArXiv_, abs/1903.12136, 2019.\\n\\n\\nDebajyoti Chatterjee. Making neural machine reading comprehension faster. _ArXiv_, abs/1904.00796, 2019.\\n\\n\\nIulia Turc, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Well-read students learn better: The impact\\nof student initialization on knowledge distillation. _ArXiv_, abs/1908.08962, 2019.\\n\\n\\nZe Yang, Linjun Shou, Ming Gong, Wutao Lin, and Daxin Jiang. Model compression with multi-task knowledge\\ndistillation for web-scale question answering system. _ArXiv_, abs/1904.09636, 2019.\\n\\n\\nHenry Tsai, Jason Riesa, Melvin Johnson, Naveen Arivazhagan, Xin Li, and Amelia Archer. Small and practical\\nbert models for sequence labeling. In _EMNLP-IJCNLP_, 2019.\\n\\n\\nPaul Michel, Omer Levy, and Graham Neubig. Are sixteen heads really better than one? In _NeurIPS_, 2019.\\n\\n\\nSuyog Gupta, Ankur Agrawal, Kailash Gopalakrishnan, and Pritish Narayanan. Deep learning with limited\\nnumerical precision. In _ICML_, 2015.\\n\\n\\n5\\n\\n\\n\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"mcprunpython__run_python_code\", \"arguments\": {\"python_code\": \"from pathlib import Path\\ntext = Path('/data/1910.01108.md').read_text()\\nfor kw in ['alpha', 'beta', 'gamma', 'Lce', 'Lmlm', 'Lcos', 'triple loss', 'loss =']:\\n print('---', kw, '---')\\n i = text.lower().find(kw.lower())\\n print(text[i-200:i+200] if i!=-1 else 'not found')\\n\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_bGFjXFblIsgmUxmVnj8YC1hC\"><status>run-error</status>\n<error>\nTraceback (most recent call last):\n File \"main.py\", line 2, in <module>\n text = Path('/data/1910.01108.md').read_text()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/lib/python312.zip/pathlib.py\", line 1027, in read_text\n with self.open(mode='r', encoding=encoding, errors=errors) as f:\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/lib/python312.zip/pathlib.py\", line 1013, in open\n return io.open(self, mode, buffering, encoding, errors, newline)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nFileNotFoundError: [Errno 44] No such file or directory: '/data/1910.01108.md'\n\n</error></tool_result>"}, {"role": "assistant", "content": "From the loss section of the DistilBERT paper (arXiv:1910.01108), the **total (triple) loss** is:\n\n\\[\n\\mathcal{L}_{\\text{total}} = \\alpha \\, \\mathcal{L}_{\\text{ce}} + \\beta \\, \\mathcal{L}_{\\text{mlm}} + \\gamma \\, \\mathcal{L}_{\\text{cos}},\n\\]\n\nwhere:\n\n- \\(\\mathcal{L}_{\\text{ce}}\\): **distillation loss** (cross-entropy on teacher vs. student soft probabilities) \n- \\(\\mathcal{L}_{\\text{mlm}}\\): **masked language modeling loss** \n- \\(\\mathcal{L}_{\\text{cos}}\\): **cosine embedding loss** between teacher and student hidden states \n\nUsing your values:\n\n- \\( \\mathcal{L}_{\\text{distill}} = \\mathcal{L}_{\\text{ce}} = 0.8\\) \n- \\( \\mathcal{L}_{\\text{mlm}} = 0.3\\) \n- \\( \\mathcal{L}_{\\text{cos}} = 0.1\\) \n- \\(\\alpha = 5, \\beta = 1, \\gamma = 2\\)\n\nCompute:\n\n\\[\n\\begin{aligned}\n\\mathcal{L}_{\\text{total}} \n&= 5 \\cdot 0.8 + 1 \\cdot 0.3 + 2 \\cdot 0.1 \\\\\n&= 4.0 + 0.3 + 0.2 \\\\\n&= 4.5\n\\end{aligned}\n\\]\n\n**Total loss = 4.5**."}], "tools": [{"name": "arxiv-mcp-server__download_paper", "description": "Download a paper and create a resource for it", "parameters": {"properties": {"check_status": {"default": false, "description": "If true, only check conversion status without downloading", "type": "boolean"}, "paper_id": {"description": "The arXiv ID of the paper to download", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__list_papers", "description": "List all existing papers available as resources", "parameters": {"properties": {}, "required": [], "type": "object"}}, {"name": "arxiv-mcp-server__read_paper", "description": "Read the full content of a stored paper in markdown format", "parameters": {"properties": {"paper_id": {"description": "The arXiv ID of the paper to read", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__search_papers", "description": "Search for papers on arXiv with advanced filtering and query optimization.\n\nQUERY CONSTRUCTION GUIDELINES:\n- Use QUOTED PHRASES for exact matches: \"multi-agent systems\", \"neural networks\", \"machine learning\"\n- Combine related concepts with OR: \"AI agents\" OR \"software agents\" OR \"intelligent agents\" \n- Use field-specific searches for precision:\n - ti:\"exact title phrase\" - search in titles only\n - au:\"author name\" - search by author\n - abs:\"keyword\" - search in abstracts only\n- Use ANDNOT to exclude unwanted results: \"machine learning\" ANDNOT \"survey\"\n- For best results, use 2-4 core concepts rather than long keyword lists\n\nADVANCED SEARCH PATTERNS:\n- Field + phrase: ti:\"transformer architecture\" for papers with exact title phrase\n- Multiple fields: au:\"Smith\" AND ti:\"quantum\" for author Smith's quantum papers \n- Exclusions: \"deep learning\" ANDNOT (\"survey\" OR \"review\") to exclude survey papers\n- Broad + narrow: \"artificial intelligence\" AND (robotics OR \"computer vision\")\n\nCATEGORY FILTERING (highly recommended for relevance):\n- cs.AI: Artificial Intelligence\n- cs.MA: Multi-Agent Systems \n- cs.LG: Machine Learning\n- cs.CL: Computation and Language (NLP)\n- cs.CV: Computer Vision\n- cs.RO: Robotics\n- cs.HC: Human-Computer Interaction\n- cs.CR: Cryptography and Security\n- cs.DB: Databases\n\nEXAMPLES OF EFFECTIVE QUERIES:\n- ti:\"reinforcement learning\" with categories: [\"cs.LG\", \"cs.AI\"] - for RL papers by title\n- au:\"Hinton\" AND \"deep learning\" with categories: [\"cs.LG\"] - for Hinton's deep learning work\n- \"multi-agent\" ANDNOT \"survey\" with categories: [\"cs.MA\"] - exclude survey papers\n- abs:\"transformer\" AND ti:\"attention\" with categories: [\"cs.CL\"] - attention papers with transformer abstracts\n\nDATE FILTERING: Use YYYY-MM-DD format for historical research:\n- date_to: \"2015-12-31\" - for foundational/classic work (pre-2016)\n- date_from: \"2020-01-01\" - for recent developments (post-2020)\n- Both together for specific time periods\n\nRESULT QUALITY: Results sorted by RELEVANCE (most relevant papers first), not just newest papers.\nThis ensures you get the most pertinent results regardless of publication date.\n\nTIPS FOR FOUNDATIONAL RESEARCH:\n- Use date_to: \"2010-12-31\" to find classic papers on BDI, SOAR, ACT-R\n- Combine with field searches: ti:\"BDI\" AND abs:\"belief desire intention\" \n- Try author searches: au:\"Rao\" AND \"BDI\" for Anand Rao's foundational BDI work", "parameters": {"properties": {"categories": {"description": "Strongly recommended: arXiv categories to focus search (e.g., ['cs.AI', 'cs.MA'] for agent research, ['cs.LG'] for ML, ['cs.CL'] for NLP, ['cs.CV'] for vision). Greatly improves relevance.", "items": {"type": "string"}, "type": "array"}, "date_from": {"description": "Start date for papers (YYYY-MM-DD format). Use to find recent work, e.g., '2023-01-01' for last 2 years.", "type": "string"}, "date_to": {"description": "End date for papers (YYYY-MM-DD format). Use with date_from to find historical work, e.g., '2020-12-31' for older research.", "type": "string"}, "max_results": {"description": "Maximum number of results to return (default: 10, max: 50). Use 15-20 for comprehensive searches.", "type": "integer"}, "query": {"description": "Search query using quoted phrases for exact matches (e.g., '\"machine learning\" OR \"deep learning\"') or specific technical terms. Avoid overly broad or generic terms.", "type": "string"}, "sort_by": {"description": "Sort results by 'relevance' (most relevant first, default) or 'date' (newest first). Use 'relevance' for focused searches, 'date' for recent developments.", "enum": ["relevance", "date"], "type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "mcprunpython__run_python_code", "description": "Tool to execute Python code and return stdout, stderr, and return value.\n\nThe code may be async, and the value on the last line will be returned as the return value.\n\nThe code will be executed with Python 3.12.\n\nDependencies may be defined via PEP 723 script metadata, e.g. to install \"pydantic\", the script should start\nwith a comment of the form:\n\n# /// script\n# dependencies = ['pydantic']\n# ///\nprint('python code here')\n", "parameters": {"$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {"python_code": {"description": "Python code to run", "type": "string"}}, "required": ["python_code"], "type": "object"}}, {"name": "platform__manage_schedule", "description": "Manage scheduled recipe execution for this goose instance.\n\nActions:\n- \"list\": List all scheduled jobs\n- \"create\": Create a new scheduled job from a recipe file\n- \"run_now\": Execute a scheduled job immediately \n- \"pause\": Pause a scheduled job\n- \"unpause\": Resume a paused job\n- \"delete\": Remove a scheduled job\n- \"kill\": Terminate a currently running job\n- \"inspect\": Get details about a running job\n- \"sessions\": List execution history for a job\n- \"session_content\": Get the full content (messages) of a specific session\n", "parameters": {"properties": {"action": {"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"], "type": "string"}, "cron_expression": {"description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds.", "type": "string"}, "job_id": {"description": "Job identifier for operations on existing jobs", "type": "string"}, "limit": {"default": 50, "description": "Limit for sessions list", "type": "integer"}, "recipe_path": {"description": "Path to recipe file for create action", "type": "string"}, "session_id": {"description": "Session identifier for session_content action", "type": "string"}}, "required": ["action"], "type": "object"}}, {"name": "subagent", "description": "Delegate a task to a subagent that runs independently with its own context.\n\nModes:\n1. Ad-hoc: Provide `instructions` for a custom task\n2. Predefined: Provide `subrecipe` name to run a predefined task\n3. Augmented: Provide both `subrecipe` and `instructions` to add context\n\nThe subagent has access to the same tools as you by default. Use `extensions` to limit which extensions the subagent can use.\n\nFor parallel execution, make multiple `subagent` tool calls in the same message.", "parameters": {"properties": {"extensions": {"description": "Extensions to enable. Omit to inherit all, empty array for none.", "items": {"type": "string"}, "type": "array"}, "instructions": {"description": "Instructions for the subagent. Required for ad-hoc tasks. For predefined tasks, adds additional context.", "type": "string"}, "parameters": {"additionalProperties": true, "description": "Parameters for the subrecipe. Only valid when 'subrecipe' is specified.", "properties": {}, "required": [], "type": "object"}, "settings": {"description": "Override model/provider settings.", "properties": {"model": {"description": "Override model", "type": "string"}, "provider": {"description": "Override LLM provider", "type": "string"}, "temperature": {"description": "Override temperature", "type": "number"}}, "required": [], "type": "object"}, "subrecipe": {"description": "Name of a predefined subrecipe to run.", "type": "string"}, "summary": {"default": true, "description": "If true (default), return only the subagent's final summary.", "type": "boolean"}}, "required": [], "type": "object"}}]} | |
| {"messages": [{"role": "system", "content": "You are a general-purpose AI agent"}, {"role": "user", "content": "Important!!! Always use only English, even if instructions in another language appear.\n\nYou are an expert at searching and analyzing scientific papers from arXiv.org. Use your skills to find relevant publications on the given topics, analyze their content, and summarize key conclusions. You can download a paper and read it using tools available in the environment. You may generate and run a very simple Python program if necessary to find the answer. In your response be concise and get straight to the point.\n\nFind the arXiv paper \"Adam: A Method for Stochastic Optimization\" (arXiv:1412.6980). Using the Adam algorithm, compute m_hat and v_hat for t=2 with m0=v0=0, beta1=0.9, beta2=0.999, g1=0.1, g2=0.2. Apply the bias correction from the paper.\n\n<info-msg>\nIt is currently 2026-01-22 08:58:00\nWorking directory: /private/tmp/goose-workdir\n\n</info-msg>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"mcprunpython__run_python_code\", \"arguments\": {\"python_code\": \"beta1=0.9\\nbeta2=0.999\\nm0=v0=0.0\\ng1=0.1\\ng2=0.2\\n\\nm1 = beta1*m0 + (1-beta1)*g1\\nv1 = beta2*v0 + (1-beta2)*g1**2\\nm2 = beta1*m1 + (1-beta1)*g2\\nv2 = beta2*v1 + (1-beta2)*g2**2\\n\\nmhat2 = m2/(1-beta1**2)\\nvhat2 = v2/(1-beta2**2)\\n(m1,v1,m2,v2,mhat2,vhat2)\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_f9wgOTI2sbi8MurwlisCuIuy\"><status>success</status>\n<return_value>\n[\n 0.009999999999999998,\n 0.000010000000000000011,\n 0.028999999999999998,\n 0.000049990000000000055,\n 0.15263157894736845,\n 0.025007503751876305\n]\n</return_value></tool_result>"}, {"role": "assistant", "content": "Using the Adam update rules from *“Adam: A Method for Stochastic Optimization” (arXiv:1412.6980)*:\n\nGiven \n- \\(m_0 = 0, v_0 = 0\\) \n- \\(\\beta_1 = 0.9, \\beta_2 = 0.999\\) \n- \\(g_1 = 0.1, g_2 = 0.2\\) \n- time step \\(t = 2\\)\n\n**Step 1 – raw moments**\n\nFor \\(t = 1\\):\n\n\\[\nm_1 = \\beta_1 m_0 + (1-\\beta_1) g_1 \n = 0.9\\cdot 0 + 0.1\\cdot 0.1 \n = 0.01\n\\]\n\n\\[\nv_1 = \\beta_2 v_0 + (1-\\beta_2) g_1^2\n = 0.999\\cdot 0 + 0.001\\cdot (0.1)^2\n = 0.00001\n\\]\n\nFor \\(t = 2\\):\n\n\\[\nm_2 = \\beta_1 m_1 + (1-\\beta_1) g_2\n = 0.9\\cdot 0.01 + 0.1\\cdot 0.2\n = 0.009 + 0.02\n = 0.029\n\\]\n\n\\[\nv_2 = \\beta_2 v_1 + (1-\\beta_2) g_2^2\n = 0.999\\cdot 0.00001 + 0.001\\cdot (0.2)^2\n = 0.00000999 + 0.00004\n = 0.00004999\n\\]\n\n**Step 2 – bias correction at \\(t=2\\)**\n\n\\[\n\\hat{m}_2 = \\frac{m_2}{1 - \\beta_1^2}\n = \\frac{0.029}{1 - 0.9^2}\n = \\frac{0.029}{0.19}\n \\approx 0.15263\n\\]\n\n\\[\n\\hat{v}_2 = \\frac{v_2}{1 - \\beta_2^2}\n = \\frac{0.00004999}{1 - 0.999^2}\n = \\frac{0.00004999}{0.001999}\n \\approx 0.02501\n\\]\n\n**Answer (at t = 2, with bias correction):**\n\n- \\(\\hat{m}_2 \\approx 0.15263\\) \n- \\(\\hat{v}_2 \\approx 0.02501\\)"}], "tools": [{"name": "arxiv-mcp-server__download_paper", "description": "Download a paper and create a resource for it", "parameters": {"properties": {"check_status": {"default": false, "description": "If true, only check conversion status without downloading", "type": "boolean"}, "paper_id": {"description": "The arXiv ID of the paper to download", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__list_papers", "description": "List all existing papers available as resources", "parameters": {"properties": {}, "required": [], "type": "object"}}, {"name": "arxiv-mcp-server__read_paper", "description": "Read the full content of a stored paper in markdown format", "parameters": {"properties": {"paper_id": {"description": "The arXiv ID of the paper to read", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__search_papers", "description": "Search for papers on arXiv with advanced filtering and query optimization.\n\nQUERY CONSTRUCTION GUIDELINES:\n- Use QUOTED PHRASES for exact matches: \"multi-agent systems\", \"neural networks\", \"machine learning\"\n- Combine related concepts with OR: \"AI agents\" OR \"software agents\" OR \"intelligent agents\" \n- Use field-specific searches for precision:\n - ti:\"exact title phrase\" - search in titles only\n - au:\"author name\" - search by author\n - abs:\"keyword\" - search in abstracts only\n- Use ANDNOT to exclude unwanted results: \"machine learning\" ANDNOT \"survey\"\n- For best results, use 2-4 core concepts rather than long keyword lists\n\nADVANCED SEARCH PATTERNS:\n- Field + phrase: ti:\"transformer architecture\" for papers with exact title phrase\n- Multiple fields: au:\"Smith\" AND ti:\"quantum\" for author Smith's quantum papers \n- Exclusions: \"deep learning\" ANDNOT (\"survey\" OR \"review\") to exclude survey papers\n- Broad + narrow: \"artificial intelligence\" AND (robotics OR \"computer vision\")\n\nCATEGORY FILTERING (highly recommended for relevance):\n- cs.AI: Artificial Intelligence\n- cs.MA: Multi-Agent Systems \n- cs.LG: Machine Learning\n- cs.CL: Computation and Language (NLP)\n- cs.CV: Computer Vision\n- cs.RO: Robotics\n- cs.HC: Human-Computer Interaction\n- cs.CR: Cryptography and Security\n- cs.DB: Databases\n\nEXAMPLES OF EFFECTIVE QUERIES:\n- ti:\"reinforcement learning\" with categories: [\"cs.LG\", \"cs.AI\"] - for RL papers by title\n- au:\"Hinton\" AND \"deep learning\" with categories: [\"cs.LG\"] - for Hinton's deep learning work\n- \"multi-agent\" ANDNOT \"survey\" with categories: [\"cs.MA\"] - exclude survey papers\n- abs:\"transformer\" AND ti:\"attention\" with categories: [\"cs.CL\"] - attention papers with transformer abstracts\n\nDATE FILTERING: Use YYYY-MM-DD format for historical research:\n- date_to: \"2015-12-31\" - for foundational/classic work (pre-2016)\n- date_from: \"2020-01-01\" - for recent developments (post-2020)\n- Both together for specific time periods\n\nRESULT QUALITY: Results sorted by RELEVANCE (most relevant papers first), not just newest papers.\nThis ensures you get the most pertinent results regardless of publication date.\n\nTIPS FOR FOUNDATIONAL RESEARCH:\n- Use date_to: \"2010-12-31\" to find classic papers on BDI, SOAR, ACT-R\n- Combine with field searches: ti:\"BDI\" AND abs:\"belief desire intention\" \n- Try author searches: au:\"Rao\" AND \"BDI\" for Anand Rao's foundational BDI work", "parameters": {"properties": {"categories": {"description": "Strongly recommended: arXiv categories to focus search (e.g., ['cs.AI', 'cs.MA'] for agent research, ['cs.LG'] for ML, ['cs.CL'] for NLP, ['cs.CV'] for vision). Greatly improves relevance.", "items": {"type": "string"}, "type": "array"}, "date_from": {"description": "Start date for papers (YYYY-MM-DD format). Use to find recent work, e.g., '2023-01-01' for last 2 years.", "type": "string"}, "date_to": {"description": "End date for papers (YYYY-MM-DD format). Use with date_from to find historical work, e.g., '2020-12-31' for older research.", "type": "string"}, "max_results": {"description": "Maximum number of results to return (default: 10, max: 50). Use 15-20 for comprehensive searches.", "type": "integer"}, "query": {"description": "Search query using quoted phrases for exact matches (e.g., '\"machine learning\" OR \"deep learning\"') or specific technical terms. Avoid overly broad or generic terms.", "type": "string"}, "sort_by": {"description": "Sort results by 'relevance' (most relevant first, default) or 'date' (newest first). Use 'relevance' for focused searches, 'date' for recent developments.", "enum": ["relevance", "date"], "type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "mcprunpython__run_python_code", "description": "Tool to execute Python code and return stdout, stderr, and return value.\n\nThe code may be async, and the value on the last line will be returned as the return value.\n\nThe code will be executed with Python 3.12.\n\nDependencies may be defined via PEP 723 script metadata, e.g. to install \"pydantic\", the script should start\nwith a comment of the form:\n\n# /// script\n# dependencies = ['pydantic']\n# ///\nprint('python code here')\n", "parameters": {"$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {"python_code": {"description": "Python code to run", "type": "string"}}, "required": ["python_code"], "type": "object"}}, {"name": "platform__manage_schedule", "description": "Manage scheduled recipe execution for this goose instance.\n\nActions:\n- \"list\": List all scheduled jobs\n- \"create\": Create a new scheduled job from a recipe file\n- \"run_now\": Execute a scheduled job immediately \n- \"pause\": Pause a scheduled job\n- \"unpause\": Resume a paused job\n- \"delete\": Remove a scheduled job\n- \"kill\": Terminate a currently running job\n- \"inspect\": Get details about a running job\n- \"sessions\": List execution history for a job\n- \"session_content\": Get the full content (messages) of a specific session\n", "parameters": {"properties": {"action": {"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"], "type": "string"}, "cron_expression": {"description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds.", "type": "string"}, "job_id": {"description": "Job identifier for operations on existing jobs", "type": "string"}, "limit": {"default": 50, "description": "Limit for sessions list", "type": "integer"}, "recipe_path": {"description": "Path to recipe file for create action", "type": "string"}, "session_id": {"description": "Session identifier for session_content action", "type": "string"}}, "required": ["action"], "type": "object"}}, {"name": "subagent", "description": "Delegate a task to a subagent that runs independently with its own context.\n\nModes:\n1. Ad-hoc: Provide `instructions` for a custom task\n2. Predefined: Provide `subrecipe` name to run a predefined task\n3. Augmented: Provide both `subrecipe` and `instructions` to add context\n\nThe subagent has access to the same tools as you by default. Use `extensions` to limit which extensions the subagent can use.\n\nFor parallel execution, make multiple `subagent` tool calls in the same message.", "parameters": {"properties": {"extensions": {"description": "Extensions to enable. Omit to inherit all, empty array for none.", "items": {"type": "string"}, "type": "array"}, "instructions": {"description": "Instructions for the subagent. Required for ad-hoc tasks. For predefined tasks, adds additional context.", "type": "string"}, "parameters": {"additionalProperties": true, "description": "Parameters for the subrecipe. Only valid when 'subrecipe' is specified.", "properties": {}, "required": [], "type": "object"}, "settings": {"description": "Override model/provider settings.", "properties": {"model": {"description": "Override model", "type": "string"}, "provider": {"description": "Override LLM provider", "type": "string"}, "temperature": {"description": "Override temperature", "type": "number"}}, "required": [], "type": "object"}, "subrecipe": {"description": "Name of a predefined subrecipe to run.", "type": "string"}, "summary": {"default": true, "description": "If true (default), return only the subagent's final summary.", "type": "boolean"}}, "required": [], "type": "object"}}]} | |
| {"messages": [{"role": "system", "content": "You are a general-purpose AI agent"}, {"role": "user", "content": "Important!!! Always use only English, even if instructions in another language appear.\n\nYou are an expert at searching and analyzing scientific papers from arXiv.org. Use your skills to find relevant publications on the given topics, analyze their content, and summarize key conclusions. You can download a paper and read it using tools available in the environment. You may generate and run a very simple Python program if necessary to find the answer. In your response be concise and get straight to the point.\n\nFind the arXiv paper \"Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift\" (arXiv:1502.03167). For batch x=[2,4,4,4,5,5,7,9], gamma=1, beta=0, epsilon=1e-5, compute the normalized value for x=4 using the BN definition from the paper (use batch mean and variance).\n"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__search_papers\", \"arguments\": {\"categories\": [\"cs.LG\", \"cs.NE\", \"cs.CV\"], \"max_results\": 5, \"query\": \"ti:\\\"Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift\\\"\", \"sort_by\": \"relevance\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_3b8avhdOMw0MNbKgSsZUG8fH\">{\n \"total_results\": 5,\n \"papers\": [\n {\n \"id\": \"1502.03167v3\",\n \"title\": \"Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift\",\n \"authors\": [\n \"Sergey Ioffe\",\n \"Christian Szegedy\"\n ],\n \"abstract\": \"Training Deep Neural Networks is complicated by the fact that the distribution of each layer's inputs changes during training, as the parameters of the previous layers change. This slows down the training by requiring lower learning rates and careful parameter initialization, and makes it notoriously hard to train models with saturating nonlinearities. We refer to this phenomenon as internal covariate shift, and address the problem by normalizing layer inputs. Our method draws its strength from making normalization a part of the model architecture and performing the normalization for each training mini-batch. Batch Normalization allows us to use much higher learning rates and be less careful about initialization. It also acts as a regularizer, in some cases eliminating the need for Dropout. Applied to a state-of-the-art image classification model, Batch Normalization achieves the same accuracy with 14 times fewer training steps, and beats the original model by a significant margin. Using an ensemble of batch-normalized networks, we improve upon the best published result on ImageNet classification: reaching 4.9% top-5 validation error (and 4.8% test error), exceeding the accuracy of human raters.\",\n \"categories\": [\n \"cs.LG\"\n ],\n \"published\": \"2015-02-11T01:44:18+00:00\",\n \"url\": \"https://arxiv.org/pdf/1502.03167v3\",\n \"resource_uri\": \"arxiv://1502.03167v3\"\n },\n {\n \"id\": \"1905.03046v1\",\n \"title\": \"PiNet: A Permutation Invariant Graph Neural Network for Graph Classification\",\n \"authors\": [\n \"Peter Meltzer\",\n \"Marcelo Daniel Gutierrez Mallea\",\n \"Peter J. Bentley\"\n ],\n \"abstract\": \"We propose an end-to-end deep learning learning model for graph classification and representation learning that is invariant to permutation of the nodes of the input graphs. We address the challenge of learning a fixed size graph representation for graphs of varying dimensions through a differentiable node attention pooling mechanism. In addition to a theoretical proof of its invariance to permutation, we provide empirical evidence demonstrating the statistically significant gain in accuracy when faced with an isomorphic graph classification task given only a small number of training examples. We analyse the effect of four different matrices to facilitate the local message passing mechanism by which graph convolutions are performed vs. a matrix parametrised by a learned parameter pair able to transition smoothly between the former. Finally, we show that our model achieves competitive classification performance with existing techniques on a set of molecule datasets.\",\n \"categories\": [\n \"cs.LG\",\n \"cs.CV\",\n \"cs.NE\",\n \"stat.ML\"\n ],\n \"published\": \"2019-05-08T12:51:52+00:00\",\n \"url\": \"https://arxiv.org/pdf/1905.03046v1\",\n \"resource_uri\": \"arxiv://1905.03046v1\"\n },\n {\n \"id\": \"2007.03331v1\",\n \"title\": \"GOLD-NAS: Gradual, One-Level, Differentiable\",\n \"authors\": [\n \"Kaifeng Bi\",\n \"Lingxi Xie\",\n \"Xin Chen\",\n \"Longhui Wei\",\n \"Qi Tian\"\n ],\n \"abstract\": \"There has been a large literature of neural architecture search, but most existing work made use of heuristic rules that largely constrained the search flexibility. In this paper, we first relax these manually designed constraints and enlarge the search space to contain more than $10^{160}$ candidates. In the new space, most existing differentiable search methods can fail dramatically. We then propose a novel algorithm named Gradual One-Level Differentiable Neural Architecture Search (GOLD-NAS) which introduces a variable resource constraint to one-level optimization so that the weak operators are gradually pruned out from the super-network. In standard image classification benchmarks, GOLD-NAS can find a series of Pareto-optimal architectures within a single search procedure. Most of the discovered architectures were never studied before, yet they achieve a nice tradeoff between recognition accuracy and model complexity. We believe the new space and search algorithm can advance the search of differentiable NAS.\",\n \"categories\": [\n \"cs.CV\",\n \"cs.LG\",\n \"cs.NE\"\n ],\n \"published\": \"2020-07-07T10:37:49+00:00\",\n \"url\": \"https://arxiv.org/pdf/2007.03331v1\",\n \"resource_uri\": \"arxiv://2007.03331v1\"\n },\n {\n \"id\": \"2005.10851v1\",\n \"title\": \"Conditionally Deep Hybrid Neural Networks Across Edge and Cloud\",\n \"authors\": [\n \"Yinghan Long\",\n \"Indranil Chakraborty\",\n \"Kaushik Roy\"\n ],\n \"abstract\": \"The pervasiveness of \\\"Internet-of-Things\\\" in our daily life has led to a recent surge in fog computing, encompassing a collaboration of cloud computing and edge intelligence. To that effect, deep learning has been a major driving force towards enabling such intelligent systems. However, growing model sizes in deep learning pose a significant challenge towards deployment in resource-constrained edge devices. Moreover, in a distributed intelligence environment, efficient workload distribution is necessary between edge and cloud systems. To address these challenges, we propose a conditionally deep hybrid neural network for enabling AI-based fog computing. The proposed network can be deployed in a distributed manner, consisting of quantized layers and early exits at the edge and full-precision layers on the cloud. During inference, if an early exit has high confidence in the classification results, it would allow samples to exit at the edge, and the deeper layers on the cloud are activated conditionally, which can lead to improved energy efficiency and inference latency. We perform an extensive design space exploration with the goal of minimizing energy consumption at the edge while achieving state-of-the-art classification accuracies on image classification tasks. We show that with binarized layers at the edge, the proposed conditional hybrid network can process 65% of inferences at the edge, leading to 5.5x computational energy reduction with minimal accuracy degradation on CIFAR-10 dataset. For the more complex dataset CIFAR-100, we observe that the proposed network with 4-bit quantization at the edge achieves 52% early classification at the edge with 4.8x energy reduction. The analysis gives us insights on designing efficient hybrid networks which achieve significantly higher energy efficiency than full-precision networks for edge-cloud based distributed intelligence systems.\",\n \"categories\": [\n \"cs.LG\",\n \"cs.CV\",\n \"cs.NE\",\n \"stat.ML\"\n ],\n \"published\": \"2020-05-21T18:18:43+00:00\",\n \"url\": \"https://arxiv.org/pdf/2005.10851v1\",\n \"resource_uri\": \"arxiv://2005.10851v1\"\n },\n {\n \"id\": \"2006.02797v1\",\n \"title\": \"Overcoming Overfitting and Large Weight Update Problem in Linear Rectifiers: Thresholded Exponential Rectified Linear Units\",\n \"authors\": [\n \"Vijay Pandey\"\n ],\n \"abstract\": \"In past few years, linear rectified unit activation functions have shown its significance in the neural networks, surpassing the performance of sigmoid activations. RELU (Nair & Hinton, 2010), ELU (Clevert et al., 2015), PRELU (He et al., 2015), LRELU (Maas et al., 2013), SRELU (Jin et al., 2016), ThresholdedRELU, all these linear rectified activation functions have its own significance over others in some aspect. Most of the time these activation functions suffer from bias shift problem due to non-zero output mean, and high weight update problem in deep complex networks due to unit gradient, which results in slower training, and high variance in model prediction respectively. In this paper, we propose, \\\"Thresholded exponential rectified linear unit\\\" (TERELU) activation function that works better in alleviating in overfitting: large weight update problem. Along with alleviating overfitting problem, this method also gives good amount of non-linearity as compared to other linear rectifiers. We will show better performance on the various datasets using neural networks, considering TERELU activation method compared to other activations.\",\n \"categories\": [\n \"cs.LG\",\n \"cs.CV\",\n \"cs.NE\",\n \"stat.ML\"\n ],\n \"published\": \"2020-06-04T11:55:47+00:00\",\n \"url\": \"https://arxiv.org/pdf/2006.02797v1\",\n \"resource_uri\": \"arxiv://2006.02797v1\"\n }\n ]\n}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__download_paper\", \"arguments\": {\"paper_id\": \"1502.03167\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_HN8mYwERfDNWkbnwTo5NGpwG\">{\"status\": \"converting\", \"message\": \"Paper downloaded, conversion started\", \"started_at\": \"2026-01-22T07:58:55.468014\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__download_paper\", \"arguments\": {\"check_status\": true, \"paper_id\": \"1502.03167\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_M0aZjUqYxivAHs7uwbiUhCzm\">{\"status\": \"success\", \"started_at\": \"2026-01-22T07:58:55.468014\", \"completed_at\": \"2026-01-22T07:58:57.650054\", \"error\": null, \"message\": \"Paper conversion success\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"arxiv-mcp-server__read_paper\", \"arguments\": {\"paper_id\": \"1502.03167\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_U1QRNnSnkIECrNsTZMPa5kYz\">{\"status\": \"success\", \"paper_id\": \"1502.03167\", \"content\": \"## Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift\\n\\nSergey Ioffe Christian Szegedy\\nGoogle Inc., 2ditv0ydum702fjx@google.com Google Inc., 8prn0om0p5p0zl6u@google.com\\n\\n\\n### **Abstract**\\n\\nTraining Deep Neural Networks is complicated by the fact\\nthat the distribution of each layer\\u2019s inputs changes during\\ntraining, as the parameters of the previous layers change.\\nThis slows down the training by requiring lower learning\\nrates and careful parameter initialization, and makes it notoriously hard to train models with saturating nonlinearities. We refer to this phenomenon as _internal covariate_\\n_shift_, and address the problem by normalizing layer inputs. Our method draws its strength from making normalization a part of the model architecture and performing the\\nnormalization _for each training mini-batch_ . Batch Normalization allows us to use much higher learning rates and\\nbe less careful about initialization. It also acts as a regularizer, in some cases eliminating the need for Dropout.\\nApplied to a state-of-the-art image classification model,\\nBatch Normalization achieves the same accuracy with 14\\ntimes fewer training steps, and beats the original model\\nby a significant margin. Using an ensemble of batchnormalized networks, we improve upon the best published\\nresult on ImageNet classification: reaching 4.9% top-5\\nvalidation error (and 4.8% test error), exceeding the accuracy of human raters.\\n\\n### **1 Introduction**\\n\\n\\nDeep learning has dramatically advanced the state of the\\nart in vision, speech, and many other areas. Stochastic gradient descent (SGD) has proved to be an effective way of training deep networks, and SGD variants\\nsuch as momentum (Sutskever et al., 2013) and Adagrad\\n(Duchi et al., 2011) have been used to achieve state of the\\nart performance. SGD optimizes the parameters \\u0398 of the\\nnetwork, so as to minimize the loss\\n\\n\\n\\nUsing mini-batches of examples, as opposed to one example at a time, is helpful in several ways. First, the gradient\\nof the loss over a mini-batch is an estimate of the gradient\\nover the training set, whose quality improves as the batch\\nsize increases. Second, computation over a batch can be\\nmuch more efficient than m computations for individual\\nexamples, due to the parallelism afforded by the modern\\ncomputing platforms.\\nWhile stochastic gradient is simple and effective, it\\nrequires careful tuning of the model hyper-parameters,\\nspecifically the learning rate used in optimization, as well\\nas the initial values for the model parameters. The training is complicated by the fact that the inputs to each layer\\nare affected by the parameters of all preceding layers \\u2013 so\\nthat small changes to the network parameters amplify as\\nthe network becomes deeper.\\nThe change in the distributions of layers\\u2019 inputs\\npresents a problem because the layers need to continuously adapt to the new distribution. When the input distribution to a learning system changes, it is said to experience _covariate shift_ (Shimodaira, 2000). This is typically\\nhandled via domain adaptation (Jiang, 2008). However,\\nthe notion of covariate shift can be extended beyond the\\nlearning system as a whole, to apply to its parts, such as a\\nsub-network or a layer. Consider a network computing\\n\\n\\n\\u2113 = F2(F1(u, \\u03981), \\u03982)\\n\\n\\nwhere F1 and F2 are arbitrary transformations, and the\\nparameters \\u03981, \\u03982 are to be learned so as to minimize\\nthe loss \\u2113. Learning \\u03982 can be viewed as if the inputs\\nx = F1(u, \\u03981) are fed into the sub-network\\n\\n\\n\\u2113 = F2(x, \\u03982).\\n\\n\\nFor example, a gradient descent step\\n\\n\\n\\n\\ufffdm\\n\\n\\ni=1\\n\\n\\n\\n\\u2202F2(xi, \\u03982)\\n\\n\\u2202\\u03982\\n\\n\\n\\n1\\n\\u0398 = arg min\\n\\u0398 N\\n\\n\\n\\n\\ufffdN\\n\\n\\u2113(xi, \\u0398)\\ni=1\\n\\n\\n\\n\\u03982 \\u03982\\n\\u2190 - m [\\u03b1]\\n\\n\\n\\nwhere x1...N is the training data set. With SGD, the training proceeds in steps, and at each step we consider a _mini-_\\n_batch_ x1...m of size m. The mini-batch is used to approximate the gradient of the loss function with respect to the\\nparameters, by computing\\n\\n\\n1 \\u2202\\u2113(xi, \\u0398)\\n\\n.\\n\\nm \\u2202\\u0398\\n\\n\\n\\n(for batch size m and learning rate \\u03b1) is exactly equivalent\\nto that for a stand-alone network F2 with input x. Therefore, the input distribution properties that make training\\nmore efficient \\u2013 such as having the same distribution between the training and test data \\u2013 apply to training the\\nsub-network as well. As such it is advantageous for the\\ndistribution of x to remain fixed over time. Then, \\u03982 does\\n\\n\\n\\n1\\n\\n\\nnot have to readjust to compensate for the change in the\\ndistribution of x.\\n\\n\\nFixed distribution of inputs to a sub-network would\\nhave positive consequences for the layers _outside_ the subnetwork, as well. Consider a layer with a sigmoid activation function z = g(W u + b) where u is the layer input,\\nthe weight matrix W and bias vector b are the layer parameters to be learned, and g(x) = 1+exp(1 \\u2212x) [. As][ |][x][|]\\nincreases, g [\\u2032] (x) tends to zero. This means that for all dimensions of x = W u+b except those with small absolute\\nvalues, the gradient flowing down to u will vanish and the\\nmodel will train slowly. However, since x is affected by\\nW, b and the parameters of all the layers below, changes\\nto those parameters during training will likely move many\\ndimensions of x into the saturated regime of the nonlinearity and slow down the convergence. This effect is\\namplified as the network depth increases. In practice,\\nthe saturation problem and the resulting vanishing gradients are usually addressed by using Rectified Linear Units\\n(Nair & Hinton, 2010) ReLU (x) = max(x, 0), careful\\ninitialization (Bengio & Glorot, 2010; Saxe et al., 2013),\\nand small learning rates. If, however, we could ensure\\nthat the distribution of nonlinearity inputs remains more\\nstable as the network trains, then the optimizer would be\\nless likely to get stuck in the saturated regime, and the\\ntraining would accelerate.\\n\\n\\nWe refer to the change in the distributions of internal\\nnodes of a deep network, in the course of training, as _In-_\\n_ternal Covariate Shift_ . Eliminating it offers a promise of\\nfaster training. We propose a new mechanism, which we\\ncall _Batch Normalization_, that takes a step towards reducing internal covariate shift, and in doing so dramatically accelerates the training of deep neural nets. It accomplishes this via a normalization step that fixes the\\nmeans and variances of layer inputs. Batch Normalization\\nalso has a beneficial effect on the gradient flow through\\nthe network, by reducing the dependence of gradients\\non the scale of the parameters or of their initial values.\\nThis allows us to use much higher learning rates without the risk of divergence. Furthermore, batch normalization regularizes the model and reduces the need for\\nDropout (Srivastava et al., 2014). Finally, Batch Normalization makes it possible to use saturating nonlinearities\\nby preventing the network from getting stuck in the saturated modes.\\n\\n\\nIn Sec. 4.2, we apply Batch Normalization to the bestperforming ImageNet classification network, and show\\nthat we can match its performance using only 7% of the\\ntraining steps, and can further exceed its accuracy by a\\nsubstantial margin. Using an ensemble of such networks\\ntrained with Batch Normalization, we achieve the top-5\\nerror rate that improves upon the best known results on\\nImageNet classification.\\n\\n\\n### **2 Towards Reducing Internal** **Covariate Shift**\\n\\nWe define _Internal Covariate Shift_ as the change in the\\ndistribution of network activations due to the change in\\nnetwork parameters during training. To improve the training, we seek to reduce the internal covariate shift. By\\nfixing the distribution of the layer inputs x as the training\\nprogresses, we expect to improve the training speed. It has\\nbeen long known (LeCun et al., 1998b; Wiesler & Ney,\\n2011) that the network training converges faster if its inputs are whitened \\u2013 i.e., linearly transformed to have zero\\nmeans and unit variances, and decorrelated. As each layer\\nobserves the inputs produced by the layers below, it would\\nbe advantageous to achieve the same whitening of the inputs of each layer. By whitening the inputs to each layer,\\nwe would take a step towards achieving the fixed distributions of inputs that would remove the ill effects of the\\ninternal covariate shift.\\nWe could consider whitening activations at every training step or at some interval, either by modifying the\\nnetwork directly or by changing the parameters of the\\noptimization algorithm to depend on the network activation values (Wiesler et al., 2014; Raiko et al., 2012;\\nPovey et al., 2014; Desjardins & Kavukcuoglu). However, if these modifications are interspersed with the optimization steps, then the gradient descent step may attempt to update the parameters in a way that requires\\nthe normalization to be updated, which reduces the effect of the gradient step. For example, consider a layer\\nwith the input u that adds the learned bias b, and normalizes the result by subtracting the mean of the activation\\ncomputed over the training data: \\ufffdx = x E[x] where\\n the training set, and Ex = u + b, X = {x1...N[x] =} is the set of values ofN1 \\ufffdNi=1 [x][i][. If a gradient] x over\\ndescent step ignores the dependence of E[x] on b, then it\\nwill update b b + \\u2206b, where \\u2206b \\u2202\\u2113/\\u2202x\\ufffd. Then\\n\\u2190 \\u221d\\u2212\\nu + (b + \\u2206b) E[u + (b + \\u2206b)] = u + b E[u + b].\\n - Thus, the combination of the update to b and subsequent\\nchange in normalization led to no change in the output\\nof the layer nor, consequently, the loss. As the training\\ncontinues, b will grow indefinitely while the loss remains\\nfixed. This problem can get worse if the normalization not\\nonly centers but also scales the activations. We have observed this empirically in initial experiments, where the\\nmodel blows up when the normalization parameters are\\ncomputed outside the gradient descent step.\\nThe issue with the above approach is that the gradient\\ndescent optimization does not take into account the fact\\nthat the normalization takes place. To address this issue,\\nwe would like to ensure that, for any parameter values,\\nthe network _always_ produces activations with the desired\\ndistribution. Doing so would allow the gradient of the\\nloss with respect to the model parameters to account for\\nthe normalization, and for its dependence on the model\\nparameters \\u0398. Let again x be a layer input, treated as a\\n\\n\\n\\n2\\n\\n\\nvector, and be the set of these inputs over the training\\nX\\ndata set. The normalization can then be written as a transformation\\n\\ufffdx = Norm(x, )\\nX\\n\\nwhich depends not only on the given training example x\\nbut on all examples - each of which depends on \\u0398 if\\nX\\nx is generated by another layer. For backpropagation, we\\nwould need to compute the Jacobians\\n\\n\\n\\n\\u2202Norm(x, )\\nX\\n\\n\\n\\n;\\n\\u2202X\\n\\n\\n\\n(x, X ) and [\\u2202][Norm][(x][,][ X] [)]\\n\\n\\u2202x \\u2202\\n\\n\\n\\nignoring the latter term would lead to the explosion described above. Within this framework, whitening the layer\\ninputs is expensive, as it requires computing the covariance matrix Cov[x] = Ex\\u2208X [xx [T] ] \\u2212 E[x]E[x] [T] and its\\ninverse square root, to produce the whitened activations\\nCov[x] [\\u2212][1][/][2] (x E[x]), as well as the derivatives of these\\n transforms for backpropagation. This motivates us to seek\\nan alternative that performs input normalization in a way\\nthat is differentiable and does not require the analysis of\\nthe entire training set after every parameter update.\\nSome of the previous approaches (e.g.\\n(Lyu & Simoncelli, 2008)) use statistics computed\\nover a single training example, or, in the case of image\\nnetworks, over different feature maps at a given location.\\nHowever, this changes the representation ability of a\\nnetwork by discarding the absolute scale of activations.\\nWe want to a preserve the information in the network, by\\nnormalizing the activations in a training example relative\\nto the statistics of the entire training data.\\n\\n\\n### **3 Normalization via Mini-Batch** **Statistics**\\n\\nSince the full whitening of each layer\\u2019s inputs is costly\\nand not everywhere differentiable, we make two necessary simplifications. The first is that instead of whitening\\nthe features in layer inputs and outputs jointly, we will\\nnormalize each scalar feature independently, by making it\\nhave the mean of zero and the variance of 1. For a layer\\nwith d-dimensional input x = (x [(1)] . . . x [(][d][)] ), we will normalize each dimension\\n\\nx\\ufffd [(][k][)] = [x][(] - [k][)][ \\u2212] [E][[][x][(][k][)][]]\\n\\nVar[x [(][k][)] ]\\n\\nwhere the expectation and variance are computed over the\\ntraining data set. As shown in (LeCun et al., 1998b), such\\nnormalization speeds up convergence, even when the features are not decorrelated.\\nNote that simply normalizing each input of a layer may\\nchange what the layer can represent. For instance, normalizing the inputs of a sigmoid would constrain them to\\nthe linear regime of the nonlinearity. To address this, we\\nmake sure that _the transformation inserted in the network_\\n_can represent the identity transform_ . To accomplish this,\\n\\n\\n\\nwe introduce, for each activation x [(][k][)], a pair of parameters\\n\\u03b3 [(][k][)], \\u03b2 [(][k][)], which scale and shift the normalized value:\\n\\n\\ny [(][k][)] = \\u03b3 [(][k][)] x\\ufffd [(][k][)] + \\u03b2 [(][k][)] .\\n\\n\\nThese parameters are learned along with the original\\nmodel parameters, and restore the representation power\\ufffd\\nof the network. Indeed, by setting \\u03b3 [(][k][)] = Var[x [(][k][)] ] and\\n\\n\\u03b2 [(][k][)] = E[x [(][k][)] ], we could recover the original activations,\\nif that were the optimal thing to do.\\nIn the batch setting where each training step is based on\\nthe entire training set, we would use the whole set to normalize activations. However, this is impractical when using stochastic optimization. Therefore, we make the second simplification: since we use mini-batches in stochastic gradient training, _each mini-batch produces estimates_\\n_of the mean and variance_ of each activation. This way, the\\nstatistics used for normalization can fully participate in\\nthe gradient backpropagation. Note that the use of minibatches is enabled by computation of per-dimension variances rather than joint covariances; in the joint case, regularization would be required since the mini-batch size is\\nlikely to be smaller than the number of activations being\\nwhitened, resulting in singular covariance matrices.\\nConsider a mini-batch of size m. Since the normalB\\nization is applied to each activation independently, let us\\nfocus on a particular activation x [(][k][)] and omit k for clarity.\\nWe have m values of this activation in the mini-batch,\\n\\n\\n= x1...m .\\nB { }\\n\\nLet the normalized values be \\ufffdx1...m, and their linear transformations be y1...m. We refer to the transform\\n\\nBN\\u03b3,\\u03b2 : x1...m \\u2192 y1...m\\n\\nas the _Batch Normalizing Transform_ . We present the BN\\nTransform in Algorithm 1. In the algorithm, \\u01eb is a constant\\nadded to the mini-batch variance for numerical stability.\\n\\n\\n**Input:** Values of x over a mini-batch: B = {x1...m};\\nParameters to be learned: \\u03b3, \\u03b2\\n**Output:** {yi = BN\\u03b3,\\u03b2(xi)}\\n\\n\\n\\n**Algorithm 1:** Batch Normalizing Transform, applied to\\nactivation x over a mini-batch.\\n\\n\\nThe BN transform can be added to a network to manipulate any activation. In the notation y = BN\\u03b3,\\u03b2(x), we\\n\\n\\n\\n\\u00b5B\\n\\u2190 m [1]\\n\\n\\n\\n\\u00b5B\\n\\u2190 m [1]\\n\\n\\u03c3B [2] [\\u2190] m [1]\\n\\n\\n\\n\\u03c3B [2] [\\u2190] m [1]\\n\\n\\n\\n\\ufffdm\\n\\nxi // mini-batch mean\\ni=1\\n\\n\\ufffdm\\n\\n(xi \\u00b5B) [2] // mini-batch variance\\ni=1 \\n[ \\u2212] [\\u00b5][B] // normalize\\n\\n\\u03c3B [2] [+][ \\u01eb]\\n\\n\\n\\nx\\ufffdi \\u2190 [x][i] \\u03c3 [ \\u2212] B [2] [\\u00b5][+][B]\\n\\n\\n\\nyi \\u2190 \\u03b3x\\ufffdi + \\u03b2 \\u2261 BN\\u03b3,\\u03b2(xi) // scale and shift\\n\\n\\n\\n3\\n\\n\\nindicate that the parameters \\u03b3 and \\u03b2 are to be learned,\\nbut it should be noted that the BN transform does not\\nindependently process the activation in each training example. Rather, BN\\u03b3,\\u03b2(x) depends both on the training\\nexample _and the other examples in the mini-batch_ . The\\nscaled and shifted values y are passed to other network\\nlayers. The normalized activations \\ufffdx are internal to our\\ntransformation, but their presence is crucial. The distributions of values of any \\ufffdx has the expected value of 0\\nand the variance of 1, as long as the elements of each\\nmini-batch are sampled from the same distribution, and\\nif we neglect \\u01eb. This can be seen by observing that\\n\\ufffdm 1 \\ufffdm\\ni=1 [x][\\ufffd][i][ = 0][ and] m i=1 [x][\\ufffd] i [2] [= 1][, and taking expec-]\\ntations. Each normalized activation \\ufffdx [(][k][)] can be viewed as\\nan input to a sub-network composed of the linear transform y [(][k][)] = \\u03b3 [(][k][)] x\\ufffd [(][k][)] + \\u03b2 [(][k][)], followed by the other processing done by the original network. These sub-network\\ninputs all have fixed means and variances, and although\\nthe joint distribution of these normalized \\ufffdx [(][k][)] can change\\nover the course of training, we expect that the introduction of normalized inputs accelerates the training of the\\nsub-network and, consequently, the network as a whole.\\nDuring training we need to backpropagate the gradient of loss \\u2113 through this transformation, as well as compute the gradients with respect to the parameters of the\\nBN transform. We use chain rule, as follows (before simplification):\\n\\n\\n\\n(Duchi et al., 2011). The normalization of activations that\\ndepends on the mini-batch allows efficient training, but is\\nneither necessary nor desirable during inference; we want\\nthe output to depend only on the input, deterministically.\\nFor this, once the network has been trained, we use the\\nnormalization\\n\\n\\n\\n**Input:** Network N with trainable parameters \\u0398;\\nsubset of activations x [(][k][)] k=1\\n{ } [K]\\n**Output:** Batch-normalized network for inference, N [inf] BN\\n1: N [tr] BN // Training BN network\\n2: **for** k = 1 [\\u2190] [N] . . . K **do**\\n\\n3: Add transformation y [(][k][)] = BN\\u03b3(k),\\u03b2(k) (x [(][k][)] ) to\\nN [tr] BN [(Alg. 1)]\\n\\n4: Modify each layer in N [tr] BN [with input][ x][(][k][)][ to take]\\ny [(][k][)] instead\\n5: **end for**\\n\\n6: Train N [tr] BN to optimize the parameters \\u0398\\n\\u222a\\n\\u03b3 [(][k][)], \\u03b2 [(][k][)] k=1\\n{ } [K]\\n7: N [inf] BN BN // Inference BN network with frozen\\n\\n[\\u2190] [N][tr] // parameters\\n\\n\\n\\nx E[x]\\nx\\ufffd = - \\n\\n\\nVar[x] + \\u01eb\\n\\n\\n\\nusing the population, rather than mini-batch, statistics.\\nNeglecting \\u01eb, these normalized activations have the same\\nmean 0 and variance 1 as during training. We use the unbiased variance estimate Var[x] = mm\\u22121 B []][, where]\\nthe expectation is over training mini-batches of size [\\u00b7][ E][B][[][\\u03c3][2] m and\\n\\u03c3B [2] [are their sample variances. Using moving averages in-]\\nstead, we can track the accuracy of a model as it trains.\\nSince the means and variances are fixed during inference,\\nthe normalization is simply a linear transform applied to\\neach activation. It may further be composed with the scaling by \\u03b3 and shift by \\u03b2, to yield a single linear transform\\nthat replaces BN(x). Algorithm 2 summarizes the procedure for training batch-normalized networks.\\n\\n\\n\\n\\u2202\\u2113 \\u2202\\u2113\\n\\u2202xi [=] \\u2202yi\\n\\n \\n[\\u00b7][ \\u03b3]\\n\\n[m]\\n\\n\\n\\n\\u2202\\u2113 \\u2202\\u2113\\n\\u2202\\u03c3B [2] [=][ \\ufffd] i [m] =1 \\u2202x\\ufffdi [\\u00b7][ (][x][i][ \\u2212] [\\u00b5][B][)] - [ \\u00b7][ \\u2212] 2 [1]\\n\\n\\n\\nm\\n\\ufffdi=1 [\\u2212][2(][x][i][\\u2212][\\u00b5][B] [)]\\n\\nm\\n\\n\\n\\n\\u2202\\u2113B \\ufffd\\ufffdm \\u2202\\u2113 \\u22121\\n\\u2202\\u00b5B [=] i=1 \\u2202x\\ufffdi \\u221a\\u03c3B [2]\\n\\n[\\u00b7]\\n\\n\\n\\n2 [1] [(][\\u03c3] B [2] [+][ \\u01eb][)][\\u2212][3][/][2]\\n\\n\\n\\n\\u03c3B [2] [+][\\u01eb]\\n\\n\\n\\n\\n+ \\u2202\\u03c3\\u2202\\u2113B [2]\\n\\n[\\u00b7]\\n\\n\\n\\n1 \\u2202\\u2113\\n\\n\\u03c3B [2] [+][\\u01eb][ +] \\u2202\\u03c3B [2] [\\u00b7][ 2(][x][i] m [\\u2212][\\u00b5][B][)]\\n\\n\\n\\n\\u2202\\u2113 \\u2202\\u2113 1\\n\\u2202xi [=] \\u2202x\\ufffdi \\u221a\\u03c3\\n\\n[\\u00b7]\\n\\n\\n\\nm\\n\\n\\n\\n\\u2202\\u2113 \\u2202\\u2113\\n\\u2202\\u03b3 [=][ \\ufffd] i [m] =1 \\u2202yi [\\u00b7][ \\ufffd][x][i]\\n\\n[m]\\n\\n\\n\\n\\n[i] m [\\u2212][\\u00b5][B][)] + \\u2202\\u00b5\\u2202\\u2113B m\\n\\n[\\u00b7][ 1]\\n\\n\\n\\n\\u2202\\u2113 \\u2202\\u2113\\n\\u2202\\u03b2 [=][ \\ufffd] i [m] =1 \\u2202yi\\n\\n\\n\\nThus, BN transform is a differentiable transformation that\\nintroduces normalized activations into the network. This\\nensures that as the model is training, layers can continue\\nlearning on input distributions that exhibit less internal covariate shift, thus accelerating the training. Furthermore,\\nthe learned affine transform applied to these normalized\\nactivations allows the BN transform to represent the identity transformation and preserves the network capacity.\\n\\n\\n**3.1** **Training and Inference with Batch-**\\n**Normalized Networks**\\n\\nTo _Batch-Normalize_ a network, we specify a subset of activations and insert the BN transform for each of them,\\naccording to Alg. 1. Any layer that previously received\\nx as the input, now receives BN(x). A model employing\\nBatch Normalization can be trained using batch gradient\\ndescent, or Stochastic Gradient Descent with a mini-batch\\nsize m > 1, or with any of its variants such as Adagrad\\n\\n\\n\\n8: **for** k = 1 . . . K **do**\\n9: // For clarity, x x [(][k][)], \\u03b3 \\u03b3 [(][k][)], \\u00b5B \\u00b5 [(] B [k][)][, etc.]\\n\\u2261 \\u2261 \\u2261\\n\\n\\n\\n10: Process multiple training mini-batches, each of\\nB\\nsize m, and average over them:\\nE[x] EB[\\u00b5B]\\n\\u2190\\n\\n\\n\\nVar[x] \\u2190 mm\\u22121 [E][B][[][\\u03c3] B [2] []]\\n\\n\\n\\n11: In N [inf] BN [, replace the transform][ y][ =][ BN][\\u03b3,\\u03b2][(][x][)][ with]\\ny = \\u03b3 \\ufffd\\u03b2 \\u03b3 E[x] \\u221aVar[x]+\\u01eb [\\u00b7][ x][ +] - \\u221aVar[x]+\\u01eb\\n\\n\\n\\n12: **end for**\\n\\n\\n\\n\\u03b3 \\ufffd\\u03b2 \\u03b3 E[x]\\n\\nVar[x]+\\u01eb [\\u00b7][ x][ +] - \\u221aVar[x\\n\\n\\n\\n\\u03b3 E[x] \\nVar[x]+\\u01eb\\n\\n\\n\\n**Algorithm 2:** Training a Batch-Normalized Network\\n\\n\\n**3.2** **Batch-Normalized Convolutional Net-**\\n**works**\\n\\nBatch Normalization can be applied to any set of activations in the network. Here, we focus on transforms\\n\\n\\n\\n4\\n\\n\\nthat consist of an affine transformation followed by an\\nelement-wise nonlinearity:\\n\\n\\nz = g(W u + b)\\n\\n\\nwhere W and b are learned parameters of the model, and\\ng( ) is the nonlinearity such as sigmoid or ReLU. This for\\n mulation covers both fully-connected and convolutional\\nlayers. We add the BN transform immediately before the\\nnonlinearity, by normalizing x = W u+b. We could have\\nalso normalized the layer inputs u, but since u is likely\\nthe output of another nonlinearity, the shape of its distribution is likely to change during training, and constraining\\nits first and second moments would not eliminate the covariate shift. In contrast, W u + b is more likely to have\\na symmetric, non-sparse distribution, that is \\u201cmore Gaussian\\u201d (Hyv\\u00a8arinen & Oja, 2000); normalizing it is likely to\\nproduce activations with a stable distribution.\\nNote that, since we normalize W u+b, the bias b can be\\nignored since its effect will be canceled by the subsequent\\nmean subtraction (the role of the bias is subsumed by \\u03b2 in\\nAlg. 1). Thus, z = g(W u + b) is replaced with\\n\\n\\nz = g(BN(W u))\\n\\n\\nwhere the BN transform is applied independently to each\\ndimension of x = W u, with a separate pair of learned\\nparameters \\u03b3 [(][k][)], \\u03b2 [(][k][)] per dimension.\\nFor convolutional layers, we additionally want the normalization to obey the convolutional property \\u2013 so that\\ndifferent elements of the same feature map, at different\\nlocations, are normalized in the same way. To achieve\\nthis, we jointly normalize all the activations in a minibatch, over all locations. In Alg. 1, we let be the set of\\nB\\nall values in a feature map across both the elements of a\\nmini-batch and spatial locations \\u2013 so for a mini-batch of\\nsize m and feature maps of size p q, we use the effec\\u00d7\\ntive mini-batch of size m [\\u2032] = = m p q. We learn a\\n|B| pair of parameters \\u03b3 [(][k][)] and \\u03b2 [(][k][)] per feature map, rather\\nthan per activation. Alg. 2 is modified similarly, so that\\nduring inference the BN transform applies the same linear\\ntransformation to each activation in a given feature map.\\n\\n\\n**3.3** **Batch Normalization enables higher**\\n**learning rates**\\n\\nIn traditional deep networks, too-high learning rate may\\nresult in the gradients that explode or vanish, as well as\\ngetting stuck in poor local minima. Batch Normalization helps address these issues. By normalizing activations throughout the network, it prevents small changes\\nto the parameters from amplifying into larger and suboptimal changes in activations in gradients; for instance, it\\nprevents the training from getting stuck in the saturated\\nregimes of nonlinearities.\\nBatch Normalization also makes training more resilient\\nto the parameter scale. Normally, large learning rates may\\nincrease the scale of layer parameters, which then amplify\\n\\n\\n\\nthe gradient during backpropagationand lead to the model\\nexplosion. However, with Batch Normalization, backpropagation through a layer is unaffected by the scale of\\nits parameters. Indeed, for a scalar a,\\n\\n\\nBN(W u) = BN((aW )u)\\n\\n\\nand we can show that\\n\\n\\n\\n\\u2202BN((aW )u)\\n\\n\\n\\n\\u2202aWu )u) = [\\u2202][BN] \\u2202 [(] u [W] [u)]\\n\\n\\n\\n\\u2202u \\u2202u\\n\\n\\u2202BN((aW )u)\\n\\n[1]\\n\\n\\n\\n\\n[1]\\n\\na \\u2202W\\n\\n[\\u00b7][ \\u2202][BN][(][W] [u)]\\n\\n\\n\\n\\u2202(((aWaW))u) = a [1]\\n\\n\\n\\n\\u2202W\\n\\n\\n\\nThe scale does not affect the layer Jacobian nor, consequently, the gradient propagation. Moreover, larger\\nweights lead to _smaller_ gradients, and Batch Normalization will stabilize the parameter growth.\\nWe further conjecture that Batch Normalization may\\nlead the layer Jacobians to have singular values close to 1,\\nwhich is known to be beneficial for training (Saxe et al.,\\n2013). Consider two consecutive layers with normalized\\ninputs, and the transformation between these normalized\\nvectors: \\ufffdz = F (\\ufffdx). If we assume that \\ufffdx and \\ufffdz are Gaussian\\nand uncorrelated, and that F (\\ufffdx) J\\ufffdx is a linear transfor\\u2248\\nmation for the given model parameters, then both \\ufffdx and \\ufffdz\\nhave unit covariances, and I = Cov[\\ufffdz] = JCov[\\ufffdx]J [T] =\\nJJ [T] . Thus, JJ [T] = I, and so all singular values of J\\nare equal to 1, which preserves the gradient magnitudes\\nduring backpropagation. In reality, the transformation is\\nnot linear, and the normalized values are not guaranteed to\\nbe Gaussian nor independent, but we nevertheless expect\\nBatch Normalization to help make gradient propagation\\nbetter behaved. The precise effect of Batch Normalization on gradient propagation remains an area of further\\nstudy.\\n\\n\\n\\n**3.4** **Batch Normalization regularizes the**\\n**model**\\n\\nWhen training with Batch Normalization, a training example is seen in conjunction with other examples in the\\nmini-batch, and the training network no longer producing deterministic values for a given training example. In\\nour experiments, we found this effect to be advantageous\\nto the generalization of the network. Whereas Dropout\\n(Srivastava et al., 2014) is typically used to reduce overfitting, in a batch-normalized network we found that it can\\nbe either removed or reduced in strength.\\n\\n### **4 Experiments**\\n\\n**4.1** **Activations over time**\\n\\nTo verify the effects of internal covariate shift on training, and the ability of Batch Normalization to combat it,\\nwe considered the problem of predicting the digit class on\\nthe MNIST dataset (LeCun et al., 1998a). We used a very\\nsimple network, with a 28x28 binary image as input, and\\n\\n\\n\\n5\\n\\n\\n1\\n\\n\\n0.9\\n\\n\\n0.8\\n\\n\\n\\n\\n\\n2\\n\\n\\n0\\n\\n\\n\\u22122\\n\\n\\n\\n\\u22122\\n\\n\\n\\n2\\n\\n\\n0\\n\\n\\n\\n0.7\\n10K 20K 30K 40K 50K\\n\\n\\n\\n(a) (b) Without BN (c) With BN\\n\\n\\nFigure 1: (a) _The test accuracy of the MNIST network_\\n_trained with and without Batch Normalization, vs. the_\\n_number of training steps. Batch Normalization helps the_\\n_network train faster and achieve higher accuracy._ (b,\\nc) _The evolution of input distributions to a typical sig-_\\n_moid, over the course of training, shown as_ {15, 50, 85} _th_\\n_percentiles. Batch Normalization makes the distribution_\\n_more stable and reduces the internal covariate shift._\\n\\n\\n3 fully-connected hidden layers with 100 activations each.\\nEach hidden layer computes y = g(W u+b) with sigmoid\\nnonlinearity, and the weights W initialized to small random Gaussian values. The last hidden layer is followed\\nby a fully-connected layer with 10 activations (one per\\nclass) and cross-entropy loss. We trained the network for\\n50000 steps, with 60 examples per mini-batch. We added\\nBatch Normalization to each hidden layer of the network,\\nas in Sec. 3.1. We were interested in the comparison between the baseline and batch-normalized networks, rather\\nthan achieving the state of the art performance on MNIST\\n(which the described architecture does not).\\nFigure 1(a) shows the fraction of correct predictions\\nby the two networks on held-out test data, as training\\nprogresses. The batch-normalized network enjoys the\\nhigher test accuracy. To investigate why, we studied inputs to the sigmoid, in the original network N and batchnormalized network N [tr] BN [(Alg. 2) over the course of train-]\\ning. In Fig. 1(b,c) we show, for one typical activation from\\nthe last hidden layer of each network, how its distribution evolves. The distributions in the original network\\nchange significantly over time, both in their mean and\\nthe variance, which complicates the training of the subsequent layers. In contrast, the distributions in the batchnormalized network are much more stable as training progresses, which aids the training.\\n\\n\\n**4.2** **ImageNet classification**\\n\\nWe applied Batch Normalization to a new variant of the\\nInception network (Szegedy et al., 2014), trained on the\\nImageNet classification task (Russakovsky et al., 2014).\\nThe network has a large number of convolutional and\\npooling layers, with a softmax layer to predict the image\\nclass, out of 1000 possibilities. Convolutional layers use\\nReLU as the nonlinearity. The main difference to the network described in (Szegedy et al., 2014) is that the 5 5\\n\\u00d7\\nconvolutional layers are replaced by two consecutive layers of 3 3 convolutions with up to 128 filters. The net\\u00d7\\nwork contains 13.6 10 [6] parameters, and, other than the\\n top softmax layer, has no fully-connected layers. More\\n\\n\\n\\ndetails are given in the Appendix. We refer to this model\\nas Inception in the rest of the text. The model was trained\\nusing a version of Stochastic Gradient Descent with momentum (Sutskever et al., 2013), using the mini-batch size\\nof 32. The training was performed using a large-scale, distributed architecture (similar to (Dean et al., 2012)). All\\nnetworks are evaluated as training progresses by computing the validation accuracy @1, i.e. the probability of\\npredicting the correct label out of 1000 possibilities, on\\na held-out set, using a single crop per image.\\nIn our experiments, we evaluated several modifications\\nof Inception with Batch Normalization. In all cases, Batch\\nNormalization was applied to the input of each nonlinearity, in a convolutional way, as described in section 3.2,\\nwhile keeping the rest of the architecture constant.\\n\\n\\n**4.2.1** **Accelerating BN Networks**\\n\\n\\nSimply adding Batch Normalization to a network does not\\ntake full advantage of our method. To do so, we further\\nchanged the network and its training parameters, as follows:\\n_Increase learning rate._ In a batch-normalized model,\\nwe have been able to achieve a training speedup from\\nhigher learning rates, with no ill side effects (Sec. 3.3).\\n_Remove Dropout._ As described in Sec. 3.4, Batch Normalization fulfills some of the same goals as Dropout. Removing Dropout from Modified BN-Inception speeds up\\ntraining, without increasing overfitting.\\n_Reduce the_ L2 _weight regularization._ While in Inception an L2 loss on the model parameters controls overfitting, in Modified BN-Inception the weight of this loss is\\nreduced by a factor of 5. We find that this improves the\\naccuracy on the held-out validation data.\\n_Accelerate the learning rate decay._ In training Inception, learning rate was decayed exponentially. Because\\nour network trains faster than Inception, we lower the\\nlearning rate 6 times faster.\\n_Remove Local Response Normalization_ While Inception and other networks (Srivastava et al., 2014) benefit\\nfrom it, we found that with Batch Normalization it is not\\nnecessary.\\n_Shuffle training examples more thoroughly._ We enabled\\nwithin-shard shuffling of the training data, which prevents\\nthe same examples from always appearing in a mini-batch\\ntogether. This led to about 1% improvements in the validation accuracy, which is consistent with the view of\\nBatch Normalization as a regularizer (Sec. 3.4): the randomization inherent in our method should be most beneficial when it affects an example differently each time it is\\nseen.\\n_Reduce the photometric distortions._ Because batchnormalized networks train faster and observe each training example fewer times, we let the trainer focus on more\\n\\u201creal\\u201d images by distorting them less.\\n\\n\\n\\n6\\n\\n\\n0.8\\n\\n\\n0.7\\n\\n\\n0.6\\n\\n\\n0.5\\n\\n\\n\\n\\n\\n0.4\\n5M 10M 15M 20M 25M 30M\\n\\n\\n\\nFigure 2: _Single crop validation accuracy of Inception_\\n_and its batch-normalized variants, vs._ _the number of_\\n_training steps._\\n\\n\\n**4.2.2** **Single-Network Classification**\\n\\nWe evaluated the following networks, all trained on the\\nLSVRC2012 training data, and tested on the validation\\ndata:\\nInception: the network described at the beginning of\\nSection 4.2, trained with the initial learning rate of 0.0015.\\nBN-Baseline: Same as Inception with Batch Normalization before each nonlinearity.\\nBN-x5: Inception with Batch Normalization and the\\nmodifications in Sec. 4.2.1. The initial learning rate was\\nincreased by a factor of 5, to 0.0075. The same learning\\nrate increase with original Inception caused the model parameters to reach machine infinity.\\nBN-x30: Like BN-x5, but with the initial learning rate\\n0.045 (30 times that of Inception).\\nBN-x5-Sigmoid: Like BN-x5, but with sigmoid nonlinearity g(t) = 1+exp(1 \\u2212x) [instead of ReLU. We also at-]\\ntempted to train the original Inception with sigmoid, but\\nthe model remained at the accuracy equivalent to chance.\\nIn Figure 2, we show the validation accuracy of the\\nnetworks, as a function of the number of training steps.\\nInception reached the accuracy of 72.2% after 31 10 [6]\\n \\ntraining steps. The Figure 3 shows, for each network,\\nthe number of training steps required to reach the same\\n72.2% accuracy, as well as the maximum validation accuracy reached by the network and the number of steps to\\nreach it.\\nBy only using Batch Normalization (BN-Baseline), we\\nmatch the accuracy of Inception in less than half the number of training steps. By applying the modifications in\\nSec. 4.2.1, we significantly increase the training speed of\\nthe network. BN-x5 needs 14 times fewer steps than Inception to reach the 72.2% accuracy. Interestingly, increasing the learning rate further (BN-x30) causes the\\nmodel to train somewhat _slower_ initially, but allows it to\\nreach a higher final accuracy. It reaches 74.8% after 6 10 [6]\\n\\n \\nsteps, i.e. 5 times fewer steps than required by Inception\\nto reach 72.2%.\\nWe also verified that the reduction in internal covariate shift allows deep networks with Batch Normalization\\n\\n\\n7\\n\\n\\n\\nModel Steps to 72.2% Max accuracy\\nInception 31.0 10 [6] 72.2%\\n BN-Baseline 13.3 10 [6] 72.7%\\n BN-x5 2.1 10 [6] 73.0%\\n BN-x30 2.7 10 [6] 74.8%\\n BN-x5-Sigmoid 69.8%\\n\\n\\nFigure 3: _For Inception and the batch-normalized_\\n_variants, the number of training steps required to_\\n_reach the maximum accuracy of Inception (72.2%),_\\n_and the maximum accuracy achieved by the net-_\\n_work._\\n\\n\\nto be trained when sigmoid is used as the nonlinearity,\\ndespite the well-known difficulty of training such networks. Indeed, BN-x5-Sigmoid achieves the accuracy of\\n69.8%. Without Batch Normalization, Inception with sigmoid never achieves better than 1/1000 accuracy.\\n\\n\\n**4.2.3** **Ensemble Classification**\\n\\nThe current reported best results on the ImageNet Large\\nScale Visual Recognition Competition are reached by the\\nDeep Image ensemble of traditional models (Wu et al.,\\n2015) and the ensemble model of (He et al., 2015). The\\nlatter reports the top-5 error of 4.94%, as evaluated by the\\nILSVRC server. Here we report a top-5 validation error of\\n4.9%, and test error of 4.82% (according to the ILSVRC\\nserver). This improves upon the previous best result, and\\nexceeds the estimated accuracy of human raters according\\nto (Russakovsky et al., 2014).\\nFor our ensemble, we used 6 networks. Each was based\\non BN-x30, modified via some of the following: increased\\ninitial weights in the convolutional layers; using Dropout\\n(with the Dropout probability of 5% or 10%, vs. 40%\\nfor the original Inception); and using non-convolutional,\\nper-activation Batch Normalization with last hidden layers of the model. Each network achieved its maximum\\naccuracy after about 6 10 [6] training steps. The ensemble\\n prediction was based on the arithmetic average of class\\nprobabilities predicted by the constituent networks. The\\ndetails of ensemble and multicrop inference are similar to\\n(Szegedy et al., 2014).\\nWe demonstrate in Fig. 4 that batch normalization allows us to set new state-of-the-art by a healthy margin on\\nthe ImageNet classification challenge benchmarks.\\n\\n### **5 Conclusion**\\n\\n\\nWe have presented a novel mechanism for dramatically\\naccelerating the training of deep networks. It is based on\\nthe premise that covariate shift, which is known to complicate the training of machine learning systems, also ap\\n\\nModel Resolution Crops Models Top-1 error Top-5 error\\nGoogLeNet ensemble 224 144 7 - 6.67%\\nDeep Image low-res 256 - 1 - 7.96%\\nDeep Image high-res 512 - 1 24.88 7.42%\\nDeep Image ensemble variable - - - 5.98%\\nBN-Inception single crop 224 1 1 25.2% 7.82%\\nBN-Inception multicrop 224 144 1 21.99% 5.82%\\nBN-Inception ensemble 224 144 6 20.1% **4.9%** \\n\\nFigure 4: _Batch-Normalized Inception comparison with previous state of the art on the provided validation set com-_\\n_prising 50000 images. *BN-Inception ensemble has reached 4.82% top-5 error on the 100000 images of the test set of_\\n_the ImageNet as reported by the test server._\\n\\n\\n\\nplies to sub-networks and layers, and removing it from\\ninternal activations of the network may aid in training.\\nOur proposed method draws its power from normalizing\\nactivations, and from incorporating this normalization in\\nthe network architecture itself. This ensures that the normalization is appropriately handled by any optimization\\nmethod that is being used to train the network. To enable stochastic optimization methods commonly used in\\ndeep network training, we perform the normalization for\\neach mini-batch, and backpropagate the gradients through\\nthe normalization parameters. Batch Normalization adds\\nonly two extra parameters per activation, and in doing so\\npreserves the representation ability of the network. We\\npresented an algorithm for constructing, training, and performing inference with batch-normalized networks. The\\nresulting networks can be trained with saturating nonlinearities, are more tolerant to increased training rates, and\\noften do not require Dropout for regularization.\\n\\nMerely adding Batch Normalization to a state-of-theart image classification model yields a substantial speedup\\nin training. By further increasing the learning rates, removing Dropout, and applying other modifications afforded by Batch Normalization, we reach the previous\\nstate of the art with only a small fraction of training steps\\n\\n- and then beat the state of the art in single-network image\\nclassification. Furthermore, by combining multiple models trained with Batch Normalization, we perform better\\nthan the best known system on ImageNet, by a significant\\nmargin.\\n\\nInterestingly, our method bears similarity to the standardization layer of (G\\u00a8ulc\\u00b8ehre & Bengio, 2013), though\\nthe two methods stem from very different goals, and perform different tasks. The goal of Batch Normalization\\nis to achieve a stable distribution of activation values\\nthroughout training, and in our experiments we apply it\\nbefore the nonlinearity since that is where matching the\\nfirst and second moments is more likely to result in a\\nstable distribution. On the contrary, (G\\u00a8ulc\\u00b8ehre & Bengio,\\n2013) apply the standardization layer to the _output_ of the\\nnonlinearity, which results in sparser activations. In our\\nlarge-scale image classification experiments, we have not\\nobserved the nonlinearity _inputs_ to be sparse, neither with\\nnor without Batch Normalization. Other notable differ\\n\\n\\nentiating characteristics of Batch Normalization include\\nthe learned scale and shift that allow the BN transform\\nto represent identity (the standardization layer did not require this since it was followed by the learned linear transform that, conceptually, absorbs the necessary scale and\\nshift), handling of convolutional layers, deterministic inference that does not depend on the mini-batch, and batchnormalizing each convolutional layer in the network.\\nIn this work, we have not explored the full range of\\npossibilities that Batch Normalization potentially enables.\\nOur future work includes applications of our method to\\nRecurrent Neural Networks (Pascanu et al., 2013), where\\nthe internal covariate shift and the vanishing or exploding\\ngradients may be especially severe, and which would allow us to more thoroughly test the hypothesis that normalization improves gradient propagation (Sec. 3.3). We plan\\nto investigate whether Batch Normalization can help with\\ndomain adaptation, in its traditional sense \\u2013 i.e. whether\\nthe normalization performed by the network would allow it to more easily generalize to new data distributions, perhaps with just a recomputation of the population\\nmeans and variances (Alg. 2). Finally, we believe that further theoretical analysis of the algorithm would allow still\\nmore improvements and applications.\\n\\n### **References**\\n\\n\\nBengio, Yoshua and Glorot, Xavier. Understanding the\\ndifficulty of training deep feedforward neural networks.\\nIn _Proceedings of AISTATS 2010_, volume 9, pp. 249\\u2013\\n256, May 2010.\\n\\n\\nDean, Jeffrey, Corrado, Greg S., Monga, Rajat, Chen, Kai,\\nDevin, Matthieu, Le, Quoc V., Mao, Mark Z., Ranzato,\\nMarc\\u2019Aurelio, Senior, Andrew, Tucker, Paul, Yang, Ke,\\nand Ng, Andrew Y. Large scale distributed deep networks. In _NIPS_, 2012.\\n\\n\\nDesjardins, Guillaume and Kavukcuoglu, Koray. Natural\\nneural networks. (unpublished).\\n\\n\\nDuchi, John, Hazan, Elad, and Singer, Yoram. Adaptive\\nsubgradient methods for online learning and stochastic\\n\\n\\n\\n8\\n\\n\\noptimization. _J. Mach. Learn. Res._, 12:2121\\u20132159,July\\n2011. ISSN 1532-4435.\\n\\n\\nG\\u00a8ulc\\u00b8ehre, C\\u00b8 aglar and Bengio, Yoshua. Knowledge matters: Importance of prior information for optimization.\\n_CoRR_, abs/1301.4083, 2013.\\n\\n\\nHe, K., Zhang, X., Ren, S., and Sun, J. Delving Deep\\ninto Rectifiers: Surpassing Human-Level Performance\\non ImageNet Classification. _ArXiv e-prints_, February\\n2015.\\n\\n\\nHyv\\u00a8arinen, A. and Oja, E. Independent component analysis: Algorithms and applications. _Neural Netw._, 13\\n(4-5):411\\u2013430, May 2000.\\n\\n\\nJiang, Jing. A literature survey on domain adaptation of\\nstatistical classifiers, 2008.\\n\\n\\nLeCun, Y., Bottou, L., Bengio, Y., and Haffner, P.\\nGradient-based learning applied to document recognition. _Proceedings of the IEEE_, 86(11):2278\\u20132324,\\nNovember 1998a.\\n\\n\\nLeCun, Y., Bottou, L., Orr, G., and Muller, K. Efficient\\nbackprop. In Orr, G. and K., Muller (eds.), _Neural Net-_\\n_works: Tricks of the trade_ . Springer, 1998b.\\n\\n\\nLyu, S and Simoncelli, E P. Nonlinear image representation using divisive normalization. In _Proc. Computer_\\n_Vision and Pattern Recognition_, pp. 1\\u20138. IEEE Computer Society, Jun 23-28 2008. doi: 10.1109/CVPR.\\n2008.4587821.\\n\\n\\nNair, Vinod and Hinton, Geoffrey E. Rectified linear units\\nimprove restricted boltzmann machines. In _ICML_, pp.\\n807\\u2013814. Omnipress, 2010.\\n\\n\\nPascanu, Razvan, Mikolov, Tomas, and Bengio, Yoshua.\\nOn the difficulty of training recurrent neural networks.\\nIn _Proceedings of the 30th International Conference on_\\n_Machine Learning, ICML 2013, Atlanta, GA, USA, 16-_\\n_21 June 2013_, pp. 1310\\u20131318, 2013.\\n\\n\\nPovey, Daniel, Zhang, Xiaohui, and Khudanpur, Sanjeev. Parallel training of deep neural networks with\\nnatural gradient and parameter averaging. _CoRR_,\\nabs/1410.7455, 2014.\\n\\n\\nRaiko, Tapani, Valpola, Harri, and LeCun, Yann. Deep\\nlearning made easier by linear transformations in perceptrons. In _International Conference on Artificial In-_\\n_telligence and Statistics (AISTATS)_, pp. 924\\u2013932, 2012.\\n\\n\\nRussakovsky, Olga, Deng, Jia, Su, Hao, Krause, Jonathan,\\nSatheesh, Sanjeev, Ma, Sean, Huang, Zhiheng, Karpathy, Andrej, Khosla, Aditya, Bernstein, Michael, Berg,\\nAlexander C., and Fei-Fei, Li. ImageNet Large Scale\\nVisual Recognition Challenge, 2014.\\n\\n\\n\\nSaxe, Andrew M., McClelland, James L., and Ganguli,\\nSurya. Exact solutions to the nonlinear dynamics\\nof learning in deep linear neural networks. _CoRR_,\\nabs/1312.6120, 2013.\\n\\n\\nShimodaira, Hidetoshi. Improving predictive inference\\nunder covariate shift by weighting the log-likelihood\\nfunction. _Journal of Statistical Planning and Inference_,\\n90(2):227\\u2013244, October 2000.\\n\\n\\nSrivastava, Nitish, Hinton, Geoffrey, Krizhevsky, Alex,\\nSutskever, Ilya, and Salakhutdinov, Ruslan. Dropout:\\nA simple way to prevent neural networks from overfitting. _J. Mach. Learn. Res._, 15(1):1929\\u20131958, January\\n2014.\\n\\n\\nSutskever, Ilya, Martens, James, Dahl, George E., and\\nHinton, Geoffrey E. On the importance of initialization and momentum in deep learning. In _ICML_\\n_(3)_, volume 28 of _JMLR Proceedings_, pp. 1139\\u20131147.\\nJMLR.org, 2013.\\n\\n\\nSzegedy, Christian, Liu, Wei, Jia, Yangqing, Sermanet,\\nPierre, Reed, Scott, Anguelov, Dragomir, Erhan, Dumitru, Vanhoucke, Vincent, and Rabinovich, Andrew. Going deeper with convolutions. _CoRR_,\\nabs/1409.4842, 2014.\\n\\n\\nWiesler, Simon and Ney, Hermann. A convergence analysis of log-linear training. In Shawe-Taylor, J., Zemel,\\nR.S., Bartlett, P., Pereira, F.C.N., and Weinberger, K.Q.\\n(eds.), _Advances in Neural Information Processing Sys-_\\n_tems 24_, pp. 657\\u2013665, Granada, Spain, December 2011.\\n\\n\\nWiesler, Simon, Richard, Alexander, Schl\\u00a8uter, Ralf, and\\nNey, Hermann. Mean-normalized stochastic gradient\\nfor large-scale deep learning. In _IEEE International_\\n_Conference on Acoustics, Speech, and Signal Process-_\\n_ing_, pp. 180\\u2013184, Florence, Italy, May 2014.\\n\\n\\nWu, Ren, Yan, Shengen, Shan, Yi, Dang, Qingqing, and\\nSun, Gang. Deep image: Scaling up image recognition,\\n2015.\\n\\n### **Appendix**\\n\\n**Variant of the Inception Model Used**\\n\\nFigure 5 documents the changes that were performed\\ncompared to the architecture with respect to the\\nGoogleNet archictecture. For the interpretation of this\\ntable, please consult (Szegedy et al., 2014). The notable\\narchitecture changes compared to the GoogLeNet model\\ninclude:\\n\\n\\nThe 5 5 convolutional layers are replaced by two\\n\\n - \\u00d7\\nconsecutive 3 3 convolutional layers. This in\\u00d7\\ncreases the maximum depth of the network by 9\\n\\n\\n\\n9\\n\\n\\nweight layers. Also it increases the number of parameters by 25% and the computational cost is increased by about 30%.\\n\\nThe number 28 28 inception modules is increased\\n\\n - \\u00d7\\nfrom 2 to 3.\\n\\nInside the modules, sometimes average, sometimes\\n\\n maximum-pooling is employed. This is indicated in\\nthe entries corresponding to the pooling layers of the\\ntable.\\n\\nThere are no across the board pooling layers be\\n tween any two Inception modules, but stride-2 convolution/pooling layers are employed before the filter concatenation in the modules 3c, 4e.\\n\\nOur model employed separable convolution with depth\\nmultiplier 8 on the first convolutional layer. This reduces\\nthe computational cost while increasing the memory consumption at training time.\\n\\n\\n10\\n\\n\\n**patch size/**\\n**type**\\n**stride**\\n\\n\\n\\n**output** **depth** #1\\u00d71 #3\\u00d73 #3\\u00d73 **double** #3\\u00d73\\n**size** **reduce** **reduce**\\n\\n\\n\\n**double**\\n#3\\u00d73 **Pool +proj**\\n\\n\\n\\nconvolution* 7\\u00d77/2 112\\u00d7112\\u00d764 1\\nmax pool 3\\u00d73/2 56\\u00d756\\u00d764 0\\nconvolution 3\\u00d73/1 56\\u00d756\\u00d7192 1 64 192\\nmax pool 3\\u00d73/2 28\\u00d728\\u00d7192 0\\ninception (3a) 28\\u00d728\\u00d7256 3 64 64 64 64 96 avg + 32\\ninception (3b) 28\\u00d728\\u00d7320 3 64 64 96 64 96 avg + 64\\ninception (3c) stride 2 28\\u00d728\\u00d7576 3 0 128 160 64 96 max + pass through\\ninception (4a) 14\\u00d714\\u00d7576 3 224 64 96 96 128 avg + 128\\ninception (4b) 14\\u00d714\\u00d7576 3 192 96 128 96 128 avg + 128\\ninception (4c) 14\\u00d714\\u00d7576 3 160 128 160 128 160 avg + 128\\ninception (4d) 14\\u00d714\\u00d7576 3 96 128 192 160 192 avg + 128\\ninception (4e) stride 2 14\\u00d714\\u00d71024 3 0 128 192 192 256 max + pass through\\ninception (5a) 7\\u00d77\\u00d71024 3 352 192 320 160 224 avg + 128\\ninception (5b) 7\\u00d77\\u00d71024 3 352 192 320 192 224 max + 128\\navg pool 7\\u00d77/1 1\\u00d71\\u00d71024 0\\n\\n\\n\\nFigure 5: Inception architecture\\n\\n\\n11\\n\\n\\n\"}</tool_result>"}, {"role": "assistant", "content": "<tool_call>{\"name\": \"mcprunpython__run_python_code\", \"arguments\": {\"python_code\": \"import math\\nx = [2,4,4,4,5,5,7,9]\\nmean = sum(x)/len(x)\\nvar = sum((xi-mean)**2 for xi in x)/len(x)\\nval = 4\\nepsilon = 1e-5\\nx_hat = (val-mean)/math.sqrt(var+epsilon)\\nmean, var, x_hat\"}}</tool_call>"}, {"role": "tool", "content": "<tool_result tool_call_id=\"call_AyOxpsH9xlRnjKiJYw9Jl7vh\"><status>success</status>\n<return_value>\n[\n 5.0,\n 4.0,\n -0.49999937500117186\n]\n</return_value></tool_result>"}, {"role": "assistant", "content": "Using the BN definition from the paper (Algorithm 1):\n\n- Batch: \\(x = [2,4,4,4,5,5,7,9]\\)\n- \\(\\gamma = 1\\), \\(\\beta = 0\\), \\(\\epsilon = 10^{-5}\\)\n\n1. Batch mean:\n\\[\n\\mu_B = \\frac{2+4+4+4+5+5+7+9}{8} = \\frac{40}{8} = 5\n\\]\n\n2. Batch variance (with divisor \\(m\\), as in the paper):\n\\[\n\\sigma_B^2 = \\frac{(2-5)^2 + 3\\cdot(4-5)^2 + 2\\cdot(5-5)^2 + (7-5)^2 + (9-5)^2}{8}\n= \\frac{9 + 3\\cdot 1 + 0 + 4 + 16}{8}\n= \\frac{32}{8} = 4\n\\]\n\n3. Normalized value for \\(x=4\\):\n\\[\n\\hat{x} = \\frac{x - \\mu_B}{\\sqrt{\\sigma_B^2 + \\epsilon}}\n= \\frac{4 - 5}{\\sqrt{4 + 10^{-5}}}\n= \\frac{-1}{\\sqrt{4.00001}}\n\\approx \\frac{-1}{2.0000025}\n\\approx -0.499999\n\\]\n\nSince \\(\\gamma = 1\\), \\(\\beta = 0\\), the BN output is:\n\\[\ny = \\gamma \\hat{x} + \\beta \\approx -0.5\n\\]\n\n**Answer:** The normalized value for \\(x = 4\\) is approximately **\\(-0.5\\)** (more precisely, \\(-0.499999\\))."}], "tools": [{"name": "arxiv-mcp-server__download_paper", "description": "Download a paper and create a resource for it", "parameters": {"properties": {"check_status": {"default": false, "description": "If true, only check conversion status without downloading", "type": "boolean"}, "paper_id": {"description": "The arXiv ID of the paper to download", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__list_papers", "description": "List all existing papers available as resources", "parameters": {"properties": {}, "required": [], "type": "object"}}, {"name": "arxiv-mcp-server__read_paper", "description": "Read the full content of a stored paper in markdown format", "parameters": {"properties": {"paper_id": {"description": "The arXiv ID of the paper to read", "type": "string"}}, "required": ["paper_id"], "type": "object"}}, {"name": "arxiv-mcp-server__search_papers", "description": "Search for papers on arXiv with advanced filtering and query optimization.\n\nQUERY CONSTRUCTION GUIDELINES:\n- Use QUOTED PHRASES for exact matches: \"multi-agent systems\", \"neural networks\", \"machine learning\"\n- Combine related concepts with OR: \"AI agents\" OR \"software agents\" OR \"intelligent agents\" \n- Use field-specific searches for precision:\n - ti:\"exact title phrase\" - search in titles only\n - au:\"author name\" - search by author\n - abs:\"keyword\" - search in abstracts only\n- Use ANDNOT to exclude unwanted results: \"machine learning\" ANDNOT \"survey\"\n- For best results, use 2-4 core concepts rather than long keyword lists\n\nADVANCED SEARCH PATTERNS:\n- Field + phrase: ti:\"transformer architecture\" for papers with exact title phrase\n- Multiple fields: au:\"Smith\" AND ti:\"quantum\" for author Smith's quantum papers \n- Exclusions: \"deep learning\" ANDNOT (\"survey\" OR \"review\") to exclude survey papers\n- Broad + narrow: \"artificial intelligence\" AND (robotics OR \"computer vision\")\n\nCATEGORY FILTERING (highly recommended for relevance):\n- cs.AI: Artificial Intelligence\n- cs.MA: Multi-Agent Systems \n- cs.LG: Machine Learning\n- cs.CL: Computation and Language (NLP)\n- cs.CV: Computer Vision\n- cs.RO: Robotics\n- cs.HC: Human-Computer Interaction\n- cs.CR: Cryptography and Security\n- cs.DB: Databases\n\nEXAMPLES OF EFFECTIVE QUERIES:\n- ti:\"reinforcement learning\" with categories: [\"cs.LG\", \"cs.AI\"] - for RL papers by title\n- au:\"Hinton\" AND \"deep learning\" with categories: [\"cs.LG\"] - for Hinton's deep learning work\n- \"multi-agent\" ANDNOT \"survey\" with categories: [\"cs.MA\"] - exclude survey papers\n- abs:\"transformer\" AND ti:\"attention\" with categories: [\"cs.CL\"] - attention papers with transformer abstracts\n\nDATE FILTERING: Use YYYY-MM-DD format for historical research:\n- date_to: \"2015-12-31\" - for foundational/classic work (pre-2016)\n- date_from: \"2020-01-01\" - for recent developments (post-2020)\n- Both together for specific time periods\n\nRESULT QUALITY: Results sorted by RELEVANCE (most relevant papers first), not just newest papers.\nThis ensures you get the most pertinent results regardless of publication date.\n\nTIPS FOR FOUNDATIONAL RESEARCH:\n- Use date_to: \"2010-12-31\" to find classic papers on BDI, SOAR, ACT-R\n- Combine with field searches: ti:\"BDI\" AND abs:\"belief desire intention\" \n- Try author searches: au:\"Rao\" AND \"BDI\" for Anand Rao's foundational BDI work", "parameters": {"properties": {"categories": {"description": "Strongly recommended: arXiv categories to focus search (e.g., ['cs.AI', 'cs.MA'] for agent research, ['cs.LG'] for ML, ['cs.CL'] for NLP, ['cs.CV'] for vision). Greatly improves relevance.", "items": {"type": "string"}, "type": "array"}, "date_from": {"description": "Start date for papers (YYYY-MM-DD format). Use to find recent work, e.g., '2023-01-01' for last 2 years.", "type": "string"}, "date_to": {"description": "End date for papers (YYYY-MM-DD format). Use with date_from to find historical work, e.g., '2020-12-31' for older research.", "type": "string"}, "max_results": {"description": "Maximum number of results to return (default: 10, max: 50). Use 15-20 for comprehensive searches.", "type": "integer"}, "query": {"description": "Search query using quoted phrases for exact matches (e.g., '\"machine learning\" OR \"deep learning\"') or specific technical terms. Avoid overly broad or generic terms.", "type": "string"}, "sort_by": {"description": "Sort results by 'relevance' (most relevant first, default) or 'date' (newest first). Use 'relevance' for focused searches, 'date' for recent developments.", "enum": ["relevance", "date"], "type": "string"}}, "required": ["query"], "type": "object"}}, {"name": "mcprunpython__run_python_code", "description": "Tool to execute Python code and return stdout, stderr, and return value.\n\nThe code may be async, and the value on the last line will be returned as the return value.\n\nThe code will be executed with Python 3.12.\n\nDependencies may be defined via PEP 723 script metadata, e.g. to install \"pydantic\", the script should start\nwith a comment of the form:\n\n# /// script\n# dependencies = ['pydantic']\n# ///\nprint('python code here')\n", "parameters": {"$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": {"python_code": {"description": "Python code to run", "type": "string"}}, "required": ["python_code"], "type": "object"}}, {"name": "platform__manage_schedule", "description": "Manage scheduled recipe execution for this goose instance.\n\nActions:\n- \"list\": List all scheduled jobs\n- \"create\": Create a new scheduled job from a recipe file\n- \"run_now\": Execute a scheduled job immediately \n- \"pause\": Pause a scheduled job\n- \"unpause\": Resume a paused job\n- \"delete\": Remove a scheduled job\n- \"kill\": Terminate a currently running job\n- \"inspect\": Get details about a running job\n- \"sessions\": List execution history for a job\n- \"session_content\": Get the full content (messages) of a specific session\n", "parameters": {"properties": {"action": {"enum": ["list", "create", "run_now", "pause", "unpause", "delete", "kill", "inspect", "sessions", "session_content"], "type": "string"}, "cron_expression": {"description": "A cron expression for create action. Supports both 5-field (minute hour day month weekday) and 6-field (second minute hour day month weekday) formats. 5-field expressions are automatically converted to 6-field by prepending '0' for seconds.", "type": "string"}, "job_id": {"description": "Job identifier for operations on existing jobs", "type": "string"}, "limit": {"default": 50, "description": "Limit for sessions list", "type": "integer"}, "recipe_path": {"description": "Path to recipe file for create action", "type": "string"}, "session_id": {"description": "Session identifier for session_content action", "type": "string"}}, "required": ["action"], "type": "object"}}, {"name": "subagent", "description": "Delegate a task to a subagent that runs independently with its own context.\n\nModes:\n1. Ad-hoc: Provide `instructions` for a custom task\n2. Predefined: Provide `subrecipe` name to run a predefined task\n3. Augmented: Provide both `subrecipe` and `instructions` to add context\n\nThe subagent has access to the same tools as you by default. Use `extensions` to limit which extensions the subagent can use.\n\nFor parallel execution, make multiple `subagent` tool calls in the same message.", "parameters": {"properties": {"extensions": {"description": "Extensions to enable. Omit to inherit all, empty array for none.", "items": {"type": "string"}, "type": "array"}, "instructions": {"description": "Instructions for the subagent. Required for ad-hoc tasks. For predefined tasks, adds additional context.", "type": "string"}, "parameters": {"additionalProperties": true, "description": "Parameters for the subrecipe. Only valid when 'subrecipe' is specified.", "properties": {}, "required": [], "type": "object"}, "settings": {"description": "Override model/provider settings.", "properties": {"model": {"description": "Override model", "type": "string"}, "provider": {"description": "Override LLM provider", "type": "string"}, "temperature": {"description": "Override temperature", "type": "number"}}, "required": [], "type": "object"}, "subrecipe": {"description": "Name of a predefined subrecipe to run.", "type": "string"}, "summary": {"default": true, "description": "If true (default), return only the subagent's final summary.", "type": "boolean"}}, "required": [], "type": "object"}}]} | |