iassafc/LangChainJSDotNet

Question: Does this library support similarity search in a local vector db?

Opened this issue · 2 comments

Does this library support similarity search in a local vector db (e.g. Chroma) , using embedding model rather than OpenAI (e.g. "sentence-transformers/all-MiniLM-L6-v2") ?

Thanks!

I write a function but the 'import { HuggingFaceTransformersEmbeddings } ' doesn't work in the way I have here:

        static async Task RunEmbedding()
        {
            using var langchainjs = new LangChainJS();

            langchainjs.SetEnvironmentVariable("OPENAI_API_KEY", Configuration["OPENAI_API_KEY"]);

            langchainjs.Setup(@"

                import { HuggingFaceTransformersEmbeddings } from ""langchain/embeddings/hf_transformers"";

                const model = new HuggingFaceTransformersEmbeddings({
                  modelName: ""Xenova/all-MiniLM-L6-v2"",
                });

                globalThis.run = async () => {

                    const res = await model.embedQuery(
                      ""What would be a good company name for a company that makes colorful socks?""
                    );

                    return res.trim();
                }
            ");

            var result = await langchainjs.InvokeAsync<string>("run");

            Console.WriteLine(result);
        }

@iassafc

Does this library support similarity search in a local vector db (e.g. Chroma) , using embedding model rather than OpenAI (e.g. "sentence-transformers/all-MiniLM-L6-v2") ?

HuggingFace transformers embeddings support in LangChain.js rely on an extra peer dependency - a concept that does not translate well to .NET.

I'll look into it and update.

Chroma support should already be included but I've not tested it specifically. Please update if it works as expected.