Spaces:
Sleeping
Sleeping
Alina Lozovskaya
commited on
Commit
·
6454c0e
1
Parent(s):
204d9e6
Auth
Browse files- Dockerfile +2 -1
- pyproject.toml +1 -1
- uv.lock +31 -16
- yourbench_space/__init__.py +0 -0
- app.py → yourbench_space/app.py +5 -106
- yourbench_space/config.py +107 -0
- yourbench_space/utils.py +4 -0
Dockerfile
CHANGED
@@ -46,6 +46,7 @@ COPY --chown=uvuser:uvuser . ./
|
|
46 |
# Expose Gradio app port
|
47 |
EXPOSE 7860
|
48 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
|
|
49 |
|
50 |
# Run the application
|
51 |
-
CMD ["uv", "run", "python", "app.py"]
|
|
|
46 |
# Expose Gradio app port
|
47 |
EXPOSE 7860
|
48 |
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
49 |
+
ENV SYSTEM=spaces
|
50 |
|
51 |
# Run the application
|
52 |
+
CMD ["uv", "run", "python", "yourbench_space/app.py"]
|
pyproject.toml
CHANGED
@@ -19,7 +19,7 @@ dependencies = [
|
|
19 |
"torch>=2.6.0",
|
20 |
"tqdm>=4.67.1",
|
21 |
"transformers>=4.48.3",
|
22 |
-
"
|
23 |
]
|
24 |
|
25 |
[build-system]
|
|
|
19 |
"torch>=2.6.0",
|
20 |
"tqdm>=4.67.1",
|
21 |
"transformers>=4.48.3",
|
22 |
+
"ruamel-yaml>=0.18.10",
|
23 |
]
|
24 |
|
25 |
[build-system]
|
uv.lock
CHANGED
@@ -532,20 +532,6 @@ wheels = [
|
|
532 |
{ url = "https://files.pythonhosted.org/packages/95/cb/002424d4f5af1425f9cfe7dcee3ed795ed1367bf0f185a6c4bf81385e1d6/gradio_client-1.7.2-py3-none-any.whl", hash = "sha256:50d61b4db3e87639430a121a7cde4303055486ed72a5035edae94b4fbe6a0e6b", size = 322052 },
|
533 |
]
|
534 |
|
535 |
-
[[package]]
|
536 |
-
name = "gradiologin"
|
537 |
-
version = "0.1.0"
|
538 |
-
source = { registry = "https://pypi.org/simple" }
|
539 |
-
dependencies = [
|
540 |
-
{ name = "authlib" },
|
541 |
-
{ name = "gradio" },
|
542 |
-
{ name = "itsdangerous" },
|
543 |
-
]
|
544 |
-
sdist = { url = "https://files.pythonhosted.org/packages/75/88/ca2122597e416e87bbc97201909fcc028f3296b39d6b5b20409d7583d204/gradiologin-0.1.0.tar.gz", hash = "sha256:388fcfb94161fc1a61492fc729bc4dff3e437b8ac063735f5a9e8886b36f35b1", size = 5905 }
|
545 |
-
wheels = [
|
546 |
-
{ url = "https://files.pythonhosted.org/packages/fc/55/c4c397bb0f9a512e9a77daaf49dbdebeaa2487930b23caa62a716ef4bf6e/gradiologin-0.1.0-py3-none-any.whl", hash = "sha256:111af87a94867f9ca0602976fdbe2f23be8d5557c91b3a4e5c2db096e7f053d0", size = 7238 },
|
547 |
-
]
|
548 |
-
|
549 |
[[package]]
|
550 |
name = "groovy"
|
551 |
version = "0.1.2"
|
@@ -1503,6 +1489,35 @@ wheels = [
|
|
1503 |
{ url = "https://files.pythonhosted.org/packages/a3/4f/0fce63e0f5cdd658e71e21abd17ac1bc9312741ebb8b3f74eeed2ebdf771/rpds_py-0.23.1-cp312-cp312-win_amd64.whl", hash = "sha256:b03a8d50b137ee758e4c73638b10747b7c39988eb8e6cd11abb7084266455165", size = 237426 },
|
1504 |
]
|
1505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1506 |
[[package]]
|
1507 |
name = "ruff"
|
1508 |
version = "0.9.9"
|
@@ -1971,7 +1986,6 @@ dependencies = [
|
|
1971 |
{ name = "asyncio" },
|
1972 |
{ name = "datasets" },
|
1973 |
{ name = "gradio", extra = ["oauth"] },
|
1974 |
-
{ name = "gradiologin" },
|
1975 |
{ name = "hf-transfer" },
|
1976 |
{ name = "langfuse" },
|
1977 |
{ name = "litellm" },
|
@@ -1980,6 +1994,7 @@ dependencies = [
|
|
1980 |
{ name = "matplotlib" },
|
1981 |
{ name = "openai" },
|
1982 |
{ name = "python-dotenv" },
|
|
|
1983 |
{ name = "torch" },
|
1984 |
{ name = "tqdm" },
|
1985 |
{ name = "transformers" },
|
@@ -1991,7 +2006,6 @@ requires-dist = [
|
|
1991 |
{ name = "asyncio", specifier = ">=3.4.3" },
|
1992 |
{ name = "datasets", specifier = ">=3.3.0" },
|
1993 |
{ name = "gradio", extras = ["oauth"], specifier = ">=5.20.0" },
|
1994 |
-
{ name = "gradiologin", specifier = ">=0.1.0" },
|
1995 |
{ name = "hf-transfer", specifier = ">=0.1.9" },
|
1996 |
{ name = "langfuse", specifier = ">=2.59.3" },
|
1997 |
{ name = "litellm", specifier = ">=1.61.16" },
|
@@ -2000,6 +2014,7 @@ requires-dist = [
|
|
2000 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
2001 |
{ name = "openai", specifier = ">=1.63.0" },
|
2002 |
{ name = "python-dotenv", specifier = ">=1.0.1" },
|
|
|
2003 |
{ name = "torch", specifier = ">=2.6.0" },
|
2004 |
{ name = "tqdm", specifier = ">=4.67.1" },
|
2005 |
{ name = "transformers", specifier = ">=4.48.3" },
|
|
|
532 |
{ url = "https://files.pythonhosted.org/packages/95/cb/002424d4f5af1425f9cfe7dcee3ed795ed1367bf0f185a6c4bf81385e1d6/gradio_client-1.7.2-py3-none-any.whl", hash = "sha256:50d61b4db3e87639430a121a7cde4303055486ed72a5035edae94b4fbe6a0e6b", size = 322052 },
|
533 |
]
|
534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
[[package]]
|
536 |
name = "groovy"
|
537 |
version = "0.1.2"
|
|
|
1489 |
{ url = "https://files.pythonhosted.org/packages/a3/4f/0fce63e0f5cdd658e71e21abd17ac1bc9312741ebb8b3f74eeed2ebdf771/rpds_py-0.23.1-cp312-cp312-win_amd64.whl", hash = "sha256:b03a8d50b137ee758e4c73638b10747b7c39988eb8e6cd11abb7084266455165", size = 237426 },
|
1490 |
]
|
1491 |
|
1492 |
+
[[package]]
|
1493 |
+
name = "ruamel-yaml"
|
1494 |
+
version = "0.18.10"
|
1495 |
+
source = { registry = "https://pypi.org/simple" }
|
1496 |
+
dependencies = [
|
1497 |
+
{ name = "ruamel-yaml-clib", marker = "platform_python_implementation == 'CPython'" },
|
1498 |
+
]
|
1499 |
+
sdist = { url = "https://files.pythonhosted.org/packages/ea/46/f44d8be06b85bc7c4d8c95d658be2b68f27711f279bf9dd0612a5e4794f5/ruamel.yaml-0.18.10.tar.gz", hash = "sha256:20c86ab29ac2153f80a428e1254a8adf686d3383df04490514ca3b79a362db58", size = 143447 }
|
1500 |
+
wheels = [
|
1501 |
+
{ url = "https://files.pythonhosted.org/packages/c2/36/dfc1ebc0081e6d39924a2cc53654497f967a084a436bb64402dfce4254d9/ruamel.yaml-0.18.10-py3-none-any.whl", hash = "sha256:30f22513ab2301b3d2b577adc121c6471f28734d3d9728581245f1e76468b4f1", size = 117729 },
|
1502 |
+
]
|
1503 |
+
|
1504 |
+
[[package]]
|
1505 |
+
name = "ruamel-yaml-clib"
|
1506 |
+
version = "0.2.12"
|
1507 |
+
source = { registry = "https://pypi.org/simple" }
|
1508 |
+
sdist = { url = "https://files.pythonhosted.org/packages/20/84/80203abff8ea4993a87d823a5f632e4d92831ef75d404c9fc78d0176d2b5/ruamel.yaml.clib-0.2.12.tar.gz", hash = "sha256:6c8fbb13ec503f99a91901ab46e0b07ae7941cd527393187039aec586fdfd36f", size = 225315 }
|
1509 |
+
wheels = [
|
1510 |
+
{ url = "https://files.pythonhosted.org/packages/48/41/e7a405afbdc26af961678474a55373e1b323605a4f5e2ddd4a80ea80f628/ruamel.yaml.clib-0.2.12-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:20b0f8dc160ba83b6dcc0e256846e1a02d044e13f7ea74a3d1d56ede4e48c632", size = 133433 },
|
1511 |
+
{ url = "https://files.pythonhosted.org/packages/ec/b0/b850385604334c2ce90e3ee1013bd911aedf058a934905863a6ea95e9eb4/ruamel.yaml.clib-0.2.12-cp312-cp312-manylinux2014_aarch64.whl", hash = "sha256:943f32bc9dedb3abff9879edc134901df92cfce2c3d5c9348f172f62eb2d771d", size = 647362 },
|
1512 |
+
{ url = "https://files.pythonhosted.org/packages/44/d0/3f68a86e006448fb6c005aee66565b9eb89014a70c491d70c08de597f8e4/ruamel.yaml.clib-0.2.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:95c3829bb364fdb8e0332c9931ecf57d9be3519241323c5274bd82f709cebc0c", size = 754118 },
|
1513 |
+
{ url = "https://files.pythonhosted.org/packages/52/a9/d39f3c5ada0a3bb2870d7db41901125dbe2434fa4f12ca8c5b83a42d7c53/ruamel.yaml.clib-0.2.12-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:749c16fcc4a2b09f28843cda5a193e0283e47454b63ec4b81eaa2242f50e4ccd", size = 706497 },
|
1514 |
+
{ url = "https://files.pythonhosted.org/packages/b0/fa/097e38135dadd9ac25aecf2a54be17ddf6e4c23e43d538492a90ab3d71c6/ruamel.yaml.clib-0.2.12-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:bf165fef1f223beae7333275156ab2022cffe255dcc51c27f066b4370da81e31", size = 698042 },
|
1515 |
+
{ url = "https://files.pythonhosted.org/packages/ec/d5/a659ca6f503b9379b930f13bc6b130c9f176469b73b9834296822a83a132/ruamel.yaml.clib-0.2.12-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:32621c177bbf782ca5a18ba4d7af0f1082a3f6e517ac2a18b3974d4edf349680", size = 745831 },
|
1516 |
+
{ url = "https://files.pythonhosted.org/packages/db/5d/36619b61ffa2429eeaefaab4f3374666adf36ad8ac6330d855848d7d36fd/ruamel.yaml.clib-0.2.12-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:b82a7c94a498853aa0b272fd5bc67f29008da798d4f93a2f9f289feb8426a58d", size = 715692 },
|
1517 |
+
{ url = "https://files.pythonhosted.org/packages/b1/82/85cb92f15a4231c89b95dfe08b09eb6adca929ef7df7e17ab59902b6f589/ruamel.yaml.clib-0.2.12-cp312-cp312-win32.whl", hash = "sha256:e8c4ebfcfd57177b572e2040777b8abc537cdef58a2120e830124946aa9b42c5", size = 98777 },
|
1518 |
+
{ url = "https://files.pythonhosted.org/packages/d7/8f/c3654f6f1ddb75daf3922c3d8fc6005b1ab56671ad56ffb874d908bfa668/ruamel.yaml.clib-0.2.12-cp312-cp312-win_amd64.whl", hash = "sha256:0467c5965282c62203273b838ae77c0d29d7638c8a4e3a1c8bdd3602c10904e4", size = 115523 },
|
1519 |
+
]
|
1520 |
+
|
1521 |
[[package]]
|
1522 |
name = "ruff"
|
1523 |
version = "0.9.9"
|
|
|
1986 |
{ name = "asyncio" },
|
1987 |
{ name = "datasets" },
|
1988 |
{ name = "gradio", extra = ["oauth"] },
|
|
|
1989 |
{ name = "hf-transfer" },
|
1990 |
{ name = "langfuse" },
|
1991 |
{ name = "litellm" },
|
|
|
1994 |
{ name = "matplotlib" },
|
1995 |
{ name = "openai" },
|
1996 |
{ name = "python-dotenv" },
|
1997 |
+
{ name = "ruamel-yaml" },
|
1998 |
{ name = "torch" },
|
1999 |
{ name = "tqdm" },
|
2000 |
{ name = "transformers" },
|
|
|
2006 |
{ name = "asyncio", specifier = ">=3.4.3" },
|
2007 |
{ name = "datasets", specifier = ">=3.3.0" },
|
2008 |
{ name = "gradio", extras = ["oauth"], specifier = ">=5.20.0" },
|
|
|
2009 |
{ name = "hf-transfer", specifier = ">=0.1.9" },
|
2010 |
{ name = "langfuse", specifier = ">=2.59.3" },
|
2011 |
{ name = "litellm", specifier = ">=1.61.16" },
|
|
|
2014 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
2015 |
{ name = "openai", specifier = ">=1.63.0" },
|
2016 |
{ name = "python-dotenv", specifier = ">=1.0.1" },
|
2017 |
+
{ name = "ruamel-yaml", specifier = ">=0.18.10" },
|
2018 |
{ name = "torch", specifier = ">=2.6.0" },
|
2019 |
{ name = "tqdm", specifier = ">=4.67.1" },
|
2020 |
{ name = "transformers", specifier = ">=4.48.3" },
|
yourbench_space/__init__.py
ADDED
File without changes
|
app.py → yourbench_space/app.py
RENAMED
@@ -8,14 +8,15 @@ import shutil
|
|
8 |
import io
|
9 |
import yaml
|
10 |
import gradio as gr
|
11 |
-
import gradiologin as gl
|
12 |
from huggingface_hub import whoami
|
13 |
from loguru import logger
|
14 |
from yourbench.pipeline import run_pipeline
|
15 |
|
16 |
-
|
|
|
|
|
17 |
UPLOAD_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
18 |
-
|
19 |
|
20 |
logger.remove()
|
21 |
logger.add(sys.stderr, level="INFO")
|
@@ -88,108 +89,6 @@ command = ["uv", "run", "yourbench", f"--config={CONFIG_PATH}"]
|
|
88 |
manager = SubprocessManager(command)
|
89 |
|
90 |
|
91 |
-
def generate_config(hf_token: gr.OAuthToken | None, hf_org, model_name, provider, base_url, api_key, max_concurrent_requests):
|
92 |
-
config = {
|
93 |
-
"hf_configuration": {
|
94 |
-
"token": hf_token,
|
95 |
-
"private": True,
|
96 |
-
"hf_organization": hf_org
|
97 |
-
},
|
98 |
-
"model_list": [{
|
99 |
-
"model_name": model_name,
|
100 |
-
"provider": provider,
|
101 |
-
"base_url": base_url,
|
102 |
-
"api_key": api_key,
|
103 |
-
"max_concurrent_requests": max_concurrent_requests
|
104 |
-
}],
|
105 |
-
"model_roles": {role: [model_name] for role in [
|
106 |
-
"ingestion", "summarization", "single_shot_question_generation",
|
107 |
-
"multi_hop_question_generation", "answer_generation", "judge_answers"
|
108 |
-
]},
|
109 |
-
"inference_config": {"max_concurrent_requests": 16},
|
110 |
-
"pipeline": {
|
111 |
-
"ingestion": {
|
112 |
-
"source_documents_dir": "/app/uploaded_files",
|
113 |
-
"output_dir": "/app/ingested",
|
114 |
-
"run": True
|
115 |
-
},
|
116 |
-
"upload_ingest_to_hub": {
|
117 |
-
"source_documents_dir": "/app/ingested",
|
118 |
-
"hub_dataset_name": "test_ingested_documents",
|
119 |
-
"local_dataset_path": "/app/ingested_dataset",
|
120 |
-
"run": True
|
121 |
-
},
|
122 |
-
"summarization": {
|
123 |
-
"source_dataset_name": "test_ingested_documents",
|
124 |
-
"output_dataset_name": "test_summaries",
|
125 |
-
"local_dataset_path": "/results/test_summaries",
|
126 |
-
"concat_existing_dataset": False,
|
127 |
-
"run": True
|
128 |
-
},
|
129 |
-
"chunking": {
|
130 |
-
"source_dataset_name": "test_summaries",
|
131 |
-
"output_dataset_name": "test_chunked_documents",
|
132 |
-
"local_dataset_path": "/results/test_chunked_documents",
|
133 |
-
"concat_existing_dataset": False,
|
134 |
-
"chunking_configuration": {
|
135 |
-
"l_min_tokens": 64,
|
136 |
-
"l_max_tokens": 128,
|
137 |
-
"tau_threshold": 0.3,
|
138 |
-
"h_min": 2,
|
139 |
-
"h_max": 4
|
140 |
-
},
|
141 |
-
"run": True
|
142 |
-
},
|
143 |
-
"single_shot_question_generation": {
|
144 |
-
"source_dataset_name": "test_chunked_documents",
|
145 |
-
"output_dataset_name": "test_single_shot_questions",
|
146 |
-
"local_dataset_path": "/results/test_single_shot_questions",
|
147 |
-
"diversification_seed": "24 year old adult",
|
148 |
-
"concat_existing_dataset": False,
|
149 |
-
"run": True
|
150 |
-
},
|
151 |
-
"multi_hop_question_generation": {
|
152 |
-
"source_dataset_name": "test_chunked_documents",
|
153 |
-
"output_dataset_name": "test_multi_hop_questions",
|
154 |
-
"local_dataset_path": "/results/test_multi_hop_questions",
|
155 |
-
"concat_existing_dataset": False,
|
156 |
-
"run": True
|
157 |
-
},
|
158 |
-
"answer_generation": {
|
159 |
-
"run": True,
|
160 |
-
"question_dataset_name": "test_single_shot_questions",
|
161 |
-
"output_dataset_name": "test_answered_questions",
|
162 |
-
"local_dataset_path": "/results/test_answered_questions",
|
163 |
-
"concat_existing_dataset": False,
|
164 |
-
"strategies": [{
|
165 |
-
"name": "zeroshot",
|
166 |
-
"prompt": "ZEROSHOT_QA_USER_PROMPT",
|
167 |
-
"model_name": model_name
|
168 |
-
}, {
|
169 |
-
"name": "gold",
|
170 |
-
"prompt": "GOLD_QA_USER_PROMPT",
|
171 |
-
"model_name": model_name
|
172 |
-
}]
|
173 |
-
},
|
174 |
-
"judge_answers": {
|
175 |
-
"run": True,
|
176 |
-
"source_judge_dataset_name": "test_answered_questions",
|
177 |
-
"output_judged_dataset_name": "test_judged_comparisons",
|
178 |
-
"local_dataset_path": "/results/test_judged_comparisons",
|
179 |
-
"concat_existing_dataset": False,
|
180 |
-
"comparing_strategies": [["zeroshot", "gold"]],
|
181 |
-
"chunk_column_index": 0,
|
182 |
-
"random_seed": 42
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
return yaml.dump(config, default_flow_style=False)
|
187 |
-
|
188 |
-
def save_config(yaml_text):
|
189 |
-
with open(CONFIG_PATH, "w") as file:
|
190 |
-
file.write(yaml_text)
|
191 |
-
return "✅ Config saved!"
|
192 |
-
|
193 |
def save_files(files: list[str]):
|
194 |
saved_paths = [shutil.move(str(pathlib.Path(file)), str(UPLOAD_DIRECTORY / pathlib.Path(file).name)) for file in files]
|
195 |
return f"Files saved to: {', '.join(saved_paths)}"
|
@@ -288,4 +187,4 @@ with gr.Blocks() as app:
|
|
288 |
kill_button = gr.Button("Kill Task")
|
289 |
kill_button.click(manager.kill_process)
|
290 |
|
291 |
-
app.launch()
|
|
|
8 |
import io
|
9 |
import yaml
|
10 |
import gradio as gr
|
|
|
11 |
from huggingface_hub import whoami
|
12 |
from loguru import logger
|
13 |
from yourbench.pipeline import run_pipeline
|
14 |
|
15 |
+
from yourbench_space.config import generate_config, save_config
|
16 |
+
from yourbench_space.utils import CONFIG_PATH, UPLOAD_DIRECTORY
|
17 |
+
|
18 |
UPLOAD_DIRECTORY.mkdir(parents=True, exist_ok=True)
|
19 |
+
|
20 |
|
21 |
logger.remove()
|
22 |
logger.add(sys.stderr, level="INFO")
|
|
|
89 |
manager = SubprocessManager(command)
|
90 |
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
def save_files(files: list[str]):
|
93 |
saved_paths = [shutil.move(str(pathlib.Path(file)), str(UPLOAD_DIRECTORY / pathlib.Path(file).name)) for file in files]
|
94 |
return f"Files saved to: {', '.join(saved_paths)}"
|
|
|
187 |
kill_button = gr.Button("Kill Task")
|
188 |
kill_button.click(manager.kill_process)
|
189 |
|
190 |
+
app.launch()
|
yourbench_space/config.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import yaml
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
from yourbench_space.utils import CONFIG_PATH
|
5 |
+
|
6 |
+
|
7 |
+
def generate_config(hf_token: gr.OAuthToken | None, hf_org, model_name, provider, base_url, api_key, max_concurrent_requests):
|
8 |
+
config = {
|
9 |
+
"hf_configuration": {
|
10 |
+
"token": hf_token,
|
11 |
+
"private": True,
|
12 |
+
"hf_organization": hf_org
|
13 |
+
},
|
14 |
+
"model_list": [{
|
15 |
+
"model_name": model_name,
|
16 |
+
"provider": provider,
|
17 |
+
"base_url": base_url,
|
18 |
+
"api_key": api_key,
|
19 |
+
"max_concurrent_requests": max_concurrent_requests
|
20 |
+
}],
|
21 |
+
"model_roles": {role: [model_name] for role in [
|
22 |
+
"ingestion", "summarization", "single_shot_question_generation",
|
23 |
+
"multi_hop_question_generation", "answer_generation", "judge_answers"
|
24 |
+
]},
|
25 |
+
"inference_config": {"max_concurrent_requests": 16},
|
26 |
+
"pipeline": {
|
27 |
+
"ingestion": {
|
28 |
+
"source_documents_dir": "/app/uploaded_files",
|
29 |
+
"output_dir": "/app/ingested",
|
30 |
+
"run": True
|
31 |
+
},
|
32 |
+
"upload_ingest_to_hub": {
|
33 |
+
"source_documents_dir": "/app/ingested",
|
34 |
+
"hub_dataset_name": "test_ingested_documents",
|
35 |
+
"local_dataset_path": "/app/ingested_dataset",
|
36 |
+
"run": True
|
37 |
+
},
|
38 |
+
"summarization": {
|
39 |
+
"source_dataset_name": "test_ingested_documents",
|
40 |
+
"output_dataset_name": "test_summaries",
|
41 |
+
"local_dataset_path": "/results/test_summaries",
|
42 |
+
"concat_existing_dataset": False,
|
43 |
+
"run": True
|
44 |
+
},
|
45 |
+
"chunking": {
|
46 |
+
"source_dataset_name": "test_summaries",
|
47 |
+
"output_dataset_name": "test_chunked_documents",
|
48 |
+
"local_dataset_path": "/results/test_chunked_documents",
|
49 |
+
"concat_existing_dataset": False,
|
50 |
+
"chunking_configuration": {
|
51 |
+
"l_min_tokens": 64,
|
52 |
+
"l_max_tokens": 128,
|
53 |
+
"tau_threshold": 0.3,
|
54 |
+
"h_min": 2,
|
55 |
+
"h_max": 4
|
56 |
+
},
|
57 |
+
"run": True
|
58 |
+
},
|
59 |
+
"single_shot_question_generation": {
|
60 |
+
"source_dataset_name": "test_chunked_documents",
|
61 |
+
"output_dataset_name": "test_single_shot_questions",
|
62 |
+
"local_dataset_path": "/results/test_single_shot_questions",
|
63 |
+
"diversification_seed": "24 year old adult",
|
64 |
+
"concat_existing_dataset": False,
|
65 |
+
"run": True
|
66 |
+
},
|
67 |
+
"multi_hop_question_generation": {
|
68 |
+
"source_dataset_name": "test_chunked_documents",
|
69 |
+
"output_dataset_name": "test_multi_hop_questions",
|
70 |
+
"local_dataset_path": "/results/test_multi_hop_questions",
|
71 |
+
"concat_existing_dataset": False,
|
72 |
+
"run": True
|
73 |
+
},
|
74 |
+
"answer_generation": {
|
75 |
+
"run": True,
|
76 |
+
"question_dataset_name": "test_single_shot_questions",
|
77 |
+
"output_dataset_name": "test_answered_questions",
|
78 |
+
"local_dataset_path": "/results/test_answered_questions",
|
79 |
+
"concat_existing_dataset": False,
|
80 |
+
"strategies": [{
|
81 |
+
"name": "zeroshot",
|
82 |
+
"prompt": "ZEROSHOT_QA_USER_PROMPT",
|
83 |
+
"model_name": model_name
|
84 |
+
}, {
|
85 |
+
"name": "gold",
|
86 |
+
"prompt": "GOLD_QA_USER_PROMPT",
|
87 |
+
"model_name": model_name
|
88 |
+
}]
|
89 |
+
},
|
90 |
+
"judge_answers": {
|
91 |
+
"run": True,
|
92 |
+
"source_judge_dataset_name": "test_answered_questions",
|
93 |
+
"output_judged_dataset_name": "test_judged_comparisons",
|
94 |
+
"local_dataset_path": "/results/test_judged_comparisons",
|
95 |
+
"concat_existing_dataset": False,
|
96 |
+
"comparing_strategies": [["zeroshot", "gold"]],
|
97 |
+
"chunk_column_index": 0,
|
98 |
+
"random_seed": 42
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
return yaml.dump(config, default_flow_style=False)
|
103 |
+
|
104 |
+
def save_config(yaml_text):
|
105 |
+
with open(CONFIG_PATH, "w") as file:
|
106 |
+
file.write(yaml_text)
|
107 |
+
return "✅ Config saved!"
|
yourbench_space/utils.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pathlib
|
2 |
+
|
3 |
+
UPLOAD_DIRECTORY = pathlib.Path("/app/uploaded_files")
|
4 |
+
CONFIG_PATH = pathlib.Path("/app/yourbench_config.yml")
|