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

Adds hyde prompts for Ask ChatGPT command #23

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

kristenbrann
Copy link
Member

https://arxiv.org/pdf/2212.10496.pdf

When you ask chatgpt a question, now we:

  • ask chatgpt to generate a markdown note that would answer the question via completions
  • parse the note chatgpt writes into blocks
  • generate embeddings for the hyde note, all its blocks, and the original question
  • compare vectors for all of the above to vectors from your vault
  • use the top 8 matches as context for your question to chatgpt

@cpaika cpaika self-requested a review March 19, 2023 22:15
@cpaika cpaika self-assigned this Mar 19, 2023
src/VectorStore.ts Outdated Show resolved Hide resolved
src/VectorStore.ts Outdated Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved
const nearestVectors = this.vectorStore.getNearestVectors(embeddingResponse, 8, this.settings.relevanceThreshold)
conversation.push(hydeMessage)
const hydeResponse = await this.openAIHandler.createChatCompletion(conversation)
if (!hydeResponse || hydeResponse.choices.length === 0 || !hydeResponse.choices[0].message) {
Copy link
Contributor

@cpaika cpaika Mar 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement idea: instead of failing here, let's degrade and just search based on your search without the hyde. Does that make sense? Shouldn't be this PR.

I could imagine completions being unavailable but embeddings being fine, would be nice if we could recover and still serve limited functionality.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I agree. We should make this degrade to simple embeddings search. (Though in your example if completions was completely down the user wouldn't be successfully asking GPT any questions either.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true this would only apply to semantic search

src/main.ts Outdated Show resolved Hide resolved
cpaika
cpaika previously approved these changes Mar 19, 2023
Copy link
Contributor

@cpaika cpaika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some nits but overall like it this should be a good improvement

@kristenbrann kristenbrann merged commit 87f079a into exoascension:main Mar 20, 2023
@kristenbrann kristenbrann deleted the hyde branch March 20, 2023 00:08
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.

2 participants