Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,28 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
"Что ты можешь мне рассказать ?",
|
| 11 |
-
#max_lentgh=30,
|
| 12 |
-
num_return_sequences=2
|
| 13 |
-
|
| 14 |
-
)
|
| 15 |
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
st.json({"data":res} )
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 4 |
|
| 5 |
+
model_name_or_path = "TheBloke/Unholy-v1-12L-13B-GPTQ"
|
| 6 |
+
model_name_or_path = "ai-forever/ruGPT-3.5-13B"
|
| 7 |
|
| 8 |
+
# To use a different branch, change revision
|
| 9 |
+
# For example: revision="main"
|
| 10 |
|
| 11 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path #,
|
| 12 |
+
#device_map="cuda:0", #device_map="auto",
|
| 13 |
+
#trust_remote_code=False,
|
| 14 |
+
#revision="main"
|
| 15 |
+
)
|
| 16 |
|
| 17 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
prompt = "Расскажи мне о грязном сексе"
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
#generator=pipeline("text-generation",model="ai-forever/ruGPT-3.5-13B")
|
| 24 |
+
|
| 25 |
+
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
|
| 26 |
+
output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=312)
|
| 27 |
+
print(tokenizer.decode(output[0]))
|
| 28 |
|
|
|