openai multiclass classification logprobs doesn't return defined classes, instead it returns one class and variations of it

huangapple go评论78阅读模式
英文:

openai multiclass classification logprobs doesn't return defined classes, instead it returns one class and variations of it

问题

根据您提供的内容,您遇到了多类别分类问题的问题。您的期望行为是分类响应应返回具有最高置信度的多个类别,然后在logprobs中包括所有其他类别的置信度。但实际行为似乎是返回第一个类别(预测类别),而其他类别只是它的变化。

这可能是由于多类别分类模型的工作方式以及输入数据的格式等因素导致的。如果您希望改进这一行为,您可以尝试以下几个方法:

  1. 增加max_tokens的值:通过增加max_tokens的值,您可以获得更多的响应文本,从而更好地理解模型的分类置信度。

  2. 调整输入数据格式:确保输入数据与模型的期望格式一致。您已经提到您已经按照文档的建议定义了类别,但您可以再次检查确保没有格式问题。

  3. 调整训练数据:可能需要调整训练数据的准备方式,以确保模型更好地理解类别和多类别分类的问题。

  4. 尝试不同的模型:如果问题仍然存在,可以尝试使用其他OpenAI提供的模型,看是否有更好的性能。

请注意,多类别分类可能需要进行一些调整和实验,以获得最佳结果。如果您可以提供更多细节或需要进一步的帮助,请随时告诉我。

英文:

As stated in the title, the multiclass classification doesn't return the correct classes I defined in the training set, instead it returns the first class (predicted class) and other classes are just a variation of it.

example request:

curl https://api.openai.com/v1/completions   -H 'Content-Type: application/json'   -H 'Authorization: KEY'   -d '{
  "model": "curie:model_id",
  "prompt": "test_sample \n\n###\n\n",
  "max_tokens": 1,
  "logprobs": 7
}'

example response:

	"id": "xxx",
	"object": "text_completion",
	"created": 1675633654,
	"model": "curie:modle_id",
	"choices": [{
		"text": " 6",
		"index": 0,
		"logprobs": {
			"tokens": [" 6"],
			"token_logprobs": [-0.000016165199],
			"top_logprobs": [{
				"6": -11.555985,
				" six": -13.56059,
				" 625": -15.326343,
				" 6": -0.000016165199,
				" 7": -12.376487
			}],
			"text_offset": [27]
		},
		"finish_reason": "length"
	}],
	"usage": {
		"prompt_tokens": 9,
		"completion_tokens": 1,
		"total_tokens": 10
	}
}

as we can see from the response the top_logprobs are just variations from the top class

I have a dataset of 1000 samples and 7 classes, which is around 145 samples/class more then the 100 samples/class recommended by the documentation.

I've defined the classes just like the documentation recommends: (ensuring it's one token with a space, etc..) in-fact I tried several implementation of classes all of which returned the same results, one implementation i tested was the convert the classes from one token to numbers which yielded the same result as shown here (https://community.openai.com/t/multiple-labels-in-the-file-for-multi-class-classification-task/3541).

Training samples are defined like this:

df['training_sample'] = df['training_sample'].apply(lambda x: x + '\n\n###\n\n')

the expected behavior is for the classification response to return the most classes with most confidence then the confidences of all the other classes in logprobs

the actual behavior is something like this, the provided is when I changed the labels to numbers, same unwanted behavior

答案1

得分: 1

设置temperature=0在使用经过微调的分类器时是建议的。这将减少logprobs中出现奇怪类别的数量。

然而,根据我的经验,logprobs并不总是会返回您在训练模型时使用的类别(特别是在多类问题和与训练数据非常不同的文本中)。

因此,更安全的做法是筛选类别名称并在概率上应用某种阈值。

英文:

Setting temperature=0 is recommended when using a fine-tuned classifier. This will reduce the number of weird classes appearing in logprobs.

However, from my experience, it's not guaranteed that logprobs will always return the classes you trained the model with (especially with multiclass problems and text very different from the training data).

So it's safer to filter class names and apply some kind of threshold on the probabilities.

huangapple
  • 本文由 发表于 2023年2月6日 06:06:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75355847.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定