Spaces:
Runtime error
Runtime error
Update synthetic_data.py
Browse files- synthetic_data.py +32 -11
synthetic_data.py
CHANGED
|
@@ -1,11 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# synthetic_data.py
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import random
|
| 4 |
+
|
| 5 |
+
def generate_synthetic_dataset(num_agents=4, num_samples=20):
|
| 6 |
+
data = []
|
| 7 |
+
tasks = ["qa", "summarization", "reasoning"]
|
| 8 |
+
for a in range(num_agents):
|
| 9 |
+
agent_name = f"Agent_{a}"
|
| 10 |
+
for i in range(num_samples):
|
| 11 |
+
task = random.choice(tasks)
|
| 12 |
+
if task == "qa":
|
| 13 |
+
prompt = f"What is the capital of country {i}?"
|
| 14 |
+
reference = "Paris is the capital of France." if i % 2 == 0 else "Rome is the capital of Italy."
|
| 15 |
+
response = reference if random.random() > 0.2 else "I think it's Berlin."
|
| 16 |
+
elif task == "summarization":
|
| 17 |
+
prompt = "Summarize: 'The sun is a star that provides light and heat to the Earth.'"
|
| 18 |
+
reference = "The sun provides light and heat essential for life on Earth."
|
| 19 |
+
response = "The sun provides light and heat for Earth."
|
| 20 |
+
else:
|
| 21 |
+
prompt = "Explain why the sky is blue."
|
| 22 |
+
reference = "Rayleigh scattering causes shorter blue wavelengths to scatter more, making the sky appear blue."
|
| 23 |
+
response = reference if random.random() > 0.3 else "It is because of reflection."
|
| 24 |
+
|
| 25 |
+
data.append({
|
| 26 |
+
"prompt": prompt,
|
| 27 |
+
"response": response,
|
| 28 |
+
"task": task,
|
| 29 |
+
"agent": agent_name,
|
| 30 |
+
"reference": reference
|
| 31 |
+
})
|
| 32 |
+
return pd.DataFrame(data)
|