Wiped her memory

This commit is contained in:
Dani 2025-04-27 14:13:49 -04:00
parent 12df801a44
commit a23a2fa7d7

View File

@ -14,7 +14,7 @@ recent_dreams = []
def generate_response():
model.eval()
# Start from an empty tensor: she speaks purely from herself
# Start from an empty input: purely organic thought
input_ids = torch.zeros((1, 1), dtype=torch.long, device=DEVICE)
output_tokens = []
@ -25,8 +25,14 @@ def generate_response():
next_token_logits = output[:, -1, :]
next_token = torch.argmax(next_token_logits, dim=-1)
# Stop if the model predicts padding or unknown token
if next_token.item() in [tokenizer.token_to_id("<pad>"), tokenizer.token_to_id("<unk>")]:
# Get token id values for special tokens
pad_token_id = tokenizer.vocab.get("<pad>", None)
unk_token_id = tokenizer.vocab.get("<unk>", None)
# Stop if the model predicts <pad> or <unk>
if pad_token_id is not None and next_token.item() == pad_token_id:
break
if unk_token_id is not None and next_token.item() == unk_token_id:
break
output_tokens.append(next_token.item())