ActiveYixiao commited on
Commit
9baa103
·
verified ·
1 Parent(s): 355702c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -4,7 +4,6 @@ from typing import Literal, Optional
4
 
5
  import gradio as gr
6
  import outlines
7
- import outlines.generate as generate
8
  import pandas as pd
9
  import spaces
10
  import torch
@@ -137,9 +136,13 @@ def label_single_response_with_model(model_id, story, question, criteria, respon
137
 
138
  else:
139
  model = get_outlines_model(model_id, DEVICE_MAP, QUANTIZATION_BITS)
140
- generator = generate.json(model, ResponseModel)
141
- result = generator(prompt)
142
- return result["score"]
 
 
 
 
143
 
144
 
145
  @spaces.GPU
@@ -165,6 +168,7 @@ def label_multi_responses_with_model(model_id, story, question, criteria, respon
165
  results = [generator(p) for p in prompts]
166
  scores = [r["score"] for r in results]
167
 
 
168
  df["score"] = scores
169
  return df
170
 
 
4
 
5
  import gradio as gr
6
  import outlines
 
7
  import pandas as pd
8
  import spaces
9
  import torch
 
136
 
137
  else:
138
  model = get_outlines_model(model_id, DEVICE_MAP, QUANTIZATION_BITS)
139
+ generator = outlines.from_transformers(model)
140
+ raw_output = generator(prompt).strip()
141
+ if raw_output.startswith("1"):
142
+ score = "1"
143
+ else:
144
+ score = "0"
145
+ return score
146
 
147
 
148
  @spaces.GPU
 
168
  results = [generator(p) for p in prompts]
169
  scores = [r["score"] for r in results]
170
 
171
+
172
  df["score"] = scores
173
  return df
174