File size: 1,082 Bytes
524def9
 
 
c8262aa
524def9
 
faadb9d
 
524def9
 
 
 
 
faadb9d
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from llama_cpp import Llama

llm = Llama(model_path="ggml-alpaca-7b-q4.bin")

def generate_text(input_text):
    output = llm(input_text, max_tokens=256, stop=["Q:", "\n"], echo=True)
    return output['choices']['text']

input_text = gr.inputs.Textbox(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="Llama Language Model", description="Enter your input text to generate output text.").launch()


description = "llama.cpp implementation in python [https://github.com/abetlen/llama-cpp-python]"

examples = [
    ["Q: What is the capital of France? A: ", "The capital of France is Paris."],
    ["Q: Who wrote the novel 'Pride and Prejudice'? A: ", "The novel 'Pride and Prejudice' was written by Jane Austen."],
    ["Q: What is the square root of 64? A: ", "The square root of 64 is 8."]
]

gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Llama Language Model", description=description, examples=examples).launch()