shivam9980 commited on
Commit
7b4b5e6
1 Parent(s): 62a00b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -1,3 +1,28 @@
1
- import gradio as gr
 
 
 
 
2
 
3
- gr.load("models/shivam9980/mistral-7b-news").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Load model directly
2
+ import streamlit as st
3
+ from transformers import AutoModel
4
+ model,tokenizer = AutoModel.from_pretrained("shivam9980/mistral-7b-news")
5
+ alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
6
 
7
+ ### Instruction:
8
+ {}
9
+
10
+ ### Input:
11
+ {}
12
+
13
+ ### Response:
14
+ {}"""
15
+
16
+ content = st.text_input('Content')
17
+ inputs = tokenizer(
18
+ [
19
+ alpaca_prompt.format(
20
+ "The following passage is content from a news report. Please summarize this passage in one sentence or less.", # instruction
21
+ content, # input
22
+ "", # output - leave this blank for generation!
23
+ )
24
+ ], return_tensors = "pt").to("cuda")
25
+
26
+ outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
27
+ results= tokenizer.batch_decode(outputs)
28
+ st.write(results)