Views
No views yet
1from llama_cpp import Llama
2from huggingface_hub import hf_hub_download
3
4# Download model
5model_path = hf_hub_download(
6 repo_id="yamraj047/my_optimal_model-GGUF",
7 filename="my-optimal-model-Q4_K_M.gguf"
8)
9
10# Load model
11llm = Llama(model_path=model_path, n_ctx=2048, n_threads=4)
12
13# Generate text
14response = llm("Your prompt here", max_tokens=300)
15print(response['choices'][0]['text'])1from llama_cpp import Llama
2from huggingface_hub import hf_hub_download
3import gradio as gr
4
5model_path = hf_hub_download(
6 repo_id="yamraj047/my_optimal_model-GGUF",
7 filename="my-optimal-model-Q4_K_M.gguf"
8)
9
10llm = Llama(model_path=model_path, n_ctx=2048, n_threads=4)
11
12def chat(message, history):
13 response = llm(message, max_tokens=400, temperature=0.7)
14 return response['choices'][0]['text'].strip()
15
16demo = gr.ChatInterface(
17 fn=chat,
18 title="🤖 My Optimal Model Assistant"
19)
20
21demo.launch()| Version | Size | Quality | Use Case |
|---|---|---|---|
| Original FP16 | 14.5 GB | 100% | GPU inference |
| GGUF Q4_K_M | 4.07 GB | 98% | CPU inference |