Commit
·
1264fc9
1
Parent(s):
8e17490
update app.py
Browse files
app.py
CHANGED
|
@@ -28,19 +28,13 @@ tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
| 28 |
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 29 |
|
| 30 |
# Create text generation pipeline
|
| 31 |
-
pipe = pipeline(
|
| 32 |
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
st.
|
| 41 |
-
# Add user message to chat history
|
| 42 |
-
st.session_state.query = prompt
|
| 43 |
-
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 44 |
-
# Generate response
|
| 45 |
-
result = pipe(prompt)#, max_length=100, num_return_sequences=1)
|
| 46 |
-
|
|
|
|
| 28 |
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 29 |
|
| 30 |
# Create text generation pipeline
|
| 31 |
+
pipe = pipeline(model = model, tokenizer = tokenizer)
|
| 32 |
|
| 33 |
|
| 34 |
+
with st.form('my_form'):
|
| 35 |
+
question = st.text_area('Enter your question:', 'Tell me about attention mechanisms in a transformer?')
|
| 36 |
+
submitted = st.form_submit_button('Submit')
|
| 37 |
+
if submitted:
|
| 38 |
+
result = pipe(question, max_length=100)
|
| 39 |
+
st.write(question)
|
| 40 |
+
st.write(result[0]['generated_text'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|