Spaces:
Runtime error
Runtime error
Commit
·
b5f1235
1
Parent(s):
4c9ff5d
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,11 +5,19 @@ from gpt4all import GPT4All
|
|
| 5 |
model_path = "pytorch_model-00001-of-00002.bin"
|
| 6 |
|
| 7 |
# Initialize the GPT4All model
|
| 8 |
-
model = GPT4All(model_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
def generate_text(input_text):
|
| 11 |
-
output = model.generate(input_text)
|
| 12 |
-
return output
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
text_generation_interface = gr.Interface(
|
| 15 |
fn=generate_text,
|
|
|
|
| 5 |
model_path = "pytorch_model-00001-of-00002.bin"
|
| 6 |
|
| 7 |
# Initialize the GPT4All model
|
| 8 |
+
# model = GPT4All(model_path
|
| 9 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 10 |
+
model_path,
|
| 11 |
+
quantization_config=bnb_config,
|
| 12 |
+
device_map=device_map
|
| 13 |
+
)
|
| 14 |
|
| 15 |
def generate_text(input_text):
|
| 16 |
+
# output = model.generate(input_text)
|
| 17 |
+
# return output
|
| 18 |
+
pipe = pipeline(task="text-generation", model=model, tokenizer=tokenizer, max_length=200)
|
| 19 |
+
result = pipe(f"<s>[INST] {prompt} [/INST]")
|
| 20 |
+
return result
|
| 21 |
|
| 22 |
text_generation_interface = gr.Interface(
|
| 23 |
fn=generate_text,
|