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

feat(core): llm integration for cli #236

Draft
wants to merge 39 commits into
base: main
Choose a base branch
from

Conversation

andrewrust-virtru
Copy link

@andrewrust-virtru andrewrust-virtru commented Jul 23, 2024

SEE FULL STATUS on OpenTDF Issue #455 and/or otdfctl issue #12

This PR integrates capacity for a localized LLM model to be used as an aid for troubleshooting DSP and otdfctl via prompt injection of relevant documentation into a local LLM(ex: ollama)

Architecture Overview

Screenshot 2024-07-25 at 11 57 37 AM

System Requirements:

  • Local-first LLM
  • CLI access, simple TUI interface
  • Basic stats on request time & tokens
  • Exception handling & error processing (no hanging prompts)
    - [ ] Documentation retrieval and injection
  • Wrapping prompts with both sanitization~~ and relevant docs~~

Future Wishlist

  • perhaps linking to relevant docs via RAG implementation
  • instead of ollama/gemma/etc fine-tuned personalized LLM on Virtru's non-sensitive data (all agnostic code and docs)

Open Bugs/Issues:

  • Bad UI when waiting for initial response
  • Not graceful exit if model is not running on device yet
  • Need to flush out sanitization/entry prompt

@andrewrust-virtru
Copy link
Author

andrewrust-virtru commented Jul 25, 2024

Thinking in the open about strategy for documentation injection: Could use 'fuzzy-finder'-esque wrapper to determine concepts or words that are relevant to a user's query. Might have to start with dict of common associations. Ex:

['DSP', 'Data Security Platform' ...] --> ['$def_of_dsp', $opt_link_to_readme_section]
['PEP', 'Policy Enforcement Points' ...] --> ['$def_of_peps', $opt_link_to_readme_section]
...

This, along with basic sanitization wrapping in sanitizer.go would be the basis for entire prompt. Open item would be to adjust parameters based on the token_lens/context_size of the model when considering tradeoffs for speed... default is 2K, 8K IIUC.

@jrschumacher
Copy link
Member

@andrewrust-virtru when considering the reducing context have you looked at prompt-engineering with llama2? https://medium.com/@eboraks/llama-2-prompt-engineering-extracting-information-from-articles-examples-45158ff9bd23

For instance if we append <SYS>...</SYS> to the user's prompt we can ensure the response will be limited by what we want.

<s>[INST] <<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.  
Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. 
Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. 
If you don't know the answer to a question, please don't share false information.
<</SYS>>

Tell me how to choose a favorite color

@andrewrust-virtru
Copy link
Author

andrewrust-virtru commented Aug 6, 2024

UPDATE(08/06/24): https://github.com/virtru-corp/data-security-platform/issues/455#issuecomment-2272393715

In preparation for intern presentation Thursday, ending 'new feature' commits. Just necessary bug fixes for a working demo. Updating documentation for OpenTDF issue #455 on base issue for otdfctl: issue #12.

Related to archived Atlassian goal and abandoned otdfctl branch #40

@andrewrust-virtru andrewrust-virtru marked this pull request as ready for review August 7, 2024 00:28
@andrewrust-virtru andrewrust-virtru requested a review from a team as a code owner August 7, 2024 00:28
@jrschumacher jrschumacher marked this pull request as draft September 6, 2024 18:01
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

Successfully merging this pull request may close these issues.

Spike/PoC utilizing local LLM to enable better understanding OpenTDF
2 participants