Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import outlines
|
|
| 7 |
import pandas as pd
|
| 8 |
import spaces
|
| 9 |
import torch
|
|
|
|
| 10 |
from peft import PeftConfig, PeftModel
|
| 11 |
from pydantic import BaseModel, ConfigDict
|
| 12 |
from transformers import (
|
|
@@ -136,13 +137,9 @@ def label_single_response_with_model(model_id, story, question, criteria, respon
|
|
| 136 |
|
| 137 |
else:
|
| 138 |
model = get_outlines_model(model_id, DEVICE_MAP, QUANTIZATION_BITS)
|
| 139 |
-
generator =
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
score = "1"
|
| 143 |
-
else:
|
| 144 |
-
score = "0"
|
| 145 |
-
return score
|
| 146 |
|
| 147 |
|
| 148 |
@spaces.GPU
|
|
@@ -168,7 +165,6 @@ def label_multi_responses_with_model(model_id, story, question, criteria, respon
|
|
| 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 |
|
|
|
|
| 7 |
import pandas as pd
|
| 8 |
import spaces
|
| 9 |
import torch
|
| 10 |
+
from outlines import generate
|
| 11 |
from peft import PeftConfig, PeftModel
|
| 12 |
from pydantic import BaseModel, ConfigDict
|
| 13 |
from transformers import (
|
|
|
|
| 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 |
results = [generator(p) for p in prompts]
|
| 166 |
scores = [r["score"] for r in results]
|
| 167 |
|
|
|
|
| 168 |
df["score"] = scores
|
| 169 |
return df
|
| 170 |
|