File size: 1,081 Bytes
a262b22
 
18cb184
a262b22
18cb184
9c253fd
fd63c99
18cb184
 
 
 
fd63c99
 
 
 
 
 
a262b22
 
 
fd63c99
 
 
18cb184
 
fd63c99
 
a262b22
 
 
 
 
 
 
ee70033
a262b22
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
from llama_cpp import Llama
import os

# Path to the first shard of the model
model_path = "DeepSeek-R1-Zero-Q4_K_M/DeepSeek-R1-Zero-Q4_K_M-00001-of-00009.gguf"

# Debugging: Verify working directory and model path
print("Current working directory:", os.getcwd())
print("Full model path:", os.path.join(os.getcwd(), model_path))

# Initialize the model
try:
    model = Llama(model_path=model_path, n_threads=8)
except ValueError as e:
    print(f"Error initializing the model: {e}")
    exit(1)

# Define the prediction function
def predict(prompt):
    try:
        # Generate output using the model
        output = model(prompt)
        # Extract and return the text from the response
        return output["choices"][0]["text"]
    except Exception as e:
        return f"Error during inference: {e}"

# Create the Gradio interface
iface = gr.Interface(
    fn=predict,
    inputs="text",
    outputs="text",
    title="DeepSeek-R1-Zero",
    description="A Gradio interface for the DeepSeek-R1-Zero model"
)

if __name__ == "__main__":
    iface.launch()