[Feature] Add Ollama support#1036
Conversation
from guidance import models
ollama = models.Ollama('phi3.5')
ollama = models.Ollama('phi3.5:3.8b')
ollama = models.Ollama('phi3.5:latest')
... |
|
Hi @microdev1, this is a great start on Ollama support in Guidance. Thanks for your contribution! I tested the Ollama class and was able to run a model using it, so I can confirm the basic functionality is working. However, there is some additional work needed regarding chat templates. Without the proper template, Guidance walks off the end of a role and continues generating text beyond the <|end|> token. Ollama stores the chat template in the modelfile, and it looks like this for phi 3: In contrast to Ollama, Guidance uses a Jinja style template like this:
Guidance also has classes wrapping the templates like this: Ideally when Ollama model is loaded, the proper chat template would automatically be loaded as well. If you're curious, the chat templates code is in All that being said, I think your implementation would technically work as long as someone provides the appropriate chat template string with the |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1036 +/- ##
===========================================
+ Coverage 43.24% 54.61% +11.37%
===========================================
Files 70 71 +1
Lines 5777 5799 +22
===========================================
+ Hits 2498 3167 +669
+ Misses 3279 2632 -647 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds a thin wrapper for models pulled using Ollama. Gets the local model path using the provided model name, and then instantiates the
LlamaCppEnginewith it and other args.