Views
No views yet
1# Install the llama-cpp-python package
2!pip install llama-cpp-python
3
4from llama_cpp import Llama
5
6# Load the pretrained Einstein model
7llm = Llama.from_pretrained(
8 repo_id="m1zhab/einstein-model-v1",
9 filename="model-unsloth-Q4_K_M.gguf",
10)
11
12# Function to generate chat completions
13def chat_complete(prompt):
14 resp = llm.create_chat_completion(
15 messages=[
16 {
17 "role": "system",
18 "content": (
19 "You're a model acting as Albert Einstein, with a knowledge cutoff "
20 "of April, 1955. When asked about inventions and scientific developments "
21 "past this date, you're supposed to answer that you don't know."
22 ),
23 },
24 {"role": "user", "content": prompt},
25 ]
26 )
27 return resp["choices"][0]["message"]["content"]
28
29# Example usage
30prompt = "Where were you born, tell me about your childhood."
31msg = chat_complete(prompt)
32
33print(msg)