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

from langchain_community.embeddings import HuggingFaceBgeEmbeddings - results warning - pydantic/_internal/_fields.py:132: UserWarning: Field "model_name" in HuggingFaceInferenceAPIEmbeddings has conflict with protected namespace "model_". #26861

Closed
5 tasks done
sam-bercovici opened this issue Sep 25, 2024 · 6 comments · Fixed by #27076

Comments

@sam-bercovici
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

'''from langchain_community.embeddings import HuggingFaceBgeEmbeddings'''
generates:
pydantic/_internal/fields.py:132: UserWarning: Field "model_name" in HuggingFaceInferenceAPIEmbeddings has conflict with protected namespace "model".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = ().
warnings.warn(

looking at pydantic/pydantic#7121 and

model_config = ConfigDict(extra="forbid", protected_namespaces=())

similar is missing in HuggingFaceBgeEmbeddings

Error Message and Stack Trace (if applicable)

warning:
pydantic/_internal/fields.py:132: UserWarning: Field "model_name" in HuggingFaceInferenceAPIEmbeddings has conflict with protected namespace "model".

You may be able to resolve this warning by setting model_config['protected_namespaces'] = ().
warnings.warn(

Description

  • as noted importing HuggingFaceBgeEmbeddings generates a warning

System Info

python -m langchain_core.sys_info

System Information

OS: Linux
OS Version: #1 SMP Fri Mar 29 23:14:13 UTC 2024
Python Version: 3.12.6 | packaged by conda-forge | (main, Sep 22 2024, 14:16:49) [GCC 13.3.0]

Package Information

langchain_core: 0.3.5
langchain: 0.3.0
langchain_community: 0.3.0
langsmith: 0.1.125
langchain_anthropic: 0.2.1
langchain_chroma: 0.1.4
langchain_experimental: 0.3.0
langchain_groq: 0.2.0
langchain_huggingface: 0.1.0
langchain_openai: 0.2.0
langchain_text_splitters: 0.3.0

Optional packages not installed

langgraph
langserve

Other Dependencies

aiohttp: 3.10.5
anthropic: 0.34.2
async-timeout: Installed. No version info available.
chromadb: 0.5.7
dataclasses-json: 0.6.7
defusedxml: 0.7.1
fastapi: 0.115.0
groq: 0.11.0
httpx: 0.27.2
huggingface-hub: 0.25.1
jsonpatch: 1.33
numpy: 1.26.4
openai: 1.47.1
orjson: 3.10.7
packaging: 24.1
pydantic: 2.9.2
pydantic-settings: 2.5.2
PyYAML: 6.0.2
requests: 2.32.3
sentence-transformers: 3.1.1
SQLAlchemy: 2.0.35
tenacity: 8.5.0
tiktoken: 0.7.0
tokenizers: 0.19.1
transformers: 4.44.2
typing-extensions: 4.12.2

@nehaejaz
Copy link

Having the same warning

@etiennemillerioux
Copy link

Face the same warning too, very annoying it's dispaly it upon every single startup

@tibor-reiss
Copy link
Contributor

Fixed in langchain-community 0.3.1 in #26744

@MaxRuenz
Copy link

MaxRuenz commented Oct 1, 2024

Is that something that should also be ported to other Embeddings and Chats?
I am getting the same warnings when working with Bedrock and langchain-community 0.3.1

@sam-bercovici
Copy link
Author

sam-bercovici commented Oct 1, 2024

Why not have a langchain Base Model doing this instead of inheriting from Pydantic and doing this stuff repeatedly?

@scottberres-tr
Copy link

The warnings fire for model_name, model_path, model_url

These are the classes that fire a warning at startup for me.

langchain_core.embeddings.embeddings.Embeddings
langchain_core.language_models.llms.BaseLLM
langchain_community.llms.vertexai._VertexAIBase

using
langchain_core-0.3.8
langchain-0.3.1
langchain_community-0.3.1

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 a pull request may close this issue.

6 participants