Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1 @@
|
|
| 1 |
-
|
| 2 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
-
|
| 4 |
-
import torch
|
| 5 |
-
|
| 6 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 7 |
-
trust_remote_code=True,
|
| 8 |
-
device_map="auto",
|
| 9 |
-
low_cpu_mem_usage=True,
|
| 10 |
-
|
| 11 |
-
)
|
| 12 |
-
tokenizer = AutoTokenizer.from_pretrained("tiiuae/falcon-7b-instruct")
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
def generate_text(input_text):
|
| 16 |
-
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
| 17 |
-
attention_mask = torch.ones(input_ids.shape)
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
output_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 21 |
-
print(output_text)
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
# Remove Prompt Echo from Generated Text
|
| 25 |
-
cleaned_output_text = output_text.replace(input_text, "")
|
| 26 |
-
return cleaned_output_text
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
text_generation_interface = gr.Interface(
|
| 30 |
-
fn=generate_text,
|
| 31 |
-
inputs=[
|
| 32 |
-
gr.inputs.Textbox(label="Input Text"),
|
| 33 |
-
],
|
|
|
|
| 1 |
+
pip install llama-cpp-python
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|