Upload root_scripts/prompt_compare.txt with huggingface_hub
Browse files
root_scripts/prompt_compare.txt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
========== ORIGINAL PROMPT ==========
|
| 2 |
+
def build_open_ended_prompt(sample):
|
| 3 |
+
"""Build an open-ended prompt (no MCQ options)."""
|
| 4 |
+
desc = sample.get('description', '')
|
| 5 |
+
question = sample.get('question', '')
|
| 6 |
+
|
| 7 |
+
prompt = f"""Look at the image and answer the physics question.
|
| 8 |
+
|
| 9 |
+
{desc}
|
| 10 |
+
|
| 11 |
+
{question}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
========== ORIGINAL GENERATE ==========
|
| 15 |
+
output_ids = model.generate(**inputs, max_new_tokens=MAX_NEW_TOKENS)
|
| 16 |
+
|
| 17 |
+
generated = output_ids[0][inputs.input_ids.shape[1]:]
|
| 18 |
+
response = processor.decode(generated, skip_special_tokens=True)
|
| 19 |
+
except Exception as e:
|
| 20 |
+
response = f"ERROR: {str(e)}"
|
| 21 |
+
|
| 22 |
+
========== MY PROMPT ==========
|
| 23 |
+
def build_open_ended_prompt(sample):
|
| 24 |
+
q = sample.get("question", "")
|
| 25 |
+
return f"Look at this image and answer the physics question. Think step by step and put your final answer in \\boxed{{}}.\n\nQuestion: {q}"
|
| 26 |
+
|
| 27 |
+
def run_inference_on_gpu(gpu_id, model_path, samples, output_file):
|
| 28 |
+
"""Run inference for a subset of samples on a specific GPU."""
|
| 29 |
+
|
| 30 |
+
========== MY GENERATE ==========
|
| 31 |
+
output_ids = model.generate(**inputs, max_new_tokens=2048, temperature=0.1, do_sample=False)
|
| 32 |
+
|
| 33 |
+
output_text = processor.batch_decode(output_ids[:, inputs.input_ids.shape[1]:],
|
| 34 |
+
skip_special_tokens=True)[0]
|