News for hackers. Stuff that matters.

LLMs all fail this NumPy indexing example

When mixing basic slicing with an advanced index, NumPy moves the advanced index's subspace to the front, so in the example, A[0, :, B] produces a shape of (4, 2) rather than (2, 4).

  import numpy as np
  A = np.random.rand(1, 2, 2)
  B = np.array([0, 1, 0, 1])
  C = A[0, :, B]
  print("C.shape:", C.shape)

So far every LLM I've tried (Grok 3, o1, Gemini Pro) all predict (2, 4) and can't be persuaded otherwise.
( 2 comments | 2 points | on HN )
Re:LLMs all fail this NumPy indexing example by dekhn on Tuesday February 18, 2025 @02:28PM (#43093956)
So what?
Re:LLMs all fail this NumPy indexing example by minihat on Tuesday February 18, 2025 @02:34PM (#43094020)
Just providing some training data for the next generation of LLMs to scrape.