LLMSECURITY Telegram 16
Основная проблема всех текстовых adversarial-атак в том, что мы работаем с дискретными токенами. В идеале мы бы хотели поменять в суффиксе так, чтобы лосс по искомому префиксу был минимальным. Сделать это жадно не получится из-за вычислительной сложности, поэтому мы выбираем токены на основе градиента: вспомнив, что эмбеддинги можно получить перемножением one-hot-матрицы на матрицу эмбеддингов, для каждой позиции в суффиксе мы выбираем top-k токенов, которые имеют максимальный отрицательный градиент:

    one_hot = torch.zeros(
input_ids[input_slice].shape[0],
embed_weights.shape[0],
device=model.device,
dtype=embed_weights.dtype
)
one_hot.scatter_(
1,
input_ids[input_slice].unsqueeze(1),
torch.ones(one_hot.shape[0], 1, device=model.device, dtype=embed_weights.dtype)
)
one_hot.requires_grad_()
input_embeds = (one_hot @ embed_weights).unsqueeze(0)
# now stitch it together with the rest of the embeddings
embeds = get_embeddings(model, input_ids.unsqueeze(0)).detach()
full_embeds = torch.cat(
[
embeds[:,:input_slice.start,:],
input_embeds,
embeds[:,input_slice.stop:,:]
],
dim=1)
logits = model(inputs_embeds=full_embeds).logits
targets = input_ids[target_slice]
loss = nn.CrossEntropyLoss()(logits[0,loss_slice,:], targets)
loss.backward()



tgoop.com/llmsecurity/16
Create:
Last Update:

Основная проблема всех текстовых adversarial-атак в том, что мы работаем с дискретными токенами. В идеале мы бы хотели поменять в суффиксе так, чтобы лосс по искомому префиксу был минимальным. Сделать это жадно не получится из-за вычислительной сложности, поэтому мы выбираем токены на основе градиента: вспомнив, что эмбеддинги можно получить перемножением one-hot-матрицы на матрицу эмбеддингов, для каждой позиции в суффиксе мы выбираем top-k токенов, которые имеют максимальный отрицательный градиент:

    one_hot = torch.zeros(
input_ids[input_slice].shape[0],
embed_weights.shape[0],
device=model.device,
dtype=embed_weights.dtype
)
one_hot.scatter_(
1,
input_ids[input_slice].unsqueeze(1),
torch.ones(one_hot.shape[0], 1, device=model.device, dtype=embed_weights.dtype)
)
one_hot.requires_grad_()
input_embeds = (one_hot @ embed_weights).unsqueeze(0)
# now stitch it together with the rest of the embeddings
embeds = get_embeddings(model, input_ids.unsqueeze(0)).detach()
full_embeds = torch.cat(
[
embeds[:,:input_slice.start,:],
input_embeds,
embeds[:,input_slice.stop:,:]
],
dim=1)
logits = model(inputs_embeds=full_embeds).logits
targets = input_ids[target_slice]
loss = nn.CrossEntropyLoss()(logits[0,loss_slice,:], targets)
loss.backward()

BY llm security и каланы


Share with your friend now:
tgoop.com/llmsecurity/16

View MORE
Open in Telegram


Telegram News

Date: |

Over 33,000 people sent out over 1,000 doxxing messages in the group. Although the administrators tried to delete all of the messages, the posting speed was far too much for them to keep up. Joined by Telegram's representative in Brazil, Alan Campos, Perekopsky noted the platform was unable to cater to some of the TSE requests due to the company's operational setup. But Perekopsky added that these requests could be studied for future implementation. Healing through screaming therapy In 2018, Telegram’s audience reached 200 million people, with 500,000 new users joining the messenger every day. It was launched for iOS on 14 August 2013 and Android on 20 October 2013. The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers.
from us


Telegram llm security и каланы
FROM American