File size: 510 Bytes
2838153
 
 
375019e
2838153
 
dd4f3cf
2838153
 
 
 
 
d782922
2838153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from llama_cpp import Llama

llm = Llama(model_path="ggml-alpaca-7b-q4.bin", n_ctx=256, n_batch=128)

def generate_text(input_text):
    output = llm(f"{input_text}", max_tokens=128, stop=["Q:", "\n", "#"], echo=False)
    return output['choices'][0]['text']

input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
output_text = gr.outputs.Textbox(label="Output text")

gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Alpaca GGML").launch()