Views
No views yet
1pip install llama-cpp-python
2from llama_cpp import Llama
3from huggingface_hub import hf_hub_download
4
5# Download model
6model_path = hf_hub_download(
7 repo_id="yamraj047/nepal-legal-mistral-7b-GGUF",
8 filename="nepal-legal-Q4_K_M.gguf"
9)
10
11# Load model
12llm = Llama(model_path=model_path, n_ctx=2048, n_threads=4)
13
14# Ask question
15response = llm("What is theft under Nepal law?", max_tokens=300)
16print(response['choices'][0]['text'])1pip install llama-cpp-python
2from llama_cpp import Llama
3from huggingface_hub import hf_hub_download
4import gradio as gr
5
6model_path = hf_hub_download(
7 repo_id="yamraj047/nepal-legal-mistral-7b-GGUF",
8 filename="nepal-legal-Q4_K_M.gguf"
9)
10
11llm = Llama(model_path=model_path, n_ctx=2048, n_threads=4)
12
13def chat(message, history):
14 prompt = f'''### Instruction:
15You are a legal assistant for Nepal law.
16
17### Input:
18{message}
19
20### Response:
21'''
22 response = llm(prompt, max_tokens=400, temperature=0.7)
23 return response['choices'][0]['text'].strip()
24
25demo = gr.ChatInterface(
26 fn=chat,
27 title="⚖️ Nepal Legal Assistant"
28)
29demo.launch()