awinml's picture
Upload app.py (#2)
9202a4a
raw
history blame
1.04 kB
import gradio as gr
from llama_cpp import Llama
llm = Llama(model_path="vicuna-AlekseyKorshuk-7B-GPTQ-4bit-128g.GGML.bin", n_ctx=2048)
def generate_text(llm, prompt, max_tokens=468, temperature=0.1, top_p=0.5):
output = llm(prompt, max_tokens=max_tokens, temperature=temperature, top_p=top_p, echo=False, stop=["#"])
text = output['choices'][0]['text']
return text
input_text = gr.inputs.Textbox(lines= 10, label="Enter your input text")
output_text = gr.outputs.Textbox(label="Output text")
description = "llama.cpp implementation in python [https://github.com/abetlen/llama-cpp-python]"
examples = [
["What is the capital of France? ", "The capital of France is Paris."],
["Who wrote the novel 'Pride and Prejudice'?", "The novel 'Pride and Prejudice' was written by Jane Austen."],
["What is the square root of 64?", "The square root of 64 is 8."]
]
gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Vicuna Language Model", description=description, examples=examples).launch()