awaescher / OllamaSharp

The easiest way to use the Ollama API in .NET
https://www.nuget.org/packages/OllamaSharp
MIT License
439 stars 60 forks source link

How to connect with the knowledge base #42

Closed anan1213095357 closed 3 months ago

anan1213095357 commented 4 months ago

How to connect with the knowledge base

mili-tan commented 4 months ago

Maybe you should try LangChain or Semantic Kernel, or learn how Retrieval Augmented Generation (RAG) works and implement the search yourself using OllamaApiClient.GenerateEmbeddings and some vector database.

anan1213095357 commented 4 months ago

Maybe you should try LangChain or Semantic Kernel, or learn how Retrieval Augmented Generation (RAG) works and implement the search yourself using OllamaApiClient.GenerateEmbeddings and some vector database.

I understand that retrieval vectors can be saved, but how can the vectors obtained through GenerateEmbedding be output as text?

mili-tan commented 4 months ago

I understand that retrieval vectors can be saved, but how can the vectors obtained through GenerateEmbedding be output as text?

It doesn't seem to work like that way, the vectors resulting from Embedding are only used to compare similarity distances. You may need to make the association between the vectors and the original text yourself. Vector databases can usually have text or id attached to them. https://platform.openai.com/docs/tutorials/web-qa-embeddings

awaescher commented 3 months ago

This is not in the context of the Ollama API alone, so it's out of range of this project. @mili-tan is right, you should use langchain or semantic kernel for this. There are tons of articles out there, I think this one is a good one to start: