paulbricman / dual-obsidian-client

A skilled virtual assistant for Obsidian.
https://paulbricman.com/thoughtware/dual
Mozilla Public License 2.0
242 stars 7 forks source link

torch.embedding IndexError: index out of range in self #37

Closed paulbricman closed 3 years ago

paulbricman commented 3 years ago

File "...\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\torch\nn\functional.py", line 1916, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) IndexError: index out of range in self

This happens sometimes on Windows in open dialogue. It only pops up with specific questions. My working hypothesis is that nasty characters in retrieved notes hurdle the generation process.

zacKolton commented 3 years ago
Screen Shot 2021-04-19 at 1 59 06 AM

This is what I get when trying to chat with the "bot". I am using a Mac, and so far this is every time. Given, the latest version is posted in the readme, then I have the latest version as of today.

paulbricman commented 3 years ago

@zacKolton Can you try Find notes about will this work? I'll check if core.entry_contents contains the right stuff.

paulbricman commented 3 years ago

Can't seem to replicate the issue on my machine. To get a better sense of the state of your machine, try the following in the skeleton folder(!) and post your outputs in the issue:

$ python3
from core import Core
c = Core('/vault/root/path')
print(len(c.entry_contents), len(c.entry_filenames))
print(c.fluid_search('will this work'))
zacKolton commented 3 years ago

Im going to give it a try again, but instead I've imported my entire notion workbook into obsidian to try and get some better results. I suspect I was not using good data (I imported all of my iMessages as a csv file because I was lazy at first) which probably was not the best idea.

Currently the Dual is training with the alignment utility - which has about an hour to go, so il try and do everything again and if that still does not work, il try your troubleshooting.

Really impressed by this plugin by the way, its the one thing that converted me from notion to obsidian

zacKolton commented 3 years ago

Follow up: After redoing everything it worked. I would assume its because of the notion import, before I just had a bunch of text on one page (thinking I was smart of course). For anyone wondering, just search up notion to obsidian on GitHub, its really simple.

Anyways it works now, Screen Shot 2021-04-19 at 12 26 06 PM

(Extremely general question) How long / how many interactions do you find it takes till Dual responds normally lol?

paulbricman commented 3 years ago

Lol, I'm glad it worked! So you're saying you had several long notes and you split them into smaller ones? Wonder how that helped. Can you try asking it a question completely unrelated to anything in your collection? Maybe it's when no relevant notes to the question can be retrieved or something.

How long / how many interactions do you find it takes till Dual responds normally lol?

Did you fine-tune it using the online notebook? Relevant comment for your question: https://www.reddit.com/r/ObsidianMD/comments/mq1zcg/meet_dual_your_new_virtual_assistant_for/gugg3em/?context=3

That said, the models used (see #42) and architecture in general (see https://github.com/Psionica/Dual/tree/master/experimental-recipes) might change, it's too soon to tell.

kinoc commented 3 years ago

I had a similar problem to @zacKolton original problem, but changing _opendialogue in core.py to this seemed to fix the problem for me. It covers the case of degenerate vaults, like having only a few files.

       if self.essence_ready == False:
            return ['The essence is not present at the required location.']

        candidate_entry_contents=[]
        try:
            candidate_entry_filenames = self.fluid_search(question, selected_candidates=considered_candidates)
            candidate_entry_contents = reversed([self.entries[e][0] for e in candidate_entry_filenames])
        except:
            candidate_entry_contents=[]
        generator_prompt = '\n\n'.join(candidate_entry_contents) + '\n\nQ: ' + question + '\nA: '
        input_ids = self.gen_tokenizer.encode(generator_prompt, return_tensors='pt')

This way, as long as the essense image files are visible, it will generate something.

paulbricman commented 3 years ago

I'm closing this issue for now because it'll most likely not remain relevant given the large refactoring planned for #45