Improve Ollama to implement #summarize and #default_dimension#462
Merged
andreibondarev merged 14 commits intoFeb 24, 2024
Merged
Conversation
Add specs for #complete, #summarize, and #default_dimension
Contributor
Author
|
I know #144 was talking about VCR, but it's a slightly older discussion, and hand-mocking Faraday calls seems sub-optimal too. |
…. For others, defer to embedding a sample value
Contributor
Author
|
Ok , I've done this now and merged in I checked the embedding size for the four most popular LLMs at https://ollama.com/library, and there definitely is a long tail of models provided by Ollama. I added tests for all and also added a vcr spec for the least popular model (i.e. |
Collaborator
|
@rickychilcott Thanks for this PR btw! Makes me think that we need to implement this dynamic Could you please upmerge this PR? |
# Conflicts: # Gemfile.lock
Contributor
Author
|
Merged main. Thanks @andreibondarev |
Contributor
Author
|
@andreibondarev - anything I need to do to get this merged? |
Collaborator
|
@rickychilcott Looks great, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Because Ollama can run multiple models,
embedwill return different embedding vector sizes. Based on the current running model, we will generate an embedding and return the size indefault_dimensioninstead of nil. I was not able to find a way to get the size of the embeddings in the docs (see https://github.com/ollama/ollama/blob/main/docs/api.md#show-model-information)Also, I wanted to implement
summarizefor Ollama, and it seems that there is no dedicated endpoint for that operation. I used the pattern from OpenAI's ChatGPT to use a prompt to get the summary. However, I was consistently getting "Sure, here is a summary of the text" at the beginning of my response, so I modified the prompt specifically for llama2 to give only a summary. I'm not sure it's ideal, because each model will have its own best prompt to return a summary.In addition, I added specs for
complete,summarize, anddefault_dimension. Since Ollama can chunk output, I couldn't find a way to shim the tests using the existing patterns (something previous devs were seemingly also stumped by). I added VCR which will at least capture the right chunked response and serve it up. However, it will not actually chunk in the same way it does live, so I had to make a minor change to the streaming code to handle it from VCR and live. I don't believe I've broken streaming.Addresses #380 for Ollama.