-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[Local Embeddings] Community Support thread #370
Comments
I don't think so at the moment. |
You can change the embeddings API base url to the local one
it must still be compatible with OpenAI API schema |
It works with ollama embedding by changing the file in /opt/anaconda3/envs/graphrag/lib/python3.11/site-packages/graphrag/llm/openai/openai_embeddings_llm.py with from typing_extensions import Unpack from graphrag.llm.base import BaseLLM from .openai_configuration import OpenAIConfiguration import ollama class OpenAIEmbeddingsLLM(BaseLLM[EmbeddingInput, EmbeddingOutput]):
|
Thank you for sharing. Pretty brutal fix but if it work then at least this is a stop gap until the Microsoft team implement a more elegant solution. maybe checking for the presence of an ollama = true in the embedding parameters could allow to keep the default behaviour and only use the hack when true. |
My solution was to write a local server with Flask that basically serves as a decoder of "cl100k_base" and a caller of ollama. Then change the api_base for embedding to the local host address. It works pretty well as far as I am concerned. |
@zeyunie-vecml, yes, that's precisely what the provided server does in addition to the OAI <-> Ollama translation UPD: messed up GitHub threads, was in relation to this server |
I'm making this thread as our official discussion place for Local Embeddings setup and troubleshooting. |
i think add middleware api for oai embeddings:
## parallelization: override the global parallelization settings for embeddings
async_mode: threaded # or asyncio
llm:
api_key: ${GRAPHRAG_API_KEY}
type: openai_embedding # or azure_openai_embedding
model: mxbai-embed-large
api_base: http://localhost:8686/api import fastapi
from langchain_community.embeddings.ollama import OllamaEmbeddings
app = fastapi.FastAPI()
@app.post('/api/embeddings')
def embeddings(body:dict):
# print(body)
ollama = OllamaEmbeddings(model=body['model'])
res = ollama.embed_documents(body['input'])
return {
'data': [
{'embedding': rs } for rs in res
]
} |
I used ollama embedding with the above modification in embedding function and was able of generating the graph, but I can't query the graph with similar modification to another embed function. for attempt in retryer:
Kind of wondering what's going wrong here:) |
#451. |
Instead of ollama I am trying llama.cpp for embeddings but I get this error: 11:17:36,84 graphrag.llm.openai.create_openai_client INFO Creating OpenAI client base_url=http://localhost:8080 |
I'm having the same problem. Is this solved or how to avoid it? |
@wanglufei1 check out #345 . Embedding with Ollama would work with modification made by user Spacelearner. |
@silviachen46 |
The local search with embeddings from Ollama now works. |
Consolidating Ollama-related issues: #657 |
The text was updated successfully, but these errors were encountered: