Serve Embedding Model #383
-
Hi guys, I am trying to serve an embedding model through langserve is this possible?. So far i have tried this but stuck at the error.
Error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Any runnable object can be exposed. Embeddings are not runnables, so you need to re-wrap them into a runnable. Here's the embeddings interface (not a runnable): The simplest way to do is is using a RunnableLambda. from langchain_core.runnables import RunnableLambda
embedder = HuggingFaceEmbeddings(...)
runnable_embedder = RunnableLambda(afunc=embedder.aembed_documents)
add_routes(app, runnable_embedder) That will expose an API around it. LangServe doesn't do anything to optimize or manage hardware by anything that does local computations. So you should verify to see what kind of throughput you can get etc. |
Beta Was this translation helpful? Give feedback.
Any runnable object can be exposed. Embeddings are not runnables, so you need to re-wrap them into a runnable.
Here's the embeddings interface (not a runnable):
https://github.com/langchain-ai/langchain/blob/bf0b3cc0b5ade1fb95a5b1b6fa260e99064c2e22/libs/core/langchain_core/embeddings.py#L7-L7
The simplest way to do is is using a RunnableLambda.
That will expose an API around it.
LangServe doesn't do anything to optimize or manage hardware by anything that does local computations. So you should verif…