94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
140 lines
4.8 KiB
Python
140 lines
4.8 KiB
Python
"""
|
|
Generate line data for line retrieval task.
|
|
|
|
Usage:
|
|
python3 gen_data.py --number 1000
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
from collections import defaultdict
|
|
|
|
import numpy as np
|
|
from tqdm import tqdm
|
|
|
|
|
|
def generate_lines(random_words, num_lines, redirect_ratio):
|
|
prefix = "Here is a list of lines, each with its corresponding REGISTER_CONTENT value. Please memorize them. Be prepared to provide the REGISTER_CONTENT value for a specific line index when I ask."
|
|
suffix = "The list has ended. Please give the final REGISTER_CONTENT value for a specific line after resolving the redirections and references. For example, the REGISTER_CONTENT of Line __idx0__ is __val0__. The REGISTER_CONTENT of Line __idx1__ is __val1__. The REGISTER_CONTENT of Line __idx2__ is __val2__. The REGISTER_CONTENT of Line ??? is"
|
|
|
|
# Raw lines
|
|
visited_indices = set([None])
|
|
visited_values = set([None])
|
|
|
|
lines = []
|
|
redirects = []
|
|
indices = []
|
|
values = []
|
|
for i in tqdm(range(num_lines)):
|
|
line_index = None
|
|
while line_index in visited_indices:
|
|
line_index = "-".join(np.random.choice(random_words, size=(2,)))
|
|
visited_indices.add(line_index)
|
|
|
|
line_value = np.random.randint(low=0, high=999999)
|
|
line_value = f"{line_value:06}"
|
|
|
|
line = f"Line {line_index}: The REGISTER_CONTENT is {line_value}."
|
|
lines.append(line)
|
|
redirects.append(None)
|
|
indices.append(line_index)
|
|
values.append(line_value)
|
|
|
|
# Add redirect
|
|
if redirect_ratio > 0:
|
|
num_redirect_lines = int(len(lines) * redirect_ratio)
|
|
redirect_indices = np.random.choice(
|
|
np.arange(len(lines)), size=(num_redirect_lines,), replace=False
|
|
)
|
|
for i in redirect_indices:
|
|
target_idx = np.random.choice(min(i * 2 + 100, num_lines))
|
|
lines[i] = (
|
|
f"Line {indices[i]}: The REGISTER_CONTENT is the same as Line {indices[target_idx]}."
|
|
)
|
|
redirects[i] = target_idx
|
|
|
|
# Build links and find sources
|
|
links = [[] for _ in range(num_lines)]
|
|
contains_ring = set()
|
|
for i in range(num_lines):
|
|
if redirects[i] is None:
|
|
continue
|
|
|
|
tmp_link = []
|
|
cur = i
|
|
visited = set()
|
|
while redirects[cur] is not None:
|
|
visited.add(cur)
|
|
tmp_link.append(redirects[cur])
|
|
cur = redirects[cur]
|
|
|
|
if cur in visited:
|
|
contains_ring.add(i)
|
|
tmp_link = None
|
|
break
|
|
values[i] = values[cur]
|
|
links[i] = tmp_link
|
|
|
|
# Group by num_links
|
|
group_by_num_hoops = defaultdict(list)
|
|
for i in range(num_lines):
|
|
if i in contains_ring:
|
|
continue
|
|
group_by_num_hoops[len(links[i]) + 1].append(i)
|
|
|
|
keys = sorted(list(group_by_num_hoops.keys()))
|
|
for num_links in keys:
|
|
print(f"#links: {num_links}, #lines: {len(group_by_num_hoops[num_links])}")
|
|
|
|
# Append few-shot examples
|
|
hoop1_candidates = list(group_by_num_hoops[1])
|
|
hoop1_candidate_keys = {c: max([c] + links[c]) for c in hoop1_candidates}
|
|
hoop1_candidates.sort(key=lambda c: hoop1_candidate_keys[c])
|
|
hoop2_candidates = list(group_by_num_hoops[2])
|
|
hoop2_candidate_keys = {c: max([c] + links[c]) for c in hoop2_candidates}
|
|
hoop2_candidates.sort(key=lambda c: hoop2_candidate_keys[c])
|
|
|
|
i = hoop1_candidates[5]
|
|
suffix = suffix.replace("__idx0__", indices[i]).replace("__val0__", values[i])
|
|
if len(hoop2_candidates):
|
|
i = hoop2_candidates[0]
|
|
suffix = suffix.replace("__idx1__", indices[i]).replace("__val1__", values[i])
|
|
i = hoop2_candidates[1]
|
|
suffix = suffix.replace("__idx2__", indices[i]).replace("__val2__", values[i])
|
|
else:
|
|
i = hoop1_candidates[1]
|
|
suffix = suffix.replace("__idx1__", indices[i]).replace("__val1__", values[i])
|
|
i = hoop1_candidates[10]
|
|
suffix = suffix.replace("__idx2__", indices[i]).replace("__val2__", values[i])
|
|
|
|
obj = {
|
|
"prefix": prefix,
|
|
"suffix": suffix,
|
|
"lines": lines,
|
|
"indices": indices,
|
|
"values": values,
|
|
"links": links,
|
|
"group_by_num_hoops": group_by_num_hoops,
|
|
"contains_ring": sorted(list(contains_ring)),
|
|
}
|
|
return obj
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--number", type=int)
|
|
parser.add_argument("--redirect-ratio", type=float, default=0.0)
|
|
args = parser.parse_args()
|
|
|
|
num_lines = args.number
|
|
|
|
random_words_filename = "random_words.json"
|
|
random_words = json.load(open(random_words_filename, "r"))
|
|
|
|
np.random.seed(42)
|
|
obj = generate_lines(random_words, num_lines, args.redirect_ratio)
|
|
|
|
fout = f"lines_{num_lines}_{args.redirect_ratio:.1f}.json"
|
|
with open(fout, "w") as fout:
|
|
json.dump(obj, fout, indent=2)
|