DR-Rakshitha commited on
Commit
2ca6e84
·
1 Parent(s): 12ea1ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -1,18 +1,25 @@
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
- # Specify the directory containing the model and tokenizer
5
- model_name = "gpt4all" # Make sure this matches the actual model directory
6
- model_path = f"./" # Path to the model directory
7
 
8
- # Initialize the GPT-4 model and tokenizer
9
- model = AutoModelForCausalLM.from_pretrained(model_path)
10
- tokenizer = AutoTokenizer.from_pretrained(model_path)
 
 
 
 
 
11
 
12
  def generate_text(input_text):
13
- input_ids = tokenizer(input_text, return_tensors="pt").input_ids
14
- generated_ids = model.generate(input_ids)
15
- generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
 
 
16
  return generated_text
17
 
18
  text_generation_interface = gr.Interface(
 
1
  import gradio as gr
2
  from transformers import AutoModelForCausalLM, AutoTokenizer
3
 
4
+ # # Specify the directory containing the model and tokenizer
5
+ # model_name = "gpt4all" # Make sure this matches the actual model directory
6
+ # model_path = f"./" # Path to the model directory
7
 
8
+ # # Initialize the GPT-4 model and tokenizer
9
+ # model = AutoModelForCausalLM.from_pretrained(model_path)
10
+ # tokenizer = AutoTokenizer.from_pretrained(model_path)
11
+
12
+ from gpt4all import GPT4All
13
+ model = GPT4All("wizardlm-13b-v1.1-superhot-8k.ggmlv3.q4_0.bin")
14
+ # output = model.generate("How to go to the hospital?")
15
+ # print(output)
16
 
17
  def generate_text(input_text):
18
+ # input_ids = tokenizer(input_text, return_tensors="pt").input_ids
19
+ # generated_ids = model.generate(input_ids)
20
+ # generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
21
+
22
+ output = model.generate(input_text)
23
  return generated_text
24
 
25
  text_generation_interface = gr.Interface(