SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2409.12740 · 2024

HLLM: Enhancing Sequential Recommendations via Hierarchical Large Language Models for Item and User Modeling

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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 0 have no contract verdict; 5 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2409.12740.json · badge: /api/ran/2409.12740.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
bytedance/hllm canonical (classifier label)
classifier basis: census
5 ran · 2 no recorded run
FunctionStatusWhere it lives
construct_rewrite_prompt_withuser_opensource Ran
ran; our contract draft was wrong, not the code
bytedance/hllm/code/HLLM_Creator_data_scripts/gpt_rewrite_user_open.py
code served (permissive licence) · get_code("8c27099f9635928e")
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 str. 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
import numpy as np

# Define ARGS dict with all required parameters
ARGS = {
    "user_profile": "用户年龄:28岁,职业:软件工程师,兴趣:科幻小说、编程、人工智能、未来科技。阅读偏好:喜欢硬科幻和技术向内容。消费能力:中等。阅读频率:每周阅读3-4小时。",
    "title": "星际旅行",
    "description": "一部关于人类探索宇宙、发现外星文明的科幻冒险小说。讲述了一支精英宇航队在深空中遭遇神秘信号,引发了一系列关于宇宙本质和人类命运的思考。",
    "title_list_str": "《三体》、《火星救援》、《人工智能简史》、《深空探测器》、《编程之美》、《宇宙简史》"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
extract_json_from_markdown Ran
ran; our contract draft was wrong, not the code
bytedance/hllm/code/HLLM_Creator_data_scripts/gpt_rewrite_user_open.py
code served (permissive licence) · get_code("9330158c89f4cd1f")
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 json
import re

def extract_json_from_markdown(markdown_text):
    match = re.search('\\{.*\\}', markdown_text, flags=re.DOTALL)
    if match:
        json_str = match.group(0)
        try:
            data = json.loads(json_str)
            return data
        except json.JSONDecodeError:
            print(f'Wrong! {json_str}')
    else:
        print('No JSON found')
    return None

# Setup valid arguments
markdown_text_with_json = """
Here is some markdown text with JSON embedded:
json
{"name": "John", "age": 30, "city": "New York"}

"""

ARGS = {
    "markdown_text": markdown_text_with_json
}
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
forward Ran
ran; our contract draft was wrong, not the code
bytedance/hllm/code/HLLM_Creator_eval_scripts/generate_useremb.py
code served (permissive licence) · get_code("261d4b69d11323bc")
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 Tensor, ndim 2, dtype family float, shape (6, 8) 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Small stand-in classes for config and components
class ConfigStandIn:
    def __init__(self, hidden_size=8):
        self.hidden_size = hidden_size

class ItemEmbedding(nn.Module):
    def __init__(self, vocab_size=10, emb_dim=8):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, emb_dim)
    
    def forward(self, x):
        return self.embedding(x)

class ItemLLM(nn.Module):
    def __init__(self, hidden_size=8):
        super().__init__()
        self.config = ConfigStandIn(hidden_size=hidden_size)
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, inputs_embeds, attention_mask=None):
        # Return object with hidden_states attribute
        output = self.linear(inputs_embeds)
        return type('Output', (), {'hidden_states': [None, output]})()

class UserLLM(nn.Module):
    def __init__(self, hidden_size=8, vocab_size=100):
        super().__init__()
        self.config = ConfigStandIn(hidden_size=hidden_size)
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def get_input_embeddings(self):
        return self.embedding
    
    def forward(self, inputs_embeds, attention_mask=None):
        output = self.linear(inputs_embeds)
        return type('Output', (), {'hidden_states': [None, output]})()

class UserProjector(nn.Module):
    def __init__(self, input_size=8, output_size=8):
        super().__init__()
        self.linear = nn.Linear(input_size, output_size)
    
    def forward(self, x):
        return self.linear(x)

class HLLM(nn.Module):
    def __init__(self, user_emb_type='text_seq', hidden_size=8):
        super().__init__()
        self.user_emb_type = user_emb_type
        self.hidden_size = hidden_size
        self.item_llm = ItemLLM(hidden_size=hidden_size)
        self.user_llm = UserLLM(hidden_size=hidden_size, vocab_size=100)
        self.item_embedding = ItemEmbedding(vocab_size=20, emb_dim=hidden_size)
        self.user_projector = UserProjector(input_size=hidden_size, output_size=hidden_size)
        self.creative_llm = type('CreativeLLM', (), {'config': ConfigStandIn(hidden_size=hidden_size)})()
        self.emb_tokens = nn.Parameter(torch.randn(1, 3, hidden_size))
        self.emb_token_n = 3
        self.item_emb_token_n = 2
        self.item_emb_tokens = torch.randn(2, hidden_size)
    
    def forward_item_emb(self, seq_item_input_ids, seq_item_position_ids, cu_input_lens, item_emb_token_n, item_emb_tokens, item_llm):
        # Mock implementation
        batch_size = seq_item_input_ids.shape[0]
        seq_len = seq_item_input_ids.shape[1] if len(seq_item_input_ids.shape) > 1 else 1
        return torch.randn(batch_size, seq_len, item_llm.config.hidden_size)

# Construct arguments
N = 2  # batch size
S = 5  # sequence length
hidden_size = 8
item_seq_len = 3

hllm = HLLM(user_emb_type='text_seq', hidden_size=hidden_size)

user_prompt_ids = torch.randint(0, 100, (N, S))
user_attention_mask = torch.ones(N, S)

seq_item_input_ids = torch.randint(0, 20, (N, item_seq_len, 4))
seq_item_position_ids = torch.arange(item_seq_len).unsqueeze(0).expand(N, -1)
seq_mask = torch.ones(N, item_seq_len)
cu_input_lens = torch.tensor([0, 4, 8])
input_id_list = torch.randint(0, 20, (N, item_seq_len))

ARGS = {
    'hllm': hllm,
    'seq_item_input_ids': seq_item_input_ids,
    'seq_mask': seq_mask,
    'cu_input_lens': cu_input_lens,
    'seq_item_position_ids': seq_item_position_ids,
    'user_prompt_ids': user_prompt_ids,
    'user_attention_mask': user_attention_mask,
    'input_id_list': input_id_list,
}
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 Tensor, ndim 2, dtype family float, shape (6, 8) — shape (6, 8) 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
gen_prompt2 Ran
ran; our contract draft was wrong, not the code
bytedance/hllm/code/HLLM_Creator_data_scripts/gen_user_open.py
code served (permissive licence) · get_code("74bf1290122b46b9")
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 str. 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
import torch.nn as nn

torch.manual_seed(0)

# Analyze the function: gen_prompt2 takes two string parameters and uses them
# in an f-string to construct and return a prompt string.
# No complex objects, models, or tensors are needed.

target_title = "The Great Gatsby"
description = "A classic American novel set in the Jazz Age, exploring themes of wealth, love, and the American Dream."

ARGS = {
    "target_title": target_title,
    "description": description
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
user_prompt_opensource Ran
ran; our contract draft was wrong, not the code
bytedance/hllm/code/HLLM_Creator_data_scripts/gpt_userinfo_open.py
code served (permissive licence) · get_code("2003997271de811b")
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 str. 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

# The function user_prompt_opensource takes user_history as a parameter
# and constructs a prompt string by interpolating user_history into an f-string.
# It returns the prompt string.

# user_history should be a string containing the user's historical behavior
# (book titles they've reviewed, in chronological order from oldest to newest)

user_history_example = "《活着》 - 2022年1月\n《人生》 - 2022年6月\n《平凡的世界》 - 2023年3月\n《三体》 - 2023年11月"

ARGS = {
    "user_history": user_history_example
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
forward Not yet run
unverified (harvested, no recorded run)
bytedance/hllm/code/HLLM_Creator_eval_scripts/generate_usertitle.py
code served (permissive licence) · get_code("bab644af7cd1ef26")
How it ran

no invocation recorded.

gen_prompt Not yet run
unverified (harvested, no recorded run)
bytedance/hllm/code/HLLM_Creator_eval_scripts/gpt_eval_open.py
code served (permissive licence) · get_code("a7f4c057cdcda01d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 7 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.

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-22.

Repositories linked to this paper

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

Abstract

Large Language Models (LLMs) have achieved remarkable success in various fields, prompting several studies to explore their potential in recommendation systems. However, these attempts have so far resulted in only modest improvements over traditional recommendation models. Moreover, three critical questions remain under-explored: firstly, the real value of LLMs' pre-trained weights, often considered to encapsulate world knowledge; secondly, the necessity of fine-tuning for recommendation tasks; lastly, whether LLMs can exhibit the same scalability benefits in recommendation systems as they do in other domains. In this paper, we propose a novel Hierarchical Large Language Model (HLLM) architecture designed to enhance sequential recommendation systems. Our approach employs a two-tier model: the first Item LLM extracts rich content features from the detailed text description of the item, while the second User LLM utilizes these features to predict users' future interests based on their interaction history. Extensive experiments demonstrate that our method effectively leverages the pre-trained capabilities of open-source LLMs, and further fine-tuning leads to significant performance boosts. Additionally, HLLM achieves excellent scalability, with the largest configuration utilizing 7B parameters for both item feature extraction and user interest modeling. Moreover, HLLM offers excellent training and serving efficiency, making it practical in real-world applications. Evaluations on two large-scale datasets, PixelRec and Amazon Reviews, show that HLLM achieves state-of-the-art results, outperforming traditional ID-based models by a wide margin. In online A/B testing, HLLM showcases notable gains, validating its practical impact in real-world recommendation scenarios. Codes are available at https://github.com/bytedance/HLLM.

For agents

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

get_harvested_code_for_paper("2409.12740")
get_code_for_paper("2409.12740")
have("2409.12740")

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

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

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

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

Connect an agent — have() is free.