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 Local Ollama Model Support to Langchain Handler #8978

Merged
merged 4 commits into from
Mar 22, 2024

Conversation

tmichaeldb
Copy link
Contributor

@tmichaeldb tmichaeldb commented Mar 22, 2024

Description

Fixes RAG-54

Will follow this up with another PR for Langchain Refactor (link)

This allows users to use their own local Ollama models with Langchain. See here for a list of all supported models.

It's important to note that many local Ollama models (i.e. mistral) are substantially slower than using other LLM APIs. Depending on the specs of the machine, you can expect anywhere from 4-10+ output tokens/second. For higher tokens/second output, users can experiment with smaller models

Type of change

(Please delete options that are not relevant)

  • ⚡ New feature (non-breaking change which adds functionality)
  • 📄 This change requires a documentation update

Verification Process

To ensure the changes are working as expected:

  • Test Location: ./tests/unit/ml_handlers/test_langchain.py
  • Verification Steps:
    1. pip install ollama to install Ollama
    2. ollama pull mistral to download the mistral model locally.
    3. Create & Query Langchain model
CREATE MODEL local_mistral_model
    PREDICT answer
    USING
        engine = 'langchain',
        model_name = 'mistral',
        user_column = 'question',
        assistant_column = 'answer',
        mode = 'conversational',
        prompt_template = 'You are a helpful assistant. Make sure to NEVER capitalize your letters. Always reply in all lowercase no matter what. Here is the user input: {{question}}';

SELECT answer FROM local_mistral_model WHERE question = 'What is your name?';

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@tmichaeldb tmichaeldb self-assigned this Mar 22, 2024
@tmichaeldb tmichaeldb requested a review from dusvyat March 22, 2024 01:22
@tmichaeldb
Copy link
Contributor Author

tmichaeldb commented Mar 22, 2024

cc @QuantumPlumber

Copy link
Contributor

@dusvyat dusvyat left a comment

Choose a reason for hiding this comment

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

LGTM. Not a blocker for this merge but it would be good to use pydantic for user input parameters in future

@tmichaeldb tmichaeldb merged commit 7fc6008 into staging Mar 22, 2024
12 checks passed
@StpMax StpMax mentioned this pull request Mar 26, 2024
@hamishfagg hamishfagg deleted the langchain-refactor branch June 10, 2024 21:31
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.

None yet

2 participants