Spaces:
Runtime error
Runtime error
File size: 1,190 Bytes
8a97208 0010001 43fbf63 0010001 1127261 8384864 4c9ff5d 0010001 8384864 b5f1235 0010001 b5f1235 8a97208 0010001 8a97208 0010001 5e527b8 8384864 |
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 38 39 40 41 42 43 |
import gradio as gr
from gpt4all import GPT4All
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
pipeline,
logging,
)
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "right" # Fix weird overflow issue with fp16 training
# Specify the local path to the downloaded model file
model_path = "pytorch_model-00001-of-00002.bin"
# Initialize the GPT4All model
# model = GPT4All(model_path
model = AutoModelForCausalLM.from_pretrained(
model_path,
quantization_config=bnb_config,
device_map=device_map
)
def generate_text(input_text):
# output = model.generate(input_text)
# return output
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
result = pipe(f"<s>[INST] {prompt} [/INST]")
return result
text_generation_interface = gr.Interface(
fn=generate_text,
inputs=[
gr.inputs.Textbox(label="Input Text"),
],
outputs=gr.inputs.Textbox(label="Generated Text"),
title="Wizardlm_13b_v1",
).launch()
|