Llama3 генерирует слишком много контента, как это решить?Python

Программы на Python
Anonymous
Llama3 генерирует слишком много контента, как это решить?

Сообщение Anonymous »

Я пытаюсь использовать Llama3 для прогнозирования оценок учащихся. Я предоставляю информацию об учениках в Llama3 8b и ожидаю получить только оценку, но модель генерирует слишком много дополнительного контекста. Как это исправить?
Это мой формат набора данных:

Код: Выделить всё

'user\nHere is the information about a student; please predict his writing score.{gender: male, lunch: free/reduced, math_score: 47, parental_level_of_education: associates degree, race_ethnicity: group A, reading_score: 57, test_preparation_course: none}\n
assistant\n44\n'
Вот мой код:

Код: Выделить всё

for i in tqdm(range(100)):
student = dataset_test[i]["text"]
input_ids = tokenizer(dataset_test[i]['text'], return_tensors='pt', padding=True, truncation=True).to("cuda").input_ids
outputs = model.generate(input_ids, max_length=150, num_return_sequences=1)
text = tokenizer.decode(outputs[0], skip_special_tokens=True)
Я просто хочу, чтобы помощник возвращал одно число, например «44».
Однако Llama вернул мне слишком много значений. Ниже приведены результаты работы Llama 3.

Код: Выделить всё

user
Here is the information about a student; please predict his writing score.{gender: male, lunch: standard, math_score: 85, parental_level_of_education: masters degree, race_ethnicity: group D, reading_score: 84, test_preparation_course: none}
assistant
82
84
80
77
85
84
81
82
83
80
86
79
85
80
81
80
80
85
84
82
84
81
80
81
84
80
83
80
79
84
84
81
79
81
80
81
80
85
82
79
81
82
Иногда Llama3 также генерирует контент, подобный следующему.

Код: Выделить всё

user
Here is the information about a student; please predict his writing score.{gender: male, lunch: free/reduced, math_score: 72, parental_level_of_education: masters degree, race_ethnicity: group C, reading_score: 66, test_preparation_course: completed}
assistant
72. This student's writing score is 66, which is 72 - 66 = 6 points lower than his math score. This suggests that he may have some writing difficulties, but his writing score is still 66, which is above the average writing score for this group. His parental level of education is a masters degree, which is a high level of education, and he completed a test
Как стандартизировать формат вывода?

Подробнее здесь: https://stackoverflow.com/questions/790 ... solve-this

Вернуться в «Python»