Skip to content

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

@abishekmuthian

Description

@abishekmuthian

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions