indikamk commited on
Commit
c6a0d9b
·
1 Parent(s): 27515cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -1,5 +1,3 @@
1
- #import gradio as gr
2
-
3
  import os
4
  os.environ["CUDA_VISIBLE_DEVICES"]="0"
5
  import torch
@@ -18,12 +16,12 @@ model = AutoModelForCausalLM.from_pretrained(
18
  tokenizer = AutoTokenizer.from_pretrained("bigscience/bloomz-3b", load_in_8bit_fp32_cpu_offload=True)
19
 
20
  def make_inference(sentence):
21
- batch = tokenizer(f"### INSTRUCTION\nBelow is a student response to a writen question about an electrical circuit. Please identify whether there is a sequential misconception. A sequential misconception in terms of electric circuits is one in which it is believed that elements that are further “downstream” from a source (such as R2 and R3 in the example circuit of Figure 1) “receive” current after elements closer to the source (R1 in the example circuit). With such a misconception, it is likely that a student will think that changes in R2 have no effect on the potential difference and current associated with R1 or Vs..\n\n### Sentence:\n{sentence}\n### Response:\n", return_tensors='pt')
22
 
23
  with torch.cuda.amp.autocast():
24
- output_tokens = model.generate(**batch, max_new_tokens=200)
25
 
26
- return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
27
 
28
  if __name__ == "__main__":
29
  # make a gradio interface
 
 
 
1
  import os
2
  os.environ["CUDA_VISIBLE_DEVICES"]="0"
3
  import torch
 
16
  tokenizer = AutoTokenizer.from_pretrained("bigscience/bloomz-3b", load_in_8bit_fp32_cpu_offload=True)
17
 
18
  def make_inference(sentence):
19
+ batch = tokenizer(f"### INSTRUCTION\nBelow is a student response to a writen question about an electrical circuit. Please identify whether there is a sequential misconception. A sequential misconception in terms of electric circuits is one in which it is believed that elements that are further “downstream” from a source (such as R2 and R3 in the example circuit of Figure 1) “receive” current after elements closer to the source (R1 in the example circuit). With such a misconception, it is likely that a student will think that changes in R2 have no effect on the potential difference and current associated with R1 or Vs..\n\n### Sentence:\n{sentence}\n### Response:\n", return_tensors='pt')
20
 
21
  with torch.cuda.amp.autocast():
22
+ output_tokens = model.generate(**batch, max_new_tokens=200)
23
 
24
+ return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
25
 
26
  if __name__ == "__main__":
27
  # make a gradio interface