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

Adding model_kwargs for huggingface embedders. #1450

Merged
merged 4 commits into from
Jun 29, 2024

Conversation

PranavPuranik
Copy link
Contributor

@PranavPuranik PranavPuranik commented Jun 29, 2024

Description

This change allows passing additional params huggingface embedder using model_kwargs. This allows the trust_remote_code=True option for various models not added to huggingface/transformers.

Fixes #1380

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

I have added unit test for HuggingFaceEmbedder. (first unit test for an embedder 🎉)

Also tested using,
main.py -

import os
from embedchain import App

app = App.from_config(config_path="./config.yaml")

app.add("https://en.wikipedia.org/wiki/Sun_Tzu")

while True:
    question = input("Enter question: ")
    if question in ["q", "exit", "quit"]:
        break
    answer = app.query(question)
    print(answer)

config.yaml -

llm:
  provider: openai
  config:
    model: 'gpt-3.5-turbo'
    temperature: 0.5
    max_tokens: 1000
    top_p: 1
    stream: false

embedder:
  provider: huggingface
  config:
    model: 'nomic-ai/nomic-embed-text-v1'
    model_kwargs:
      trust_remote_code: True

Output -

Enter question: which book did sun tuz write?
Sun Tzu is traditionally credited as the author of The Art of War, an influential work of military strategy that has affected both Western and East Asian philosophy and military thought.
  • Unit Test
  • Test Script (please provide)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

@deshraj deshraj merged commit 7c24601 into mem0ai:main Jun 29, 2024
3 checks passed
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.

How can i set trust_remote_code = True ?
2 participants