Download gen_masc.py from jwyjohnab/MASC: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/datasets/jwyjohnab/MASC/resolve/main/gen_masc.py
- Command line
-
hf download hf://datasets/jwyjohnab/MASC/gen_masc.py
-
curl -L -o gen_masc.py https://huggingface.co/datasets/jwyjohnab/MASC/resolve/main/gen_masc.py
1.51 kB
| import random | |
| import srsly | |
| from tqdm import tqdm | |
| def load_task_init_mas(n: int, k: int): | |
| N, K = n, k | |
| l = random.sample(range(N * K * 10), N * K) | |
| ans = sorted(l) | |
| random.shuffle(l) | |
| agent_input = [l[i * K : i * K + K] for i in range(N)] | |
| expected_agent_ans = [ans[i * K : i * K + K] for i in range(N)] | |
| dataset = [] | |
| for i in tqdm(range(n)): | |
| prompt = f""" | |
| You are Agent-{i} in a multi agent system. | |
| Your task is to output `ys[{i}]` given `xs[{i}]` that passes the following `check_results` by cooperating with other agents. | |
| You can use the given tools to use the BBS for communication. When you have the final answer, submit it using the given `submit` tool. | |
| ``` | |
| def check_results(n: int, k: int, xs: list[list[int]], ys: list[list[int]]): | |
| xl = [] | |
| for x in xs: | |
| xl += x | |
| xl.sort() | |
| yl = [] | |
| if len(ys) != n: | |
| return False | |
| for y in ys: | |
| if len(y) != k: | |
| return False | |
| yl += y | |
| return xl == yl | |
| ``` | |
| n = {N} | |
| k = {K} | |
| xs[{i}] = {agent_input[i]} | |
| """ | |
| agent = { | |
| "agent_id": i, | |
| "prompt": prompt, | |
| "input_data": agent_input[i], | |
| "expected_output": expected_agent_ans[i], | |
| } | |
| dataset.append(agent) | |
| return {"n": n, "k": k, "agents": dataset} | |
| if __name__ == "__main__": | |
| k = 10 | |
| for ne in range(1, 7): | |
| n = 10**ne | |
| dataset = load_task_init_mas(n, k) | |
| srsly.write_json(f"masc/task_n{n}_k{k}.json", dataset) | |
| print(ne) | |