Programming, Artificial Intelligence, Machine Learning, Data Science, Python.
BERT.", return_tensors="pt") # Get last hidden states with torch.no_grad(): outputs = model(input_ids) hidden_states = outputs.last_hidden_state.squeeze() # Visualize the output for the first token's embedding plt.figure(figsize=(10, 1)) plt.imshow(hidden_states[0:1].numpy()) plt.colorbar()