Spaces:
Runtime error
Runtime error
Abhishek Mamdapure
commited on
Commit
·
faadb9d
1
Parent(s):
c8262aa
added examples to python file
Browse files
app.py
CHANGED
@@ -4,10 +4,21 @@ from llama_cpp import Llama
|
|
4 |
llm = Llama(model_path="ggml-alpaca-7b-q4.bin")
|
5 |
|
6 |
def generate_text(input_text):
|
7 |
-
output = llm(input_text, max_tokens=
|
8 |
-
return output
|
9 |
|
10 |
input_text = gr.inputs.Textbox(label="Enter your input text")
|
11 |
output_text = gr.outputs.Textbox(label="Output text")
|
12 |
|
13 |
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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
llm = Llama(model_path="ggml-alpaca-7b-q4.bin")
|
5 |
|
6 |
def generate_text(input_text):
|
7 |
+
output = llm(input_text, max_tokens=256, stop=["Q:", "\n"], echo=True)
|
8 |
+
return output['choices']['text']
|
9 |
|
10 |
input_text = gr.inputs.Textbox(label="Enter your input text")
|
11 |
output_text = gr.outputs.Textbox(label="Output text")
|
12 |
|
13 |
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()
|
14 |
+
|
15 |
+
|
16 |
+
description = "llama.cpp implementation in python [https://github.com/abetlen/llama-cpp-python]"
|
17 |
+
|
18 |
+
examples = [
|
19 |
+
["Q: What is the capital of France? A: ", "The capital of France is Paris."],
|
20 |
+
["Q: Who wrote the novel 'Pride and Prejudice'? A: ", "The novel 'Pride and Prejudice' was written by Jane Austen."],
|
21 |
+
["Q: What is the square root of 64? A: ", "The square root of 64 is 8."]
|
22 |
+
]
|
23 |
+
|
24 |
+
gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Llama Language Model", description=description, examples=examples).launch()
|