brianpetro/obsidian-smart-connections

Embeddings no longer function (linux)

Opened this issue · 12 comments

image
Hey, looks like the smart connection plugin won't function, stays at 0% embedded with 0 blocks no matter if i force, hit make connections, etc. I'm running an AMD gpu, but there's not a clear indication of how to, if I need to, use an API model. I tried selecting an openai model and putting in my openai key, as well as trying the plugin in sandbox mode -- none of the troubleshooting steps I've taken have changed the behavior of the plugin.

Advice appreciated!

I'll note that 'Find: Make smart connections' returns 'No context found to make smart connections in', I think is the error message. I run Obsidian as an appImage and have tested running it under both my user and as sudo by changing permissions of the appimage via the permissions tab in the GUI. I'm running on Pop! OS, equivalent to Ubuntu 22.04.

Are there errors in the console log? 🌴

Yeah, a few:

VM241 about:srcdoc:424 Error processing message: Error: no available backend found. ERR: [webgpu] Error: Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.
    at l (transformers@3.0.0-alpha.16:100:1798)
    at async e.create (transformers@3.0.0-alpha.16:100:18017)
    at async f (transformers@3.0.0-alpha.16:151:1428)
    at async transformers@3.0.0-alpha.16:175:15985
    at async Promise.all (index 0)
    at async P (transformers@3.0.0-alpha.16:175:13530)
    at async Promise.all (index 0)
    at async U.from_pretrained (transformers@3.0.0-alpha.16:175:23150)
    at async Fo.from_pretrained (transformers@3.0.0-alpha.16:175:57753)
    at async Promise.all (index 1)
    ```
    
    ```
    smart_entities.js:270 Error processing smart_sources embed queue: {}
process_embed_queue @ smart_entities.js:270
await in process_embed_queue (async)
process_import_queue @ smart_sources.js:201
await in process_import_queue (async)
process_load_queue @ smart_sources.js:180
Show 3 more frames
Show less
collection.js:261 Saving smart_sources:  0 items
collection.js:264 Saved smart_sources in 0ms
index.js:120 env loaded
index.js:97 Smart Connections v2 loaded
sc_chat_model.js:4 has chat model adapter
sc_app_connector.js:83 Server running at http://localhost:37042/
sc_app_connector.js:24 ScAppConnector initialized on port 37042
node:internal/process/task_queues:95 get_conversation_ids_and_file_types
sc_settings_tab.js:21 displaying settings tab
sc_chat_view.js:14 init SmartChatRenderer
VM241 about:srcdoc:424 Error processing message: TypeError: Cannot read properties of null (reading 'dispose')
    at SmartEmbedTransformersAdapter.unload (VM241 about:srcdoc:375:22)
    at SmartEmbedModel.unload (VM241 about:srcdoc:182:24)
    at processMessage (VM241 about:srcdoc:416:21)
    at VM241 about:srcdoc:434:44
processMessage @ VM241 about:srcdoc:424
await in processMessage (async)
(anonymous) @ VM241 about:srcdoc:434
postMessage (async)
eval @ iframe.js:67
_send_message @ iframe.js:64
unload @ iframe.js:106
unload @ smart_embed_model.js:62
unload @ smart_entities.js:58
embed_model_changed @ smart_entities.js:346
handle_on_change @ node.js:274
eval @ node.js:78
(anonymous) @ app.js:1
handleMouseUp_ @ unknown
Show 8 more frames
Show less
iframe.js:81 Uncaught (in promise) Error: Cannot read properties of null (reading 'dispose')
    at SmartEmbedTransformersIframeAdapter._handle_message (iframe.js:81:47)

I'll try the Smart Connect workaround from the other issue and check back. #634

Will note that, when swapping to ada-002, I'm seeing 'didn't provide an API key' errors, and testing smart chat with an OAI api key seems to work okay.

Ah, I see swapping to ada creates a field for Openai key for embeddings in the settings -- unfortunately, it doesn't seem to send the key with the request, even when filled out + restarting the application.

Alright, seems like it just took a few more restarts to kick on. API works, can't connect to the backend, will letcha know if the Smart Connect workaround works.

Alright, did some experimenting:

Smart Connect appears to successfully create the embeddings, so the workaround for the background service error seems to work. Both Smart Sources and the plugin in Obsidian always stay 'partially loaded, should refresh/reload'. When calling the openai API, it hangs at '50/X embeddings...', as shown here:
image

When setting it to a local model, it attempts to use webgpu and won't load the created embeddings, regardless of refresh/reload/prune. Settings for Smart Connect appear to all be defaults with the basic configuration of environment and obsidian vault on.

There is a "legacy transformers" setting that can be toggled on to prevent using the GPU for local models 🌴

Update -- I can get the micro-v2 model to successfully complete the embedding flow in Obsidian smart connections using transformers v2 (smart connect is still broken, I think, see issues on that repo.) Attempting to use nomic-embed-text with transformers v2 produces the following error:
image

Interestingly, switching to transformers v2 appears to use the gpu successfully, unless the logs are incorrect:

image

The "using GPU" log is probably erroneous based on some other settings, because iirc GPU isn't available in transformers v2 🌴

Why Smart Sources embedding works, but Smart Blocks no work?

image image