Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load a basic model (replace with your preferred one)
|
| 5 |
+
agent = pipeline("text-generation", model="gpt2", max_new_tokens=100)
|
| 6 |
+
|
| 7 |
+
# Example GAIA task subset (mocked)
|
| 8 |
+
subset_tasks = [
|
| 9 |
+
{"task_id": "gaia_0001", "input": "What is the capital of France?"},
|
| 10 |
+
{"task_id": "gaia_0002", "input": "List 3 crops commonly grown in Saskatchewan."},
|
| 11 |
+
{"task_id": "gaia_0003", "input": "Explain why climate change affects agriculture."}
|
| 12 |
+
]
|
| 13 |
+
|
| 14 |
+
# Create predictions
|
| 15 |
+
submission = []
|
| 16 |
+
|
| 17 |
+
for task in subset_tasks:
|
| 18 |
+
prompt = task["input"]
|
| 19 |
+
response = agent(prompt)[0]["generated_text"]
|
| 20 |
+
|
| 21 |
+
submission.append({
|
| 22 |
+
"task_id": task["task_id"],
|
| 23 |
+
"model_answer": response.strip(),
|
| 24 |
+
"reasoning_trace": f"Used GPT-2 to generate answer to: '{prompt}'"
|
| 25 |
+
})
|
| 26 |
+
|
| 27 |
+
# Save to JSON Lines format
|
| 28 |
+
with open("submission.jsonl", "w", encoding="utf-8") as f:
|
| 29 |
+
for entry in submission:
|
| 30 |
+
f.write(json.dumps(entry) + "\n")
|
| 31 |
+
|
| 32 |
+
print("Submission file saved as submission.jsonl")
|