Shadowrocket-ADBlock-Rules
Shadowrocket-ADBlock-Rules copied to clipboard
Differences in the output of zero shot classification between python & spago for the same model
I appreciate everyone involved with the spago project for developing a proper Machine Learning framework for Go.
I'm in the process of exploring spago and found that the output for valhalla/distilbart-mnli-12-3 differs for zero shot classification when using python vs spago .
//main.go
model, err := zsc.LoadModel("spago/valhalla/distilbart-mnli-12-3")
if err != nil {
log.Fatal(err)
}
defer model.Close()
//Sequence
sequence := "PalmOS on Raspberry Pi"
// arbitrary list of topics
candidateLables := []string{"startup", "business", "legal", "tech"}
result, err := model.Classify(sequence, "", candidateLables, true)
if err != nil {
log.Fatal(err)
}
for i, item := range result.Distribution {
fmt.Printf("%d. %s [%.2f]\n", i, item.Class, item.Confidence)
}
0. tech [0.89]
1. startup [0.02]
2. legal [0.01]
3. business [0.00]
#main.py
classifier = pipeline("zero-shot-classification", model="models/distilbart-mnli-12-3")
sequence = "PalmOS on Raspberry Pi"
candidate_labels = ["startup", "business", "legal", "tech"]
res = classifier(sequence, candidate_labels, multi_label=True, truncation=False)
for i, label in enumerate(candidate_labels):
print("%d. %s [%.2f]\n" % (i, res['labels'][i], res['scores'][i]))
0. tech [0.99]
1. legal [0.77]
2. startup [0.05]
3. business [0.00]
Is this an expected behavior? If so why.
Solved #101