Views
No views yet
q4_k_m format for efficient inference on CPU and consumer-grade GPUs using llama.cpp or llama-cpp-python.q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj.gguf file (qwen2.5-7b-instruct.Q4_K_M.gguf), which can be loaded directly into UI frameworks like Streamlit using llama-cpp-python.pip install llama-cpp-python streamlitllama-cpp-python:1from llama_cpp import Llama
2
3# Load the model (moves layers to GPU if n_gpu_layers=-1 and CUDA is available)
4llm = Llama(
5 model_path="qwen2.5-7b-instruct.Q4_K_M.gguf",
6 n_ctx=2048,
7 n_gpu_layers=-1
8)
9
10# Format the prompt using standard HH-RLHF format
11prompt = "Explain the theory of relativity in simple terms."
12formatted_prompt = f"Human: {prompt} \n\nAssistant:"
13
14# Generate response
15output = llm(
16 formatted_prompt,
17 max_tokens=256,
18 temperature=0.7,
19 stop=["Human:", "\n\n"],
20 echo=False
21)
22
23print(output["choices"][0]["text"].strip())app.py) featuring an interactive chat UI. You can run it via:streamlit run app.pyHuman: {user_input}
Assistant: