Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences in the output of zero shot classification between python & spago for the same model #103

Open
abishekmuthian opened this issue Sep 13, 2021 · 1 comment

Comments

@abishekmuthian
Copy link

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.

@matteo-grella
Copy link
Member

Solved #101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants