File size: 1,149 Bytes
8a97208
c928ad3
8272482
2ca6e84
 
 
319b4d3
2ca6e84
 
 
 
 
 
 
 
319b4d3
402975e
2ca6e84
 
 
 
 
7217acf
319b4d3
0010001
8a97208
0010001
 
 
eb443cd
 
4789c94
c928ad3
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer

# # Specify the directory containing the model and tokenizer
# model_name = "gpt4all"  # Make sure this matches the actual model directory
# model_path = f"./"  # Path to the model directory

# # Initialize the GPT-4 model and tokenizer
# model = AutoModelForCausalLM.from_pretrained(model_path)
# tokenizer = AutoTokenizer.from_pretrained(model_path)

from gpt4all import GPT4All
model = GPT4All("wizardlm-13b-v1.1-superhot-8k.ggmlv3.q4_0.bin")
# output = model.generate("How to go to the hospital?")
# print(output)

def generate_text(input_text):
    # input_ids = tokenizer(input_text, return_tensors="pt").input_ids
    # generated_ids = model.generate(input_ids)
    # generated_text = tokenizer.decode(generated_ids[0], skip_special_tokens=True)

    output = model.generate(input_text)
    return output

text_generation_interface = gr.Interface(
    fn=generate_text,
    inputs=[
        gr.inputs.Textbox(label="Input Text"),
    ],
    outputs=gr.outputs.Textbox(label="Generated Text"),
    title="GPT-4 Text Generation",
).launch()



# model_name = ""