SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2023.emnlp-main.771 · EMNLP · 2023

Multi-Source Multi-Type Knowledge Exploration and Exploitation for Dialogue Generation

Zhaochun Ren, Piji Li, Hongliang Dai, Xuanfan Ni, Lu Xun, Zhou Zuoren, Zhou Shuren

Open in the Atlas

Code that ran

9 of 12 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; 2 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-24; 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/2023.emnlp-main.771.json · badge: /api/ran/2023.emnlp-main.771.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
Patrick-Ni/KnowEE canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
check_token_len Ran
ran on a synthesized input
Patrick-Ni/KnowEE/src/batch_generate.py
code served (permissive licence) · get_code("cdbf668e80f14d0c")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was 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 numpy as np

torch.manual_seed(0)

class MockTokenizer:
    """Stand-in tokenizer that mimics HuggingFace tokenizer interface"""
    def __call__(self, text, return_tensors=None, truncation=None, padding=None, add_special_tokens=None):
        # Simulate tokenization by creating a simple token count based on text length
        # Each word roughly becomes 1-2 tokens
        token_count = min(len(text.split()) * 2 + 2, 512)  # Cap at 512 for truncation simulation
        
        # Return dict with 'input_ids' as a tensor of shape (1, token_count)
        input_ids = torch.ones((1, token_count), dtype=torch.long)
        return {'input_ids': input_ids}

# Create sample texts of varying lengths
texts = [
    "This is a short text.",
    "This is a longer text with more words to simulate different token lengths.",
    "Another example text for testing the tokenizer.",
    "Short.",
]

# Create tokenizer instance
tokenizer = MockTokenizer()

# Construct ARGS dictionary
ARGS = {
    'tokenizer': tokenizer,
    'texts': texts,
}
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 tuple, ndim 1, dtype family float — a tuple 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
cut_list Ran
ran on a synthesized input
Patrick-Ni/KnowEE/src/batch_generate.py
code served (permissive licence) · get_code("f658f29e3c0c793a")
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. 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

torch.manual_seed(0)

ARGS = {
    "lists": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    "cut_len": [3, 4, 3]
}
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 list — a list 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
distinct_n_corpus_level Ran
ran, honoured the contract we drafted
Patrick-Ni/KnowEE/eval/distinct_n.py
code served (permissive licence) · get_code("22eaa33aa53d3501")
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 float, ndim 0, dtype family float, shape () 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.

from itertools import chain

torch_imported = False
try:
    import torch
    torch_imported = True
except ImportError:
    pass

# Setup the function definitions (copied from problem statement)
def pad_sequence(sequence, n, pad_left=False, pad_right=False, left_pad_symbol=None, right_pad_symbol=None):
    sequence = iter(sequence)
    if pad_left:
        sequence = chain((left_pad_symbol,) * (n - 1), sequence)
    if pad_right:
        sequence = chain(sequence, (right_pad_symbol,) * (n - 1))
    return sequence

def ngrams(sequence, n, pad_left=False, pad_right=False, left_pad_symbol=None, right_pad_symbol=None):
    sequence = pad_sequence(sequence, n, pad_left, pad_right, left_pad_symbol, right_pad_symbol)
    history = []
    while n > 1:
        history.append(next(sequence))
        n -= 1
    for item in sequence:
        history.append(item)
        yield tuple(history)
        del history[0]

def distinct_n_sentence_level(sentence, n):
    if len(sentence) == 0:
        return 0.0
    distinct_ngrams = set(ngrams(sentence, n))
    return len(distinct_ngrams) / len(sentence)

def distinct_n_corpus_level(sentences, n):
    return sum((distinct_n_sentence_level(sentence, n) for sentence in sentences)) / len(sentences)

# Create test data
# sentences: a list of sentences (each sentence is a list of words/tokens)
# n: the ngram degree

sentences = [
    ['hello', 'world', 'hello', 'there'],
    ['the', 'quick', 'brown', 'fox'],
    ['a', 'b', 'c', 'd', 'a']
]

n = 2

ARGS = {
    'sentences': sentences,
    'n': n
}
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 float, ndim 0, dtype family float, shape () — shape () 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
distinct_n_sentence_level Ran
ran, honoured the contract we drafted
Patrick-Ni/KnowEE/eval/distinct_n.py
code served (permissive licence) · get_code("c95fb1137c70d230")
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 float, ndim 0, dtype family float, shape () 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.

from itertools import chain

def pad_sequence(sequence, n, pad_left=False, pad_right=False, left_pad_symbol=None, right_pad_symbol=None):
    sequence = iter(sequence)
    if pad_left:
        sequence = chain((left_pad_symbol,) * (n - 1), sequence)
    if pad_right:
        sequence = chain(sequence, (right_pad_symbol,) * (n - 1))
    return sequence

def ngrams(sequence, n, pad_left=False, pad_right=False, left_pad_symbol=None, right_pad_symbol=None):
    sequence = pad_sequence(sequence, n, pad_left, pad_right, left_pad_symbol, right_pad_symbol)
    history = []
    while n > 1:
        history.append(next(sequence))
        n -= 1
    for item in sequence:
        history.append(item)
        yield tuple(history)
        del history[0]

def distinct_n_sentence_level(sentence, n):
    if len(sentence) == 0:
        return 0.0
    distinct_ngrams = set(ngrams(sentence, n))
    return len(distinct_ngrams) / len(sentence)

ARGS = {
    "sentence": ["the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"],
    "n": 2,
}
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 float, ndim 0, dtype family float, shape () — shape () 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
load_generated_knowledge Ran
ran on a synthesized input
Patrick-Ni/KnowEE/src/load_models_and_datasets.py
code served (permissive licence) · get_code("a5a79d48f83ea145")
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, ndim 2, dtype family float; no output shape is stated. The image it ran in was 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 os
import tempfile

# Create a temporary directory with the required text files
temp_dir = tempfile.mkdtemp()
path = temp_dir + '/'

# Create emotion.txt with eval-able lines
with open(path + 'emotion.txt', 'w') as f:
    f.write("'happy'\n")
    f.write("'sad'\n")

# Create intent.txt with eval-able lines
with open(path + 'intent.txt', 'w') as f:
    f.write("'ask'\n")
    f.write("'inform'\n")

# Create need.txt with eval-able lines
with open(path + 'need.txt', 'w') as f:
    f.write("'support'\n")
    f.write("'advice'\n")

# Create persona_A.txt
with open(path + 'persona_A.txt', 'w') as f:
    f.write("friendly\n")
    f.write("helpful\n")

# Create persona_B.txt
with open(path + 'persona_B.txt', 'w') as f:
    f.write("reserved\n")
    f.write("thoughtful\n")

# Create topic.txt
with open(path + 'topic.txt', 'w') as f:
    f.write("technology\n")
    f.write("health\n")

# Create wiki.txt
with open(path + 'wiki.txt', 'w') as f:
    f.write("Wikipedia article on AI\n")
    f.write("Wikipedia article on medicine\n")

ARGS = {
    'path': path
}
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 tuple, ndim 2, dtype family float — a tuple 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
load_main_datasets Ran
ran on a synthesized input
Patrick-Ni/KnowEE/src/load_models_and_datasets.py
code served (permissive licence) · get_code("ae479151cf04f35c")
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 2, dtype family float; no output shape is stated. The image it ran in was 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 pandas as pd
import tempfile
import json
import os

# Create a temporary directory structure with test data
temp_dir = tempfile.mkdtemp()
root = temp_dir + '/'

# Create directory structure
os.makedirs(root + 'data/empathetic', exist_ok=True)
os.makedirs(root + 'data/dailydialog', exist_ok=True)
os.makedirs(root + 'data/open_dialog_kg', exist_ok=True)
os.makedirs(root + 'data/blended_skill_talk', exist_ok=True)
os.makedirs(root + 'data/persona_chat', exist_ok=True)

# Create test data files
test_data = {
    'dialogue': [
        ['Speaker 1: Hello', 'Speaker 2: Hi there'],
        ['Speaker 1: How are you?', 'Speaker 2: I am fine']
    ]
}

# Write test JSON files for each dataset
datasets = ['empathetic', 'dailydialog', 'open_dialog_kg', 'blended_skill_talk', 'persona_chat']
for dataset in datasets:
    filepath = root + f'data/{dataset}/test.json'
    with open(filepath, 'w') as f:
        json.dump(test_data, f)

ARGS = {
    'dataset': 'empathetic',
    'root': root
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, 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
pad_sequence Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
Patrick-Ni/KnowEE/eval/distinct_n.py
pointer only (licence: MIT); the stored copy get_code serves, from alex-haochenli/reco, is pointer only (licence: NONE) · get_code("cd90fe437a24c233")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from alex-haochenli/reco, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

split_batch Ran
ran; our contract draft was wrong, not the code
Patrick-Ni/KnowEE/src/batch_generate.py
pointer only (licence: MIT); the stored copy get_code serves, from mala-lab/RHO, is pointer only (licence: NONE) · get_code("52877319159d65f9")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from mala-lab/RHO, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

trans_str Ran
ran on a synthesized input
Patrick-Ni/KnowEE/src/Calculate.py
code served (permissive licence) · get_code("e9aa07fc629e7a25")
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. 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

torch.manual_seed(0)

def trans_str(string):
    string = string.replace('["none"]', '')
    strings = string.split(']')
    lists = []
    for s in strings:
        if len(s) <= 1 or s[0] != '[':
            continue
        s = eval(s + ']')
        lists.extend(s)
    return lists

# The function takes a string parameter and processes it
# It looks for patterns like ["item1", "item2"] and extracts them
# Let's create a valid test string with nested list notation

test_string = '["apple", "banana"]["orange", "grape"]'

ARGS = {
    'string': test_string
}
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 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
batch_generate Not yet run
unverified (harvested, no recorded run)
Patrick-Ni/KnowEE/src/interactive.py
code served (permissive licence) · get_code("04c570ef95f1a23e")
How it ran

no invocation recorded.

check_token_len Not yet run
unverified (harvested, no recorded run)
Patrick-Ni/KnowEE/src/Calculate.py
code served (permissive licence) · get_code("0970cd3e93e3ec68")
How it ran

no invocation recorded.

load_model_and_tokenizer Not yet run
unverified (harvested, no recorded run)
Patrick-Ni/KnowEE/src/load_models_and_datasets.py
code served (permissive licence) · get_code("bb16cfebf07908c0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 4 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 4 later) and 8 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
pad_sequence 10 other papers
5 dated earlier, 4 later, 1 same year, order not determinable
1909.09436 (2019-09)
CodeSearchNet Challenge: Evaluating the State of Semantic Code Search
1911.04700 (2019-11)
A Pre-training Based Personalized Dialogue Generation Model with Persona-sparse Data
2009.10297 (2020-09)
CodeBLEU: a Method for Automatic Evaluation of Code Synthesis
and 7 more not named here
split_batch 6 other papers
1 dated earlier, 4 later, 1 same year, order not determinable
2201.06367 (2022-01)
Towards Unsupervised Deep Graph Structure Learning
aaai_25573 (2023 (year only))
Beyond Smoothing: Unsupervised Graph Representation Learning with Edge Heterophily Discriminating
2406.10471 (2024-06)
PERSONALIZED PIECES: Efficient Personalized Large Language Models through Collaborative Efforts
and 3 more not named here
distinct_n_corpus_level 1 other paper
1 later
2408.08693 (2024-08)
Med-PMC: Medical Personalized Multi-modal Consultation with a Proactive Ask-First-Observe-Next Paradigm
distinct_n_sentence_level 1 other paper
1 later
2408.08693 (2024-08)
Med-PMC: Medical Personalized Multi-modal Consultation with a Proactive Ask-First-Observe-Next Paradigm

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

Repositories linked to this paper

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

Abstract

Open-domain multi-turn dialogue generation encounters the significant challenge of lacking various types of knowledge from diverse sources. Existing models typically focus on identifying specific types of dialogue knowledge and utilize corresponding datasets for training. However, this approach often leads to limited generalization capabilities and increased computational resource requirements. Recently, large language models (LLMs) have shown impressive performance on natural language processing tasks. To harness the knowledge storage of LLMs, we propose a framework named KnowEE that explores multi-source multi-type knowledge from LLMs by leveraging diverse datasets and then exploits the obtained knowledge for response generation. Our framework comprises two phases: First, we leverage five external datasets encompassing various types of knowledge to extract the most relevant samples to the dialogue context which are served as prompts to generate corresponding type of knowledge; Second, we inject the acquired knowledge into the ongoing dialogue context in fine-grained and coarse-grained manners, which is then fed into LLMs to generate the final dialogue response. Both automatic and manual evaluation results validate the effectiveness of our framework in exploring and exploiting multi-source multi-type knowledge to generate coherent, informative, and fluent responses. 1 * * Corresponding author. 1 Code: https://github.com/Patrick-Ni/KnowEE I am interested in the cultural history of the Republic of China period. Are Lu Xun and Zhou Shuren two people? No, Lu Xun and Zhou Shuren are the same person. Lu Xun is the pen name of Zhou Shuren.

For agents

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

get_harvested_code_for_paper("2023.emnlp-main.771")
get_code_for_paper("2023.emnlp-main.771")
have("2023.emnlp-main.771")

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

curl https://syntology.ai/api/ran/2023.emnlp-main.771.json

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

[![Syntology run record](https://syntology.ai/api/ran/2023.emnlp-main.771.svg)](https://syntology.ai/paper/2023.emnlp-main.771)

Connect an agent — have() is free.