Programming, Artificial Intelligence, Machine Learning, Data Science, Python.
words = ["apple", "banana", "orange", "pizza", "burger", "salad", "soup", "cake", "cookie", "ice cream"] embeddings = [] for word in words: inputs = tokenizer(word, return_tensors='pt') with torch.no_grad(): outputs = model(**inputs) embeddings.append(outputs.last_hidden_state[0, 0, :].numpy()) pca