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

Simplified llama2.c.dll #507

Open
JohnClaw opened this issue Apr 20, 2024 · 4 comments
Open

Simplified llama2.c.dll #507

JohnClaw opened this issue Apr 20, 2024 · 4 comments

Comments

@JohnClaw
Copy link

Llama.dll that can be downloaded from llama.cpp repo is suitable mostly for programming languages that have abilities to work with rather difficult (for novice coder) concepts like pointers, structures etc. The same thing applies to this repo. So the question is: does anybody know any simplified implementation of llama2.c.dll or llama.cpp.dll? For example, it would be wonderful if it will be possible to work with this dll in such way:

CONSOLE

Dim LLama_DLL as Integer

Load "llama.dll" as LLama_DLL

Call function Load_Local_Gguf ("Llama-2-7b-q8.0.gguf") from LLama_DLL

Call function Set_Context_Size_For_Loaded_Gguf (4096) from LLama_DLL

Dim Answer$ As String

Dim Question$ As String

Label #Begin

Input Question$

Answer$ = Call function SentPromptToLoadedGguf (Question$) from LLama_DLL

Print Answer$

Goto #Begin

@jameswdelancey
Copy link
Contributor

I have done this to call from PHP for a web app but I haven't shared it on github yet. It's not a big modification, especially since the refactor on this repo. It consists of passing a pointer to the main function with what would be arguments for a CLI, putting the pointer in transformer.data, replacing the fread with memcpy in the read_configuration, and I think that's it. I can upload if there's nothing out there right now.

@jameswdelancey
Copy link
Contributor

https://github.com/jameswdelancey/llama3.c/blob/master/runqdll.c#L1054

If you look at the bottom, you can see how quick and dirty replicated the CLI args with the build_main call. This works with the quantized version of LLaMA 3B base or instruct when exported by export.py as a version-2 (quantized ak42 magic)

@jameswdelancey
Copy link
Contributor

It doesn't work with LLaMA2 or tinyshakespear or tinystories though, because the overhaul to Llama3 has taken place, but can be backported.

@JohnClaw
Copy link
Author

JohnClaw commented May 11, 2024

It doesn't work with LLaMA2 or tinyshakespear or tinystories though, because the overhaul to Llama3 has taken place, but can be backported.

I found dll that can chat with llm-s using one simple function without pointers and structures: https://github.com/tinyBigGAMES/Dllama
It's ideal for novice coders like me and can be used from any programming language. For example, here's AutoIt's (https://www.autoitscript.com/site/) implementation:

Local $answer = DllCall($hDLL, "str:cdecl", "Dllama_Simple_Inference", "str", "config.json", "str", "llama3", "str", $question, "uint", 1024)

Could you add such simple function to your dll, please?

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

2 participants