SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.06830 · ICLR · 2024

Lemur: Harmonizing Natural Language and Code for Language Agents

Hong Kong, Caiming Xiong, Bailin Wang, Chen Xing, Lingpeng Kong, Zhoujun Cheng, Tianbao Xie, Weijia Shi, Siheng Zhao, Yitao Liu, Yiheng Xu, Hongjin Su, and 7 more

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.06830.json · badge: /api/ran/2310.06830.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
OpenLemur/Lemur canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
dispatch_openai_chat_requesets Ran
ran; our contract draft was wrong, not the code
OpenLemur/Lemur/xchat/eval/dispatch_openai_requests.py
code served (permissive licence) · get_code("8140036b8f8671e0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned coroutine. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import asyncio
from typing import Any, Dict, List

# Setup for dispatch_openai_chat_requesets
# The function expects:
# - messages_list: List[List[Dict[str, Any]]] - list of message conversations
# - model: str - OpenAI model name
# - **completion_kwargs: Any - additional kwargs for ChatCompletion API

# Create sample messages_list with realistic OpenAI chat format
messages_list = [
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is 2+2?"},
    ],
    [
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the capital of France?"},
    ],
]

# Model name (using a standard OpenAI model string)
model = "gpt-3.5-turbo"

# Completion kwargs - standard OpenAI ChatCompletion parameters
completion_kwargs = {
    "temperature": 0.7,
    "max_tokens": 100,
    "top_p": 1.0,
}

# Construct the ARGS dict with all parameters
ARGS = {
    "messages_list": messages_list,
    "model": model,
    **completion_kwargs,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
dispatch_openai_prompt_requesets Ran
ran; our contract draft was wrong, not the code
OpenLemur/Lemur/xchat/eval/dispatch_openai_requests.py
code served (permissive licence) · get_code("1dbfc8b9e115e56e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned coroutine. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import asyncio
from typing import Any, Dict, List
from unittest.mock import AsyncMock, MagicMock
import openai

# Set up mock for OpenAI API to avoid actual network calls
openai.Completion = MagicMock()

# Create mock async response objects
async def mock_completion(**kwargs):
    """Mock async completion that returns a response-like object"""
    return f"Response for prompt: {kwargs.get('prompt', 'unknown')}"

# Configure the mock to return coroutines
openai.Completion.acreate = AsyncMock(side_effect=mock_completion)

# Define arguments
ARGS = {
    "prompt_list": [
        "What is the capital of France?",
        "Explain machine learning in simple terms.",
        "Write a short poem about AI."
    ],
    "model": "text-davinci-003",
    "max_tokens": 100,
    "temperature": 0.7,
    "top_p": 0.9
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
openai — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type coroutine — a coroutine output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a coroutine output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
estimate_pass_at_k Ran
ran; our contract draft was wrong, not the code
OpenLemur/Lemur/xchat/eval/mbpp/evaluation.py
code served (permissive licence) · get_code("af79b5e511f124e0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import itertools

# Construct valid arguments for estimate_pass_at_k

# Test case 1: num_samples as int, num_correct as list, k as int
num_samples_int = 10
num_correct_list = [5, 7, 3, 9]
k_value = 3

ARGS = {
    "num_samples": num_samples_int,
    "num_correct": num_correct_list,
    "k": k_value
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
generate_completions Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
OpenLemur/Lemur/xchat/eval/utils.py
code served (permissive licence) · get_code("3eeddf88871321ab")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from unittest.mock import MagicMock

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.pad_token_id = 0
    
    def __call__(self, texts, padding=None, return_tensors=None, add_special_tokens=None):
        batch_size = len(texts)
        seq_len = 5
        result = MagicMock()
        result.input_ids = torch.randint(1, 100, (batch_size, seq_len))
        result.attention_mask = torch.ones(batch_size, seq_len, dtype=torch.long)
        return result
    
    def batch_decode(self, token_ids, skip_special_tokens=None):
        if token_ids.dim() == 2:
            return [f"decoded_text_{i}" for i in range(token_ids.shape[0])]
        return ["decoded_text"]

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.device = torch.device('cpu')
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, attention_mask=None, stopping_criteria=None, **kwargs):
        batch_size = input_ids.shape[0]
        max_new_tokens = kwargs.get('max_new_tokens', 10)
        num_return_sequences = kwargs.get('num_return_sequences', 1)
        
        output_len = input_ids.shape[1] + max_new_tokens
        output_shape = (batch_size * num_return_sequences, output_len)
        
        output_ids = torch.randint(1, 100, output_shape)
        output_ids[:, :input_ids.shape[1]] = input_ids.repeat_interleave(num_return_sequences, dim=0)
        
        return output_ids

model = MockModel()
tokenizer = MockTokenizer()
prompts = ["Hello world", "How are you"]
batch_size = 2
stop_id_sequences = [[100, 101], [102]]
disable_tqdm = True
assigned_temperatures = [0.7, 0.8]

generation_kwargs = {
    'max_new_tokens': 10,
    'do_sample': True,
    'temperature': 0.5,
    'num_return_sequences': 1,
}

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'prompts': prompts,
    'batch_size': batch_size,
    'stop_id_sequences': stop_id_sequences,
    'disable_tqdm': disable_tqdm,
    'assigned_temperatures': assigned_temperatures,
    'generation_kwargs': generation_kwargs,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_next_word_predictions Ran
ran on a synthesized input
OpenLemur/Lemur/xchat/eval/utils.py
code served (permissive licence) · get_code("19dce514835bd816")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal mock model
class MockModel(nn.Module):
    def __init__(self, vocab_size=1000, hidden_dim=4):
        super().__init__()
        self.linear = nn.Linear(hidden_dim, vocab_size)
        self.device_type = 'cpu'
    
    @property
    def device(self):
        class Device:
            type = 'cpu'
        return Device()
    
    def forward(self, input_ids, attention_mask):
        # Simulate model output
        batch_size = input_ids.shape[0]
        logits = self.linear(torch.randn(batch_size, 4))
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits.unsqueeze(1)  # Add sequence dimension
        return output

# Create a minimal mock tokenizer
class MockTokenizer:
    def __init__(self):
        self.vocab = {i: f"token_{i}" for i in range(1000)}
    
    def __call__(self, texts, padding=None, return_tensors=None, add_special_tokens=False):
        batch_size = len(texts)
        seq_len = 3
        
        class TokenizerOutput:
            def __init__(self):
                self.input_ids = torch.randint(0, 100, (batch_size, seq_len))
                self.attention_mask = torch.ones(batch_size, seq_len)
        
        return TokenizerOutput()
    
    def convert_ids_to_tokens(self, ids):
        if isinstance(ids, torch.Tensor):
            ids = ids.tolist()
        if isinstance(ids, list):
            return [f"token_{i}" for i in ids]
        return f"token_{ids}"

model = MockModel(vocab_size=1000, hidden_dim=4)
tokenizer = MockTokenizer()
prompts = ["Hello world", "How are you"]
candidate_token_ids = [10, 20, 30, 40]

ARGS = {
    "model": model,
    "tokenizer": tokenizer,
    "prompts": prompts,
    "candidate_token_ids": candidate_token_ids,
    "batch_size": 2,
    "return_token_predictions": False,
    "disable_tqdm": True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
getprompts Ran
ran; our contract draft was wrong, not the code
OpenLemur/Lemur/xchat/eval/humaneval/prompts.py
code served (permissive licence) · get_code("98257d49f14f4875")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ChatMLPrompt. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# Define ARGS with valid arguments for the getprompts function
ARGS = {
    'chat_format': 'chatml'
}

# Test that the setup works by calling the function with each valid format
test_formats = ['base', 'chatml', 'tulu', 'llama2chat', 'vicuna']
for fmt in test_formats:
    ARGS['chat_format'] = fmt
    # This would be called to verify setup: getprompts(**ARGS)

# Set to one specific format for final ARGS
ARGS = {
    'chat_format': 'chatml'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ChatMLPrompt — a ChatMLPrompt output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ChatMLPrompt output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_problems Ran
ran; our contract draft was wrong, not the code
OpenLemur/Lemur/xchat/eval/mbpp/data.py
code served (permissive licence) · get_code("1cf1721a0bcb876e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tempfile
import json
import gzip
import os

# Create a temporary jsonl file for testing
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test_problems.jsonl")

# Write some test data to the file
test_data = [
    {"task_id": "task_1", "description": "First task", "difficulty": 1},
    {"task_id": "task_2", "description": "Second task", "difficulty": 2},
    {"task_id": "task_3", "description": "Third task", "difficulty": 3},
]

with open(test_file, 'w') as f:
    for item in test_data:
        f.write(json.dumps(item) + '\n')

# Define ARGS with the test file path
ARGS = {
    "evalset_file": test_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_correctness Not yet run
unverified (harvested, no recorded run)
OpenLemur/Lemur/xchat/eval/mbpp/execution.py
code served (permissive licence) · get_code("b8cf46548e4cd074")
How it ran

no invocation recorded.

load_hf_lm_and_tokenizer Not yet run
unverified (harvested, no recorded run)
OpenLemur/Lemur/xchat/eval/utils.py
code served (permissive licence) · get_code("be8165ca7e91d372")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 5 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 5 later) and 4 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
estimate_pass_at_k 20 other papers
6 dated earlier, 1 the same month, 13 later
2107.03374 (2021-07)
Evaluating Large Language Models Trained on Code
2207.14255 (2022-07)
Efficient Training of Language Models to Fill in the Middle
2210.14868 (2022-10)
Multi-lingual Evaluation of Code Generation Models
and 17 more not named here
dispatch_openai_prompt_requesets 8 other papers
8 later
2401.10768 (2024-01)
Knowledge Verification to Nip Hallucination in the Bud
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
and 5 more not named here
dispatch_openai_chat_requesets 7 other papers
7 later
2401.10768 (2024-01)
Knowledge Verification to Nip Hallucination in the Bud
2401.15006 (2024-01)
Airavata: Introducing Hindi Instruction-tuned LLM
2401.16405 (2024-01)
Scaling Sparse Fine-Tuning to Large Language Models
and 4 more not named here
get_next_word_predictions 3 other papers
3 later
2406.18629 (2024-06)
Step-DPO: Step-wise Preference Optimization for Long-chain Reasoning of LLMs
2502.12067 (2025-02)
TokenSkip: Controllable Chain-of-Thought Compression in LLMs
2506.20512 (2025-06)
OctoThinker: Mid-training Incentivizes Reinforcement Learning Scaling
read_problems 1 other paper
1 later
2407.01910 (2024-07)
MG-Verilog: Multi-grained Dataset Towards Enhanced LLM-assisted Verilog Generation

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We introduce Lemur and Lemur-Chat, openly accessible language models optimized for both natural language and coding capabilities to serve as the backbone of versatile language agents. The evolution from language chat models to functional language agents demands that models not only master human interaction, reasoning, and planning but also ensure grounding in the relevant environments. This calls for a harmonious blend of language and coding capabilities in the models. Lemur and Lemur-Chat are proposed to address this necessity, demonstrating balanced proficiencies in both domains, unlike existing open-source models that tend to specialize in either. Through meticulous pretraining using a code-intensive corpus and instruction fine-tuning on text and code data, our models achieve state-of-the-art averaged performance across diverse text and coding benchmarks. Comprehensive experiments demonstrate Lemur's superiority over existing open-source models and its proficiency across various agent tasks involving human communication, tool usage, and interaction under fully-and partially-observable environments. The harmonization between natural and programming languages enables Lemur-Chat to significantly narrow the gap with proprietary models on agent abilities, providing key insights into developing advanced open-source agents adept at reasoning, planning, and operating seamlessly across environments. Our model and code have been open-sourced at https://github.com/OpenLemur/Lemur.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.06830")
get_code_for_paper("2310.06830")
have("2310.06830")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.06830.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.06830.svg)](https://syntology.ai/paper/2310.06830)

Connect an agent — have() is free.