Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
x = st.slider('Select a value')
|
5 |
st.write(x, 'squared is', x * x)
|
@@ -10,5 +11,17 @@ result = st.empty()
|
|
10 |
llm = pipeline('text-generation', model='gpt2')
|
11 |
|
12 |
if btn:
|
13 |
-
res = llm(text)
|
14 |
-
result.success(res[0]["generated_text"].strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
4 |
|
5 |
x = st.slider('Select a value')
|
6 |
st.write(x, 'squared is', x * x)
|
|
|
11 |
llm = pipeline('text-generation', model='gpt2')
|
12 |
|
13 |
if btn:
|
14 |
+
# res = llm(text)
|
15 |
+
# result.success(res[0]["generated_text"].strip())
|
16 |
+
|
17 |
+
model_id = "mistral-community/Mixtral-8x22B-v0.1"
|
18 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
19 |
+
|
20 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
21 |
+
|
22 |
+
text = "Hello my name is"
|
23 |
+
inputs = tokenizer(text, return_tensors="pt")
|
24 |
+
|
25 |
+
outputs = model.generate(**inputs, max_new_tokens=60)
|
26 |
+
|
27 |
+
result.success(tokenizer.decode(outputs[0], skip_special_tokens=True))
|