Pytorch Userwarning: не удалось инициализировать Numpy: _array_api не найдено и проблема инициализации веса BertmodelPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Pytorch Userwarning: не удалось инициализировать Numpy: _array_api не найдено и проблема инициализации веса Bertmodel

Сообщение Anonymous »

Я работаю с Pytorch и библиотекой Trangering Face Transformers, чтобы точно настроить модель Bert (UFNLP/Gatortron-Base) для задачи нижней течения.
Я получил предупреждение, связанное с Numpy инициализация: < /p>

c:lomaserserserser\ appdata\local\programs\python\python312\ lib\site-packages\torch\storage.py:321: Userwarnn .. \ torch \ csrc \ utils \ tensor_numpy.cpp: 84.) "Lang-Py PrettyPrint-Override">type himport torch
from transformers import BertTokenizer, BertModel

tokenizer = BertTokenizer.from_pretrained('UFNLP/gatortron-base')
model = BertModel.from_pretrained('UFNLP/gatortron-base')

model.eval()

def prepare_input(text):
tokens = tokenizer.encode_plus(text, return_tensors='pt', add_special_tokens=True, max_length=512, truncation=True)
return tokens['input_ids'], tokens['attention_mask']

def get_response(input_ids, attention_mask):
with torch.no_grad():
outputs = model(input_ids=input_ids, attention_mask=attention_mask)
if 'logits' in outputs:
predictions = torch.argmax(outputs['logits'], dim=-1)
else:
# Adjust this based on the actual structure of `outputs`
predictions = torch.argmax(outputs[0], dim=-1)

# predictions = torch.argmax(outputs.logits, dim=-1)
return tokenizer.decode(predictions[0], skip_special_tokens=True)

input_text = "Hello, how are you?"
input_ids, attention_mask = prepare_input(input_text)
response = get_response(input_ids, attention_mask)
print("Response from the model:", response)ere
< /code>

python: 3.12 < /li>
numpy: 1.19.5 < /li>
< /ul>

Подробнее здесь: https://stackoverflow.com/questions/786 ... and-bertmo
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

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