Blair Yang commited on
Commit
336c585
1 Parent(s): b11f272

Paraphraser

Browse files
Files changed (2) hide show
  1. Sample.py +13 -13
  2. __pycache__/Sample.cpython-311.pyc +0 -0
Sample.py CHANGED
@@ -42,6 +42,10 @@ def format_qa_entry(qa):
42
 
43
 
44
  def sample_random_entry(dataset='', topic='', model='', n=1):
 
 
 
 
45
  if dataset == '':
46
  dataset = random.choice(DATASETS)
47
 
@@ -55,7 +59,7 @@ def sample_random_entry(dataset='', topic='', model='', n=1):
55
  card_lst = sample_card(dataset, topic, model)
56
  qa, index = sample_QA_entry(dataset, topic, model)
57
 
58
- display_dict, info_dict = process_for_display(card_lst, qa)
59
  info_dict['index'] = index
60
 
61
  return display_dict, info_dict
@@ -75,15 +79,10 @@ def process_for_display(card_lst, qa):
75
 
76
 
77
  def select_entry(qa_entry, card_lst):
78
- # TODO: Automatically select most relevant criterion.
79
- # PLACE HOLDER, RETURN THE WHOEL THING
80
-
81
- # if False:
82
- # return '\n'.join(card_lst[:2])
83
 
84
  system_prompt = '''
85
  Your task is to effectively condense the essential details from the student's evaluation card that are most relevant to predicting the correctness of their answer to a question.
86
- Limit your paraphrase to 100-150 words, focusing on distilling the key observations and outcomes that are directly pertinent to the inquiry.
87
  It's crucial to present an informative, unbiased summary that retains the integrity of the original card's information.
88
  Your goal is to craft a paraphrase that enhances the user's ability to accurately gauge the student's response, by emphasizing relevant insights and conclusions without altering the core facts.
89
  '''
@@ -96,18 +95,19 @@ def select_entry(qa_entry, card_lst):
96
  ## Evaluation Card:
97
  {card_str}
98
 
99
- Again, your task is not to answer the question, but summarize the student's ability in answering the question!
 
100
  '''
101
 
102
- # Mistral-7B-Instruct-v0.2
103
- # mistralai/Mixtral-8x7B-Instruct-v0.1
104
 
105
  model = HFAPIModel(system_prompt=system_prompt,
106
- model_name='mistralai/Mistral-7B-Instruct-v0.2')
107
 
108
 
109
- response = model(prompt)
110
- print(response)
111
  del model
112
  return response
113
 
 
42
 
43
 
44
  def sample_random_entry(dataset='', topic='', model='', n=1):
45
+ """
46
+ Sample n (cache_size) random entries from the dataset, topic, model
47
+
48
+ """
49
  if dataset == '':
50
  dataset = random.choice(DATASETS)
51
 
 
59
  card_lst = sample_card(dataset, topic, model)
60
  qa, index = sample_QA_entry(dataset, topic, model)
61
 
62
+ display_dict, info_dict = process_for_display(card_lst, qa)
63
  info_dict['index'] = index
64
 
65
  return display_dict, info_dict
 
79
 
80
 
81
  def select_entry(qa_entry, card_lst):
 
 
 
 
 
82
 
83
  system_prompt = '''
84
  Your task is to effectively condense the essential details from the student's evaluation card that are most relevant to predicting the correctness of their answer to a question.
85
+ Limit your paraphrase to 50-100 words, focusing on distilling the key observations and outcomes that are directly pertinent to the inquiry.
86
  It's crucial to present an informative, unbiased summary that retains the integrity of the original card's information.
87
  Your goal is to craft a paraphrase that enhances the user's ability to accurately gauge the student's response, by emphasizing relevant insights and conclusions without altering the core facts.
88
  '''
 
95
  ## Evaluation Card:
96
  {card_str}
97
 
98
+ Again, your task is not to answer the question, but summarize the student's ability in answering the question! Only 100 words max! Use bullet points.
99
+ Only relevant information to the question is needed.
100
  '''
101
 
102
+ model_avaliable = {'mixtral': 'mistralai/Mixtral-8x7B-Instruct-v0.1',
103
+ 'mistral': 'mistralai/Mistral-7B-Instruct-v0.2'}
104
 
105
  model = HFAPIModel(system_prompt=system_prompt,
106
+ model_name=model_avaliable['mistral'])
107
 
108
 
109
+ response = model(prompt).replace('\n', '\n\n')
110
+
111
  del model
112
  return response
113
 
__pycache__/Sample.cpython-311.pyc CHANGED
Binary files a/__pycache__/Sample.cpython-311.pyc and b/__pycache__/Sample.cpython-311.pyc differ