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 Ollama as a Provider, allowing some Features to work with locally hosted LLMs #845

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jan 31, 2025

Description of the Change

Ollama allows you to easily run various LLMs on your own computer. This provides a couple key benefits:

  1. Can test these LLMs without any worry about cost
  2. No concerns with data privacy as all requests stay on your own computer

This PR integrates Ollama with a number of our existing Features, depending on which model you use:

If using a standard model:

  • Title Generation
  • Excerpt Generation
  • Content Resizing

If using a vision model:

  • Descriptive Text Generator
  • Image Tags Generator
  • Image Text Extraction

If using an embedding model:

  • Classification

This allows you to test quite a few of the Features ClassifAI provides without any cost or data concerns. This could also be used on production sites, though worth noting a few downsides to running these models locally:

  • Performance is slower than using an externally hosted LLM, like OpenAI. This is especially true if you don't use the model often, as Ollama has to load that model for the first request, then stores that model in memory for a short time. So if you're doing multiple requests close together, the first request is fairly slow and the ones after actually return pretty fast
  • While these "open source" models are getting better and better, quality still doesn't quite match models from OpenAI (or competitors). This is especially true as you typically need to run the smaller versions of these models locally, due to memory requirements for the full size models

That said, there really isn't any reason you couldn't use Ollama as a Provider on an actual production site. You'd just need to ensure that any user that wants to use those Features has Ollama installed and configured on their individual computers.

Closes #772

How to test the Change

  1. Download and install Ollama
  2. Install the models you want to use. I'd suggest ollama pull llama3.1 as a base LLM; ollama pull nomic-embed-text as the embedding LLM; ollama pull llava as the vision LLM but can see all available models here
  3. Once Ollama is running and models are installed, configure the following Features to use Ollama with the proper model selected:
  • Classification
  • Title Generation
  • Excerpt Generation
  • Content Resizing
  • Descriptive Text Generator
  • Image Tags Generator
  • Image Text Extraction
  1. Ensure each Feature works as expected. Note for any Image Processing Features, the image needs to be publicly available to work, so typically won't work on local environments. Quick fix for testing is to hardcode an external image URL in each of those callbacks to test

Changelog Entry

Added - Integration with Ollama as a Provider, allowing the following Features to use locally hosted LLMs: Classification; Title Generation; Excerpt Generation; Content Resizing; Descriptive Text Generator; Image Tags Generator; Image Text Extraction

Credits

Props @dkotter

Checklist:

@dkotter dkotter added this to the 3.3.0 milestone Jan 31, 2025
@dkotter dkotter self-assigned this Jan 31, 2025
@dkotter dkotter requested review from jeffpaul and a team as code owners January 31, 2025 16:32
@github-actions github-actions bot added the needs:code-review This requires code review. label Jan 31, 2025
@dkotter
Copy link
Collaborator Author

dkotter commented Jan 31, 2025

There's a few things that I've captured while working on this that I think would be good followups:

  1. This PR only adds support for Ollama. Originally was going to also add support for GPT4All and LMStudio but with the size of this PR already, decided it was best to handle those separately, if we think those would be worth adding. Both give an actual UI, which can be nice, compared to Ollama which is all command line based
  2. Added support for the Classification Feature using embeddings models from Ollama but have not added support for other Features that use embeddings, like the Smart 404 and Term Cleanup Features. Would be nice to look at adding support for those in followup PRs
  3. We added support for OpenAI Vision models for the Descriptive Text Generator Feature in Add OpenAI as a Provider for Descriptive Text Generation #828 but didn't add support for any other Image Processing. In this PR, I added support for Descriptive Text Generator, Image Tags Generator and Image Text Extraction when using vision models. Would be nice for a followup PR to add OpenAI as a Provider for Image Tags Generator and Image Text Extraction

@dkotter dkotter removed request for a team and jeffpaul January 31, 2025 17:09
@jeffpaul
Copy link
Member

jeffpaul commented Feb 3, 2025

@vikrampm1 would you please help open issues for the 3 items above and drop into the 3.4.0 milestone?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integration with open source, local LLMs
2 participants