File size: 1,565 Bytes
9628ad8
e054708
51ae812
dd6b4ee
 
 
 
51ae812
 
dd6b4ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2de620d
51ae812
74f67ec
9628ad8
 
74f67ec
 
 
 
 
9628ad8
74f67ec
0691591
9628ad8
51ae812
dd6b4ee
74f67ec
 
 
 
51ae812
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from openai import OpenAI
client = OpenAI(api_key = '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')

import pandas as pd
from huggingface_hub import hf_hub_download

def compute(params):
    public_score = 0
    private_score = 0

    solution_file = hf_hub_download(
        repo_id=params.competition_id,
        filename="solution.csv",
        token=params.token,
        repo_type="dataset",
    )

    solution_df = pd.read_csv(solution_file)

    submission_filename = f"submissions/{params.team_id}-{params.submission_id}.csv"
    submission_file = hf_hub_download(
        repo_id=params.competition_id,
        filename=submission_filename,
        token=params.token,
        repo_type="dataset",
    )
    submission_df = pd.read_csv(submission_file)

    submitted_answer = str(submission_df.iloc[0]['pred'])
    gt = str(solution_df.iloc[0]['pred'])

    prompt=f"Give me a score from 1 to 10 (higher is better) judging how similar these two captions are. Caption one: {submitted_answer}. Caption two: {gt}\nScore:"
    
    try:
        response = client.completions.create(
            engine="gpt-3.5-turbo-instruct",
            prompt=prompt,
            temperature=0,
            max_tokens=1,
        )
        
        public_score = int(response.choices[0].text.strip())
        
    except:
        print("Error w/ api")

    private_score = public_score
        
    metric_dict = {"public_score": {"metric1": public_score},
                   "private_score": {"metric1": private_score}
                   }

    return metric_dict