Jeff Myers II commited on
Commit
acf540f
·
1 Parent(s): 5326dc3

Update space

Browse files
Files changed (1) hide show
  1. Gemma_Model.py +7 -7
Gemma_Model.py CHANGED
@@ -8,14 +8,14 @@ class GemmaLLM:
8
 
9
  def __init__(self):
10
  model_id = "google/gemma-3-1b-it"
11
- quantization_config = BitsAndBytesConfig(load_in_8bit=True)
12
 
13
  self.model = Gemma3ForCausalLM.from_pretrained(
14
  model_id,
15
  device_map="cpu",
16
- quantization_config=quantization_config,
17
- low_cpu_mem_usage=True,
18
- torch_dtype=torch.float16,
19
  ).eval()
20
 
21
  self.tokenizer = AutoTokenizer.from_pretrained(model_id)
@@ -73,9 +73,9 @@ class GemmaLLM:
73
 
74
  def get_questions_message(self, summary, num_questions, difficulty) -> dict:
75
  schema = json.dumps([
76
- dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__]),
77
- dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__]),
78
- dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__])], indent=4)
79
 
80
  question = "You are a helpful assistant. Your main task is to generate " + str(num_questions) + " multiple choice questions from an article. Respond in the following JSON structure and schema:\n\njson\n```\n" + schema + "\n```\n\nThere should only be " + str(num_questions) + " questions generated. Each question should only have 3 false answers and 1 correct answer. The correct answer should be the most relevant answer based on the context derived from the article. False answers should not contain the correct answer. False answers should contain false information but also be reasonably plausible for answering the question. ONLY RESPOND WITH RAW JSON!!!"
81
 
 
8
 
9
  def __init__(self):
10
  model_id = "google/gemma-3-1b-it"
11
+ # quantization_config = BitsAndBytesConfig(load_in_8bit=True)
12
 
13
  self.model = Gemma3ForCausalLM.from_pretrained(
14
  model_id,
15
  device_map="cpu",
16
+ # quantization_config=quantization_config,
17
+ # low_cpu_mem_usage=True,
18
+ # torch_dtype=torch.float16,
19
  ).eval()
20
 
21
  self.tokenizer = AutoTokenizer.from_pretrained(model_id)
 
73
 
74
  def get_questions_message(self, summary, num_questions, difficulty) -> dict:
75
  schema = json.dumps([
76
+ dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__]),
77
+ dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__]),
78
+ dict(question=str.__name__, correct_answer=str.__name__, false_answers=[str.__name__, str.__name__, str.__name__])], indent=4)
79
 
80
  question = "You are a helpful assistant. Your main task is to generate " + str(num_questions) + " multiple choice questions from an article. Respond in the following JSON structure and schema:\n\njson\n```\n" + schema + "\n```\n\nThere should only be " + str(num_questions) + " questions generated. Each question should only have 3 false answers and 1 correct answer. The correct answer should be the most relevant answer based on the context derived from the article. False answers should not contain the correct answer. False answers should contain false information but also be reasonably plausible for answering the question. ONLY RESPOND WITH RAW JSON!!!"
81