Spaces:
Running
on
Zero
Running
on
Zero
Lord-Raven
commited on
Commit
·
7168d3b
1
Parent(s):
2150498
Experimenting with few-shot classification.
Browse files
app.py
CHANGED
@@ -49,17 +49,12 @@ file_name = "onnx/model_quantized.onnx"
|
|
49 |
tokenizer_name = "cross-encoder/nli-deberta-v3-small"
|
50 |
model = ORTModelForSequenceClassification.from_pretrained(model_name, file_name=file_name)
|
51 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, model_max_length=512)
|
|
|
52 |
|
53 |
-
few_shot_model_name = "moshew/bge-small-en-v1.5_setfit-sst2-english"
|
54 |
-
few_shot_model = setFitModel.from_pretrained(few_shot_model_name)
|
55 |
few_shot_tokenizer = AutoTokenizer.from_pretrained('bge_auto_opt_04', model_max_length=512)
|
56 |
ort_model = ORTModelForFeatureExtraction.from_pretrained('bge_auto_opt_O4')
|
57 |
-
|
58 |
-
|
59 |
-
# file = cached_download("https://huggingface.co/" + model_name + "")
|
60 |
-
# sess = InferenceSession(file)
|
61 |
-
|
62 |
-
classifier = pipeline(task="zero-shot-classification", model=model, tokenizer=tokenizer)
|
63 |
|
64 |
def classify(data_string, request: gradio.Request):
|
65 |
if request:
|
|
|
49 |
tokenizer_name = "cross-encoder/nli-deberta-v3-small"
|
50 |
model = ORTModelForSequenceClassification.from_pretrained(model_name, file_name=file_name)
|
51 |
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, model_max_length=512)
|
52 |
+
classifier = pipeline(task="zero-shot-classification", model=model, tokenizer=tokenizer)
|
53 |
|
|
|
|
|
54 |
few_shot_tokenizer = AutoTokenizer.from_pretrained('bge_auto_opt_04', model_max_length=512)
|
55 |
ort_model = ORTModelForFeatureExtraction.from_pretrained('bge_auto_opt_O4')
|
56 |
+
few_shot_model = SetFitModel.from_pretrained("moshew/bge-small-en-v1.5_setfit-sst2-english")
|
57 |
+
onnx_few_shot_model = OnnxSetFitModel(ort_model, few_shot_tokenizer, few_shot_model.model_head)
|
|
|
|
|
|
|
|
|
58 |
|
59 |
def classify(data_string, request: gradio.Request):
|
60 |
if request:
|