Files changed (1) hide show
  1. app.py +23 -11
app.py CHANGED
@@ -3,6 +3,7 @@ import urllib.request
3
  import gradio as gr
4
  from llama_cpp import Llama
5
 
 
6
  def download_file(file_link, filename):
7
  # Checks if the file already exists before downloading
8
  if not os.path.isfile(filename):
@@ -11,6 +12,7 @@ def download_file(file_link, filename):
11
  else:
12
  print("File already exists.")
13
 
 
14
  # Dowloading GGML model from HuggingFace
15
  ggml_model_path = "https://huggingface.co/CRD716/ggml-vicuna-1.1-quantized/resolve/main/ggml-vicuna-7b-1.1-q4_1.bin"
16
  filename = "ggml-vicuna-7b-1.1-q4_1.bin"
@@ -20,26 +22,36 @@ download_file(ggml_model_path, filename)
20
 
21
  llm = Llama(model_path=filename, n_ctx=512, n_batch=126)
22
 
 
23
  def generate_text(prompt):
24
- output = llm(prompt, max_tokens=256, temperature=0.1, top_p=0.5, echo=False, stop=["#"])
25
- output_text = output['choices'][0]['text']
 
 
 
 
 
 
 
26
  return output_text
27
 
 
28
  description = "Vicuna-7B"
29
 
30
  examples = [
31
  ["What is the capital of France? ", "The capital of France is Paris."],
32
- ["Who wrote the novel 'Pride and Prejudice'?", "The novel 'Pride and Prejudice' was written by Jane Austen."],
33
- ["What is the square root of 64?", "The square root of 64 is 8."]
 
 
 
34
  ]
35
 
36
  gradio_interface = gr.Interface(
37
- fn=generate_text,
38
- inputs="text",
39
- outputs="text",
40
- examples=examples
41
- title="Vicuna-7B",
42
  )
43
  gradio_interface.launch()
44
-
45
-
 
3
  import gradio as gr
4
  from llama_cpp import Llama
5
 
6
+
7
  def download_file(file_link, filename):
8
  # Checks if the file already exists before downloading
9
  if not os.path.isfile(filename):
 
12
  else:
13
  print("File already exists.")
14
 
15
+
16
  # Dowloading GGML model from HuggingFace
17
  ggml_model_path = "https://huggingface.co/CRD716/ggml-vicuna-1.1-quantized/resolve/main/ggml-vicuna-7b-1.1-q4_1.bin"
18
  filename = "ggml-vicuna-7b-1.1-q4_1.bin"
 
22
 
23
  llm = Llama(model_path=filename, n_ctx=512, n_batch=126)
24
 
25
+
26
  def generate_text(prompt):
27
+ output = llm(
28
+ prompt,
29
+ max_tokens=256,
30
+ temperature=0.1,
31
+ top_p=0.5,
32
+ echo=False,
33
+ stop=["#"],
34
+ )
35
+ output_text = output["choices"][0]["text"]
36
  return output_text
37
 
38
+
39
  description = "Vicuna-7B"
40
 
41
  examples = [
42
  ["What is the capital of France? ", "The capital of France is Paris."],
43
+ [
44
+ "Who wrote the novel 'Pride and Prejudice'?",
45
+ "The novel 'Pride and Prejudice' was written by Jane Austen.",
46
+ ],
47
+ ["What is the square root of 64?", "The square root of 64 is 8."],
48
  ]
49
 
50
  gradio_interface = gr.Interface(
51
+ fn=generate_text,
52
+ inputs="text",
53
+ outputs="text",
54
+ examples=examples,
55
+ title="Vicuna-7B",
56
  )
57
  gradio_interface.launch()