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

LlamaEmbedder How to use #91

Closed
twentytwokhz opened this issue Aug 8, 2023 · 7 comments
Closed

LlamaEmbedder How to use #91

twentytwokhz opened this issue Aug 8, 2023 · 7 comments

Comments

@twentytwokhz
Copy link

How should I use the LlamaEmbedder after I created one?
I was not able to find any relevant information or code snippets.
Thanks!

@martindevans
Copy link
Member

var @params = new ModelParams(modelPath);
var embedder = new LLamaEmbedder(@params);
var result = embedder.GetEmbeddings("Hello");

This seems to work for me. result is filled with a load of numbers which are presumably the embedding vector of "Hello"

@twentytwokhz
Copy link
Author

I might not have explained it accurately 🥲
After creating that vector how can I use it within LlamaSharp for an existing model?

@martindevans
Copy link
Member

I don't think LLamaSharp itself has anything that will consume embeddings, that's usually down to your own system (e.g. an external vector database). What are you actually trying to do with the embeddings?

@twentytwokhz
Copy link
Author

I'm trying to get the embedding from a text extracted from a PDF File. I want to feed it into the llm model for a QA type bot

@martindevans
Copy link
Member

Maybe I'm misunderstanding what you're asking, but I don't think you'd feed the embeddings into the LLM. Instead you would retrieve some text (e.g. using a vector database to find knowledge "nearby" the question embedding vector) and then feed that into the context when you ask your question. That's not something LLamaSharp does - it'll do the start (generate embeddings) and the end (run the LLM) but not the middle bit (use the embeddings to retrieve some knowledge).

I know some people have been working on higher level things (e.g. BotSharp and SemanticKernel) which may do more of what you want (I'm not very familiar with those projects, so I'm not sure)

@twentytwokhz
Copy link
Author

Thank you for clarifying!

@Oceania2018
Copy link
Member

@twentytwokhz @martindevans Here is the updated docs related to how to adpot the LlamaSharp in a high level bot framework. I'll keep update the docs and let me know if you can run it through according the latest docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants