Skip to content
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

System.MissingMethodException when using LLMSharpEmbeddings #483

Closed
mzand111 opened this issue Dec 6, 2024 · 1 comment
Closed

System.MissingMethodException when using LLMSharpEmbeddings #483

mzand111 opened this issue Dec 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mzand111
Copy link
Contributor

mzand111 commented Dec 6, 2024

Describe the bug

I'm trying to use LLMSharpEmbeddings to use a SqlLite db to setup a RAG:

 var modelPath = @"D:\LLMModels\Models\thespis-13b-v0.5.Q2_K.gguf";
 //Also tested with Meta-Llama-3.1-8B-Instruct-Q6_K

 var vectorDatabase = new SqLiteVectorDatabase(dataSource: @"D:\LLMModels\DBs\hp.db");
 var embeddingModel = LLamaSharpEmbeddings.FromPath(modelPath);

 var fileAddress = @"D:\LLMModels\RAGResources\Books\Harry-Potter-and-the-Philosophers-Stone.pdf";
 var dataSource = DataSource.FromPath(fileAddress);


 var vectorCollection = await vectorDatabase.AddDocumentsFromAsync<PdfPigPdfLoader>(
     embeddingModel, // Used to convert text to embeddings
     dimensions: 5120, // Not sure about this param!
     dataSource: dataSource,
     collectionName: "harrypotter", // Can be omitted, use if you want to have multiple collections
     textSplitter: null,
     behavior: AddDocumentsToDatabaseBehavior.OverwriteExistingCollection);


 const string question = "What is Harry's Address?";
 var similarDocuments = await vectorCollection.GetSimilarDocuments(embeddingModel, question, amount: 5);

 Console.WriteLine($"Similar Doc Count: {similarDocuments.Count}");

However at this line:

var embeddingModel = LLamaSharpEmbeddings.FromPath(modelPath);

the following exception is thrown:
System.MissingMethodException HResult=0x80131513 Message=Method not found: '!!0 Microsoft.Extensions.AI.IEmbeddingGenerator2.GetService(System.Object)'.
Source=LangChain.Providers.LLamaSharp
StackTrace:
at LangChain.Providers.LLamaSharp.LLamaSharpEmbeddings..ctor(LLamaSharpConfiguration configuration)
`

Steps to reproduce the bug

  1. Create a console app and add required packages
  2. Copy and paste the given code to the main method
  3. Adjust the address of the model to your local address
  4. Run the project

Expected behavior

No response

Screenshots

image

NuGet package version

Additional context

I also tried this:

 var embeddingModel = new LLamaSharpEmbeddings(new LLamaSharpConfiguration
 {
     PathToModelFile = modelPath,
     EmbeddingMode = true,
 });
@mzand111 mzand111 added the bug Something isn't working label Dec 6, 2024
@mzand111
Copy link
Contributor Author

mzand111 commented Dec 6, 2024

Dear admin, please remove this. I should have asked this in the LLamaSharp project

@mzand111 mzand111 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant