Comments (10)
Great. I'll work on it
from langchain.
if you have any questions about the right place to put it or the conventions, happy to take a look at any even half-implemented stuff! just lmk
from langchain.
Would like to work on adding support for HF models. I think it is more convenient to use sentence_transformers as they can handle both sentence transformers and models coming from HF by adding a mean pooling layer. What do you think?
from langchain.
i think thats a great idea!
from langchain.
I made an initial implementation where i tried to stay close to how the openai one is implemented. Please check in the link below. I don't like the part where i instiatiate SentenceTransformer class inside embed functions and would love to have some suggestions there. Thanks
https://github.com/issam9/langchain/blob/issam/hf_embeddings/langchain/embeddings/huggingface.py
from langchain.
yeah the init is a little tricky. i dont love the way we do the initialization for other things, may try to rework that in the future. In the meantime, what about adding a classmethod and making it like:
@classmethod
def from_model_name(cls, model_name):
import sentence tranformers
model = sentence_transformers.SentenceTransformer(model_name)
return cls(model)
thoughts?
from langchain.
am thinking of changing to use pydantic dataclasses to take advantage of the postinit stuff https://stackoverflow.com/questions/66571079/alter-field-after-instantiation-in-pydantic-basemodel-class
from langchain.
I tried doing that by overriding init which makes it possible to keep using BaseModel:
def __init__(self, **kw):
super().__init__(**kw)
try:
import sentence_transformers
self.client = sentence_transformers.SentenceTransformer(self.model_name)
except ImportError:
raise ValueError(
"Could not import sentence_transformers python package. "
"Please it install it with `pip install sentence_transformers`."
)
from langchain.
yeah i dont hate that implementation either. id be down to do something like that as well. need to figure out longer term plan and unify across codebsase, but in short term im down to do it that way and see how well it works
from langchain.
Hi, I created a pull request with init override implementation. please lmk if i need to apply any changes
from langchain.
Related Issues (20)
- openai: add "name" to supported properties for tool messages?
- Vertex AI Search doesn't return the result with chunked dataset
- BUG in langchain_community.vectorstores.qdrant HOT 1
- Structured Output with Groq: Error code: 400 - {'error': {'message': 'response_format` does not support streaming', 'type': 'invalid_request_error'}} HOT 3
- [Community] Tavily Search lost Tool output Callbacks in newest versions HOT 2
- Similarity Search Returns Empty when Using Milvus
- Update with_structured_output to explicitly pass tool name
- DOC: ChatHuggingFace incorrectly marked as supporting structured output HOT 8
- llm_transformer.convert_to_graph_documents TypeError: list indices must be integers or slices, not str HOT 15
- TypeError: typing.ClassVar[typing.Collection[str]] is not valid as type argument Selection deleted HOT 1
- langchain_community.utilities.SQLDatabase: include_tables {...} not found in database HOT 2
- ERROR: Could not build wheels for greenlet, which is required to install pyproject.toml-based projects HOT 1
- DOC: missing parenthesis
- BaseChatModel.stream method not supporting caching
- create_sql_agent with ChatMistralAI causes this error:"Expected last role User or Tool (or Assistant with prefix True) for serving but got assistant"
- `merge_message_runs` incompatible with LCEL
- The get_openai_callback() function is not updated for Azure models. HOT 2
- 'ChatGoogleGenerativeAI wrapper class doesn't work with google chat models such as 'chat-bison@002
- Within async context, `RunnableWithMessageHistory` calls sync `.messages` property instead of async `.aget_messages()` method
- Spam issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from langchain.