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

Add model specifity for embeddings capabilities for ollama #57

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.org
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Support Ollama function calling, for models which support it.
- Make sure every model, even unknown models, return some value for ~llm-chat-token-limit~.
- Add token count for llama3.1 model.
- Make =llm-capabilities= work model-by-model for embeddings and functions
* Version 0.17.0
- Introduced =llm-prompt= for prompt management and creation from generators.
- Removed Gemini and Vertex token counting, because =llm-prompt= uses token
Expand Down
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ In addition to the provider, which you may want multiple of (for example, to cha
- ~:host~: The host that ollama is run on. This is optional and will default to localhost.
- ~:port~: The port that ollama is run on. This is optional and will default to the default ollama port.
- ~:chat-model~: The model name to use for chat. This is not optional for chat use, since there is no default.
- ~:embedding-model~: The model name to use for embeddings. This is not optional for embedding use, since there is no default.
- ~:embedding-model~: The model name to use for embeddings (only [some models](https://ollama.com/search?q=&c=embedding) can be used for embeddings. This is not optional for embedding use, since there is no default.
** GPT4All
[[https://gpt4all.io/index.html][GPT4All]] is a way to run large language models locally. To use it with =llm= package, you must click "Enable API Server" in the settings. It does not offer embeddings or streaming functionality, though, so Ollama might be a better fit for users who are not already set up with local models. You can set it up with the following parameters:
- ~:host~: The host that GPT4All is run on. This is optional and will default to localhost.
Expand Down
11 changes: 10 additions & 1 deletion llm-ollama.el
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ PROVIDER is the llm-ollama provider."
(llm-provider-utils-model-token-limit (llm-ollama-chat-model provider)))

(cl-defmethod llm-capabilities ((provider llm-ollama))
(append (list 'streaming 'embeddings)
(append (list 'streaming)
;; See https://ollama.com/search?q=&c=embedding
(when (and (llm-ollama-embedding-model provider)
(string-match
(rx (or "nomic-embed-text"
"mxbai-embed-large"
"all-minilm"
"snowflake-arctic-embed"))
(llm-ollama-embedding-model provider)))
(list 'embeddings))
;; see https://ollama.com/search?c=tools
(when (string-match
(rx (or "llama3.1" "mistral-nemo" "mistral-large"
Expand Down
17 changes: 16 additions & 1 deletion llm-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,22 @@
(should-not (has-fc "gemma"))
(should-not (has-fc "gemma2"))
(should-not (has-fc "llama2"))
(should-not (has-fc "llama"))))
(should-not (has-fc "llama"))
(should-not (has-fc "unknown"))))

(ert-deftest llm-test-ollama-embedding-capabilities ()
;; tests subject to change as models may get function calling
(cl-flet ((has-emb (model)
(member 'embeddings
(llm-capabilities (make-llm-ollama :embedding-model model
:chat-model "mistral")))))
(should-not (has-emb "llama3.1"))
(should-not (has-emb "mistral"))
(should (has-emb "nomic-embed-text"))
(should (has-emb "mxbai-embed-large"))
(should-not (has-emb "mxbai-embed-small"))
(should-not (has-emb "unknown"))
(should-not (has-emb nil))))

(provide 'llm-test)
;;; llm-test.el ends here