maximum recursion depth exceeded in comparison during sense2vec.eval

I get the following error when trying to run sense2vec.eval against approx. 1K terms created with sense2vec.teach.

I am not sure whether I should try with fewer terms, or if there is some other problem causing this issue.

Running command:

prodigy sense2vec.eval nna-vocab package/sense2vec/s2v_reddit_2015_md
✨  Starting the web server at http://localhost:8080 ...
Open the app in your browser and start annotating!

Task exception was never retrieved
future: <Task finished name='Task-6' coro=<RequestResponseCycle.run_asgi() done, defined at /home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py:402> exception=RecursionError('maximum recursion depth exceeded in comparison')>
Traceback (most recent call last):
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 3185, in ndim
    return a.ndim
AttributeError: 'int' object has no attribute 'ndim'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
    self.logger.error(msg, exc_info=exc)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/logging/__init__.py", line 1475, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/logging/__init__.py", line 1598, in handle
    if (not self.disabled) and self.filter(record):
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/logging/__init__.py", line 811, in filter
    result = f.filter(record)
  File "cython_src/prodigy/util.pyx", line 147, in prodigy.util.ServerErrorFilter.filter
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 404, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/fastapi/applications.py", line 270, in __call__
    await super().__call__(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/routing.py", line 706, in __call__
    await route.handle(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/fastapi/routing.py", line 165, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/prodigy/app.py", line 498, in get_session_questions
    return _shared_get_questions(controller, req.session_id, excludes=req.excludes)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/prodigy/app.py", line 463, in _shared_get_questions
    tasks = controller.get_questions(session_id=session_id, excludes=excludes)
  File "cython_src/prodigy/core.pyx", line 266, in prodigy.core.Controller.get_questions
  File "cython_src/prodigy/core.pyx", line 267, in prodigy.core.Controller.get_questions
  File "cython_src/prodigy/components/feeds.pyx", line 383, in prodigy.components.feeds.Feed.get_batch
  File "cython_src/prodigy/components/feeds.pyx", line 327, in prodigy.components.feeds.Feed._enqueue_tasks
  File "cython_src/prodigy/components/stream.pyx", line 170, in prodigy.components.stream.Stream.__next__
  File "cython_src/prodigy/components/stream.pyx", line 174, in prodigy.components.stream.Stream.__next__
  File "cython_src/prodigy/components/filters.pyx", line 91, in filter_tasks
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/prodigy_recipes.py", line 289, in get_stream
    key_a, key_b, key_c, sim_ab, sim_ac = strategy_func(s2v, all_keys)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/prodigy_recipes.py", line 392, in eval_strategy_most_similar
    return eval_strategy_most_similar(s2v, keys)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/prodigy_recipes.py", line 392, in eval_strategy_most_similar
    return eval_strategy_most_similar(s2v, keys)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/prodigy_recipes.py", line 392, in eval_strategy_most_similar
    return eval_strategy_most_similar(s2v, keys)
  [Previous line repeated 965 more times]
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/prodigy_recipes.py", line 389, in eval_strategy_most_similar
    most_similar = s2v.most_similar(key_a, n=min(2000, len(s2v)))
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/sense2vec/sense2vec.py", line 229, in most_similar
    result_keys, _, scores = self.vectors.most_similar(
  File "spacy/vectors.pyx", line 513, in spacy.vectors.Vectors.most_similar
  File "<__array_function__ internals>", line 200, in clip
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2180, in clip
    return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
    return bound(*args, **kwds)
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/_methods.py", line 136, in _clip
    if _clip_dep_is_scalar_nan(min):
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/_methods.py", line 96, in _clip_dep_is_scalar_nan
    if ndim(a) != 0:
  File "<__array_function__ internals>", line 200, in ndim
  File "/home/mhunter/mambaforge/envs/nna-api/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 3187, in ndim
    return asarray(a).ndim
RecursionError: maximum recursion depth exceeded in comparison

Hi Meike!

I get the following error when trying to run sense2vec.eval against approx. 1K terms created with sense2vec.teach.

Did you train your own sense2vec model here? If so, with what script?

That's strange. I just downloaded the original s2v model locally and got it running just fine.

> python -m prodigy sense2vec.eval nna-vocab s2v_old 

Added dataset nna-vocab to database SQLite.

✨  Starting the web server at http://localhost:8080 ...
Open the app in your browser and start annotating!

Just to check, are you using the original 2015 model? If so: I wasn't able to run this last week because Github had all sorts of downtime issues which broke the s2v download. It's a bit of a long shot, but it might be the case that you've downloaded a corrupt version of the model weights, which is what happened to me last week. Could you try again just in case?

If that does not work, could you double check your s2v version? Also, is there a reason why you're using the 2015 variant instead of the 2019 one?