To load and execute the orpheus-3b-0.1-ft-q4_k_m.gguf model, you can use the llama.cpp library. Here's a step-by-step guide with code examples:
- Install llama.cpp:
bash
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make
- Download the model:
bash
wget https://huggingface.co/odomcl22/orpheus-3b-0.1-ft-Q4_K_M-GGUF/resolve/main/orpheus-3b-0.1-ft-q4_k_m.gguf
- Run inference using the command-line interface:
bash
./main -m orpheus-3b-0.1-ft-q4_k_m.gguf -p "The meaning to life and the universe is" -n 128
Alternatively, you can use the server mode for more flexibility:
bash
./server -m orpheus-3b-0.1-ft-q4_k_m.gguf -c 2048
- For programmatic use, you can integrate llama.cpp into your C++ project. Here's a basic example:
cpp
#include "llama.h"
int main() {
llama_context_params params = llama_context_default_params();
params.n_ctx = 2048;
params.n_threads = 4;
llama_model * model = llama_load_model_from_file("orpheus-3b-0.1-ft-q4_k_m.gguf", params);
llama_context * ctx = llama_new_context_with_model(model, params);
const char * prompt = "The meaning to life and the universe is";
llama_eval(ctx, llama_tokenize(ctx, prompt, -1, true), 0, 4, nullptr);
// Generate tokens
for (int i = 0; i < 128; i++) {
float * logits = llama_get_logits(ctx);
int token = llama_sample_top_p_top_k(ctx, nullptr, 0, 40, 0.95, 0.8, 1.0);
llama_eval(ctx, &token, 1, 4, nullptr);
printf("%s", llama_token_to_str(ctx, token));
}
llama_free(ctx);
llama_free_model(model);
return 0;
}
Compile this code with:
bash
g++ -I. example.cpp -o example -lllama
Run the compiled program:
This code loads the model, processes a prompt, and generates a response[1][3][5].
Remember to adjust paths and parameters as needed for your specific setup and requirements.