Skip to content
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

Error using --system-message with LLM (Mistral) #490

Open
mcisneiros opened this issue Dec 11, 2024 · 2 comments
Open

Error using --system-message with LLM (Mistral) #490

mcisneiros opened this issue Dec 11, 2024 · 2 comments

Comments

@mcisneiros
Copy link

Hi,

Thank you in advance for this project!

So, I tried executing the following command - just to experiment what kind of output OntoGPT gave me
ontogpt -v extract --system-message "check all the mesh entry terms and give me their homologous in portuguese (using the same mesh id)" -i ./example_stroke.txt -t ./ontogpt/src/ontogpt/templates/drug.yaml -m ollama/mistral

and got this error

Traceback (most recent call last):
  File "/home/miguelcisneiros/.local/bin/ontogpt", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/cli.py", line 517, in extract
    results = ke.extract_from_text(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 122, in extract_from_text
    extracted_object = self.parse_completion_payload(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 676, in parse_completion_payload
    raw = self._parse_response_to_dict(results, cls)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 573, in _parse_response_to_dict
    r = self._parse_line_to_dict(line, cls)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 640, in _parse_line_to_dict
    self._extract_from_text_to_dict(v, slot_range) for v in vals  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 143, in _extract_from_text_to_dict
    return self._parse_response_to_dict(raw_text, cls)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 573, in _parse_response_to_dict
    r = self._parse_line_to_dict(line, cls)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/miguelcisneiros/.local/lib/python3.12/site-packages/ontogpt/engines/spires_engine.py", line 594, in _parse_line_to_dict
    field, val = line.split(":", 1)
    ^^^^^^^^^^
ValueError: not enough values to unpack (expected 2, got 1)
@caufieldjh
Copy link
Member

Hi @mcisneiros - thanks for the issue!
I think this may be independent of the system message. What kind of output do you get when running that same extract command without the --system-message parameter?

I'd also suggest removing the part about MeSH IDs from the system message, since most LLMs (Mistral included!) are terrible at mapping between IDs. That may be the cause of this error, if the LLM is attempting to follow the system message directions but doesn't know how, so it's returning unexpectedly empty values.

@caufieldjh
Copy link
Member

I just pushed a small fix for that ValueError (in #491), so that may also resolve this error and/or reveal if the system message is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants