Stevross commited on
Commit
7ce9bfb
·
1 Parent(s): 9219f40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -11
app.py CHANGED
@@ -1,18 +1,12 @@
1
  import streamlit as st
2
- from transformers import pipeline
3
 
4
-
5
- # Load the model in full precision
6
  model = AutoModelForCausalLM.from_pretrained("PAIXAI/Astrid-1B").to(dtype=torch.float32)
 
7
 
8
-
9
- # Initialize the model and tokenizer for CPU
10
- generate_text = pipeline(
11
- model="PAIXAI/Astrid-1B",
12
- torch_dtype="auto",
13
- trust_remote_code=True,
14
- use_fast=True
15
- )
16
 
17
  # Streamlit UI
18
  st.title("Astrid-1B Chatbot")
 
1
  import streamlit as st
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer, TextGenerationPipeline
3
 
4
+ # Load the model and tokenizer in full precision
 
5
  model = AutoModelForCausalLM.from_pretrained("PAIXAI/Astrid-1B").to(dtype=torch.float32)
6
+ tokenizer = AutoTokenizer.from_pretrained("PAIXAI/Astrid-1B")
7
 
8
+ # Initialize the pipeline with the model and tokenizer
9
+ generate_text = TextGenerationPipeline(model=model, tokenizer=tokenizer, device=0 if torch.cuda.is_available() else -1)
 
 
 
 
 
 
10
 
11
  # Streamlit UI
12
  st.title("Astrid-1B Chatbot")