Skip to content

Don't use 32 bit for big objects error #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
mirkancal opened this issue Oct 1, 2024 · 11 comments
Closed
1 task done

Don't use 32 bit for big objects error #676

mirkancal opened this issue Oct 1, 2024 · 11 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@mirkancal
Copy link

mirkancal commented Oct 1, 2024

Is there an existing issue?

Build info

  • objectbox version: [e.g. 2.3.1]
  • Flutter/Dart version: [e.g. 3.1.0, see flutter --version or dart --version]
  • Build OS: [e.g. Ubuntu 22.04 | Windows 11 | macOS 10.16 ]
  • Deployment OS or device: iPhone 16 pro emulator with iOS 18

Steps to reproduce

TODO Tell us exactly how to reproduce the problem.

There's an example app throws that error: https://github.com/alfredobs97/gem_notes

Expected behavior

TODO Tell us what you expect to happen.

Actual behavior

TODO Tell us what actually happens.

Code

TODO Add a code example to help us reproduce your problem.

Code
[Paste your code here]

Logs, stack traces

TODO Add relevant logs, a stack trace or crash report.

Logs
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: StorageException: Do not use vector-based find on 32 bit systems with big objects (OBX_ERROR code 10098)

I'll add more logs and clean up the description, trying few things at the moment. it was discussed on langchain.dart discord and also under this issue: #94 (comment)

@mirkancal mirkancal added the bug Something isn't working label Oct 1, 2024
@greenrobot
Copy link
Member

@mirkancal Do you have a calling stack?

@mirkancal
Copy link
Author

@greenrobot it's a simple app and all i see this warning below. Is there any example app that I can try vector search?

Connecting to VM Service at ws://127.0.0.1:9753/1sYAGR20GYs=/ws
Connected to the VM Service.
[+22462 ms] [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: StorageException: Do not use vector-based find on 32 bit systems with big objects (OBX_ERROR code 10098)
          #0      ObjectBoxNativeError.throwMapped (package:objectbox/src/native/bindings/helpers.dart:99:11)
          #1      throwLatestNativeError (package:objectbox/src/native/bindings/helpers.dart:54:48)
          #2      checkObxPtr (package:objectbox/src/native/bindings/helpers.dart:31:5)
          #3      Query.findWithScores (package:objectbox/src/native/query/query.dart:1185:23)
          #4      BaseObjectBoxVectorStore.similaritySearchByVectorWithScores (package:langchain_community/src/vector_stores/objectbox/base_objectbox.dart:110:50)
          #5      VectorStore.similaritySearchWithScores (package:langchain_core/src/vector_stores/base.dart:120:12)
          <asynchronous suspension>
          #6      VectorStore.similaritySearch (package:langchain_core/src/vector_stores/base.dart:81:28)
          <asynchronous suspension>
          #7      Runnable.stream (package:langchain_core/src/runnables/runnable.dart:2<…>

@greenrobot-team
Copy link
Member

Edited original post to add this was run on an iPhone simulator. Which is also where I'll try to reproduce.

@greenrobot-team greenrobot-team self-assigned this Oct 7, 2024
@greenrobot-team
Copy link
Member

Tested the linked app on an iOS 17 (so not 18) simulator on an Intel Mac and it works as expected.

@mirkancal What Mac and macOS version are you using to run this?

As for vector search, there is a simple example available. See also the blog post. I'm not aware of a Retrieval-augmented generation (RAG) demo app though.

@greenrobot-team greenrobot-team added the more info required Needs more info to become actionable. Auto-closed if no response. label Oct 7, 2024
@mirkancal
Copy link
Author

@greenrobot-team thank you for checking this out. I'm on apple silicone, specifically 16inch - m1 max with with 15.0.1

@greenrobot-team
Copy link
Member

Thanks! Actually I overlooked that this happens when running a query, not when creating a store. I'll have another look.

@davidmigloz
Copy link

I managed to reproduce the issue in the gem_notes using both a simulator (iPhone 16 Pro) and a real device (iPhone 12), and with OpenAI embeddings (1536 dimensions) and Google AI embeddings (768 dimensions).

@github-actions github-actions bot removed the more info required Needs more info to become actionable. Auto-closed if no response. label Oct 8, 2024
@ArachnaDigitalLtd
Copy link

ArachnaDigitalLtd commented Oct 14, 2024

Getting the same issue here on both simulator and physical iOS devices:

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: StorageException: Do not use vector-based find on 32 bit systems with big objects (OBX_ERROR code 10098)
#0 ObjectBoxNativeError.throwMapped (package:objectbox/src/native/bindings/helpers.dart:99:11)
#1 throwLatestNativeError (package:objectbox/src/native/bindings/helpers.dart:54:48)
#2 checkObxPtr (package:objectbox/src/native/bindings/helpers.dart:31:5)
#3 Query.findWithScores (package:objectbox/src/native/query/query.dart:1185:23)
#4 searchByEmbedding (package:arachna_myspeechpal/custom_code/actions/search_by_embedding.dart:24:25)
#5 _HomePageWidgetState.build... (package:arachna_myspeechpal/src/home/home_page/home_page_widget.dart:208:68)

Checked all build settings in XCode and it is excluding 32 bit. Running OpenAI 1536 and tried Gemini 768, still same issue.

Android works perfectly well.

Running on MacBook Air M2 8GB

Offending code:

@entity()
class Locations {
@id()
int id = 0;
String? name;
@HnswIndex(dimensions: 1536)
@Property(type: PropertyType.floatVector)
List? nameEmbedding;
Locations(this.name, this.nameEmbedding);
}

@entity()
class People {
// Updated to People (plural)
@id()
int id = 0;
String? name;
@HnswIndex(dimensions: 1536)
@Property(type: PropertyType.floatVector)
List? nameEmbedding;
People(this.name, this.nameEmbedding);
}

Future<List?> searchByEmbedding(
List templateEmbedding) async {
final box = ObjectBox.instance.peopleBox;
final query = box
.query(People_.nameEmbedding.nearestNeighborsF32(templateEmbedding, 9))
.build();

final results = query.findWithScores();

final double scoreThreshold = 0.3;

List peopleDataList = results.map((result) {
return PeopleDataStruct(
id: result.object.id,
name: result.object.name,
nameEmbedding: result.object.nameEmbedding,
score: result.score,
);
}).where((result) {
return result.score < scoreThreshold;
}).toList();

FFAppState().peopleData = peopleDataList;
}

@greenrobot-team
Copy link
Member

Thanks for the details! I could reproduce this and a fix is completed and will be included in the next release.

@greenrobot-team greenrobot-team added this to the 4.0.3 milestone Oct 15, 2024
@greenrobot-team
Copy link
Member

Release 4.0.3 is available which fixes this issue.

To update to this release, for a Flutter project run flutter pub upgrade or for a Dart Native project dart pub upgrade.

@davidmigloz
Copy link

davidmigloz commented Oct 22, 2024

I confirm that it's fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants