-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
45 lines (37 loc) · 1.26 KB
/
example.py
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
from pairs import PairsGreedy, PairsBeam
from pairs import shuffle_lists, load_summEval
# Load example data
summ_eval_path = 'data/SummEval/model_annotations.aligned.paired.jsonl'
input_doc, output_doc, _ = load_summEval(summ_eval_path, flat_output=False)
doc_id = 42
input, output = input_doc[doc_id], output_doc[doc_id]
input, output = shuffle_lists(input, output)
# The same input source text corresponds to multiple output summaries
print('Number of summary candidates:', len(output))
method = 'PairsGreedy'
if method == 'PairsGreedy':
# Set hyperparameters
params = {
'engine': "mistralai/Mistral-7B-Instruct-v0.1",
# 'engine': "microsoft/Phi-3-medium-4k-instruct",
# 'engine': "gpt-3.5-turbo",
'api_call': 0,
'with_input': True,
'calibrate': False,
}
# Rank the output summaries
indices = PairsGreedy(input[0], output, params)
print(indices)
elif method == 'PairsBeam':
# Set hyperparameters
params = {
'engine': "mistralai/Mistral-7B-Instruct-v0.1",
'beam_size': 2000,
'api_call': 0,
'prob_gap': 0.1,
'with_input': True,
'calibrate': True,
}
# Rank the output summaries
indices = PairsBeam(input[0], output, params)
print(indices)